From 03afdb4a0ed611006baad88974a6ea573a1f040a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 Mar 2019 18:09:44 -0700 Subject: [PATCH] Improve typing for Generators and Async Generators --- src/compiler/checker.ts | 790 +++++++++++++----- src/compiler/commandLineParser.ts | 1 + src/compiler/diagnosticMessages.json | 8 + src/compiler/types.ts | 16 +- src/lib/es2015.generator.d.ts | 9 +- src/lib/es2015.iterable.d.ts | 159 ++-- src/lib/es2018.asyncgenerator.d.ts | 58 ++ src/lib/es2018.d.ts | 1 + src/lib/esnext.bigint.d.ts | 8 +- src/lib/libs.json | 1 + .../unittests/config/commandLineParsing.ts | 6 +- .../reference/FunctionDeclaration11_es6.types | 2 +- .../reference/FunctionDeclaration13_es6.types | 2 +- .../reference/FunctionDeclaration1_es6.types | 2 +- .../reference/FunctionDeclaration6_es6.types | 2 +- .../reference/FunctionDeclaration7_es6.types | 4 +- .../reference/FunctionDeclaration9_es6.types | 10 +- .../reference/FunctionExpression1_es6.types | 4 +- .../reference/FunctionExpression2_es6.types | 6 +- .../FunctionPropertyAssignments1_es6.types | 6 +- .../FunctionPropertyAssignments2_es6.types | 6 +- .../FunctionPropertyAssignments3_es6.types | 6 +- .../FunctionPropertyAssignments5_es6.types | 6 +- .../FunctionPropertyAssignments6_es6.types | 6 +- .../MemberFunctionDeclaration1_es6.types | 2 +- .../MemberFunctionDeclaration2_es6.types | 2 +- .../MemberFunctionDeclaration3_es6.types | 2 +- .../MemberFunctionDeclaration4_es6.types | 2 +- .../MemberFunctionDeclaration7_es6.types | 2 +- .../reference/YieldExpression10_es6.types | 6 +- .../reference/YieldExpression11_es6.types | 2 +- .../reference/YieldExpression13_es6.types | 2 +- .../reference/YieldExpression16_es6.types | 4 +- .../reference/YieldExpression19_es6.types | 8 +- .../reference/YieldExpression3_es6.types | 2 +- .../reference/YieldExpression4_es6.types | 2 +- .../reference/YieldExpression5_es6.types | 2 +- .../reference/YieldExpression7_es6.types | 4 +- .../reference/YieldExpression8_es6.types | 8 +- .../reference/YieldExpression9_es6.types | 4 +- .../reference/YieldStarExpression3_es6.types | 2 +- .../reference/YieldStarExpression4_es6.types | 4 +- tests/baselines/reference/arrayFrom.types | 12 +- .../reference/asyncImportNestedYield.types | 2 +- .../reference/asyncMethodWithSuper_es6.types | 8 +- ...ckScopedBindingsInDownlevelGenerator.types | 2 +- .../reference/castOfYield.errors.txt | 4 +- .../baselines/reference/controlFlowIIFE.types | 6 +- ...ructuredLateBoundNameHasCorrectTypes.types | 4 +- ....asyncGenerators.classMethods.es2015.types | 32 +- ....asyncGenerators.classMethods.es2018.types | 32 +- ...ter.asyncGenerators.classMethods.es5.types | 32 +- ...nerators.functionDeclarations.es2015.types | 28 +- ...nerators.functionDeclarations.es2018.types | 28 +- ...cGenerators.functionDeclarations.es5.types | 28 +- ...enerators.functionExpressions.es2015.types | 42 +- ...enerators.functionExpressions.es2018.types | 42 +- ...ncGenerators.functionExpressions.es5.types | 42 +- ...nerators.objectLiteralMethods.es2015.types | 56 +- ...nerators.objectLiteralMethods.es2018.types | 56 +- ...cGenerators.objectLiteralMethods.es5.types | 56 +- .../reference/emitter.forAwait.es2015.types | 6 +- .../reference/emitter.forAwait.es2017.types | 6 +- .../reference/emitter.forAwait.es2018.types | 6 +- .../reference/emitter.forAwait.es5.types | 6 +- ...ionsForbiddenInParameterInitializers.types | 2 +- tests/baselines/reference/for-of12.types | 6 +- tests/baselines/reference/for-of13.types | 6 +- tests/baselines/reference/for-of14.errors.txt | 10 +- tests/baselines/reference/for-of14.js | 8 +- tests/baselines/reference/for-of14.symbols | 10 +- tests/baselines/reference/for-of14.types | 10 +- tests/baselines/reference/for-of15.errors.txt | 6 +- tests/baselines/reference/for-of15.js | 8 +- tests/baselines/reference/for-of15.symbols | 14 +- tests/baselines/reference/for-of15.types | 10 +- tests/baselines/reference/for-of16.errors.txt | 6 +- tests/baselines/reference/for-of16.js | 8 +- tests/baselines/reference/for-of16.symbols | 12 +- tests/baselines/reference/for-of16.types | 10 +- tests/baselines/reference/for-of18.js | 8 +- tests/baselines/reference/for-of18.symbols | 14 +- tests/baselines/reference/for-of18.types | 10 +- tests/baselines/reference/for-of25.js | 8 +- tests/baselines/reference/for-of25.symbols | 10 +- tests/baselines/reference/for-of25.types | 10 +- tests/baselines/reference/for-of26.js | 8 +- tests/baselines/reference/for-of26.symbols | 14 +- tests/baselines/reference/for-of26.types | 10 +- tests/baselines/reference/for-of27.js | 8 +- tests/baselines/reference/for-of27.symbols | 10 +- tests/baselines/reference/for-of27.types | 10 +- tests/baselines/reference/for-of28.js | 8 +- tests/baselines/reference/for-of28.symbols | 14 +- tests/baselines/reference/for-of28.types | 10 +- tests/baselines/reference/for-of30.errors.txt | 26 +- tests/baselines/reference/for-of30.js | 12 +- tests/baselines/reference/for-of30.symbols | 20 +- tests/baselines/reference/for-of30.types | 14 +- tests/baselines/reference/for-of31.errors.txt | 32 +- tests/baselines/reference/for-of31.js | 10 +- tests/baselines/reference/for-of31.symbols | 16 +- tests/baselines/reference/for-of31.types | 12 +- tests/baselines/reference/for-of33.errors.txt | 4 +- tests/baselines/reference/for-of33.js | 8 +- tests/baselines/reference/for-of33.symbols | 10 +- tests/baselines/reference/for-of33.types | 10 +- tests/baselines/reference/for-of34.errors.txt | 6 +- tests/baselines/reference/for-of34.js | 10 +- tests/baselines/reference/for-of34.symbols | 16 +- tests/baselines/reference/for-of34.types | 12 +- tests/baselines/reference/for-of35.errors.txt | 6 +- tests/baselines/reference/for-of35.js | 10 +- tests/baselines/reference/for-of35.symbols | 16 +- tests/baselines/reference/for-of35.types | 12 +- .../reference/generatorES6InAMDModule.types | 2 +- .../baselines/reference/generatorES6_1.types | 2 +- .../baselines/reference/generatorES6_2.types | 2 +- .../baselines/reference/generatorES6_3.types | 4 +- .../baselines/reference/generatorES6_4.types | 6 +- .../baselines/reference/generatorES6_5.types | 2 +- .../baselines/reference/generatorES6_6.types | 2 +- .../generatorExplicitReturnType.errors.txt | 41 + .../reference/generatorExplicitReturnType.js | 44 + .../generatorExplicitReturnType.symbols | 48 ++ .../generatorExplicitReturnType.types | 58 ++ .../reference/generatorImplicitAny.js | 5 + .../reference/generatorImplicitAny.symbols | 4 + .../reference/generatorImplicitAny.types | 4 + .../generatorNoImplicitReturns.types | 2 +- .../reference/generatorReturnTypeInference.js | 167 ++++ .../generatorReturnTypeInference.symbols | 158 ++++ .../generatorReturnTypeInference.types | 203 +++++ .../reference/generatorTypeCheck12.errors.txt | 9 + .../reference/generatorTypeCheck13.errors.txt | 10 + .../reference/generatorTypeCheck14.types | 2 +- .../reference/generatorTypeCheck15.types | 2 +- .../reference/generatorTypeCheck16.types | 2 +- .../reference/generatorTypeCheck19.types | 2 +- .../reference/generatorTypeCheck20.types | 2 +- .../reference/generatorTypeCheck22.types | 6 +- .../reference/generatorTypeCheck23.types | 6 +- .../reference/generatorTypeCheck24.types | 8 +- .../reference/generatorTypeCheck25.errors.txt | 36 +- .../reference/generatorTypeCheck25.types | 6 +- .../reference/generatorTypeCheck26.types | 2 +- .../reference/generatorTypeCheck27.types | 6 +- .../reference/generatorTypeCheck28.types | 6 +- .../reference/generatorTypeCheck29.types | 4 +- .../reference/generatorTypeCheck30.types | 4 +- .../reference/generatorTypeCheck31.errors.txt | 8 +- .../reference/generatorTypeCheck31.types | 4 +- .../reference/generatorTypeCheck33.types | 4 +- .../reference/generatorTypeCheck34.types | 4 +- .../reference/generatorTypeCheck35.types | 2 +- .../reference/generatorTypeCheck36.types | 2 +- .../reference/generatorTypeCheck37.types | 2 +- .../reference/generatorTypeCheck38.types | 2 +- .../reference/generatorTypeCheck39.types | 2 +- .../reference/generatorTypeCheck40.types | 2 +- .../reference/generatorTypeCheck41.types | 2 +- .../reference/generatorTypeCheck42.types | 2 +- .../reference/generatorTypeCheck43.types | 8 +- .../reference/generatorTypeCheck44.types | 2 +- .../reference/generatorTypeCheck45.types | 2 +- .../reference/generatorTypeCheck46.types | 8 +- .../reference/generatorTypeCheck47.errors.txt | 7 - .../reference/generatorTypeCheck47.types | 2 +- .../reference/generatorTypeCheck48.types | 4 +- .../reference/generatorTypeCheck49.types | 2 +- .../reference/generatorTypeCheck50.types | 2 +- .../reference/generatorTypeCheck51.errors.txt | 11 - .../reference/generatorTypeCheck51.types | 4 +- .../reference/generatorTypeCheck52.types | 2 +- .../reference/generatorTypeCheck53.types | 4 +- .../reference/generatorTypeCheck54.types | 6 +- .../reference/generatorTypeCheck55.types | 2 +- .../reference/generatorTypeCheck56.types | 4 +- .../reference/generatorTypeCheck57.types | 2 +- .../reference/generatorTypeCheck58.types | 2 +- .../reference/generatorTypeCheck59.types | 2 +- .../reference/generatorTypeCheck6.errors.txt | 4 +- .../reference/generatorTypeCheck60.types | 2 +- .../reference/generatorTypeCheck61.types | 2 +- .../reference/generatorTypeCheck62.types | 10 +- .../reference/generatorTypeCheck63.errors.txt | 69 +- .../reference/generatorTypeCheck63.types | 12 +- .../reference/generatorTypeCheck7.errors.txt | 4 +- .../reference/generatorTypeCheck8.errors.txt | 20 +- ...portCallExpressionReturnPromiseOfAny.types | 2 +- ...rtHelpersNoHelpersForAsyncGenerators.types | 4 +- .../iteratorSpreadInArray9.errors.txt | 12 +- .../reference/iteratorSpreadInCall12.js | 8 +- .../reference/iteratorSpreadInCall12.symbols | 14 +- .../reference/iteratorSpreadInCall12.types | 22 +- .../reference/iteratorSpreadInCall5.js | 8 +- .../reference/iteratorSpreadInCall5.symbols | 14 +- .../reference/iteratorSpreadInCall5.types | 14 +- .../iteratorSpreadInCall6.errors.txt | 6 +- .../reference/iteratorSpreadInCall6.js | 8 +- .../reference/iteratorSpreadInCall6.symbols | 14 +- .../reference/iteratorSpreadInCall6.types | 14 +- .../iteratorSpreadInCall7.errors.txt | 6 +- .../reference/iteratorSpreadInCall7.js | 8 +- .../reference/iteratorSpreadInCall7.symbols | 14 +- .../reference/iteratorSpreadInCall7.types | 14 +- .../iteratorSpreadInCall8.errors.txt | 6 +- .../reference/iteratorSpreadInCall8.js | 8 +- .../reference/iteratorSpreadInCall8.symbols | 14 +- .../reference/iteratorSpreadInCall8.types | 14 +- .../iteratorSpreadInCall9.errors.txt | 6 +- .../reference/iteratorSpreadInCall9.js | 8 +- .../reference/iteratorSpreadInCall9.symbols | 14 +- .../reference/iteratorSpreadInCall9.types | 18 +- .../reference/labeledStatementWithLabel.types | 2 +- .../labeledStatementWithLabel_es2015.types | 2 +- .../labeledStatementWithLabel_strict.types | 2 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 10 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 10 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 10 +- ...dularizeLibrary_TargetES6UsingES6Lib.types | 6 +- ...Library_UsingES5LibAndES6FeatureLibs.types | 2 +- ....asyncGenerators.classMethods.es2018.types | 44 +- ...nerators.functionDeclarations.es2018.types | 46 +- ...enerators.functionExpressions.es2018.types | 74 +- ...nerators.objectLiteralMethods.es2018.types | 118 +-- .../reference/parser.forAwait.es2018.types | 8 +- .../restParameterInDownlevelGenerator.types | 2 +- .../strictGeneratorTypes/tsconfig.json | 5 + ...MapValidationVarInDownLevelGenerator.types | 2 +- ...romGeneratorMakesRequiredParams.errors.txt | 4 +- .../templateStringInYieldKeyword.types | 2 +- ...eStringWithEmbeddedYieldKeyword.errors.txt | 4 +- ...ateStringWithEmbeddedYieldKeywordES6.types | 2 +- .../types.asyncGenerators.es2018.1.types | 134 +-- .../types.asyncGenerators.es2018.2.errors.txt | 134 +-- .../types.asyncGenerators.es2018.2.types | 84 +- .../reference/types.forAwait.es2018.1.types | 2 +- .../types.forAwait.es2018.3.errors.txt | 4 +- tests/baselines/reference/uniqueSymbols.types | 30 +- .../reference/uniqueSymbolsDeclarations.js | 20 +- .../reference/uniqueSymbolsDeclarations.types | 30 +- .../reference/vExplicitReturnType.symbols | 48 ++ .../reference/yieldExpression1.types | 2 +- .../yieldExpressionInControlFlow.errors.txt | 5 +- .../yieldExpressionInControlFlow.types | 10 +- .../reference/yieldExpressionInFlowLoop.types | 2 +- .../yieldExpressionInnerCommentEmit.types | 6 +- .../es6/for-ofStatements/for-of14.ts | 4 +- .../es6/for-ofStatements/for-of15.ts | 4 +- .../es6/for-ofStatements/for-of16.ts | 4 +- .../es6/for-ofStatements/for-of18.ts | 4 +- .../es6/for-ofStatements/for-of25.ts | 4 +- .../es6/for-ofStatements/for-of26.ts | 4 +- .../es6/for-ofStatements/for-of27.ts | 4 +- .../es6/for-ofStatements/for-of28.ts | 4 +- .../es6/for-ofStatements/for-of30.ts | 8 +- .../es6/for-ofStatements/for-of31.ts | 6 +- .../es6/for-ofStatements/for-of33.ts | 4 +- .../es6/for-ofStatements/for-of34.ts | 6 +- .../es6/for-ofStatements/for-of35.ts | 6 +- .../es6/spread/iteratorSpreadInCall12.ts | 4 +- .../es6/spread/iteratorSpreadInCall5.ts | 4 +- .../es6/spread/iteratorSpreadInCall6.ts | 4 +- .../es6/spread/iteratorSpreadInCall7.ts | 4 +- .../es6/spread/iteratorSpreadInCall8.ts | 4 +- .../es6/spread/iteratorSpreadInCall9.ts | 4 +- .../generators/generatorExplicitReturnType.ts | 28 + .../generators/generatorImplicitAny.ts | 6 + .../generatorReturnTypeInference.ts | 96 +++ 270 files changed, 3064 insertions(+), 1645 deletions(-) create mode 100644 src/lib/es2018.asyncgenerator.d.ts create mode 100644 tests/baselines/reference/generatorExplicitReturnType.errors.txt create mode 100644 tests/baselines/reference/generatorExplicitReturnType.js create mode 100644 tests/baselines/reference/generatorExplicitReturnType.symbols create mode 100644 tests/baselines/reference/generatorExplicitReturnType.types create mode 100644 tests/baselines/reference/generatorImplicitAny.js create mode 100644 tests/baselines/reference/generatorImplicitAny.symbols create mode 100644 tests/baselines/reference/generatorImplicitAny.types create mode 100644 tests/baselines/reference/generatorReturnTypeInference.js create mode 100644 tests/baselines/reference/generatorReturnTypeInference.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeInference.types create mode 100644 tests/baselines/reference/generatorTypeCheck12.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck13.errors.txt delete mode 100644 tests/baselines/reference/generatorTypeCheck47.errors.txt delete mode 100644 tests/baselines/reference/generatorTypeCheck51.errors.txt create mode 100644 tests/baselines/reference/showConfig/Shows tsconfig for single option/strictGeneratorTypes/tsconfig.json create mode 100644 tests/baselines/reference/vExplicitReturnType.symbols create mode 100644 tests/cases/conformance/generators/generatorExplicitReturnType.ts create mode 100644 tests/cases/conformance/generators/generatorImplicitAny.ts create mode 100644 tests/cases/conformance/generators/generatorReturnTypeInference.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 23525ad2f2382..c6a51381e75dd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11,6 +11,20 @@ namespace ts { let nextMergeId = 1; let nextFlowId = 1; + const enum IterationTypesCacheKind { + Iterable, + Iterator, + AsyncIterable, + AsyncIterator, + IteratorResult, + } + + const enum IterationTypeKind { + Yield, + Return, + Next, + } + export function getNodeId(node: Node): number { if (!node.id) { node.id = nextNodeId; @@ -527,9 +541,13 @@ namespace ts { let deferredGlobalIterableType: GenericType; let deferredGlobalIteratorType: GenericType; let deferredGlobalIterableIteratorType: GenericType; + let deferredGlobalGeneratorType: GenericType; + let deferredGlobalIteratorYieldResultType: GenericType; + let deferredGlobalIteratorReturnResultType: GenericType; let deferredGlobalAsyncIterableType: GenericType; let deferredGlobalAsyncIteratorType: GenericType; let deferredGlobalAsyncIterableIteratorType: GenericType; + let deferredGlobalAsyncGeneratorType: GenericType; let deferredGlobalTemplateStringsArrayType: ObjectType; let deferredGlobalImportMetaType: ObjectType; let deferredGlobalExtractSymbol: Symbol; @@ -9149,6 +9167,10 @@ namespace ts { return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; } + function getGlobalAsyncGeneratorType(reportErrors: boolean) { + return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator" as __String, /*arity*/ 3, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors: boolean) { return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; } @@ -9161,6 +9183,18 @@ namespace ts { return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; } + function getGlobalGeneratorType(reportErrors: boolean) { + return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator" as __String, /*arity*/ 3, reportErrors)) || emptyGenericType; + } + + function getGlobalIteratorYieldResultType(reportErrors: boolean) { + return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; + } + + function getGlobalIteratorReturnResultType(reportErrors: boolean) { + return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name: __String, arity = 0): ObjectType | undefined { const symbol = getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); @@ -9197,16 +9231,16 @@ namespace ts { return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(/*reportErrors*/ true), [iteratedType]); } - function createAsyncIterableIteratorType(iteratedType: Type): Type { - return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(/*reportErrors*/ true), [iteratedType]); + function createAsyncGeneratorType(yieldType: Type, returnType: Type, nextType: Type) { + return createTypeFromGenericGlobalType(getGlobalAsyncGeneratorType(/*reportErrors*/ true), [yieldType, returnType, nextType]); } function createIterableType(iteratedType: Type): Type { return createTypeFromGenericGlobalType(getGlobalIterableType(/*reportErrors*/ true), [iteratedType]); } - function createIterableIteratorType(iteratedType: Type): Type { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(/*reportErrors*/ true), [iteratedType]); + function createGeneratorType(yieldType: Type, returnType: Type, nextType: Type) { + return createTypeFromGenericGlobalType(getGlobalGeneratorType(/*reportErrors*/ true), [yieldType, returnType, nextType]); } function createArrayType(elementType: Type, readonly?: boolean): ObjectType { @@ -14145,6 +14179,25 @@ namespace ts { return type; } + function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type: Type | undefined, contextualSignatureReturnType: Type | undefined, isAsync: boolean) { + if (type && isUnitType(type)) { + const contextualType = !contextualSignatureReturnType ? undefined : + isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) : + contextualSignatureReturnType; + type = getWidenedLiteralLikeTypeForContextualType(type, contextualType); + } + return type; + } + + function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type: Type | undefined, contextualSignatureReturnType: Type | undefined, kind: IterationTypeKind, isAsyncGenerator: boolean) { + if (type && isUnitType(type)) { + const contextualType = !contextualSignatureReturnType ? undefined : + getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator); + type = getWidenedLiteralLikeTypeForContextualType(type, contextualType); + } + return type; + } + /** * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. @@ -17964,7 +18017,7 @@ namespace ts { if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & FunctionFlags.Async) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Yield, contextualReturnType, (functionFlags & FunctionFlags.Async) !== 0); } } @@ -18392,6 +18445,10 @@ namespace ts { case SyntaxKind.AwaitExpression: return getContextualTypeForAwaitOperand(parent); case SyntaxKind.CallExpression: + if ((parent).expression.kind === SyntaxKind.ImportKeyword) { + return stringType; + } + /* falls through */ case SyntaxKind.NewExpression: return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: @@ -22302,104 +22359,118 @@ namespace ts { } const functionFlags = getFunctionFlags(func); - let type: Type; - if (func.body.kind !== SyntaxKind.Block) { - type = checkExpressionCached(func.body, checkMode && checkMode & ~CheckMode.SkipGenericFunctions); - if (functionFlags & FunctionFlags.Async) { + const isAsync = (functionFlags & FunctionFlags.Async) !== 0; + const isGenerator = (functionFlags & FunctionFlags.Generator) !== 0; + + let returnType: Type | undefined; + let yieldType: Type | undefined; + let nextType: Type | undefined; + let fallbackReturnType: Type = voidType; + if (func.body.kind !== SyntaxKind.Block) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~CheckMode.SkipGenericFunctions); + if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which we will wrap in // the native Promise type later in this function. - type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + returnType = checkAwaitedType(returnType, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } - else { - let types = checkAndAggregateReturnExpressionTypes(func, checkMode); - if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function - types = concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), types); - if (!types || types.length === 0) { - const iterableIteratorAny = functionFlags & FunctionFlags.Async - ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function - : createIterableIteratorType(anyType); // Generator function - if (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 if (isGenerator) { // Generator or AsyncGenerator function + const returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode); + const { yieldTypes, nextTypes } = checkAndAggregateYieldOperandTypes(func, checkMode); + yieldType = some(yieldTypes) ? getUnionType(yieldTypes, UnionReduction.Subtype) : undefined; + if (!returnTypes) { + fallbackReturnType = neverType; } - else { - if (!types) { - // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & FunctionFlags.Async - ? createPromiseReturnType(func, neverType) // Async function - : neverType; // Normal function + else if (returnTypes.length > 0) { + returnType = getUnionType(returnTypes, UnionReduction.Subtype); + } + nextType = some(nextTypes) ? getIntersectionType(nextTypes) : undefined; + } + else { // Async or normal function + const types = checkAndAggregateReturnExpressionTypes(func, checkMode); + if (!types) { + // For an async function, the return type will not be never, but rather a Promise for never. + return functionFlags & FunctionFlags.Async + ? createPromiseReturnType(func, neverType) // Async function + : neverType; // Normal function + } + if (types.length === 0) { + // For an async function, the return type will not be void, but rather a Promise for void. + return functionFlags & FunctionFlags.Async + ? createPromiseReturnType(func, voidType) // Async function + : voidType; // Normal function + } + + // Return a union of the return expression types. + returnType = getUnionType(types, UnionReduction.Subtype); + } + + if (returnType || yieldType || nextType) { + const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); + if (!contextualSignature) { + if (yieldType) reportErrorsFromWidening(func, yieldType); + if (returnType) reportErrorsFromWidening(func, returnType); + if (nextType) reportErrorsFromWidening(func, nextType); + } + if (returnType && isUnitType(returnType) || + yieldType && isUnitType(yieldType) || + nextType && isUnitType(nextType)) { + const contextualType = !contextualSignature ? undefined : + contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : + getReturnTypeOfSignature(contextualSignature); + if (isGenerator) { + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, IterationTypeKind.Yield, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, IterationTypeKind.Return, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, IterationTypeKind.Next, isAsync); } - if (types.length === 0) { - // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & FunctionFlags.Async - ? createPromiseReturnType(func, voidType) // Async function - : voidType; // Normal function + else { + returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); } } - // Return a union of the return expression types. - type = getUnionType(types, UnionReduction.Subtype); + if (yieldType) yieldType = getWidenedType(yieldType); + if (returnType) returnType = getWidenedType(returnType); + if (nextType) nextType = getWidenedType(nextType); } - const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!contextualSignature) { - reportErrorsFromWidening(func, type); + if (isGenerator) { + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); } - - if (isUnitType(type)) { - let contextualType = !contextualSignature ? undefined : - contextualSignature === getSignatureFromDeclaration(func) ? type : - getReturnTypeOfSignature(contextualSignature); - if (contextualType) { - switch (functionFlags & FunctionFlags.AsyncGenerator) { - case FunctionFlags.AsyncGenerator: - contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ true); - break; - case FunctionFlags.Generator: - contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ false); - break; - case FunctionFlags.Async: - contextualType = getPromisedTypeOfPromise(contextualType); - break; - } - } - type = getWidenedLiteralLikeTypeForContextualType(type, contextualType); + else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + return isAsync + ? createPromiseType(returnType || fallbackReturnType) + : returnType || fallbackReturnType; } + } - const widenedType = getWidenedType(type); - switch (functionFlags & FunctionFlags.AsyncGenerator) { - case FunctionFlags.AsyncGenerator: - return createAsyncIterableIteratorType(widenedType); - case FunctionFlags.Generator: - return createIterableIteratorType(widenedType); - case FunctionFlags.Async: - // From within an async function you can return either a non-promise value or a promise. Any - // Promise/A+ compatible implementation will always assimilate any foreign promise, so the - // return type of the body is awaited type of the body, wrapped in a native Promise type. - return createPromiseType(widenedType); - default: - return widenedType; - } + function createGeneratorReturnType(yieldType: Type, returnType: Type, nextType: Type, isAsyncGenerator: boolean) { + return isAsyncGenerator + ? createAsyncGeneratorType(yieldType, returnType, nextType) + : createGeneratorType(yieldType, returnType, nextType); } - function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode | undefined): Type[] { - const aggregatedTypes: Type[] = []; + function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode | undefined) { + const yieldTypes: Type[] = []; + const nextTypes: Type[] = []; const isAsync = (getFunctionFlags(func) & FunctionFlags.Async) !== 0; forEachYieldExpression(func.body, yieldExpression => { - pushIfUnique(aggregatedTypes, getYieldedTypeOfYieldExpression(yieldExpression, isAsync, checkMode)); + const yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; + pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, isAsync)); + const nextType = yieldExpression.asteriskToken + ? getIterationTypeOfIterable(IterationTypeKind.Next, yieldExpressionType, yieldExpression.expression, isAsync, /*allowSyncIterables*/ true, /*checkAssignability*/ false) + : getContextualType(yieldExpression); + if (nextType) pushIfUnique(nextTypes, nextType); }); - return aggregatedTypes; + return { yieldTypes, nextTypes }; } - function getYieldedTypeOfYieldExpression(node: YieldExpression, isAsync: boolean, checkMode?: CheckMode): Type | undefined { + function getYieldedTypeOfYieldExpression(node: YieldExpression, expressionType: Type, isAsync: boolean): Type | undefined { const errorNode = node.expression || node; - const expressionType = node.expression ? checkExpression(node.expression, checkMode) : undefinedWideningType; // A `yield*` expression effectively yields everything that its operand yields const yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(expressionType, errorNode, /*allowStringInput*/ false, isAsync) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken @@ -22656,9 +22727,12 @@ namespace ts { } function getReturnOrPromisedType(node: FunctionLikeDeclaration | MethodSignature, functionFlags: FunctionFlags) { + const isGenerator = !!(functionFlags & FunctionFlags.Generator); + const isAsync = !!(functionFlags & FunctionFlags.Async); const type = getReturnTypeFromAnnotation(node); - return type && ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) ? - getAwaitedType(type) || errorType : type; + return type && isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Return, type, isAsync) || errorType : + type && isAsync ? getAwaitedType(type) || errorType : + type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node: ArrowFunction | FunctionExpression | MethodDeclaration) { @@ -22666,11 +22740,7 @@ namespace ts { const functionFlags = getFunctionFlags(node); const returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); - - if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function - // return is not necessary in the body of generators - checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); - } + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); if (node.body) { if (!getEffectiveReturnTypeNode(node)) { @@ -23602,17 +23672,26 @@ namespace ts { } const isAsync = (functionFlags & FunctionFlags.Async) !== 0; - const yieldedType = getYieldedTypeOfYieldExpression(node, isAsync)!; // TODO: GH#18217 + const yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType; + const yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, isAsync)!; // TODO: GH#18217 // 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. const returnType = getReturnTypeFromAnnotation(func); if (returnType) { - const signatureElementType = getIteratedTypeOfGenerator(returnType, isAsync) || anyType; + const signatureElementType = getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Yield, returnType, isAsync) || anyType; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureElementType, node.expression || node, node.expression); } - // Both yield and yield* expressions have type 'any' + if (node.asteriskToken) { + return getIterationTypeOfIterable(IterationTypeKind.Return, yieldExpressionType, node.expression, isAsync, /*allowSyncIterables*/ true, /*checkAssignability*/ false) + || anyType; + } + else if (returnType) { + return getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Next, returnType, isAsync) + || anyType; + } + return anyType; } @@ -24307,18 +24386,17 @@ namespace ts { error(returnTypeNode, Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - const generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags & FunctionFlags.Async) !== 0) || anyType; - const iterableIteratorInstantiation = functionFlags & FunctionFlags.Async - ? createAsyncIterableIteratorType(generatorElementType) // AsyncGenerator function - : createIterableIteratorType(generatorElementType); // Generator function - - // Naively, one could check that IterableIterator is assignable to the return type annotation. + // Naively, one could check that Generator 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, returnTypeNode); + const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Yield, returnType, (functionFlags & FunctionFlags.Async) !== 0) || anyType; + const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Return, returnType, (functionFlags & FunctionFlags.Async) !== 0) || generatorYieldType; + const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Next, returnType, (functionFlags & FunctionFlags.Async) !== 0) || unknownType; + const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags & FunctionFlags.Async)); + checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } else if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { @@ -25852,11 +25930,7 @@ namespace ts { const body = node.kind === SyntaxKind.MethodSignature ? undefined : node.body; checkSourceElement(body); - - if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function - const returnOrPromisedType = getReturnOrPromisedType(node, functionFlags); - checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); - } + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnOrPromisedType(node, functionFlags)); if (produceDiagnostics && !getEffectiveReturnTypeNode(node)) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -26835,7 +26909,7 @@ namespace ts { // downlevelIteration is requested. if (uplevelIteration || downlevelIteration || allowAsyncIterables) { // We only report errors for an invalid iterable type in ES2015 or higher. - const iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); + const iteratedType = getIterationTypeOfIterable(IterationTypeKind.Yield, inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); if (iteratedType || uplevelIteration) { return iteratedType; } @@ -26886,7 +26960,7 @@ namespace ts { // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - const isIterable = !!getIteratedTypeOfIterable(inputType, /* errorNode */ undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); + const isIterable = !!getIterationTypeOfIterable(IterationTypeKind.Yield, inputType, /* errorNode */ undefined, allowAsyncIterables, /*allowSyncIterables*/ true, checkAssignability); const diagnostic = !allowStringInput || hasStringConstituent ? downlevelIteration ? Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator @@ -26917,33 +26991,31 @@ namespace ts { } /** - * 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): + * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. * - * { // iterable - * [Symbol.iterator]: { // iteratorMethod - * (): Iterator - * } - * } + * We pick either `TYield`, `TReturn`, or `TNext` (as specified by `kind`) per the following rules: * - * For an async iterable, we expect the following structure: + * - If `allowSyncIterables` is `true` and `type` matches: + * - `{[Symbol.iterator]():{next(value?: TNext)}` + * - `{[Symbol.iterator]():{return(value?: TReturn)}` + * - `{[Symbol.iterator]():{next(): {done: false, value: TYield}}` + * - `{[Symbol.iterator]():{next(): {done: true, value: TReturn}}` * - * { // iterable - * [Symbol.asyncIterator]: { // iteratorMethod - * (): AsyncIterator - * } - * } + * - If `allowAsyncIterables` is `true` and `type` matches: + * - `{[Symbol.asyncIterator](): {next(value?: TNext | PromiseLike)}}` + * - `{[Symbol.asyncIterator](): {return(value?: TReturn | PromiseLike)}}` + * - `{[Symbol.asyncIterator](): {next(): PromiseLike<{done: false, value: TYield}>}}` + * - `{[Symbol.asyncIterator](): {next(): PromiseLike<{done: true, value: TReturn}>}}` * - * 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. + * 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 + * happens, we return `undefined` to signal that we could not find the iteration 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'. + * type. This is different from returning `anyType`, because that would signify that we have matched the + * whole pattern and that the type we picked (`TYield`, `TReturn`, or `TNext`) is `any`. * * For a **for-of** statement, `yield*` (in a normal generator), spread, array * destructuring, or normal generator we will only ever look for a `[Symbol.iterator]()` @@ -26954,42 +27026,64 @@ namespace ts { * For a **for-await-of** statement or a `yield*` in an async generator we will look for * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getIteratedTypeOfIterable(type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: boolean): Type | undefined { + function getIterationTypeOfIterable(kind: IterationTypeKind.Yield, type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: boolean): Type | undefined; + function getIterationTypeOfIterable(kind: IterationTypeKind, type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: false): Type | undefined; + function getIterationTypeOfIterable(kind: IterationTypeKind, type: Type, errorNode: Node | undefined, allowAsyncIterables: boolean, allowSyncIterables: boolean, checkAssignability: boolean): Type | undefined { + Debug.assert(kind === IterationTypeKind.Yield || !checkAssignability, "Cannot check assignability when 'kind' is not 'Yield'."); if (isTypeAny(type)) { return undefined; } - return mapType(type, getIteratedType); + return mapType(type, getIterationType); - function getIteratedType(type: Type) { + function getIterationType(type: Type) { const typeAsIterable = type; + let cachedType: Type | undefined; if (allowAsyncIterables) { - if (typeAsIterable.iteratedTypeOfAsyncIterable) { - return typeAsIterable.iteratedTypeOfAsyncIterable; + if (cachedType = getCachedIterationType(typeAsIterable, IterationTypesCacheKind.AsyncIterable, kind)) { + return cachedType; } - // As an optimization, if the type is an instantiation of the global `AsyncIterable` - // or the global `AsyncIterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { - return typeAsIterable.iteratedTypeOfAsyncIterable = (type).typeArguments![0]; + // As an optimization, if the type is an instantiation of one of the global `AsyncIterable`, + // `AsyncIterableIterator`, or `AsyncGenerator` types, then just grab its type argument. + let typeArgument: Type | undefined; + if (isReferenceToType(type, getGlobalAsyncGeneratorType(/*reportErrors*/ false))) { + typeArgument = (type).typeArguments![getTypeArgumentIndexFromIterationTypeKind(kind)]; + } + else if (kind === IterationTypeKind.Yield) { + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + typeArgument = (type).typeArguments![0]; + } + } + if (typeArgument) { + return setCachedIterationType(typeAsIterable, IterationTypesCacheKind.AsyncIterable, kind, typeArgument); } } if (allowSyncIterables) { - if (typeAsIterable.iteratedTypeOfIterable) { + if (cachedType = getCachedIterationType(typeAsIterable, IterationTypesCacheKind.Iterable, kind)) { return allowAsyncIterables - ? typeAsIterable.iteratedTypeOfAsyncIterable = getAwaitedType(typeAsIterable.iteratedTypeOfIterable) - : typeAsIterable.iteratedTypeOfIterable; + ? setCachedIterationType(typeAsIterable, IterationTypesCacheKind.AsyncIterable, kind, getAwaitedType(cachedType)) + : cachedType; } - // As an optimization, if the type is an instantiation of the global `Iterable` or - // `IterableIterator` then just grab its type argument. - if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || - isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + // As an optimization, if the type is an instantiation of one of the global `Iterable`, + // `IterableIterator`, or `Generator` types, then just grab its type argument. + let typeArgument: Type | undefined; + if (isReferenceToType(type, getGlobalGeneratorType(/*reportErrors*/ false))) { + typeArgument = (type).typeArguments![getTypeArgumentIndexFromIterationTypeKind(kind)]; + } + else if (kind === IterationTypeKind.Yield) { + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + typeArgument = (type).typeArguments![0]; + } + } + if (typeArgument) { return allowAsyncIterables - ? typeAsIterable.iteratedTypeOfAsyncIterable = getAwaitedType((type).typeArguments![0]) - : typeAsIterable.iteratedTypeOfIterable = (type).typeArguments![0]; + ? setCachedIterationType(typeAsIterable, IterationTypesCacheKind.AsyncIterable, kind, getAwaitedType(typeArgument)) + : setCachedIterationType(typeAsIterable, IterationTypesCacheKind.Iterable, kind, typeArgument); } } @@ -27010,20 +27104,20 @@ namespace ts { } const returnType = getUnionType(map(signatures, getReturnTypeOfSignature), UnionReduction.Subtype); - const iteratedType = getIteratedTypeOfIterator(returnType, errorNode, /*isAsyncIterator*/ !!asyncMethodType); - if (checkAssignability && errorNode && iteratedType) { + const iterationType = getIterationTypeOfIterator(kind, returnType, errorNode, /*isAsyncIterator*/ !!asyncMethodType); + if (checkAssignability && errorNode && iterationType && kind === IterationTypeKind.Yield) { // If `checkAssignability` was specified, we were called from // `checkIteratedTypeOrElementType`. As such, we need to validate that // the type passed in is actually an Iterable. checkTypeAssignableTo(type, asyncMethodType - ? createAsyncIterableType(iteratedType) - : createIterableType(iteratedType), errorNode); + ? createAsyncIterableType(iterationType) + : createIterableType(iterationType), errorNode); } - if (iteratedType) { + if (iterationType) { return allowAsyncIterables - ? typeAsIterable.iteratedTypeOfAsyncIterable = asyncMethodType ? iteratedType : getAwaitedType(iteratedType) - : typeAsIterable.iteratedTypeOfIterable = iteratedType; + ? setCachedIterationType(typeAsIterable, IterationTypesCacheKind.AsyncIterable, kind, asyncMethodType ? iterationType : getAwaitedType(iterationType)) + : setCachedIterationType(typeAsIterable, IterationTypesCacheKind.Iterable, kind, iterationType); } } } @@ -27034,52 +27128,90 @@ namespace ts { : Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator, typeToString(type)); } + function isIteratorResult(type: Type, kind: IterationTypeKind.Yield | IterationTypeKind.Return) { + // From https://tc39.github.io/ecma262/#sec-iteratorresult-interface: + // > [done] is the result status of an iterator `next` method call. If the end of the iterator was reached `done` is `true`. + // > If the end was not reached `done` is `false` and a value is available. + // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. + const doneType = getTypeOfPropertyOfType(type, "done" as __String) || falseType; + return isTypeAssignableTo(kind === IterationTypeKind.Yield ? falseType : trueType, doneType); + } + /** - * This function has very similar logic as getIteratedTypeOfIterable, except that it operates on - * Iterators instead of Iterables. Here is the structure: - * - * { // iterator - * next: { // nextMethod - * (): { // nextResult - * value: T // nextValue - * } - * } - * } - * - * For an async iterator, we expect the following structure: + * Determines whether `type` is an `IteratorResult`-like type whose `done` property could be `false`. + */ + function isYieldIteratorResult(type: Type) { + return isIteratorResult(type, IterationTypeKind.Yield); + } + + /** + * Determines whether `type` is an `IteratorResult`-like type whose `done` property could be `true`. + */ + function isReturnIteratorResult(type: Type) { + return isIteratorResult(type, IterationTypeKind.Return); + } + + /** + * Gets the iteration type of an `IteratorResult`-like type. * - * { // iterator - * next: { // nextMethod - * (): PromiseLike<{ // nextResult - * value: T // nextValue - * }> - * } - * } + * We pick either `TYield` or `TReturn` (as specified by `kind`) if `type` matches: + * - `{done: false, value: TYield}` + * - `{done: true, value: TReturn}` */ - function getIteratedTypeOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean): Type | undefined { - if (isTypeAny(type)) { - return undefined; + function getIterationTypeOfIteratorResult(kind: IterationTypeKind.Yield | IterationTypeKind.Return, type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { + const typeAsIterationCache = type as IterableOrIteratorType; + + let cachedType: Type | undefined; + if (cachedType = getCachedIterationType(typeAsIterationCache, IterationTypesCacheKind.IteratorResult, kind)) { + return cachedType; } - const typeAsIterator = type; - if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { - return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; + // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` + // or `IteratorReturnResult` types, then just grab its type argument. + const getGeneratorResultType = kind === IterationTypeKind.Yield ? getGlobalIteratorYieldResultType : getGlobalIteratorReturnResultType; + if (isReferenceToType(type, getGeneratorResultType(/*reportErrors*/ false))) { + const typeArgument = (type as GenericType).typeArguments![0]; + return setCachedIterationType(typeAsIterationCache, IterationTypesCacheKind.IteratorResult, kind, typeArgument); } - // As an optimization, if the type is an instantiation of the global `Iterator` (for - // a non-async iterator) or the global `AsyncIterator` (for an async-iterator) then - // just grab its type argument. - const getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; - if (isReferenceToType(type, getIteratorType(/*reportErrors*/ false))) { - return isAsyncIterator - ? typeAsIterator.iteratedTypeOfAsyncIterator = (type).typeArguments![0] - : typeAsIterator.iteratedTypeOfIterator = (type).typeArguments![0]; + // Choose any constituents that can produce the requested iteration type. + const filteredType = filterType(type, kind === IterationTypeKind.Yield ? isYieldIteratorResult : isReturnIteratorResult); + let iterationType = filteredType !== neverType ? getTypeOfPropertyOfType(filteredType, "value" as __String) : undefined; + if (!iterationType) { + if (kind === IterationTypeKind.Return) { + // From https://tc39.github.io/ecma262/#sec-iteratorresult-interface: + // > ... If the iterator does not have a return value, `value` is `undefined`. In that case, the + // > `value` property may be absent from the conforming object if it does not inherit an explicit + // > `value` property. + iterationType = voidType; + } + else { + if (errorNode) { + error(errorNode, isAsyncIterator + ? Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } } + return setCachedIterationType(typeAsIterationCache, IterationTypesCacheKind.IteratorResult, kind, iterationType); + } + + /** + * Gets the return-type of the `next` method of an `Iterator`-like or `AsyncIterator`-like type: + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{next(): T}` + * + * - If `isAsyncIterator` is `true`, we pick `T` if `type` matches: + * - `{next(): PromiseLike}` + */ + function getReturnTypeFromNextMethodOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { // Both async and non-async iterators must have a `next` method. const nextMethod = getTypeOfPropertyOfType(type, "next" as __String); if (isTypeAny(nextMethod)) { - return undefined; + return anyType; } const nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, SignatureKind.Call) : emptyArray; @@ -27089,50 +27221,215 @@ namespace ts { ? Diagnostics.An_async_iterator_must_have_a_next_method : Diagnostics.An_iterator_must_have_a_next_method); } + return errorType; + } + + let nextReturnType: Type | undefined = getUnionType(map(nextMethodSignatures, getReturnTypeOfSignature), UnionReduction.Subtype); + if (isTypeAny(nextReturnType)) { + return anyType; + } + + // For an async iterator, we must get the awaited type of the return type. + if (isAsyncIterator) { + nextReturnType = getAwaitedTypeOfPromise(nextReturnType, errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextReturnType)) { + return anyType; + } + } + + return nextReturnType; + } + + /** + * Gets the "yield" iteration type of an `Iterator`-like or `AsyncIterator`-like type: + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{next(): {done: false, value: T}}` + * + * - If `isAsyncIterator` is `true`, we pick `T` if `type` matches: + * - `{next(): PromiseLike<{done: false, value: T}>}` + */ + function getYieldIterationTypeOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { + const iteratorResultType = getReturnTypeFromNextMethodOfIterator(type, errorNode, isAsyncIterator); + if (isTypeAny(iteratorResultType)) { + return undefined; + } + + return iteratorResultType && getIterationTypeOfIteratorResult(IterationTypeKind.Yield, iteratorResultType, errorNode, isAsyncIterator); + } + + /** + * Gets the "return" iteration type from the `return` method of an `Iterator`-like or `AsyncIterator`-like type: + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{return(value: T)}` + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{return(value: T | PromiseLike)}` + */ + function getReturnIterationTypeFromReturnMethodOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { + // Both async and non-async iterators may have a `return` method. + const returnMethod = getTypeOfPropertyOfType(type, "return" as __String); + if (isTypeAny(returnMethod)) { return undefined; } - let nextResult: Type | undefined = getUnionType(map(nextMethodSignatures, getReturnTypeOfSignature), UnionReduction.Subtype); - if (isTypeAny(nextResult)) { + const returnMethodSignatures = returnMethod ? getSignaturesOfType(returnMethod, SignatureKind.Call) : emptyArray; + if (returnMethodSignatures.length === 0) { + return undefined; + } + + let returnType: Type | undefined = getTypeWithFacts(getUnionType(map(returnMethodSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull); + if (isTypeAny(returnType)) { return undefined; } - // For an async iterator, we must get the awaited type of the return type. if (isAsyncIterator) { - nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); - if (isTypeAny(nextResult)) { + returnType = getAwaitedTypeOfPromise(returnType, errorNode); + if (isTypeAny(returnType)) { return undefined; } } - const nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value" as __String); - if (!nextValue) { + return returnType; + } + + /** + * Gets the "return" iteration type of an `Iterator`-like or `AsyncIterator`-like type: + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{return(value: T)}` + * - `{next(): {done: true, value: T}}` + * + * - If `isAsyncIterator` is `true`, we pick `T` if `type` matches: + * - `{return(value: T | PromiseLike)}` + * - `{next(): PromiseLike<{done: true, value: T}>}` + */ + function getReturnIterationTypeOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { + let returnType = getReturnIterationTypeFromReturnMethodOfIterator(type, errorNode, isAsyncIterator); + if (!returnType) { + const iteratorResultType = getReturnTypeFromNextMethodOfIterator(type, errorNode, isAsyncIterator); + if (isTypeAny(iteratorResultType)) { + return undefined; + } + + returnType = iteratorResultType && getIterationTypeOfIteratorResult(IterationTypeKind.Return, iteratorResultType, errorNode, isAsyncIterator); + } + return returnType; + } + + /** + * Gets the "next" iteration type of an `Iterator`-like or `AsyncIterator`-like type: + * + * - If `isAsyncIterator` is `false`, we pick `T` if `type` matches: + * - `{next(value?: T)}` + * + * - If `isAsyncIterator` is `true`, we pick `T` if `type` matches: + * - `{next(value?: T | PromiseLike)}` + */ + function getNextIterationTypeOfIterator(type: Type, errorNode: Node | undefined, isAsyncIterator: boolean) { + // Both async and non-async iterators must have a `next` method. + const nextMethod = getTypeOfPropertyOfType(type, "next" as __String); + if (isTypeAny(nextMethod)) { + return undefined; + } + + const nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, SignatureKind.Call) : emptyArray; + if (nextMethodSignatures.length === 0) { if (errorNode) { error(errorNode, isAsyncIterator - ? Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property - : Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + ? Diagnostics.An_async_iterator_must_have_a_next_method + : Diagnostics.An_iterator_must_have_a_next_method); } return undefined; } - return isAsyncIterator - ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue - : typeAsIterator.iteratedTypeOfIterator = nextValue; + let nextParameterTypes: Type[] | undefined; + for (const signature of nextMethodSignatures) { + const type = signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : undefined; + if (type) nextParameterTypes = append(nextParameterTypes, type); + } + + // If no signature for `next()` takes an argument, then return `unknownType` instead. + if (!nextParameterTypes) { + return unknownType; + } + + let nextType: Type | undefined = getTypeWithFacts(getUnionType(nextParameterTypes), TypeFacts.NEUndefinedOrNull); + if (isTypeAny(nextType)) { + return undefined; + } + if (isAsyncIterator) { + nextType = getAwaitedTypeOfPromise(nextType, errorNode); + if (isTypeAny(nextType)) { + return undefined; + } + } + return nextType; + } + + /** + * Gets the specified "iteration type" from an `Iterator`-like or `AsyncIterator`-like type. + * + * We pick either pick either `TYield`, `TReturn`, or `TNext` (as specified by `kind`) per the following rules: + * + * - If `isAsyncIterator` is `false` and `type` matches: + * - `{next(value?: TNext)}` + * - `{return(value?: TReturn)}` + * - `{next(): {done: false, value: TYield}}` + * - `{next(): {done: true, value: TReturn}}` + * + * - If `isAsyncIterator` is `true` and `type` matches: + * - `{next(value?: TNext | PromiseLike)}` + * - `{return(value?: TReturn | PromiseLike)}` + * - `{next(): PromiseLike<{done: false, value: TYield}>}` + * - `{next(): PromiseLike<{done: true, value: TReturn}>}` + */ + function getIterationTypeOfIterator(kind: IterationTypeKind, type: Type, errorNode: Node | undefined, isAsyncIterator: boolean): Type | undefined { + if (isTypeAny(type)) { + return undefined; + } + + const typeAsIterator = type; + const cacheKind = isAsyncFunction ? IterationTypesCacheKind.AsyncIterator : IterationTypesCacheKind.Iterator; + let cacheType: Type | undefined; + if (cacheType = getCachedIterationType(typeAsIterator, cacheKind, kind)) { + return cacheType; + } + + // As an optimization, if the type is an instantiation of the global `Iterator` (for + // a non-async iterator) or the global `AsyncIterator` (for an async-iterator) then + // just grab its type argument. + const getIteratorType = kind === IterationTypeKind.Yield ? (isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType) : undefined; + const getIterableIteratorType = kind === IterationTypeKind.Yield ? (isAsyncIterator ? getGlobalAsyncIterableIteratorType : getGlobalIterableIteratorType) : undefined; + const getGeneratorType = isAsyncIterator ? getGlobalAsyncGeneratorType : getGlobalGeneratorType; + if (getIteratorType && isReferenceToType(type, getIteratorType(/*reportErrors*/ false)) || + getIterableIteratorType && isReferenceToType(type, getIterableIteratorType(/*reportErrors*/ false)) || + isReferenceToType(type, getGeneratorType(/*reportErrors*/ false))) { + const typeArgument = (type).typeArguments![getTypeArgumentIndexFromIterationTypeKind(kind)]; + return setCachedIterationType(typeAsIterator, cacheKind, kind, typeArgument); + } + + const iterationType = + kind === IterationTypeKind.Yield ? getYieldIterationTypeOfIterator(type, errorNode, isAsyncIterator) : + kind === IterationTypeKind.Return ? getReturnIterationTypeOfIterator(type, errorNode, isAsyncIterator) : + getNextIterationTypeOfIterator(type, errorNode, isAsyncIterator); + + return setCachedIterationType(typeAsIterator, cacheKind, kind, iterationType); } /** - * A generator may have a return type of `Iterator`, `Iterable`, or - * `IterableIterator`. An async generator may have a return type of `AsyncIterator`, - * `AsyncIterable`, or `AsyncIterableIterator`. This function can be used to extract - * the iterated type from this return type for contextual typing and verifying signatures. + * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, + * `IterableIterator`-like, or `Generator`-like (for a non-async generator); or `AsyncIterable`-like, + * `AsyncIterator`-like, `AsyncIterableIterator`-like, or `Generator`-like. */ - function getIteratedTypeOfGenerator(returnType: Type, isAsyncGenerator: boolean): Type | undefined { + function getIterationTypeOfGeneratorFunctionReturnType(kind: IterationTypeKind, returnType: Type, isAsyncGenerator: boolean): Type | undefined { if (isTypeAny(returnType)) { return undefined; } - return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, /*allowAsyncIterables*/ isAsyncGenerator, /*allowSyncIterables*/ !isAsyncGenerator, /*checkAssignability*/ false) - || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); + return getIterationTypeOfIterable(kind, returnType, /*errorNode*/ undefined, /*allowAsyncIterables*/ isAsyncGenerator, /*allowSyncIterables*/ !isAsyncGenerator, /*checkAssignability*/ false) + || getIterationTypeOfIterator(kind, returnType, /*errorNode*/ undefined, isAsyncGenerator); } function checkBreakOrContinueStatement(node: BreakOrContinueStatement) { @@ -27142,10 +27439,16 @@ namespace ts { // TODO: Check that target label is valid } + function unwrapReturnType(returnType: Type, functionFlags: FunctionFlags) { + const isGenerator = !!(functionFlags & FunctionFlags.Generator); + const isAsync = !!(functionFlags & FunctionFlags.Async); + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Return, returnType, isAsync) || errorType : + isAsync ? getPromisedTypeOfPromise(returnType) || errorType : + returnType; + } + function isUnwrappedReturnTypeVoidOrAny(func: SignatureDeclaration, returnType: Type): boolean { - const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncGenerator) === FunctionFlags.Async - ? getPromisedTypeOfPromise(returnType) // Async function - : returnType; // AsyncGenerator function, Generator function, or normal function + const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(func)); return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.AnyOrUnknown); } @@ -27164,17 +27467,9 @@ namespace ts { const signature = getSignatureFromDeclaration(func); const returnType = getReturnTypeOfSignature(signature); const functionFlags = getFunctionFlags(func); - const isGenerator = functionFlags & FunctionFlags.Generator; if (strictNullChecks || node.expression || returnType.flags & TypeFlags.Never) { const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (isGenerator) { // AsyncGenerator function or Generator function - // 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 types of generators when return type tracking is added - // for generators. - return; - } - else if (func.kind === SyntaxKind.SetAccessor) { + if (func.kind === SyntaxKind.SetAccessor) { if (node.expression) { error(node, Diagnostics.Setters_cannot_return_a_value); } @@ -27185,22 +27480,19 @@ namespace ts { } } else if (getReturnTypeFromAnnotation(func)) { - if (functionFlags & FunctionFlags.Async) { // Async function - const promisedType = getPromisedTypeOfPromise(returnType); - const awaitedType = checkAwaitedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (promisedType) { - // If the function has a return type, but promisedType is - // undefined, an error will be reported in checkAsyncFunctionReturnType - // so we don't need to report one here. - checkTypeAssignableToAndOptionallyElaborate(awaitedType, promisedType, node, node.expression); - } - } - else { - checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression); + const unwrappedReturnType = unwrapReturnType(returnType, functionFlags); + const unwrappedExprType = functionFlags & FunctionFlags.Async + ? checkAwaitedType(exprType, node, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : exprType; + if (unwrappedReturnType) { + // If the function has a return type, but promisedType is + // undefined, an error will be reported in checkAsyncFunctionReturnType + // so we don't need to report one here. + checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression); } } } - else if (func.kind !== SyntaxKind.Constructor && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== SyntaxKind.Constructor && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, Diagnostics.Not_all_code_paths_return_a_value); } @@ -32096,4 +32388,50 @@ namespace ts { export const LibraryManagedAttributes = "LibraryManagedAttributes" as __String; // tslint:enable variable-name } + + function getCacheKeyFromIterationTypesCacheKind(cacheKind: IterationTypesCacheKind) { + switch (cacheKind) { + case IterationTypesCacheKind.Iterable: return "iterationTypesOfIterable"; + case IterationTypesCacheKind.Iterator: return "iterationTypesOfIterator"; + case IterationTypesCacheKind.AsyncIterable: return "iterationTypesOfAsyncIterable"; + case IterationTypesCacheKind.AsyncIterator: return "iterationTypesOfAsyncIterator"; + case IterationTypesCacheKind.IteratorResult: return "iterationTypesOfIteratorResult"; + } + } + + function getCacheKeyFromIterationTypeKind(typeKind: IterationTypeKind) { + switch (typeKind) { + case IterationTypeKind.Yield: return "yieldType"; + case IterationTypeKind.Return: return "returnType"; + case IterationTypeKind.Next: return "nextType"; + } + } + + function getTypeArgumentIndexFromIterationTypeKind(typeKind: IterationTypeKind) { + switch (typeKind) { + case IterationTypeKind.Yield: return 0; + case IterationTypeKind.Return: return 1; + case IterationTypeKind.Next: return 2; + } + } + + function getCachedIterationTypes(type: IterableOrIteratorType, cacheKind: IterationTypesCacheKind, create: true): IterationTypes; + function getCachedIterationTypes(type: IterableOrIteratorType, cacheKind: IterationTypesCacheKind, create: boolean): IterationTypes | undefined; + function getCachedIterationTypes(type: IterableOrIteratorType, cacheKind: IterationTypesCacheKind, create: boolean) { + const key = getCacheKeyFromIterationTypesCacheKind(cacheKind); + return type[key] || (create ? type[key] = {} : undefined); + } + + function getCachedIterationType(typeAsIterableOrIterator: IterableOrIteratorType, cacheKind: IterationTypesCacheKind, typeKind: IterationTypeKind) { + const iterationTypes = getCachedIterationTypes(typeAsIterableOrIterator, cacheKind, /*create*/ false); + return iterationTypes && iterationTypes[getCacheKeyFromIterationTypeKind(typeKind)]; + } + + function setCachedIterationType(typeAsIterableOrIterator: IterableOrIteratorType, cacheKind: IterationTypesCacheKind, typeKind: IterationTypeKind, type: Type | undefined) { + if (type) { + const iterationTypes = getCachedIterationTypes(typeAsIterableOrIterator, cacheKind, /*create*/ true); + iterationTypes[getCacheKeyFromIterationTypeKind(typeKind)] = type; + return type; + } + } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 12a20e0df42e1..c148fddc62137 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -39,6 +39,7 @@ namespace ts { ["es2017.string", "lib.es2017.string.d.ts"], ["es2017.intl", "lib.es2017.intl.d.ts"], ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"], + ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"], ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"], ["es2018.intl", "lib.es2018.intl.d.ts"], ["es2018.promise", "lib.es2018.promise.d.ts"], diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7717f51bd50fe..2565402ac246c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3899,6 +3899,10 @@ "category": "Message", "code": 6217 }, + "Enable strict checking of generator types.": { + "category": "Message", + "code": 6218 + }, "Projects to reference": { "category": "Message", @@ -4256,6 +4260,10 @@ "category": "Error", "code": 7051 }, + "Generator implicitly has type '{0}' because it does not yield or return any values. Consider supplying a return type.": { + "category": "Error", + "code": 7052 + }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55492081050a8..4117e0daaea0f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4226,13 +4226,21 @@ namespace ts { regularType: ResolvedType; // Regular version of fresh type } + /* @internal */ + export interface IterationTypes { + yieldType?: Type; + returnType?: Type; + nextType?: Type; + } + // Just a place to cache element types of iterables and iterators /* @internal */ export interface IterableOrIteratorType extends ObjectType, UnionType { - iteratedTypeOfIterable?: Type; - iteratedTypeOfIterator?: Type; - iteratedTypeOfAsyncIterable?: Type; - iteratedTypeOfAsyncIterator?: Type; + iterationTypesOfIterable?: IterationTypes; + iterationTypesOfIterator?: IterationTypes; + iterationTypesOfAsyncIterable?: IterationTypes; + iterationTypesOfAsyncIterator?: IterationTypes; + iterationTypesOfIteratorResult?: IterationTypes; } /* @internal */ diff --git a/src/lib/es2015.generator.d.ts b/src/lib/es2015.generator.d.ts index 92bb8dca8685a..b6b5c82a1af7b 100644 --- a/src/lib/es2015.generator.d.ts +++ b/src/lib/es2015.generator.d.ts @@ -1,4 +1,11 @@ -interface Generator extends Iterator { } +/// + +interface Generator { + next(value?: TNext): IteratorResult; + return(value: TReturn): IteratorResult; + throw(e: any): IteratorResult; + [Symbol.iterator](): Generator; +} interface GeneratorFunction { /** diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index b679bea14d572..4973a45310305 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -8,11 +8,18 @@ interface SymbolConstructor { readonly iterator: symbol; } -interface IteratorResult { - done: boolean; - value: T; +interface IteratorYieldResult { + done: false; + value: TYield; } +interface IteratorReturnResult { + done: true; + value: TReturn; +} + +type IteratorResult = IteratorYieldResult | IteratorReturnResult; + interface Iterator { next(value?: any): IteratorResult; return?(value?: any): IteratorResult; @@ -27,24 +34,30 @@ interface IterableIterator extends Iterator { [Symbol.iterator](): IterableIterator; } +interface ArrayIterator { + next(): IteratorResult; + [Symbol.iterator](): ArrayIterator; + [Symbol.toStringTag]: string; +} + interface Array { /** Iterator */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an iterable of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, T]>; + entries(): ArrayIterator<[number, T]>; /** * Returns an iterable of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an iterable of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface ArrayConstructor { @@ -65,22 +78,22 @@ interface ArrayConstructor { interface ReadonlyArray { /** Iterator of values in the array. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an iterable of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, T]>; + entries(): ArrayIterator<[number, T]>; /** * Returns an iterable of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an iterable of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface IArguments { @@ -88,44 +101,50 @@ interface IArguments { [Symbol.iterator](): IterableIterator; } +interface MapIterator { + next(): IteratorResult; + [Symbol.iterator](): MapIterator; + [Symbol.toStringTag]: string; +} + interface Map { /** Returns an iterable of entries in the map. */ - [Symbol.iterator](): IterableIterator<[K, V]>; + [Symbol.iterator](): MapIterator<[K, V]>; /** * Returns an iterable of key, value pairs for every entry in the map. */ - entries(): IterableIterator<[K, V]>; + entries(): MapIterator<[K, V]>; /** * Returns an iterable of keys in the map */ - keys(): IterableIterator; + keys(): MapIterator; /** * Returns an iterable of values in the map */ - values(): IterableIterator; + values(): MapIterator; } interface ReadonlyMap { /** Returns an iterable of entries in the map. */ - [Symbol.iterator](): IterableIterator<[K, V]>; + [Symbol.iterator](): MapIterator<[K, V]>; /** * Returns an iterable of key, value pairs for every entry in the map. */ - entries(): IterableIterator<[K, V]>; + entries(): MapIterator<[K, V]>; /** * Returns an iterable of keys in the map */ - keys(): IterableIterator; + keys(): MapIterator; /** * Returns an iterable of values in the map */ - values(): IterableIterator; + values(): MapIterator; } interface MapConstructor { @@ -138,42 +157,48 @@ interface WeakMapConstructor { new (iterable: Iterable<[K, V]>): WeakMap; } +interface SetIterator { + next(): IteratorResult; + [Symbol.iterator](): SetIterator; + [Symbol.toStringTag]: string; +} + interface Set { /** Iterates over values in the set. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): SetIterator; /** * Returns an iterable of [v,v] pairs for every value `v` in the set. */ - entries(): IterableIterator<[T, T]>; + entries(): SetIterator<[T, T]>; /** * Despite its name, returns an iterable of the values in the set, */ - keys(): IterableIterator; + keys(): SetIterator; /** * Returns an iterable of values in the set. */ - values(): IterableIterator; + values(): SetIterator; } interface ReadonlySet { /** Iterates over values in the set. */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): SetIterator; /** * Returns an iterable of [v,v] pairs for every value `v` in the set. */ - entries(): IterableIterator<[T, T]>; + entries(): SetIterator<[T, T]>; /** * Despite its name, returns an iterable of the values in the set, */ - keys(): IterableIterator; + keys(): SetIterator; /** * Returns an iterable of values in the set. */ - values(): IterableIterator; + values(): SetIterator; } interface SetConstructor { @@ -210,25 +235,31 @@ declare namespace Reflect { function enumerate(target: object): IterableIterator; } +interface StringIterator { + next(): IteratorResult; + [Symbol.iterator](): StringIterator; + [Symbol.toStringTag]: string; +} + interface String { /** Iterator */ - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): StringIterator; } interface Int8Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Int8ArrayConstructor { @@ -244,19 +275,19 @@ interface Int8ArrayConstructor { } interface Uint8Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Uint8ArrayConstructor { @@ -272,21 +303,21 @@ interface Uint8ArrayConstructor { } interface Uint8ClampedArray { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Uint8ClampedArrayConstructor { @@ -303,21 +334,21 @@ interface Uint8ClampedArrayConstructor { } interface Int16Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Int16ArrayConstructor { @@ -333,19 +364,19 @@ interface Int16ArrayConstructor { } interface Uint16Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Uint16ArrayConstructor { @@ -361,19 +392,19 @@ interface Uint16ArrayConstructor { } interface Int32Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Int32ArrayConstructor { @@ -389,19 +420,19 @@ interface Int32ArrayConstructor { } interface Uint32Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Uint32ArrayConstructor { @@ -417,19 +448,19 @@ interface Uint32ArrayConstructor { } interface Float32Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Float32ArrayConstructor { @@ -445,19 +476,19 @@ interface Float32ArrayConstructor { } interface Float64Array { - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; /** * Returns an array of key, value pairs for every entry in the array */ - entries(): IterableIterator<[number, number]>; + entries(): ArrayIterator<[number, number]>; /** * Returns an list of keys in the array */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns an list of values in the array */ - values(): IterableIterator; + values(): ArrayIterator; } interface Float64ArrayConstructor { diff --git a/src/lib/es2018.asyncgenerator.d.ts b/src/lib/es2018.asyncgenerator.d.ts new file mode 100644 index 0000000000000..af069ed52f10c --- /dev/null +++ b/src/lib/es2018.asyncgenerator.d.ts @@ -0,0 +1,58 @@ +/// + +interface AsyncGenerator { + next(value?: TNext): Promise>; + return(value: TReturn): Promise>; + throw(e: unknown): Promise>; + [Symbol.asyncIterator](): AsyncGenerator; +} + +interface AsyncGeneratorFunction { + /** + * Creates a new AsyncGenerator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): AsyncGenerator; + /** + * Creates a new AsyncGenerator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): AsyncGenerator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: AsyncGenerator; +} + +interface AsyncGeneratorFunctionConstructor { + /** + * Creates a new AsyncGenerator function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): AsyncGeneratorFunction; + /** + * Creates a new AsyncGenerator function. + * @param args A list of arguments the function accepts. + */ + (...args: string[]): AsyncGeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: AsyncGeneratorFunction; +} diff --git a/src/lib/es2018.d.ts b/src/lib/es2018.d.ts index 2a20887b3ee22..b7670a81c3c44 100644 --- a/src/lib/es2018.d.ts +++ b/src/lib/es2018.d.ts @@ -1,4 +1,5 @@ /// +/// /// /// /// diff --git a/src/lib/esnext.bigint.d.ts b/src/lib/esnext.bigint.d.ts index 5718e4a575167..2f3f163cf8843 100644 --- a/src/lib/esnext.bigint.d.ts +++ b/src/lib/esnext.bigint.d.ts @@ -65,7 +65,7 @@ interface BigInt64Array { copyWithin(target: number, start: number, end?: number): this; /** Yields index, value pairs for every entry in the array. */ - entries(): IterableIterator<[number, bigint]>; + entries(): ArrayIterator<[number, bigint]>; /** * Determines whether all the members of an array satisfy the specified test. @@ -150,7 +150,7 @@ interface BigInt64Array { join(separator?: string): string; /** Yields each index in the array. */ - keys(): IterableIterator; + keys(): ArrayIterator; /** * Returns the index of the last occurrence of a value in an array. @@ -269,9 +269,9 @@ interface BigInt64Array { toString(): string; /** Yields each value in the array. */ - values(): IterableIterator; + values(): ArrayIterator; - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): ArrayIterator; readonly [Symbol.toStringTag]: "BigInt64Array"; diff --git a/src/lib/libs.json b/src/lib/libs.json index fa5f4060acd6a..6b46d6916b0b2 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -30,6 +30,7 @@ "es2017.string", "es2017.intl", "es2017.typedarrays", + "es2018.asyncgenerator", "es2018.asynciterable", "es2018.regexp", "es2018.promise", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index ccb2378c644a8..91fa562bd3c43 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -57,7 +57,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -259,7 +259,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, @@ -278,7 +278,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.string', 'es2019.symbol', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, file: undefined, diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.types b/tests/baselines/reference/FunctionDeclaration11_es6.types index 0a312c2661cf2..c5053de9781a9 100644 --- a/tests/baselines/reference/FunctionDeclaration11_es6.types +++ b/tests/baselines/reference/FunctionDeclaration11_es6.types @@ -1,4 +1,4 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts === function * yield() { ->yield : () => IterableIterator +>yield : () => Generator } diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.types b/tests/baselines/reference/FunctionDeclaration13_es6.types index b6f6aafd65814..011472ef73d96 100644 --- a/tests/baselines/reference/FunctionDeclaration13_es6.types +++ b/tests/baselines/reference/FunctionDeclaration13_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts === function * foo() { ->foo : () => IterableIterator +>foo : () => Generator // Legal to use 'yield' in a type context. var v: yield; diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.types b/tests/baselines/reference/FunctionDeclaration1_es6.types index 548b1eb98d6f3..025cbe051c6c9 100644 --- a/tests/baselines/reference/FunctionDeclaration1_es6.types +++ b/tests/baselines/reference/FunctionDeclaration1_es6.types @@ -1,4 +1,4 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts === function * foo() { ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.types b/tests/baselines/reference/FunctionDeclaration6_es6.types index 4cfb710a78177..e567b033ec6c7 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.types +++ b/tests/baselines/reference/FunctionDeclaration6_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts === function*foo(a = yield) { ->foo : (a?: any) => IterableIterator +>foo : (a?: any) => Generator >a : any >yield : any } diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.types b/tests/baselines/reference/FunctionDeclaration7_es6.types index d9635231e4a54..05df09ef780d1 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.types +++ b/tests/baselines/reference/FunctionDeclaration7_es6.types @@ -1,10 +1,10 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts === function*bar() { ->bar : () => IterableIterator +>bar : () => Generator // 'yield' here is an identifier, and not a yield expression. function*foo(a = yield) { ->foo : (a?: any) => IterableIterator +>foo : (a?: any) => Generator >a : any >yield : any } diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.types b/tests/baselines/reference/FunctionDeclaration9_es6.types index 2b915b82a67b1..0c854f623f435 100644 --- a/tests/baselines/reference/FunctionDeclaration9_es6.types +++ b/tests/baselines/reference/FunctionDeclaration9_es6.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts === function * foo() { ->foo : () => IterableIterator +>foo : () => Generator var v = { [yield]: foo } ->v : { [x: number]: () => IterableIterator; } ->{ [yield]: foo } : { [x: number]: () => IterableIterator; } ->[yield] : () => IterableIterator +>v : { [x: number]: () => Generator; } +>{ [yield]: foo } : { [x: number]: () => Generator; } +>[yield] : () => Generator >yield : any ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/FunctionExpression1_es6.types b/tests/baselines/reference/FunctionExpression1_es6.types index 1bba41f11f2e7..1c56baf396a2a 100644 --- a/tests/baselines/reference/FunctionExpression1_es6.types +++ b/tests/baselines/reference/FunctionExpression1_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts === var v = function * () { } ->v : () => IterableIterator ->function * () { } : () => IterableIterator +>v : () => Generator +>function * () { } : () => Generator diff --git a/tests/baselines/reference/FunctionExpression2_es6.types b/tests/baselines/reference/FunctionExpression2_es6.types index 7a421dd1abfa4..8945268bf715d 100644 --- a/tests/baselines/reference/FunctionExpression2_es6.types +++ b/tests/baselines/reference/FunctionExpression2_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts === var v = function * foo() { } ->v : () => IterableIterator ->function * foo() { } : () => IterableIterator ->foo : () => IterableIterator +>v : () => Generator +>function * foo() { } : () => Generator +>foo : () => Generator diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.types b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types index 90b8615003e82..8fa1b03583086 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments1_es6.types +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts === var v = { *foo() { } } ->v : { foo(): IterableIterator; } ->{ *foo() { } } : { foo(): IterableIterator; } ->foo : () => IterableIterator +>v : { foo(): Generator; } +>{ *foo() { } } : { foo(): Generator; } +>foo : () => Generator diff --git a/tests/baselines/reference/FunctionPropertyAssignments2_es6.types b/tests/baselines/reference/FunctionPropertyAssignments2_es6.types index 6b9a2da94086f..9ad073be7e909 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments2_es6.types +++ b/tests/baselines/reference/FunctionPropertyAssignments2_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts === var v = { *() { } } ->v : { (Missing)(): IterableIterator; } ->{ *() { } } : { (Missing)(): IterableIterator; } -> : () => IterableIterator +>v : { (Missing)(): Generator; } +>{ *() { } } : { (Missing)(): Generator; } +> : () => Generator diff --git a/tests/baselines/reference/FunctionPropertyAssignments3_es6.types b/tests/baselines/reference/FunctionPropertyAssignments3_es6.types index 9222f6e142de3..b49b766f1eb0d 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments3_es6.types +++ b/tests/baselines/reference/FunctionPropertyAssignments3_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts === var v = { *{ } } ->v : { (Missing)(): IterableIterator; } ->{ *{ } } : { (Missing)(): IterableIterator; } -> : () => IterableIterator +>v : { (Missing)(): Generator; } +>{ *{ } } : { (Missing)(): Generator; } +> : () => Generator diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.types b/tests/baselines/reference/FunctionPropertyAssignments5_es6.types index 9430360e9da25..18b2a7f33e50f 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments5_es6.types +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts === var v = { *[foo()]() { } } ->v : { [x: number]: () => IterableIterator; } ->{ *[foo()]() { } } : { [x: number]: () => IterableIterator; } ->[foo()] : () => IterableIterator +>v : { [x: number]: () => Generator; } +>{ *[foo()]() { } } : { [x: number]: () => Generator; } +>[foo()] : () => Generator >foo() : any >foo : any diff --git a/tests/baselines/reference/FunctionPropertyAssignments6_es6.types b/tests/baselines/reference/FunctionPropertyAssignments6_es6.types index 832acbd88406a..a7982dc2ca454 100644 --- a/tests/baselines/reference/FunctionPropertyAssignments6_es6.types +++ b/tests/baselines/reference/FunctionPropertyAssignments6_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts === var v = { *() { } } ->v : { (Missing)(): IterableIterator; } ->{ *() { } } : { (Missing)(): IterableIterator; } -> : () => IterableIterator +>v : { (Missing)(): Generator; } +>{ *() { } } : { (Missing)(): Generator; } +> : () => Generator diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.types b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types index 89eec59bb1c15..d002439563b3c 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration1_es6.types +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.types @@ -3,5 +3,5 @@ class C { >C : C *foo() { } ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.types b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types index bfc83ccfd2794..761fd3c8bb824 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration2_es6.types +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.types @@ -3,5 +3,5 @@ class C { >C : C public * foo() { } ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.types b/tests/baselines/reference/MemberFunctionDeclaration3_es6.types index e855cfa730d86..97ecf7236b0ed 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration3_es6.types +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.types @@ -3,6 +3,6 @@ class C { >C : C *[foo]() { } ->[foo] : () => IterableIterator +>[foo] : () => Generator >foo : any } diff --git a/tests/baselines/reference/MemberFunctionDeclaration4_es6.types b/tests/baselines/reference/MemberFunctionDeclaration4_es6.types index 7717c30a449be..48b1bc1f5917f 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration4_es6.types +++ b/tests/baselines/reference/MemberFunctionDeclaration4_es6.types @@ -3,5 +3,5 @@ class C { >C : C *() { } -> : () => IterableIterator +> : () => Generator } diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.types b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types index 8269f67237283..1ee2ffc1433b2 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration7_es6.types +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.types @@ -3,5 +3,5 @@ class C { >C : C *foo() { } ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/YieldExpression10_es6.types b/tests/baselines/reference/YieldExpression10_es6.types index 966baa031ed32..4f9f400a616fa 100644 --- a/tests/baselines/reference/YieldExpression10_es6.types +++ b/tests/baselines/reference/YieldExpression10_es6.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts === var v = { * foo() { ->v : { foo(): IterableIterator; } ->{ * foo() { yield(foo); }} : { foo(): IterableIterator; } ->foo : () => IterableIterator +>v : { foo(): Generator; } +>{ * foo() { yield(foo); }} : { foo(): Generator; } +>foo : () => Generator yield(foo); >yield(foo) : any diff --git a/tests/baselines/reference/YieldExpression11_es6.types b/tests/baselines/reference/YieldExpression11_es6.types index 01257e4f95fd9..0ddc8ba936c8c 100644 --- a/tests/baselines/reference/YieldExpression11_es6.types +++ b/tests/baselines/reference/YieldExpression11_es6.types @@ -3,7 +3,7 @@ class C { >C : C *foo() { ->foo : () => IterableIterator +>foo : () => Generator yield(foo); >yield(foo) : any diff --git a/tests/baselines/reference/YieldExpression13_es6.types b/tests/baselines/reference/YieldExpression13_es6.types index 011ac1e09e8fe..5859828b8fe94 100644 --- a/tests/baselines/reference/YieldExpression13_es6.types +++ b/tests/baselines/reference/YieldExpression13_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts === function* foo() { yield } ->foo : () => IterableIterator +>foo : () => Generator >yield : any diff --git a/tests/baselines/reference/YieldExpression16_es6.types b/tests/baselines/reference/YieldExpression16_es6.types index 661d60a5b58ab..67b956a3cfcec 100644 --- a/tests/baselines/reference/YieldExpression16_es6.types +++ b/tests/baselines/reference/YieldExpression16_es6.types @@ -1,12 +1,12 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator function bar() { >bar : () => void yield foo; >yield foo : any ->foo : () => IterableIterator +>foo : () => Generator } } diff --git a/tests/baselines/reference/YieldExpression19_es6.types b/tests/baselines/reference/YieldExpression19_es6.types index f57b175d53c92..cab1da911c555 100644 --- a/tests/baselines/reference/YieldExpression19_es6.types +++ b/tests/baselines/reference/YieldExpression19_es6.types @@ -1,17 +1,17 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts === function*foo() { ->foo : () => IterableIterator +>foo : () => Generator function bar() { >bar : () => void function* quux() { ->quux : () => IterableIterator<() => IterableIterator> +>quux : () => Generator<() => Generator, void, unknown> yield(foo); >yield(foo) : any ->(foo) : () => IterableIterator ->foo : () => IterableIterator +>(foo) : () => Generator +>foo : () => Generator } } } diff --git a/tests/baselines/reference/YieldExpression3_es6.types b/tests/baselines/reference/YieldExpression3_es6.types index 9e2f810d91129..31ea178bc5ab9 100644 --- a/tests/baselines/reference/YieldExpression3_es6.types +++ b/tests/baselines/reference/YieldExpression3_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield >yield : any diff --git a/tests/baselines/reference/YieldExpression4_es6.types b/tests/baselines/reference/YieldExpression4_es6.types index 929bef38edd1d..c52f9222070e5 100644 --- a/tests/baselines/reference/YieldExpression4_es6.types +++ b/tests/baselines/reference/YieldExpression4_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield; >yield : any diff --git a/tests/baselines/reference/YieldExpression5_es6.types b/tests/baselines/reference/YieldExpression5_es6.types index 77a003d09228c..24b8c13a6c960 100644 --- a/tests/baselines/reference/YieldExpression5_es6.types +++ b/tests/baselines/reference/YieldExpression5_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield* >yield* : any diff --git a/tests/baselines/reference/YieldExpression7_es6.types b/tests/baselines/reference/YieldExpression7_es6.types index 44dcc196c3bdc..8ebaa07ef604c 100644 --- a/tests/baselines/reference/YieldExpression7_es6.types +++ b/tests/baselines/reference/YieldExpression7_es6.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield foo >yield foo : any ->foo : () => IterableIterator +>foo : () => Generator } diff --git a/tests/baselines/reference/YieldExpression8_es6.types b/tests/baselines/reference/YieldExpression8_es6.types index 67343e3fbfcc8..66935c18cc5c5 100644 --- a/tests/baselines/reference/YieldExpression8_es6.types +++ b/tests/baselines/reference/YieldExpression8_es6.types @@ -2,13 +2,13 @@ yield(foo); >yield(foo) : any >yield : any ->foo : () => IterableIterator +>foo : () => Generator function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield(foo); >yield(foo) : any ->(foo) : () => IterableIterator ->foo : () => IterableIterator +>(foo) : () => Generator +>foo : () => Generator } diff --git a/tests/baselines/reference/YieldExpression9_es6.types b/tests/baselines/reference/YieldExpression9_es6.types index 109dc27058347..e277bc711c57b 100644 --- a/tests/baselines/reference/YieldExpression9_es6.types +++ b/tests/baselines/reference/YieldExpression9_es6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts === var v = function*() { ->v : () => IterableIterator ->function*() { yield(foo);} : () => IterableIterator +>v : () => Generator +>function*() { yield(foo);} : () => Generator yield(foo); >yield(foo) : any diff --git a/tests/baselines/reference/YieldStarExpression3_es6.types b/tests/baselines/reference/YieldStarExpression3_es6.types index 5bc03855b196b..fed990fe4784f 100644 --- a/tests/baselines/reference/YieldStarExpression3_es6.types +++ b/tests/baselines/reference/YieldStarExpression3_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts === function *g() { ->g : () => IterableIterator +>g : () => Generator yield *; >yield * : any diff --git a/tests/baselines/reference/YieldStarExpression4_es6.types b/tests/baselines/reference/YieldStarExpression4_es6.types index 86b727306d473..432835e5bb19a 100644 --- a/tests/baselines/reference/YieldStarExpression4_es6.types +++ b/tests/baselines/reference/YieldStarExpression4_es6.types @@ -1,8 +1,8 @@ === tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts === function *g() { ->g : () => IterableIterator +>g : () => Generator yield * []; ->yield * [] : any +>yield * [] : void >[] : undefined[] } diff --git a/tests/baselines/reference/arrayFrom.types b/tests/baselines/reference/arrayFrom.types index 69ac25474658c..de3f9addfbd62 100644 --- a/tests/baselines/reference/arrayFrom.types +++ b/tests/baselines/reference/arrayFrom.types @@ -52,10 +52,10 @@ const result2: A[] = Array.from(inputA.values()); >Array.from : { (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable | ArrayLike): T[]; (iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor >from : { (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable | ArrayLike): T[]; (iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } ->inputA.values() : IterableIterator ->inputA.values : () => IterableIterator +>inputA.values() : ArrayIterator +>inputA.values : () => ArrayIterator >inputA : A[] ->values : () => IterableIterator +>values : () => ArrayIterator const result3: B[] = Array.from(inputA.values()); // expect error >result3 : B[] @@ -63,10 +63,10 @@ const result3: B[] = Array.from(inputA.values()); // expect error >Array.from : { (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable | ArrayLike): T[]; (iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } >Array : ArrayConstructor >from : { (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable | ArrayLike): T[]; (iterable: Iterable | ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } ->inputA.values() : IterableIterator ->inputA.values : () => IterableIterator +>inputA.values() : ArrayIterator +>inputA.values : () => ArrayIterator >inputA : A[] ->values : () => IterableIterator +>values : () => ArrayIterator const result4: A[] = Array.from(inputB, ({ b }): A => ({ a: b })); >result4 : A[] diff --git a/tests/baselines/reference/asyncImportNestedYield.types b/tests/baselines/reference/asyncImportNestedYield.types index f7fbfa8f96200..59cd72d54652a 100644 --- a/tests/baselines/reference/asyncImportNestedYield.types +++ b/tests/baselines/reference/asyncImportNestedYield.types @@ -1,6 +1,6 @@ === tests/cases/compiler/asyncImportNestedYield.ts === async function* foo() { ->foo : () => AsyncIterableIterator +>foo : () => AsyncGenerator import((await import(yield "foo")).default); >import((await import(yield "foo")).default) : Promise diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.types b/tests/baselines/reference/asyncMethodWithSuper_es6.types index ae78d8bc3adde..5dcc642146a93 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.types +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.types @@ -336,7 +336,7 @@ class B extends A { } async * property_access_only_read_only_in_generator() { ->property_access_only_read_only_in_generator : () => AsyncIterableIterator +>property_access_only_read_only_in_generator : () => AsyncGenerator // call with property access super.x(); @@ -372,7 +372,7 @@ class B extends A { } async * property_access_only_write_only_in_generator() { ->property_access_only_write_only_in_generator : () => AsyncIterableIterator +>property_access_only_write_only_in_generator : () => AsyncGenerator const f = () => {}; >f : () => void @@ -420,7 +420,7 @@ class B extends A { } async * element_access_only_read_only_in_generator() { ->element_access_only_read_only_in_generator : () => AsyncIterableIterator +>element_access_only_read_only_in_generator : () => AsyncGenerator // call with element access super["x"](); @@ -456,7 +456,7 @@ class B extends A { } async * element_access_only_write_only_in_generator() { ->element_access_only_write_only_in_generator : () => AsyncIterableIterator +>element_access_only_write_only_in_generator : () => AsyncGenerator const f = () => {}; >f : () => void diff --git a/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.types b/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.types index cf93e7c2f4d21..5f9692654bafb 100644 --- a/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.types +++ b/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.types @@ -1,6 +1,6 @@ === tests/cases/compiler/blockScopedBindingsInDownlevelGenerator.ts === function* a() { ->a : () => IterableIterator +>a : () => Generator for (const i of [1,2,3]) { >i : number diff --git a/tests/baselines/reference/castOfYield.errors.txt b/tests/baselines/reference/castOfYield.errors.txt index 0d40a4dcd987d..90725000c909d 100644 --- a/tests/baselines/reference/castOfYield.errors.txt +++ b/tests/baselines/reference/castOfYield.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'IterableIterator'. +error TS2318: Cannot find global type 'Generator'. tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected. -!!! error TS2318: Cannot find global type 'IterableIterator'. +!!! error TS2318: Cannot find global type 'Generator'. ==== tests/cases/compiler/castOfYield.ts (1 errors) ==== function* f() { (yield 0); diff --git a/tests/baselines/reference/controlFlowIIFE.types b/tests/baselines/reference/controlFlowIIFE.types index 2116cfaa2aef2..64207b27061b2 100644 --- a/tests/baselines/reference/controlFlowIIFE.types +++ b/tests/baselines/reference/controlFlowIIFE.types @@ -181,9 +181,9 @@ function f5() { >v : number (function*() { ->(function*() { yield 1; v = 1; })() : IterableIterator ->(function*() { yield 1; v = 1; }) : () => IterableIterator ->function*() { yield 1; v = 1; } : () => IterableIterator +>(function*() { yield 1; v = 1; })() : Generator +>(function*() { yield 1; v = 1; }) : () => Generator +>function*() { yield 1; v = 1; } : () => Generator yield 1; >yield 1 : any diff --git a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types index 8342017958aa2..f200b265cd12a 100644 --- a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types +++ b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types @@ -3,12 +3,12 @@ let { [Symbol.iterator]: destructured } = []; >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->destructured : () => IterableIterator +>destructured : () => ArrayIterator >[] : undefined[] void destructured; >void destructured : undefined ->destructured : () => IterableIterator +>destructured : () => ArrayIterator const named = "prop"; >named : "prop" diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types index c6d6fb6758d13..ad0e942351327 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -3,7 +3,7 @@ class C1 { >C1 : C1 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es2015/asyncGenerators/C2.ts === @@ -11,7 +11,7 @@ class C2 { >C2 : C2 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,11 +36,11 @@ class C4 { >C4 : C4 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -67,7 +67,7 @@ class C6 { >C6 : C6 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 @@ -94,7 +94,7 @@ class C8 { >g : () => void } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator this.g(); >this.g() : void @@ -115,7 +115,7 @@ class C9 extends B9 { >B9 : B9 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator super.g(); >super.g() : void diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2018.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2018.types index 17fefc54e8130..b91d49d4980bf 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2018.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2018.types @@ -3,7 +3,7 @@ class C1 { >C1 : C1 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es2018/asyncGenerators/C2.ts === @@ -11,7 +11,7 @@ class C2 { >C2 : C2 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,11 +36,11 @@ class C4 { >C4 : C4 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -67,7 +67,7 @@ class C6 { >C6 : C6 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 @@ -94,7 +94,7 @@ class C8 { >g : () => void } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator this.g(); >this.g() : void @@ -115,7 +115,7 @@ class C9 extends B9 { >B9 : B9 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator super.g(); >super.g() : void diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types index 5d636d2400c6f..5fe8e9ba5eeee 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -3,7 +3,7 @@ class C1 { >C1 : C1 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es5/asyncGenerators/C2.ts === @@ -11,7 +11,7 @@ class C2 { >C2 : C2 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,11 +36,11 @@ class C4 { >C4 : C4 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -67,7 +67,7 @@ class C6 { >C6 : C6 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 @@ -94,7 +94,7 @@ class C8 { >g : () => void } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator this.g(); >this.g() : void @@ -115,7 +115,7 @@ class C9 extends B9 { >B9 : B9 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator super.g(); >super.g() : void diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types index 15ff1298b21ac..4750d03f89e17 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -1,10 +1,10 @@ === tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === async function * f1() { ->f1 : () => AsyncIterableIterator +>f1 : () => AsyncGenerator } === tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === async function * f2() { ->f2 : () => AsyncIterableIterator +>f2 : () => AsyncGenerator const x = yield; >x : any @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator const x = yield 1; >x : any @@ -21,30 +21,30 @@ async function * f3() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === async function * f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator +>f5 : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === async function * f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator const x = await 1; >x : 1 @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2018.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2018.types index 8ffd5534e4086..4bd3db7c3fa0c 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2018.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2018.types @@ -1,10 +1,10 @@ === tests/cases/conformance/emitter/es2018/asyncGenerators/F1.ts === async function * f1() { ->f1 : () => AsyncIterableIterator +>f1 : () => AsyncGenerator } === tests/cases/conformance/emitter/es2018/asyncGenerators/F2.ts === async function * f2() { ->f2 : () => AsyncIterableIterator +>f2 : () => AsyncGenerator const x = yield; >x : any @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator const x = yield 1; >x : any @@ -21,30 +21,30 @@ async function * f3() { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F4.ts === async function * f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es2018/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator +>f5 : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es2018/asyncGenerators/F6.ts === async function * f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator const x = await 1; >x : 1 @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types index 6220f5efd1eca..a4903c368cadf 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -1,10 +1,10 @@ === tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === async function * f1() { ->f1 : () => AsyncIterableIterator +>f1 : () => AsyncGenerator } === tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === async function * f2() { ->f2 : () => AsyncIterableIterator +>f2 : () => AsyncGenerator const x = yield; >x : any @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator const x = yield 1; >x : any @@ -21,30 +21,30 @@ async function * f3() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === async function * f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === async function * f5() { ->f5 : () => AsyncIterableIterator +>f5 : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === async function * f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator const x = await 1; >x : 1 @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types index 1db2126b7ed83..f25a1140b0b62 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -1,12 +1,12 @@ === tests/cases/conformance/emitter/es2015/asyncGenerators/F1.ts === const f1 = async function * () { ->f1 : () => AsyncIterableIterator ->async function * () {} : () => AsyncIterableIterator +>f1 : () => AsyncGenerator +>async function * () {} : () => AsyncGenerator } === tests/cases/conformance/emitter/es2015/asyncGenerators/F2.ts === const f2 = async function * () { ->f2 : () => AsyncIterableIterator ->async function * () { const x = yield;} : () => AsyncIterableIterator +>f2 : () => AsyncGenerator +>async function * () { const x = yield;} : () => AsyncGenerator const x = yield; >x : any @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator ->async function * () { const x = yield 1;} : () => AsyncIterableIterator +>f3 : () => AsyncGenerator +>async function * () { const x = yield 1;} : () => AsyncGenerator const x = yield 1; >x : any @@ -24,33 +24,33 @@ const f3 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F4.ts === const f4 = async function * () { ->f4 : () => AsyncIterableIterator ->async function * () { const x = yield* [1];} : () => AsyncIterableIterator +>f4 : () => AsyncGenerator +>async function * () { const x = yield* [1];} : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator +>f5 : () => AsyncGenerator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es2015/asyncGenerators/F6.ts === const f6 = async function * () { ->f6 : () => AsyncIterableIterator ->async function * () { const x = await 1;} : () => AsyncIterableIterator +>f6 : () => AsyncGenerator +>async function * () { const x = await 1;} : () => AsyncGenerator const x = await 1; >x : 1 @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncGenerator +>async function * () { return 1;} : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2018.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2018.types index 07ee0579bedab..9df6f1d5ec5c4 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2018.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2018.types @@ -1,12 +1,12 @@ === tests/cases/conformance/emitter/es2018/asyncGenerators/F1.ts === const f1 = async function * () { ->f1 : () => AsyncIterableIterator ->async function * () {} : () => AsyncIterableIterator +>f1 : () => AsyncGenerator +>async function * () {} : () => AsyncGenerator } === tests/cases/conformance/emitter/es2018/asyncGenerators/F2.ts === const f2 = async function * () { ->f2 : () => AsyncIterableIterator ->async function * () { const x = yield;} : () => AsyncIterableIterator +>f2 : () => AsyncGenerator +>async function * () { const x = yield;} : () => AsyncGenerator const x = yield; >x : any @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator ->async function * () { const x = yield 1;} : () => AsyncIterableIterator +>f3 : () => AsyncGenerator +>async function * () { const x = yield 1;} : () => AsyncGenerator const x = yield 1; >x : any @@ -24,33 +24,33 @@ const f3 = async function * () { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F4.ts === const f4 = async function * () { ->f4 : () => AsyncIterableIterator ->async function * () { const x = yield* [1];} : () => AsyncIterableIterator +>f4 : () => AsyncGenerator +>async function * () { const x = yield* [1];} : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es2018/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator +>f5 : () => AsyncGenerator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es2018/asyncGenerators/F6.ts === const f6 = async function * () { ->f6 : () => AsyncIterableIterator ->async function * () { const x = await 1;} : () => AsyncIterableIterator +>f6 : () => AsyncGenerator +>async function * () { const x = await 1;} : () => AsyncGenerator const x = await 1; >x : 1 @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es2018/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncGenerator +>async function * () { return 1;} : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types index e9da600bdbf1c..2199f961dc977 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -1,12 +1,12 @@ === tests/cases/conformance/emitter/es5/asyncGenerators/F1.ts === const f1 = async function * () { ->f1 : () => AsyncIterableIterator ->async function * () {} : () => AsyncIterableIterator +>f1 : () => AsyncGenerator +>async function * () {} : () => AsyncGenerator } === tests/cases/conformance/emitter/es5/asyncGenerators/F2.ts === const f2 = async function * () { ->f2 : () => AsyncIterableIterator ->async function * () { const x = yield;} : () => AsyncIterableIterator +>f2 : () => AsyncGenerator +>async function * () { const x = yield;} : () => AsyncGenerator const x = yield; >x : any @@ -14,8 +14,8 @@ const f2 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === const f3 = async function * () { ->f3 : () => AsyncIterableIterator ->async function * () { const x = yield 1;} : () => AsyncIterableIterator +>f3 : () => AsyncGenerator +>async function * () { const x = yield 1;} : () => AsyncGenerator const x = yield 1; >x : any @@ -24,33 +24,33 @@ const f3 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F4.ts === const f4 = async function * () { ->f4 : () => AsyncIterableIterator ->async function * () { const x = yield* [1];} : () => AsyncIterableIterator +>f4 : () => AsyncGenerator +>async function * () { const x = yield* [1];} : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } === tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts === const f5 = async function * () { ->f5 : () => AsyncIterableIterator ->async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator +>f5 : () => AsyncGenerator +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } === tests/cases/conformance/emitter/es5/asyncGenerators/F6.ts === const f6 = async function * () { ->f6 : () => AsyncIterableIterator ->async function * () { const x = await 1;} : () => AsyncIterableIterator +>f6 : () => AsyncGenerator +>async function * () { const x = await 1;} : () => AsyncGenerator const x = await 1; >x : 1 @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncGenerator +>async function * () { return 1;} : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types index 9e47fc9d98932..3f07b08546bd1 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -1,19 +1,19 @@ === tests/cases/conformance/emitter/es2015/asyncGenerators/O1.ts === const o1 = { ->o1 : { f(): AsyncIterableIterator; } ->{ async * f() { }} : { f(): AsyncIterableIterator; } +>o1 : { f(): AsyncGenerator; } +>{ async * f() { }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es2015/asyncGenerators/O2.ts === const o2 = { ->o2 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } +>o2 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } +>o3 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,44 +36,44 @@ const o3 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O4.ts === const o4 = { ->o4 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } +>o4 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } } === tests/cases/conformance/emitter/es2015/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } +>o5 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } } === tests/cases/conformance/emitter/es2015/asyncGenerators/O6.ts === const o6 = { ->o6 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } +>o6 : { f(): AsyncGenerator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncGenerator; } +>{ async * f() { return 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2018.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2018.types index 4b33425a7a47d..1ecc511efbd8d 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2018.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2018.types @@ -1,19 +1,19 @@ === tests/cases/conformance/emitter/es2018/asyncGenerators/O1.ts === const o1 = { ->o1 : { f(): AsyncIterableIterator; } ->{ async * f() { }} : { f(): AsyncIterableIterator; } +>o1 : { f(): AsyncGenerator; } +>{ async * f() { }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es2018/asyncGenerators/O2.ts === const o2 = { ->o2 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } +>o2 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/es2018/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } +>o3 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,44 +36,44 @@ const o3 = { } === tests/cases/conformance/emitter/es2018/asyncGenerators/O4.ts === const o4 = { ->o4 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } +>o4 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } } === tests/cases/conformance/emitter/es2018/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } +>o5 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } } === tests/cases/conformance/emitter/es2018/asyncGenerators/O6.ts === const o6 = { ->o6 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } +>o6 : { f(): AsyncGenerator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es2018/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncGenerator; } +>{ async * f() { return 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types index 390007605083d..755e4c55eadf3 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -1,19 +1,19 @@ === tests/cases/conformance/emitter/es5/asyncGenerators/O1.ts === const o1 = { ->o1 : { f(): AsyncIterableIterator; } ->{ async * f() { }} : { f(): AsyncIterableIterator; } +>o1 : { f(): AsyncGenerator; } +>{ async * f() { }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/emitter/es5/asyncGenerators/O2.ts === const o2 = { ->o2 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield; }} : { f(): AsyncIterableIterator; } +>o2 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield; >x : any @@ -22,11 +22,11 @@ const o2 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O3.ts === const o3 = { ->o3 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } +>o3 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield 1; >x : any @@ -36,44 +36,44 @@ const o3 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O4.ts === const o4 = { ->o4 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* [1]; }} : { f(): AsyncIterableIterator; } +>o4 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* [1]; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* [1]; ->x : any ->yield* [1] : any +>x : void +>yield* [1] : void >[1] : number[] >1 : 1 } } === tests/cases/conformance/emitter/es5/asyncGenerators/O5.ts === const o5 = { ->o5 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } +>o5 : { f(): AsyncGenerator; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = yield* (async function*() { yield 1; })(); ->x : any ->yield* (async function*() { yield 1; })() : any ->(async function*() { yield 1; })() : AsyncIterableIterator ->(async function*() { yield 1; }) : () => AsyncIterableIterator ->async function*() { yield 1; } : () => AsyncIterableIterator +>x : void +>yield* (async function*() { yield 1; })() : void +>(async function*() { yield 1; })() : AsyncGenerator +>(async function*() { yield 1; }) : () => AsyncGenerator +>async function*() { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } } === tests/cases/conformance/emitter/es5/asyncGenerators/O6.ts === const o6 = { ->o6 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = await 1; }} : { f(): AsyncIterableIterator; } +>o6 : { f(): AsyncGenerator; } +>{ async * f() { const x = await 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = await 1; >x : 1 @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncGenerator; } +>{ async * f() { return 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.forAwait.es2015.types b/tests/baselines/reference/emitter.forAwait.es2015.types index e7d1c77f34652..3c345386c3735 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.types +++ b/tests/baselines/reference/emitter.forAwait.es2015.types @@ -25,7 +25,7 @@ async function f2() { } === tests/cases/conformance/emitter/es2015/forAwait/file3.ts === async function* f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator let y: any; >y : any @@ -37,7 +37,7 @@ async function* f3() { } === tests/cases/conformance/emitter/es2015/forAwait/file4.ts === async function* f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator let x: any, y: any; >x : any @@ -68,7 +68,7 @@ async function f5() { === tests/cases/conformance/emitter/es2015/forAwait/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator let y: any; >y : any diff --git a/tests/baselines/reference/emitter.forAwait.es2017.types b/tests/baselines/reference/emitter.forAwait.es2017.types index f1dffdd280a72..19642ddd67706 100644 --- a/tests/baselines/reference/emitter.forAwait.es2017.types +++ b/tests/baselines/reference/emitter.forAwait.es2017.types @@ -25,7 +25,7 @@ async function f2() { } === tests/cases/conformance/emitter/es2017/forAwait/file3.ts === async function* f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator let y: any; >y : any @@ -37,7 +37,7 @@ async function* f3() { } === tests/cases/conformance/emitter/es2017/forAwait/file4.ts === async function* f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator let x: any, y: any; >x : any @@ -68,7 +68,7 @@ async function f5() { === tests/cases/conformance/emitter/es2017/forAwait/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator let y: any; >y : any diff --git a/tests/baselines/reference/emitter.forAwait.es2018.types b/tests/baselines/reference/emitter.forAwait.es2018.types index c9954de364da1..a9b3a94dead77 100644 --- a/tests/baselines/reference/emitter.forAwait.es2018.types +++ b/tests/baselines/reference/emitter.forAwait.es2018.types @@ -25,7 +25,7 @@ async function f2() { } === tests/cases/conformance/emitter/es2018/forAwait/file3.ts === async function* f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator let y: any; >y : any @@ -37,7 +37,7 @@ async function* f3() { } === tests/cases/conformance/emitter/es2018/forAwait/file4.ts === async function* f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator let x: any, y: any; >x : any @@ -68,7 +68,7 @@ async function f5() { === tests/cases/conformance/emitter/es2018/forAwait/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator let y: any; >y : any diff --git a/tests/baselines/reference/emitter.forAwait.es5.types b/tests/baselines/reference/emitter.forAwait.es5.types index fe0a49a901675..1452be304b6f3 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.types +++ b/tests/baselines/reference/emitter.forAwait.es5.types @@ -25,7 +25,7 @@ async function f2() { } === tests/cases/conformance/emitter/es5/forAwait/file3.ts === async function* f3() { ->f3 : () => AsyncIterableIterator +>f3 : () => AsyncGenerator let y: any; >y : any @@ -37,7 +37,7 @@ async function* f3() { } === tests/cases/conformance/emitter/es5/forAwait/file4.ts === async function* f4() { ->f4 : () => AsyncIterableIterator +>f4 : () => AsyncGenerator let x: any, y: any; >x : any @@ -68,7 +68,7 @@ async function f5() { === tests/cases/conformance/emitter/es5/forAwait/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { ->f6 : () => AsyncIterableIterator +>f6 : () => AsyncGenerator let y: any; >y : any diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types index 6142c1066facc..f70d546fce274 100644 --- a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types @@ -8,7 +8,7 @@ export async function foo({ foo = await import("./bar") }) { } export function* foo2({ foo = yield "a" }) { ->foo2 : ({ foo }: { foo?: any; }) => IterableIterator +>foo2 : ({ foo }: { foo?: any; }) => Generator >foo : any >yield "a" : any >"a" : "a" diff --git a/tests/baselines/reference/for-of12.types b/tests/baselines/reference/for-of12.types index 45b5c6ce1ce20..d185babf5ae58 100644 --- a/tests/baselines/reference/for-of12.types +++ b/tests/baselines/reference/for-of12.types @@ -4,10 +4,10 @@ var v: string; for (v of [0, ""].values()) { } >v : string ->[0, ""].values() : IterableIterator ->[0, ""].values : () => IterableIterator +>[0, ""].values() : ArrayIterator +>[0, ""].values : () => ArrayIterator >[0, ""] : (string | number)[] >0 : 0 >"" : "" ->values : () => IterableIterator +>values : () => ArrayIterator diff --git a/tests/baselines/reference/for-of13.types b/tests/baselines/reference/for-of13.types index af30e85fa1720..95ab302cc88c1 100644 --- a/tests/baselines/reference/for-of13.types +++ b/tests/baselines/reference/for-of13.types @@ -4,9 +4,9 @@ var v: string; for (v of [""].values()) { } >v : string ->[""].values() : IterableIterator ->[""].values : () => IterableIterator +>[""].values() : ArrayIterator +>[""].values : () => ArrayIterator >[""] : string[] >"" : "" ->values : () => IterableIterator +>values : () => ArrayIterator diff --git a/tests/baselines/reference/for-of14.errors.txt b/tests/baselines/reference/for-of14.errors.txt index bc8d4478834dc..5cf7b63ed5a59 100644 --- a/tests/baselines/reference/for-of14.errors.txt +++ b/tests/baselines/reference/for-of14.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/for-ofStatements/for-of14.ts(8,11): error TS2488: Type 'StringIterator' must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/es6/for-ofStatements/for-of14.ts(8,11): error TS2488: Type '_StringIterator' must have a '[Symbol.iterator]()' method that returns an iterator. ==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ==== - class StringIterator { + class _StringIterator { next() { return ""; } } var v: string; - for (v of new StringIterator) { } // Should fail because the iterator is not iterable - ~~~~~~~~~~~~~~~~~~ -!!! error TS2488: Type 'StringIterator' must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file + for (v of new _StringIterator) { } // Should fail because the iterator is not iterable + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2488: Type '_StringIterator' must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js index ac3af1ff1db05..d7adffb8f51f5 100644 --- a/tests/baselines/reference/for-of14.js +++ b/tests/baselines/reference/for-of14.js @@ -1,18 +1,18 @@ //// [for-of14.ts] -class StringIterator { +class _StringIterator { next() { return ""; } } var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable +for (v of new _StringIterator) { } // Should fail because the iterator is not iterable //// [for-of14.js] -class StringIterator { +class _StringIterator { next() { return ""; } } var v; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable +for (v of new _StringIterator) { } // Should fail because the iterator is not iterable diff --git a/tests/baselines/reference/for-of14.symbols b/tests/baselines/reference/for-of14.symbols index a46a0a3812819..06e4f10e8e562 100644 --- a/tests/baselines/reference/for-of14.symbols +++ b/tests/baselines/reference/for-of14.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of14.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of14.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of14.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of14.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of14.ts, 0, 23)) return ""; } @@ -12,7 +12,7 @@ class StringIterator { var v: string; >v : Symbol(v, Decl(for-of14.ts, 6, 3)) -for (v of new StringIterator) { } // Should fail because the iterator is not iterable +for (v of new _StringIterator) { } // Should fail because the iterator is not iterable >v : Symbol(v, Decl(for-of14.ts, 6, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of14.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of14.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of14.types b/tests/baselines/reference/for-of14.types index cadaf5b3789d6..e7672250c2112 100644 --- a/tests/baselines/reference/for-of14.types +++ b/tests/baselines/reference/for-of14.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of14.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => string @@ -13,8 +13,8 @@ class StringIterator { var v: string; >v : string -for (v of new StringIterator) { } // Should fail because the iterator is not iterable +for (v of new _StringIterator) { } // Should fail because the iterator is not iterable >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of15.errors.txt b/tests/baselines/reference/for-of15.errors.txt index 6d990aa01fcd7..6b91dd87afbed 100644 --- a/tests/baselines/reference/for-of15.errors.txt +++ b/tests/baselines/reference/for-of15.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of15.ts(11,11): error TS2490: T ==== tests/cases/conformance/es6/for-ofStatements/for-of15.ts (1 errors) ==== - class StringIterator { + class _StringIterator { next() { return ""; } @@ -12,6 +12,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of15.ts(11,11): error TS2490: T } var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ + for (v of new _StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~~ !!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. \ No newline at end of file diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js index f88c86401680c..a44d974b09910 100644 --- a/tests/baselines/reference/for-of15.js +++ b/tests/baselines/reference/for-of15.js @@ -1,5 +1,5 @@ //// [for-of15.ts] -class StringIterator { +class _StringIterator { next() { return ""; } @@ -9,10 +9,10 @@ class StringIterator { } var v: string; -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail //// [for-of15.js] -class StringIterator { +class _StringIterator { next() { return ""; } @@ -21,4 +21,4 @@ class StringIterator { } } var v; -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of15.symbols b/tests/baselines/reference/for-of15.symbols index 1a6ec8d2661bd..e8fc8b3aa837e 100644 --- a/tests/baselines/reference/for-of15.symbols +++ b/tests/baselines/reference/for-of15.symbols @@ -1,27 +1,27 @@ === tests/cases/conformance/es6/for-ofStatements/for-of15.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of15.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of15.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of15.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of15.ts, 0, 23)) return ""; } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of15.ts, 3, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of15.ts, 3, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of15.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of15.ts, 0, 0)) } } var v: string; >v : Symbol(v, Decl(for-of15.ts, 9, 3)) -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail >v : Symbol(v, Decl(for-of15.ts, 9, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of15.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of15.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of15.types b/tests/baselines/reference/for-of15.types index 3ad50870a11ad..d835646085e62 100644 --- a/tests/baselines/reference/for-of15.types +++ b/tests/baselines/reference/for-of15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of15.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => string @@ -22,8 +22,8 @@ class StringIterator { var v: string; >v : string -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of16.errors.txt b/tests/baselines/reference/for-of16.errors.txt index 7574f98e3d8a8..28b5fec6189e7 100644 --- a/tests/baselines/reference/for-of16.errors.txt +++ b/tests/baselines/reference/for-of16.errors.txt @@ -2,13 +2,13 @@ tests/cases/conformance/es6/for-ofStatements/for-of16.ts(8,11): error TS2489: An ==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ==== - class StringIterator { + class _StringIterator { [Symbol.iterator]() { return this; } } var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ + for (v of new _StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~~ !!! error TS2489: An iterator must have a 'next()' method. \ No newline at end of file diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js index 2219e15a6f92a..7074c8df434c0 100644 --- a/tests/baselines/reference/for-of16.js +++ b/tests/baselines/reference/for-of16.js @@ -1,18 +1,18 @@ //// [for-of16.ts] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return this; } } var v: string; -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail //// [for-of16.js] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return this; } } var v; -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of16.symbols b/tests/baselines/reference/for-of16.symbols index 1bd52fa5dc6c3..c825912aa6490 100644 --- a/tests/baselines/reference/for-of16.symbols +++ b/tests/baselines/reference/for-of16.symbols @@ -1,22 +1,22 @@ === tests/cases/conformance/es6/for-ofStatements/for-of16.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of16.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of16.ts, 0, 0)) [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of16.ts, 0, 22)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of16.ts, 0, 23)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of16.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of16.ts, 0, 0)) } } var v: string; >v : Symbol(v, Decl(for-of16.ts, 6, 3)) -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail >v : Symbol(v, Decl(for-of16.ts, 6, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of16.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of16.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of16.types b/tests/baselines/reference/for-of16.types index 0396cf215d288..b52afa66e3425 100644 --- a/tests/baselines/reference/for-of16.types +++ b/tests/baselines/reference/for-of16.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of16.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator [Symbol.iterator]() { >[Symbol.iterator] : () => this @@ -16,8 +16,8 @@ class StringIterator { var v: string; >v : string -for (v of new StringIterator) { } // Should fail +for (v of new _StringIterator) { } // Should fail >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js index fb7a684098a58..5c72357296411 100644 --- a/tests/baselines/reference/for-of18.js +++ b/tests/baselines/reference/for-of18.js @@ -1,5 +1,5 @@ //// [for-of18.ts] -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -12,10 +12,10 @@ class StringIterator { } var v: string; -for (v of new StringIterator) { } // Should succeed +for (v of new _StringIterator) { } // Should succeed //// [for-of18.js] -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -27,4 +27,4 @@ class StringIterator { } } var v; -for (v of new StringIterator) { } // Should succeed +for (v of new _StringIterator) { } // Should succeed diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index a8b4267e7f707..aa6f21cbaf8fa 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of18.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of18.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of18.ts, 0, 23)) return { value: "", @@ -15,20 +15,20 @@ class StringIterator { }; } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of18.ts, 6, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of18.ts, 6, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of18.ts, 0, 0)) } } var v: string; >v : Symbol(v, Decl(for-of18.ts, 12, 3)) -for (v of new StringIterator) { } // Should succeed +for (v of new _StringIterator) { } // Should succeed >v : Symbol(v, Decl(for-of18.ts, 12, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of18.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types index de784f5ec0d05..2af3e098fd492 100644 --- a/tests/baselines/reference/for-of18.types +++ b/tests/baselines/reference/for-of18.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -32,8 +32,8 @@ class StringIterator { var v: string; >v : string -for (v of new StringIterator) { } // Should succeed +for (v of new _StringIterator) { } // Should succeed >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js index 032efa52ae3c5..12261376410ec 100644 --- a/tests/baselines/reference/for-of25.js +++ b/tests/baselines/reference/for-of25.js @@ -1,18 +1,18 @@ //// [for-of25.ts] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return x; } } var x: any; -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of25.js] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return x; } } var x; -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index b8663dce90011..18ae029241ba7 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of25.ts, 0, 0)) [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of25.ts, 0, 22)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of25.ts, 0, 23)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -16,7 +16,7 @@ class StringIterator { var x: any; >x : Symbol(x, Decl(for-of25.ts, 6, 3)) -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of25.ts, 7, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of25.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of25.types b/tests/baselines/reference/for-of25.types index 5cc40748bb071..13d85f928abfc 100644 --- a/tests/baselines/reference/for-of25.types +++ b/tests/baselines/reference/for-of25.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator [Symbol.iterator]() { >[Symbol.iterator] : () => any @@ -16,8 +16,8 @@ class StringIterator { var x: any; >x : any -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js index ab9c4fdca922d..a478625d0b8c4 100644 --- a/tests/baselines/reference/for-of26.js +++ b/tests/baselines/reference/for-of26.js @@ -1,5 +1,5 @@ //// [for-of26.ts] -class StringIterator { +class _StringIterator { next() { return x; } @@ -9,10 +9,10 @@ class StringIterator { } var x: any; -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of26.js] -class StringIterator { +class _StringIterator { next() { return x; } @@ -21,4 +21,4 @@ class StringIterator { } } var x; -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index af7efefbe4539..32e22293af695 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -1,28 +1,28 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of26.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of26.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of26.ts, 0, 23)) return x; >x : Symbol(x, Decl(for-of26.ts, 9, 3)) } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of26.ts, 3, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of26.ts, 3, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of26.ts, 0, 0)) } } var x: any; >x : Symbol(x, Decl(for-of26.ts, 9, 3)) -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of26.ts, 10, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of26.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of26.types b/tests/baselines/reference/for-of26.types index 5209b1856b38f..b60449719d89c 100644 --- a/tests/baselines/reference/for-of26.types +++ b/tests/baselines/reference/for-of26.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => any @@ -22,8 +22,8 @@ class StringIterator { var x: any; >x : any -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js index 6adc66e241b2b..4e578429d0d36 100644 --- a/tests/baselines/reference/for-of27.js +++ b/tests/baselines/reference/for-of27.js @@ -1,11 +1,11 @@ //// [for-of27.ts] -class StringIterator { +class _StringIterator { [Symbol.iterator]: any; } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of27.js] -class StringIterator { +class _StringIterator { } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index 99e8402469e4f..5135fda68b70c 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -1,15 +1,15 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of27.ts, 0, 0)) [Symbol.iterator]: any; ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of27.ts, 0, 22)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of27.ts, 0, 23)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of27.ts, 4, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of27.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of27.types b/tests/baselines/reference/for-of27.types index c72d306c18765..321e07df05431 100644 --- a/tests/baselines/reference/for-of27.types +++ b/tests/baselines/reference/for-of27.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator [Symbol.iterator]: any; >[Symbol.iterator] : any @@ -9,8 +9,8 @@ class StringIterator { >iterator : symbol } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js index e06e2fc6abc0e..f5ecbf689f66c 100644 --- a/tests/baselines/reference/for-of28.js +++ b/tests/baselines/reference/for-of28.js @@ -1,17 +1,17 @@ //// [for-of28.ts] -class StringIterator { +class _StringIterator { next: any; [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of28.js] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 499e3c657ee9c..39349d43ae5c2 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -1,22 +1,22 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of28.ts, 0, 0)) next: any; ->next : Symbol(StringIterator.next, Decl(for-of28.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of28.ts, 0, 23)) [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of28.ts, 1, 14)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of28.ts, 1, 14)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of28.ts, 0, 0)) } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of28.ts, 7, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of28.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of28.types b/tests/baselines/reference/for-of28.types index d1f95753722a8..04935225b6ab9 100644 --- a/tests/baselines/reference/for-of28.types +++ b/tests/baselines/reference/for-of28.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next: any; >next : any @@ -16,8 +16,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of30.errors.txt b/tests/baselines/reference/for-of30.errors.txt index b0091c90b57c3..81988fbe26ee5 100644 --- a/tests/baselines/reference/for-of30.errors.txt +++ b/tests/baselines/reference/for-of30.errors.txt @@ -1,32 +1,32 @@ -tests/cases/conformance/es6/for-ofStatements/for-of30.ts(16,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of30.ts(16,15): error TS2322: Type '_StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. - Type '() => StringIterator' is not assignable to type '() => Iterator'. - Type 'StringIterator' is not assignable to type 'Iterator'. + Type '() => _StringIterator' is not assignable to type '() => Iterator'. + Type '_StringIterator' is not assignable to type 'Iterator'. Types of property 'return' are incompatible. - Type 'number' is not assignable to type '(value?: any) => IteratorResult'. + Type 'number' is not assignable to type '(value?: any) => IteratorResult'. ==== tests/cases/conformance/es6/for-ofStatements/for-of30.ts (1 errors) ==== - class StringIterator { + class _StringIterator { next() { return { done: false, value: "" } } - + return = 0; - + [Symbol.iterator]() { return this; } } - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. + for (var v of new _StringIterator) { } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '_StringIterator' is not assignable to type 'Iterable'. !!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Type '() => _StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type '_StringIterator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'return' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js index 935944db640e3..e37a0c29c7ac5 100644 --- a/tests/baselines/reference/for-of30.js +++ b/tests/baselines/reference/for-of30.js @@ -1,23 +1,23 @@ //// [for-of30.ts] -class StringIterator { +class _StringIterator { next() { return { done: false, value: "" } } - + return = 0; - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of30.js] -class StringIterator { +class _StringIterator { constructor() { this.return = 0; } @@ -31,4 +31,4 @@ class StringIterator { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of30.symbols b/tests/baselines/reference/for-of30.symbols index 779d8aa2b210d..e2374a541f0f6 100644 --- a/tests/baselines/reference/for-of30.symbols +++ b/tests/baselines/reference/for-of30.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of30.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of30.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of30.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of30.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of30.ts, 0, 23)) return { done: false, @@ -13,22 +13,22 @@ class StringIterator { >value : Symbol(value, Decl(for-of30.ts, 3, 24)) } } - + return = 0; ->return : Symbol(StringIterator.return, Decl(for-of30.ts, 6, 5)) - +>return : Symbol(_StringIterator.return, Decl(for-of30.ts, 6, 5)) + [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of30.ts, 8, 15)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of30.ts, 8, 15)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of30.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of30.ts, 0, 0)) } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of30.ts, 15, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of30.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of30.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of30.types b/tests/baselines/reference/for-of30.types index bd369223d7f5f..53eec6e8d1d42 100644 --- a/tests/baselines/reference/for-of30.types +++ b/tests/baselines/reference/for-of30.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of30.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { done: boolean; value: string; } @@ -17,11 +17,11 @@ class StringIterator { >"" : "" } } - + return = 0; >return : number >0 : 0 - + [Symbol.iterator]() { >[Symbol.iterator] : () => this >Symbol.iterator : symbol @@ -33,8 +33,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of31.errors.txt b/tests/baselines/reference/for-of31.errors.txt index 2b1a70529183b..c8ccdfec84214 100644 --- a/tests/baselines/reference/for-of31.errors.txt +++ b/tests/baselines/reference/for-of31.errors.txt @@ -1,33 +1,35 @@ -tests/cases/conformance/es6/for-ofStatements/for-of31.ts(14,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of31.ts(14,15): error TS2322: Type '_StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. - Type '() => StringIterator' is not assignable to type '() => Iterator'. - Type 'StringIterator' is not assignable to type 'Iterator'. + Type '() => _StringIterator' is not assignable to type '() => Iterator'. + Type '_StringIterator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. - Property 'done' is missing in type '{ value: string; }' but required in type 'IteratorResult'. + Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. + Type '{ value: string; }' is not assignable to type 'IteratorResult'. + Property 'done' is missing in type '{ value: string; }' but required in type 'IteratorReturnResult'. ==== tests/cases/conformance/es6/for-ofStatements/for-of31.ts (1 errors) ==== - class StringIterator { + class _StringIterator { next() { return { // no done property value: "" } } - + [Symbol.iterator]() { return this; } } - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. + for (var v of new _StringIterator) { } + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '_StringIterator' is not assignable to type 'Iterable'. !!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Type '() => _StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type '_StringIterator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: string; }' but required in type 'IteratorResult'. -!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:32:5: 'done' is declared here. \ No newline at end of file +!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: string; }' but required in type 'IteratorReturnResult'. +!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:37:5: 'done' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js index 84e24bed5a959..adf10c402467b 100644 --- a/tests/baselines/reference/for-of31.js +++ b/tests/baselines/reference/for-of31.js @@ -1,21 +1,21 @@ //// [for-of31.ts] -class StringIterator { +class _StringIterator { next() { return { // no done property value: "" } } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of31.js] -class StringIterator { +class _StringIterator { next() { return { // no done property @@ -26,4 +26,4 @@ class StringIterator { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of31.symbols b/tests/baselines/reference/for-of31.symbols index 41b7d0a85d624..eb5cb437601fb 100644 --- a/tests/baselines/reference/for-of31.symbols +++ b/tests/baselines/reference/for-of31.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of31.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of31.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of31.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of31.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of31.ts, 0, 23)) return { // no done property @@ -11,19 +11,19 @@ class StringIterator { >value : Symbol(value, Decl(for-of31.ts, 2, 16)) } } - + [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of31.ts, 6, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of31.ts, 6, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of31.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of31.ts, 0, 0)) } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of31.ts, 13, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of31.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of31.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of31.types b/tests/baselines/reference/for-of31.types index 843ce928c44e1..6ab43313bc164 100644 --- a/tests/baselines/reference/for-of31.types +++ b/tests/baselines/reference/for-of31.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of31.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; } @@ -14,7 +14,7 @@ class StringIterator { >"" : "" } } - + [Symbol.iterator]() { >[Symbol.iterator] : () => this >Symbol.iterator : symbol @@ -26,8 +26,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of33.errors.txt b/tests/baselines/reference/for-of33.errors.txt index eba30ce9bf990..7314f4c605ba2 100644 --- a/tests/baselines/reference/for-of33.errors.txt +++ b/tests/baselines/reference/for-of33.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of33.ts(7,10): error TS7022: 'v ==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (2 errors) ==== - class StringIterator { + class _StringIterator { [Symbol.iterator]() { ~~~~~~~~~~~~~~~~~ !!! error TS7023: '[Symbol.iterator]' 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. @@ -11,6 +11,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of33.ts(7,10): error TS7022: 'v } } - for (var v of new StringIterator) { } + for (var v of new _StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js index e77d3cf5de84b..9600f41c64d7e 100644 --- a/tests/baselines/reference/for-of33.js +++ b/tests/baselines/reference/for-of33.js @@ -1,16 +1,16 @@ //// [for-of33.ts] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return v; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of33.js] -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return v; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of33.symbols b/tests/baselines/reference/for-of33.symbols index 4dd18fdeaacfe..514ef007daf5d 100644 --- a/tests/baselines/reference/for-of33.symbols +++ b/tests/baselines/reference/for-of33.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of33.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of33.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of33.ts, 0, 0)) [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of33.ts, 0, 22)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of33.ts, 0, 23)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -13,7 +13,7 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of33.ts, 6, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of33.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of33.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of33.types b/tests/baselines/reference/for-of33.types index 1410ee0653505..5c052c9ead2b3 100644 --- a/tests/baselines/reference/for-of33.types +++ b/tests/baselines/reference/for-of33.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of33.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator [Symbol.iterator]() { >[Symbol.iterator] : () => any @@ -13,8 +13,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of34.errors.txt b/tests/baselines/reference/for-of34.errors.txt index 2d53ecb0a208a..3ea950a605260 100644 --- a/tests/baselines/reference/for-of34.errors.txt +++ b/tests/baselines/reference/for-of34.errors.txt @@ -3,18 +3,18 @@ tests/cases/conformance/es6/for-ofStatements/for-of34.ts(11,10): error TS7022: ' ==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (2 errors) ==== - class StringIterator { + class _StringIterator { next() { ~~~~ !!! error TS7023: 'next' 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. return v; } - + [Symbol.iterator]() { return this; } } - for (var v of new StringIterator) { } + for (var v of new _StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js index 2d9af61d1a389..5af4d50233501 100644 --- a/tests/baselines/reference/for-of34.js +++ b/tests/baselines/reference/for-of34.js @@ -1,18 +1,18 @@ //// [for-of34.ts] -class StringIterator { +class _StringIterator { next() { return v; } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of34.js] -class StringIterator { +class _StringIterator { next() { return v; } @@ -20,4 +20,4 @@ class StringIterator { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of34.symbols b/tests/baselines/reference/for-of34.symbols index 0b1e125275340..b8cf473b2fe1b 100644 --- a/tests/baselines/reference/for-of34.symbols +++ b/tests/baselines/reference/for-of34.symbols @@ -1,26 +1,26 @@ === tests/cases/conformance/es6/for-ofStatements/for-of34.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of34.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of34.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of34.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of34.ts, 0, 23)) return v; >v : Symbol(v, Decl(for-of34.ts, 10, 8)) } - + [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of34.ts, 3, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of34.ts, 3, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of34.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of34.ts, 0, 0)) } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of34.ts, 10, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of34.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of34.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of34.types b/tests/baselines/reference/for-of34.types index 5a4287e7843dd..b31b6da4de721 100644 --- a/tests/baselines/reference/for-of34.types +++ b/tests/baselines/reference/for-of34.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of34.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => any @@ -8,7 +8,7 @@ class StringIterator { return v; >v : any } - + [Symbol.iterator]() { >[Symbol.iterator] : () => this >Symbol.iterator : symbol @@ -20,8 +20,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/for-of35.errors.txt b/tests/baselines/reference/for-of35.errors.txt index 6f14a24fb96b6..a569da694d057 100644 --- a/tests/baselines/reference/for-of35.errors.txt +++ b/tests/baselines/reference/for-of35.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of35.ts(14,10): error TS7022: ' ==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (2 errors) ==== - class StringIterator { + class _StringIterator { next() { ~~~~ !!! error TS7023: 'next' 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. @@ -12,12 +12,12 @@ tests/cases/conformance/es6/for-ofStatements/for-of35.ts(14,10): error TS7022: ' value: v } } - + [Symbol.iterator]() { return this; } } - for (var v of new StringIterator) { } + for (var v of new _StringIterator) { } ~ !!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js index a73f873d7ce38..32cfc51fce26b 100644 --- a/tests/baselines/reference/for-of35.js +++ b/tests/baselines/reference/for-of35.js @@ -1,21 +1,21 @@ //// [for-of35.ts] -class StringIterator { +class _StringIterator { next() { return { done: true, value: v } } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } //// [for-of35.js] -class StringIterator { +class _StringIterator { next() { return { done: true, @@ -26,4 +26,4 @@ class StringIterator { return this; } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } diff --git a/tests/baselines/reference/for-of35.symbols b/tests/baselines/reference/for-of35.symbols index 4f21e538cad28..a81b4baa6f39c 100644 --- a/tests/baselines/reference/for-of35.symbols +++ b/tests/baselines/reference/for-of35.symbols @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of35.ts === -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of35.ts, 0, 0)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(for-of35.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of35.ts, 0, 22)) +>next : Symbol(_StringIterator.next, Decl(for-of35.ts, 0, 23)) return { done: true, @@ -14,19 +14,19 @@ class StringIterator { >v : Symbol(v, Decl(for-of35.ts, 13, 8)) } } - + [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(for-of35.ts, 6, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(for-of35.ts, 6, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of35.ts, 0, 0)) +>this : Symbol(_StringIterator, Decl(for-of35.ts, 0, 0)) } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : Symbol(v, Decl(for-of35.ts, 13, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of35.ts, 0, 0)) +>_StringIterator : Symbol(_StringIterator, Decl(for-of35.ts, 0, 0)) diff --git a/tests/baselines/reference/for-of35.types b/tests/baselines/reference/for-of35.types index 0c80a6633b28a..c49504765c764 100644 --- a/tests/baselines/reference/for-of35.types +++ b/tests/baselines/reference/for-of35.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of35.ts === -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => any @@ -17,7 +17,7 @@ class StringIterator { >v : any } } - + [Symbol.iterator]() { >[Symbol.iterator] : () => this >Symbol.iterator : symbol @@ -29,8 +29,8 @@ class StringIterator { } } -for (var v of new StringIterator) { } +for (var v of new _StringIterator) { } >v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/generatorES6InAMDModule.types b/tests/baselines/reference/generatorES6InAMDModule.types index 9a12a72f0055a..a1b06edc34625 100644 --- a/tests/baselines/reference/generatorES6InAMDModule.types +++ b/tests/baselines/reference/generatorES6InAMDModule.types @@ -1,6 +1,6 @@ === tests/cases/compiler/generatorES6InAMDModule.ts === export function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield >yield : any diff --git a/tests/baselines/reference/generatorES6_1.types b/tests/baselines/reference/generatorES6_1.types index 13ac7c05844a6..e1046c8548e26 100644 --- a/tests/baselines/reference/generatorES6_1.types +++ b/tests/baselines/reference/generatorES6_1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/generatorES6_1.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield >yield : any diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types index a95a0008d4fe4..61fc7db71a7f9 100644 --- a/tests/baselines/reference/generatorES6_2.types +++ b/tests/baselines/reference/generatorES6_2.types @@ -3,7 +3,7 @@ class C { >C : C public * foo() { ->foo : () => IterableIterator +>foo : () => Generator yield 1 >yield 1 : any diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types index e237cbd3510a2..2b72e71132278 100644 --- a/tests/baselines/reference/generatorES6_3.types +++ b/tests/baselines/reference/generatorES6_3.types @@ -1,7 +1,7 @@ === tests/cases/compiler/generatorES6_3.ts === var v = function*() { ->v : () => IterableIterator ->function*() { yield 0} : () => IterableIterator +>v : () => Generator +>function*() { yield 0} : () => Generator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types index fa19d8f3ae2d5..31945d0d3e6a5 100644 --- a/tests/baselines/reference/generatorES6_4.types +++ b/tests/baselines/reference/generatorES6_4.types @@ -1,10 +1,10 @@ === tests/cases/compiler/generatorES6_4.ts === var v = { ->v : { foo(): IterableIterator; } ->{ *foo() { yield 0 }} : { foo(): IterableIterator; } +>v : { foo(): Generator; } +>{ *foo() { yield 0 }} : { foo(): Generator; } *foo() { ->foo : () => IterableIterator +>foo : () => Generator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorES6_5.types b/tests/baselines/reference/generatorES6_5.types index 12396f69e242a..6ff6105b498ca 100644 --- a/tests/baselines/reference/generatorES6_5.types +++ b/tests/baselines/reference/generatorES6_5.types @@ -1,6 +1,6 @@ === tests/cases/compiler/generatorES6_5.ts === function* foo() { ->foo : () => IterableIterator +>foo : () => Generator yield a ? b : c; >yield a ? b : c : any diff --git a/tests/baselines/reference/generatorES6_6.types b/tests/baselines/reference/generatorES6_6.types index 7306b6ed99ae4..05e0bcc7f88b2 100644 --- a/tests/baselines/reference/generatorES6_6.types +++ b/tests/baselines/reference/generatorES6_6.types @@ -3,7 +3,7 @@ class C { >C : C *[Symbol.iterator]() { ->[Symbol.iterator] : () => IterableIterator +>[Symbol.iterator] : () => Generator >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol diff --git a/tests/baselines/reference/generatorExplicitReturnType.errors.txt b/tests/baselines/reference/generatorExplicitReturnType.errors.txt new file mode 100644 index 0000000000000..4841e62bba7df --- /dev/null +++ b/tests/baselines/reference/generatorExplicitReturnType.errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/generators/generatorExplicitReturnType.ts(2,5): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/generators/generatorExplicitReturnType.ts(3,11): error TS2322: Type '"a"' is not assignable to type 'number'. +tests/cases/conformance/generators/generatorExplicitReturnType.ts(4,11): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/generators/generatorExplicitReturnType.ts(5,5): error TS2322: Type '10' is not assignable to type 'boolean'. +tests/cases/conformance/generators/generatorExplicitReturnType.ts(16,11): error TS2322: Type 'symbol' is not assignable to type 'number'. + + +==== tests/cases/conformance/generators/generatorExplicitReturnType.ts (5 errors) ==== + function* g1(): Generator { + yield; // error + ~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + yield "a"; // error + ~~~ +!!! error TS2322: Type '"a"' is not assignable to type 'number'. + const x: number = yield 1; // error + ~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + return 10; // error + ~~~~~~~~~~ +!!! error TS2322: Type '10' is not assignable to type 'boolean'. + } + + function* g2(): Generator { + const x = yield 1; + return true; + } + + declare const generator: Generator; + + function* g3(): Generator { + const x: number = yield* generator; // error + ~ +!!! error TS2322: Type 'symbol' is not assignable to type 'number'. + return true; + } + + function* g4(): Generator { + const x = yield* generator; + return true; + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorExplicitReturnType.js b/tests/baselines/reference/generatorExplicitReturnType.js new file mode 100644 index 0000000000000..1669a2905e5df --- /dev/null +++ b/tests/baselines/reference/generatorExplicitReturnType.js @@ -0,0 +1,44 @@ +//// [generatorExplicitReturnType.ts] +function* g1(): Generator { + yield; // error + yield "a"; // error + const x: number = yield 1; // error + return 10; // error +} + +function* g2(): Generator { + const x = yield 1; + return true; +} + +declare const generator: Generator; + +function* g3(): Generator { + const x: number = yield* generator; // error + return true; +} + +function* g4(): Generator { + const x = yield* generator; + return true; +} + +//// [generatorExplicitReturnType.js] +function* g1() { + yield; // error + yield "a"; // error + const x = yield 1; // error + return 10; // error +} +function* g2() { + const x = yield 1; + return true; +} +function* g3() { + const x = yield* generator; // error + return true; +} +function* g4() { + const x = yield* generator; + return true; +} diff --git a/tests/baselines/reference/generatorExplicitReturnType.symbols b/tests/baselines/reference/generatorExplicitReturnType.symbols new file mode 100644 index 0000000000000..fb3676a8b78a6 --- /dev/null +++ b/tests/baselines/reference/generatorExplicitReturnType.symbols @@ -0,0 +1,48 @@ +=== tests/cases/conformance/generators/generatorExplicitReturnType.ts === +function* g1(): Generator { +>g1 : Symbol(g1, Decl(generatorExplicitReturnType.ts, 0, 0)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + yield; // error + yield "a"; // error + const x: number = yield 1; // error +>x : Symbol(x, Decl(generatorExplicitReturnType.ts, 3, 9)) + + return 10; // error +} + +function* g2(): Generator { +>g2 : Symbol(g2, Decl(generatorExplicitReturnType.ts, 5, 1)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x = yield 1; +>x : Symbol(x, Decl(generatorExplicitReturnType.ts, 8, 9)) + + return true; +} + +declare const generator: Generator; +>generator : Symbol(generator, Decl(generatorExplicitReturnType.ts, 12, 13)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + +function* g3(): Generator { +>g3 : Symbol(g3, Decl(generatorExplicitReturnType.ts, 12, 59)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x: number = yield* generator; // error +>x : Symbol(x, Decl(generatorExplicitReturnType.ts, 15, 9)) +>generator : Symbol(generator, Decl(generatorExplicitReturnType.ts, 12, 13)) + + return true; +} + +function* g4(): Generator { +>g4 : Symbol(g4, Decl(generatorExplicitReturnType.ts, 17, 1)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x = yield* generator; +>x : Symbol(x, Decl(generatorExplicitReturnType.ts, 20, 9)) +>generator : Symbol(generator, Decl(generatorExplicitReturnType.ts, 12, 13)) + + return true; +} diff --git a/tests/baselines/reference/generatorExplicitReturnType.types b/tests/baselines/reference/generatorExplicitReturnType.types new file mode 100644 index 0000000000000..6e05722d049db --- /dev/null +++ b/tests/baselines/reference/generatorExplicitReturnType.types @@ -0,0 +1,58 @@ +=== tests/cases/conformance/generators/generatorExplicitReturnType.ts === +function* g1(): Generator { +>g1 : () => Generator + + yield; // error +>yield : string + + yield "a"; // error +>yield "a" : string +>"a" : "a" + + const x: number = yield 1; // error +>x : number +>yield 1 : string +>1 : 1 + + return 10; // error +>10 : 10 +} + +function* g2(): Generator { +>g2 : () => Generator + + const x = yield 1; +>x : string +>yield 1 : string +>1 : 1 + + return true; +>true : true +} + +declare const generator: Generator; +>generator : Generator + +function* g3(): Generator { +>g3 : () => Generator + + const x: number = yield* generator; // error +>x : number +>yield* generator : symbol +>generator : Generator + + return true; +>true : true +} + +function* g4(): Generator { +>g4 : () => Generator + + const x = yield* generator; +>x : symbol +>yield* generator : symbol +>generator : Generator + + return true; +>true : true +} diff --git a/tests/baselines/reference/generatorImplicitAny.js b/tests/baselines/reference/generatorImplicitAny.js new file mode 100644 index 0000000000000..ee12d8052b831 --- /dev/null +++ b/tests/baselines/reference/generatorImplicitAny.js @@ -0,0 +1,5 @@ +//// [generatorImplicitAny.ts] +function* g() {} + +//// [generatorImplicitAny.js] +function* g() { } diff --git a/tests/baselines/reference/generatorImplicitAny.symbols b/tests/baselines/reference/generatorImplicitAny.symbols new file mode 100644 index 0000000000000..3c3929e9ab37c --- /dev/null +++ b/tests/baselines/reference/generatorImplicitAny.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/generators/generatorImplicitAny.ts === +function* g() {} +>g : Symbol(g, Decl(generatorImplicitAny.ts, 0, 0)) + diff --git a/tests/baselines/reference/generatorImplicitAny.types b/tests/baselines/reference/generatorImplicitAny.types new file mode 100644 index 0000000000000..a63d19b7fbe06 --- /dev/null +++ b/tests/baselines/reference/generatorImplicitAny.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/generators/generatorImplicitAny.ts === +function* g() {} +>g : () => Generator + diff --git a/tests/baselines/reference/generatorNoImplicitReturns.types b/tests/baselines/reference/generatorNoImplicitReturns.types index 666ce4db474c0..f8a2a073487ae 100644 --- a/tests/baselines/reference/generatorNoImplicitReturns.types +++ b/tests/baselines/reference/generatorNoImplicitReturns.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/yieldExpressions/generatorNoImplicitReturns.ts === function* testGenerator () { ->testGenerator : () => IterableIterator +>testGenerator : () => Generator if (Math.random() > 0.5) { >Math.random() > 0.5 : boolean diff --git a/tests/baselines/reference/generatorReturnTypeInference.js b/tests/baselines/reference/generatorReturnTypeInference.js new file mode 100644 index 0000000000000..2b22d758532cd --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeInference.js @@ -0,0 +1,167 @@ +//// [generatorReturnTypeInference.ts] +declare const iterableIterator: IterableIterator; +declare const generator: Generator; +declare const never: never; + +// 'yield' iteration type inference +function* g001() { // Generator + yield; +} + +function* g002() { // Generator + yield 1; +} + +function* g003() { // Generator + yield* []; +} + +function* g004() { // Generator + yield* iterableIterator; +} + +function* g005() { // Generator + yield* generator; +} + +function* g006() { // Generator<1 | 2, void, unknown> + yield 1; + yield 2; +} + +function* g007() { // Generator + yield never; +} + +// 'return' iteration type inference +function* g102() { // Generator + return 1; +} + +function* g103() { // Generator + if (Math.random()) return 1; + return 2; +} + +function* g104() { // Generator + return never; +} + +// 'next' iteration type inference +function* g201() { // Generator + let a: string = yield 1; +} + +function* g202() { // Generator<1 | 2, void, string & number> + let a: string = yield 1; + let b: number = yield 2; +} + +// mixed iteration types inference + +function* g301() { // Generator + yield; + return; +} + +function* g302() { // Generator + yield 1; + return; +} + +function* g303() { // Generator + yield; + return "a"; +} + +function* g304() { // Generator + yield 1; + return "a"; +} + +function* g305() { // Generator<1 | 2, "a" | "b", unknown> + if (Math.random()) yield 1; + yield 2; + if (Math.random()) return "a"; + return "b"; +} + +function* g306() { // Generator + const a: "hi" = yield 1; + return true; +} + + +//// [generatorReturnTypeInference.js] +// 'yield' iteration type inference +function* g001() { + yield; +} +function* g002() { + yield 1; +} +function* g003() { + yield* []; +} +function* g004() { + yield* iterableIterator; +} +function* g005() { + yield* generator; +} +function* g006() { + yield 1; + yield 2; +} +function* g007() { + yield never; +} +// 'return' iteration type inference +function* g102() { + return 1; +} +function* g103() { + if (Math.random()) + return 1; + return 2; +} +function* g104() { + return never; +} +// 'next' iteration type inference +function* g201() { + let a = yield 1; +} +function* g202() { + let a = yield 1; + let b = yield 2; +} +// mixed iteration types inference +function* g301() { + yield; + return; +} +function* g302() { + yield 1; + return; +} +function* g303() { + yield; + return "a"; +} +function* g304() { + yield 1; + return "a"; +} +function* g305() { + if (Math.random()) + yield 1; + yield 2; + if (Math.random()) + return "a"; + return "b"; +} +function* g306() { + const a = yield 1; + return true; +} diff --git a/tests/baselines/reference/generatorReturnTypeInference.symbols b/tests/baselines/reference/generatorReturnTypeInference.symbols new file mode 100644 index 0000000000000..2daaaebd137c8 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeInference.symbols @@ -0,0 +1,158 @@ +=== tests/cases/conformance/generators/generatorReturnTypeInference.ts === +declare const iterableIterator: IterableIterator; +>iterableIterator : Symbol(iterableIterator, Decl(generatorReturnTypeInference.ts, 0, 13)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) + +declare const generator: Generator; +>generator : Symbol(generator, Decl(generatorReturnTypeInference.ts, 1, 13)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + +declare const never: never; +>never : Symbol(never, Decl(generatorReturnTypeInference.ts, 2, 13)) + +// 'yield' iteration type inference +function* g001() { // Generator +>g001 : Symbol(g001, Decl(generatorReturnTypeInference.ts, 2, 27)) + + yield; +} + +function* g002() { // Generator +>g002 : Symbol(g002, Decl(generatorReturnTypeInference.ts, 7, 1)) + + yield 1; +} + +function* g003() { // Generator +>g003 : Symbol(g003, Decl(generatorReturnTypeInference.ts, 11, 1)) + + yield* []; +} + +function* g004() { // Generator +>g004 : Symbol(g004, Decl(generatorReturnTypeInference.ts, 15, 1)) + + yield* iterableIterator; +>iterableIterator : Symbol(iterableIterator, Decl(generatorReturnTypeInference.ts, 0, 13)) +} + +function* g005() { // Generator +>g005 : Symbol(g005, Decl(generatorReturnTypeInference.ts, 19, 1)) + + yield* generator; +>generator : Symbol(generator, Decl(generatorReturnTypeInference.ts, 1, 13)) +} + +function* g006() { // Generator<1 | 2, void, unknown> +>g006 : Symbol(g006, Decl(generatorReturnTypeInference.ts, 23, 1)) + + yield 1; + yield 2; +} + +function* g007() { // Generator +>g007 : Symbol(g007, Decl(generatorReturnTypeInference.ts, 28, 1)) + + yield never; +>never : Symbol(never, Decl(generatorReturnTypeInference.ts, 2, 13)) +} + +// 'return' iteration type inference +function* g102() { // Generator +>g102 : Symbol(g102, Decl(generatorReturnTypeInference.ts, 32, 1)) + + return 1; +} + +function* g103() { // Generator +>g103 : Symbol(g103, Decl(generatorReturnTypeInference.ts, 37, 1)) + + if (Math.random()) return 1; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + return 2; +} + +function* g104() { // Generator +>g104 : Symbol(g104, Decl(generatorReturnTypeInference.ts, 42, 1)) + + return never; +>never : Symbol(never, Decl(generatorReturnTypeInference.ts, 2, 13)) +} + +// 'next' iteration type inference +function* g201() { // Generator +>g201 : Symbol(g201, Decl(generatorReturnTypeInference.ts, 46, 1)) + + let a: string = yield 1; +>a : Symbol(a, Decl(generatorReturnTypeInference.ts, 50, 7)) +} + +function* g202() { // Generator<1 | 2, void, string & number> +>g202 : Symbol(g202, Decl(generatorReturnTypeInference.ts, 51, 1)) + + let a: string = yield 1; +>a : Symbol(a, Decl(generatorReturnTypeInference.ts, 54, 7)) + + let b: number = yield 2; +>b : Symbol(b, Decl(generatorReturnTypeInference.ts, 55, 7)) +} + +// mixed iteration types inference + +function* g301() { // Generator +>g301 : Symbol(g301, Decl(generatorReturnTypeInference.ts, 56, 1)) + + yield; + return; +} + +function* g302() { // Generator +>g302 : Symbol(g302, Decl(generatorReturnTypeInference.ts, 63, 1)) + + yield 1; + return; +} + +function* g303() { // Generator +>g303 : Symbol(g303, Decl(generatorReturnTypeInference.ts, 68, 1)) + + yield; + return "a"; +} + +function* g304() { // Generator +>g304 : Symbol(g304, Decl(generatorReturnTypeInference.ts, 73, 1)) + + yield 1; + return "a"; +} + +function* g305() { // Generator<1 | 2, "a" | "b", unknown> +>g305 : Symbol(g305, Decl(generatorReturnTypeInference.ts, 78, 1)) + + if (Math.random()) yield 1; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + yield 2; + if (Math.random()) return "a"; +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + return "b"; +} + +function* g306() { // Generator +>g306 : Symbol(g306, Decl(generatorReturnTypeInference.ts, 85, 1)) + + const a: "hi" = yield 1; +>a : Symbol(a, Decl(generatorReturnTypeInference.ts, 88, 9)) + + return true; +} + diff --git a/tests/baselines/reference/generatorReturnTypeInference.types b/tests/baselines/reference/generatorReturnTypeInference.types new file mode 100644 index 0000000000000..a585698ee282e --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeInference.types @@ -0,0 +1,203 @@ +=== tests/cases/conformance/generators/generatorReturnTypeInference.ts === +declare const iterableIterator: IterableIterator; +>iterableIterator : IterableIterator + +declare const generator: Generator; +>generator : Generator + +declare const never: never; +>never : never + +// 'yield' iteration type inference +function* g001() { // Generator +>g001 : () => Generator + + yield; +>yield : any +} + +function* g002() { // Generator +>g002 : () => Generator + + yield 1; +>yield 1 : any +>1 : 1 +} + +function* g003() { // Generator +>g003 : () => Generator + + yield* []; +>yield* [] : void +>[] : never[] +} + +function* g004() { // Generator +>g004 : () => Generator + + yield* iterableIterator; +>yield* iterableIterator : number | void +>iterableIterator : IterableIterator +} + +function* g005() { // Generator +>g005 : () => Generator + + yield* generator; +>yield* generator : string +>generator : Generator +} + +function* g006() { // Generator<1 | 2, void, unknown> +>g006 : () => Generator<1 | 2, void, unknown> + + yield 1; +>yield 1 : any +>1 : 1 + + yield 2; +>yield 2 : any +>2 : 2 +} + +function* g007() { // Generator +>g007 : () => Generator + + yield never; +>yield never : any +>never : never +} + +// 'return' iteration type inference +function* g102() { // Generator +>g102 : () => Generator + + return 1; +>1 : 1 +} + +function* g103() { // Generator +>g103 : () => Generator + + if (Math.random()) return 1; +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>1 : 1 + + return 2; +>2 : 2 +} + +function* g104() { // Generator +>g104 : () => Generator + + return never; +>never : never +} + +// 'next' iteration type inference +function* g201() { // Generator +>g201 : () => Generator + + let a: string = yield 1; +>a : string +>yield 1 : any +>1 : 1 +} + +function* g202() { // Generator<1 | 2, void, string & number> +>g202 : () => Generator<1 | 2, void, string & number> + + let a: string = yield 1; +>a : string +>yield 1 : any +>1 : 1 + + let b: number = yield 2; +>b : number +>yield 2 : any +>2 : 2 +} + +// mixed iteration types inference + +function* g301() { // Generator +>g301 : () => Generator + + yield; +>yield : any + + return; +} + +function* g302() { // Generator +>g302 : () => Generator + + yield 1; +>yield 1 : any +>1 : 1 + + return; +} + +function* g303() { // Generator +>g303 : () => Generator + + yield; +>yield : any + + return "a"; +>"a" : "a" +} + +function* g304() { // Generator +>g304 : () => Generator + + yield 1; +>yield 1 : any +>1 : 1 + + return "a"; +>"a" : "a" +} + +function* g305() { // Generator<1 | 2, "a" | "b", unknown> +>g305 : () => Generator<1 | 2, "a" | "b", unknown> + + if (Math.random()) yield 1; +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>yield 1 : any +>1 : 1 + + yield 2; +>yield 2 : any +>2 : 2 + + if (Math.random()) return "a"; +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>"a" : "a" + + return "b"; +>"b" : "b" +} + +function* g306() { // Generator +>g306 : () => Generator + + const a: "hi" = yield 1; +>a : "hi" +>yield 1 : any +>1 : 1 + + return true; +>true : true +} + diff --git a/tests/baselines/reference/generatorTypeCheck12.errors.txt b/tests/baselines/reference/generatorTypeCheck12.errors.txt new file mode 100644 index 0000000000000..9a834acfc5c00 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck12.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts(2,5): error TS2322: Type '""' is not assignable to type 'number | void'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck12.ts (1 errors) ==== + function* g(): IterableIterator { + return ""; + ~~~~~~~~~~ +!!! error TS2322: Type '""' is not assignable to type 'number | void'. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck13.errors.txt b/tests/baselines/reference/generatorTypeCheck13.errors.txt new file mode 100644 index 0000000000000..72403d417c28a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck13.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts(3,5): error TS2322: Type '""' is not assignable to type 'number | void'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck13.ts (1 errors) ==== + function* g(): IterableIterator { + yield 0; + return ""; + ~~~~~~~~~~ +!!! error TS2322: Type '""' is not assignable to type 'number | void'. + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck14.types b/tests/baselines/reference/generatorTypeCheck14.types index 28401e68567a2..a4113cb8be294 100644 --- a/tests/baselines/reference/generatorTypeCheck14.types +++ b/tests/baselines/reference/generatorTypeCheck14.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === function* g() { ->g : () => IterableIterator<0 | ""> +>g : () => Generator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index 33537836c120f..d8e8ed5880587 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck16.types b/tests/baselines/reference/generatorTypeCheck16.types index a607ad851c198..b8b43fcefc733 100644 --- a/tests/baselines/reference/generatorTypeCheck16.types +++ b/tests/baselines/reference/generatorTypeCheck16.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck16.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator return; } diff --git a/tests/baselines/reference/generatorTypeCheck19.types b/tests/baselines/reference/generatorTypeCheck19.types index 73612246eface..2590fa2647be8 100644 --- a/tests/baselines/reference/generatorTypeCheck19.types +++ b/tests/baselines/reference/generatorTypeCheck19.types @@ -15,7 +15,7 @@ function* g(): IterableIterator { >yield : any yield * [new Bar]; ->yield * [new Bar] : any +>yield * [new Bar] : void >[new Bar] : Bar[] >new Bar : Bar >Bar : typeof Bar diff --git a/tests/baselines/reference/generatorTypeCheck20.types b/tests/baselines/reference/generatorTypeCheck20.types index 77b15497db0e8..37dd49a8779fb 100644 --- a/tests/baselines/reference/generatorTypeCheck20.types +++ b/tests/baselines/reference/generatorTypeCheck20.types @@ -14,7 +14,7 @@ function* g(): IterableIterator { >yield : any yield * [new Baz]; ->yield * [new Baz] : any +>yield * [new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck22.types b/tests/baselines/reference/generatorTypeCheck22.types index e46e73874e619..3b5c8496f3f12 100644 --- a/tests/baselines/reference/generatorTypeCheck22.types +++ b/tests/baselines/reference/generatorTypeCheck22.types @@ -13,7 +13,7 @@ class Baz { z: number } >z : number function* g3() { ->g3 : () => IterableIterator +>g3 : () => Generator yield; >yield : any @@ -29,13 +29,13 @@ function* g3() { >Baz : typeof Baz yield *[new Bar]; ->yield *[new Bar] : any +>yield *[new Bar] : void >[new Bar] : Bar[] >new Bar : Bar >Bar : typeof Bar yield *[new Baz]; ->yield *[new Baz] : any +>yield *[new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck23.types b/tests/baselines/reference/generatorTypeCheck23.types index 1d5d294503a60..2f6c7e01a4815 100644 --- a/tests/baselines/reference/generatorTypeCheck23.types +++ b/tests/baselines/reference/generatorTypeCheck23.types @@ -13,7 +13,7 @@ class Baz { z: number } >z : number function* g3() { ->g3 : () => IterableIterator +>g3 : () => Generator yield; >yield : any @@ -34,13 +34,13 @@ function* g3() { >Baz : typeof Baz yield *[new Bar]; ->yield *[new Bar] : any +>yield *[new Bar] : void >[new Bar] : Bar[] >new Bar : Bar >Bar : typeof Bar yield *[new Baz]; ->yield *[new Baz] : any +>yield *[new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck24.types b/tests/baselines/reference/generatorTypeCheck24.types index e3c369bfce199..c75a04330cc3e 100644 --- a/tests/baselines/reference/generatorTypeCheck24.types +++ b/tests/baselines/reference/generatorTypeCheck24.types @@ -13,13 +13,13 @@ class Baz { z: number } >z : number function* g3() { ->g3 : () => IterableIterator +>g3 : () => Generator yield; >yield : any yield * [new Foo]; ->yield * [new Foo] : any +>yield * [new Foo] : void >[new Foo] : Foo[] >new Foo : Foo >Foo : typeof Foo @@ -35,13 +35,13 @@ function* g3() { >Baz : typeof Baz yield *[new Bar]; ->yield *[new Bar] : any +>yield *[new Bar] : void >[new Bar] : Bar[] >new Bar : Bar >Bar : typeof Bar yield *[new Baz]; ->yield *[new Baz] : any +>yield *[new Baz] : void >[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 index c3c456e805d7d..ee0d8c5db7a16 100644 --- a/tests/baselines/reference/generatorTypeCheck25.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck25.errors.txt @@ -1,13 +1,15 @@ -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'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error TS2322: Type '() => Generator' is not assignable to type '() => Iterable'. + Type 'Generator' 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'. + Type '() => Generator' is not assignable to type '() => Iterator'. + Type 'Generator' 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'. - Property 'x' is missing in type 'Baz' but required in type 'Foo'. + Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'Bar | Baz' is not assignable to type 'Foo'. + Property 'x' is missing in type 'Baz' but required in type 'Foo'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts (1 errors) ==== @@ -16,16 +18,18 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts(4,5): error 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: Type '() => Generator' is not assignable to type '() => Iterable'. +!!! error TS2322: Type 'Generator' 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: Type '() => Generator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'Generator' 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: Property 'x' is missing in type 'Baz' but required in type 'Foo'. +!!! error TS2322: Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2322: Type 'Bar | Baz' is not assignable to type 'Foo'. +!!! error TS2322: Property 'x' is missing in type 'Baz' but required in type 'Foo'. !!! related TS2728 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck25.ts:1:13: 'x' is declared here. yield; yield new Bar; diff --git a/tests/baselines/reference/generatorTypeCheck25.types b/tests/baselines/reference/generatorTypeCheck25.types index 4707bfe7b6b07..01f75c7fb4656 100644 --- a/tests/baselines/reference/generatorTypeCheck25.types +++ b/tests/baselines/reference/generatorTypeCheck25.types @@ -14,7 +14,7 @@ class Baz { z: number } var g3: () => Iterable = function* () { >g3 : () => Iterable ->function* () { yield; yield new Bar; yield new Baz; yield *[new Bar]; yield *[new Baz];} : () => IterableIterator +>function* () { yield; yield new Bar; yield new Baz; yield *[new Bar]; yield *[new Baz];} : () => Generator yield; >yield : any @@ -30,13 +30,13 @@ var g3: () => Iterable = function* () { >Baz : typeof Baz yield *[new Bar]; ->yield *[new Bar] : any +>yield *[new Bar] : void >[new Bar] : Bar[] >new Bar : Bar >Bar : typeof Bar yield *[new Baz]; ->yield *[new Baz] : any +>yield *[new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck26.types b/tests/baselines/reference/generatorTypeCheck26.types index 6ae17c983b8fd..1fc28dfb2bb41 100644 --- a/tests/baselines/reference/generatorTypeCheck26.types +++ b/tests/baselines/reference/generatorTypeCheck26.types @@ -12,7 +12,7 @@ function* g(): IterableIterator<(x: string) => number> { >length : number yield *[x => x.length]; ->yield *[x => x.length] : any +>yield *[x => x.length] : void >[x => x.length] : ((x: string) => number)[] >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/generatorTypeCheck27.types b/tests/baselines/reference/generatorTypeCheck27.types index 16632d021a401..58306e1fb4aec 100644 --- a/tests/baselines/reference/generatorTypeCheck27.types +++ b/tests/baselines/reference/generatorTypeCheck27.types @@ -4,9 +4,9 @@ function* g(): IterableIterator<(x: string) => number> { >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 * function* () { yield x => x.length; } () : void +>function* () { yield x => x.length; } () : Generator<(x: any) => any, void, unknown> +>function* () { yield x => x.length; } : () => Generator<(x: any) => any, void, unknown> yield x => x.length; >yield x => x.length : any diff --git a/tests/baselines/reference/generatorTypeCheck28.types b/tests/baselines/reference/generatorTypeCheck28.types index 7d5bafe28c52e..9cd4e5e82cecb 100644 --- a/tests/baselines/reference/generatorTypeCheck28.types +++ b/tests/baselines/reference/generatorTypeCheck28.types @@ -4,11 +4,11 @@ function* g(): IterableIterator<(x: string) => number> { >x : string yield * { ->yield * { *[Symbol.iterator]() { yield x => x.length; } } : any ->{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): IterableIterator<(x: string) => number>; } +>yield * { *[Symbol.iterator]() { yield x => x.length; } } : void +>{ *[Symbol.iterator]() { yield x => x.length; } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; } *[Symbol.iterator]() { ->[Symbol.iterator] : () => IterableIterator<(x: string) => number> +>[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown> >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol diff --git a/tests/baselines/reference/generatorTypeCheck29.types b/tests/baselines/reference/generatorTypeCheck29.types index 48a32f65e37f2..5faea041f1b3d 100644 --- a/tests/baselines/reference/generatorTypeCheck29.types +++ b/tests/baselines/reference/generatorTypeCheck29.types @@ -5,8 +5,8 @@ function* g2(): Iterator number>> { 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> +>function* () { yield x => x.length; } () : Generator<(x: any) => any, void, unknown> +>function* () { yield x => x.length; } : () => Generator<(x: any) => any, void, unknown> yield x => x.length; >yield x => x.length : any diff --git a/tests/baselines/reference/generatorTypeCheck30.types b/tests/baselines/reference/generatorTypeCheck30.types index 2e4971770f328..79fd97f1180e4 100644 --- a/tests/baselines/reference/generatorTypeCheck30.types +++ b/tests/baselines/reference/generatorTypeCheck30.types @@ -5,8 +5,8 @@ function* g2(): Iterator number>> { 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> +>function* () { yield x => x.length; } () : Generator<(x: any) => any, void, unknown> +>function* () { yield x => x.length; } : () => Generator<(x: any) => any, void, unknown> yield x => x.length; >yield x => x.length : any diff --git a/tests/baselines/reference/generatorTypeCheck31.errors.txt b/tests/baselines/reference/generatorTypeCheck31.errors.txt index 437b7470069b1..0ed5dcbe0e08f 100644 --- a/tests/baselines/reference/generatorTypeCheck31.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck31.errors.txt @@ -1,5 +1,5 @@ -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>'. - Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): error TS2322: Type 'Generator<(x: any) => any, void, unknown>' is not assignable to type '() => Iterable<(x: string) => number>'. + Type 'Generator<(x: any) => any, void, unknown>' provides no match for the signature '(): Iterable<(x: string) => number>'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts (1 errors) ==== @@ -10,6 +10,6 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck31.ts(2,11): erro ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } () ~~~~~~~~ -!!! error TS2322: Type 'IterableIterator<(x: any) => any>' is not assignable to type '() => Iterable<(x: string) => number>'. -!!! error TS2322: Type 'IterableIterator<(x: any) => any>' provides no match for the signature '(): Iterable<(x: string) => number>'. +!!! error TS2322: Type 'Generator<(x: any) => any, void, unknown>' is not assignable to type '() => Iterable<(x: string) => number>'. +!!! error TS2322: Type 'Generator<(x: any) => any, void, unknown>' provides no match for the signature '(): Iterable<(x: string) => number>'. } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck31.types b/tests/baselines/reference/generatorTypeCheck31.types index 2038b2ee1c2a2..04730ced6dbaa 100644 --- a/tests/baselines/reference/generatorTypeCheck31.types +++ b/tests/baselines/reference/generatorTypeCheck31.types @@ -5,8 +5,8 @@ function* g2(): Iterator<() => Iterable<(x: string) => number>> { 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> +>function* () { yield x => x.length; } () : Generator<(x: any) => any, void, unknown> +>function* () { yield x => x.length; } : () => Generator<(x: any) => any, void, unknown> yield x => x.length; >yield x => x.length : any diff --git a/tests/baselines/reference/generatorTypeCheck33.types b/tests/baselines/reference/generatorTypeCheck33.types index d6b29936530d6..e894b44a4e388 100644 --- a/tests/baselines/reference/generatorTypeCheck33.types +++ b/tests/baselines/reference/generatorTypeCheck33.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator +>g2 : () => Generator yield ""; >yield "" : any diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index f25eefb72f7be..5e2e6af134cad 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator +>g2 : () => Generator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck35.types b/tests/baselines/reference/generatorTypeCheck35.types index 333b653a50148..b35139b9c16c6 100644 --- a/tests/baselines/reference/generatorTypeCheck35.types +++ b/tests/baselines/reference/generatorTypeCheck35.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck36.types b/tests/baselines/reference/generatorTypeCheck36.types index 318a46c25fb59..9cebc9a407f12 100644 --- a/tests/baselines/reference/generatorTypeCheck36.types +++ b/tests/baselines/reference/generatorTypeCheck36.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck36.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield yield 0; >yield yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck37.types b/tests/baselines/reference/generatorTypeCheck37.types index aaa790c809474..d9c28b941ddbd 100644 --- a/tests/baselines/reference/generatorTypeCheck37.types +++ b/tests/baselines/reference/generatorTypeCheck37.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck37.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator return yield yield 0; >yield yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck38.types b/tests/baselines/reference/generatorTypeCheck38.types index 15b8528b345a6..a62587603d4f5 100644 --- a/tests/baselines/reference/generatorTypeCheck38.types +++ b/tests/baselines/reference/generatorTypeCheck38.types @@ -3,7 +3,7 @@ var yield; >yield : any function* g() { ->g : () => IterableIterator +>g : () => Generator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck39.types b/tests/baselines/reference/generatorTypeCheck39.types index e24fc173566db..5ca4062b5580d 100644 --- a/tests/baselines/reference/generatorTypeCheck39.types +++ b/tests/baselines/reference/generatorTypeCheck39.types @@ -8,7 +8,7 @@ function decorator(x: any) { >y : any } function* g() { ->g : () => IterableIterator +>g : () => Generator @decorator(yield 0) >decorator(yield 0) : (y: any) => void diff --git a/tests/baselines/reference/generatorTypeCheck40.types b/tests/baselines/reference/generatorTypeCheck40.types index cbec14d36d6b9..4e774158175fb 100644 --- a/tests/baselines/reference/generatorTypeCheck40.types +++ b/tests/baselines/reference/generatorTypeCheck40.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck40.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator class C extends (yield 0) { } >C : C diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types index 5f20d01765582..d22c875416f8b 100644 --- a/tests/baselines/reference/generatorTypeCheck41.types +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types index 47d948739f10d..f3e82ad1a98d0 100644 --- a/tests/baselines/reference/generatorTypeCheck42.types +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator let x = { >x : { [x: number]: () => void; } diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types index 298c631728ebb..cdf5cdc81bbb8 100644 --- a/tests/baselines/reference/generatorTypeCheck43.types +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator let x = { ->x : { [x: number]: () => IterableIterator; } ->{ *[yield 0]() { } } : { [x: number]: () => IterableIterator; } +>x : { [x: number]: () => Generator; } +>{ *[yield 0]() { } } : { [x: number]: () => Generator; } *[yield 0]() { ->[yield 0] : () => IterableIterator +>[yield 0] : () => Generator >yield 0 : any >0 : 0 diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types index 38b335f1ab46c..53dfd59266ec8 100644 --- a/tests/baselines/reference/generatorTypeCheck44.types +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types index 59ee8efa9f373..cf8169340b737 100644 --- a/tests/baselines/reference/generatorTypeCheck45.types +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -11,7 +11,7 @@ foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, sh >foo("", function* () { yield x => x.length }, p => undefined) : string >foo : (x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T) => T >"" : "" ->function* () { yield x => x.length } : () => IterableIterator<(x: string) => number> +>function* () { yield x => x.length } : () => Generator<(x: string) => number, void, unknown> >yield x => x.length : any >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types index 81002c761d93a..cd565d55911ee 100644 --- a/tests/baselines/reference/generatorTypeCheck46.types +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -11,14 +11,14 @@ 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 >"" : "" ->function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => IterableIterator<(x: string) => number> +>function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => Generator<(x: string) => number, void, unknown> yield* { ->yield* { *[Symbol.iterator]() { yield x => x.length } } : any ->{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): IterableIterator<(x: string) => number>; } +>yield* { *[Symbol.iterator]() { yield x => x.length } } : void +>{ *[Symbol.iterator]() { yield x => x.length } } : { [Symbol.iterator](): Generator<(x: string) => number, void, unknown>; } *[Symbol.iterator]() { ->[Symbol.iterator] : () => IterableIterator<(x: string) => number> +>[Symbol.iterator] : () => Generator<(x: string) => number, void, unknown> >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol diff --git a/tests/baselines/reference/generatorTypeCheck47.errors.txt b/tests/baselines/reference/generatorTypeCheck47.errors.txt deleted file mode 100644 index 993285179bcaa..0000000000000 --- a/tests/baselines/reference/generatorTypeCheck47.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts(1,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.types b/tests/baselines/reference/generatorTypeCheck47.types index d37512af0ac89..d5e92f02a873f 100644 --- a/tests/baselines/reference/generatorTypeCheck47.types +++ b/tests/baselines/reference/generatorTypeCheck47.types @@ -1,4 +1,4 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck47.ts === function* g() { } ->g : () => IterableIterator +>g : () => Generator diff --git a/tests/baselines/reference/generatorTypeCheck48.types b/tests/baselines/reference/generatorTypeCheck48.types index f07131595cdbc..23134d50bee16 100644 --- a/tests/baselines/reference/generatorTypeCheck48.types +++ b/tests/baselines/reference/generatorTypeCheck48.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck48.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield; >yield : any } function* h() { ->h : () => IterableIterator +>h : () => Generator yield undefined; >yield undefined : any diff --git a/tests/baselines/reference/generatorTypeCheck49.types b/tests/baselines/reference/generatorTypeCheck49.types index f73978d1a095a..985194b7392cd 100644 --- a/tests/baselines/reference/generatorTypeCheck49.types +++ b/tests/baselines/reference/generatorTypeCheck49.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck50.types b/tests/baselines/reference/generatorTypeCheck50.types index 1b25ea004f8fb..fa4561d16a1ec 100644 --- a/tests/baselines/reference/generatorTypeCheck50.types +++ b/tests/baselines/reference/generatorTypeCheck50.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck50.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator yield yield; >yield yield : any diff --git a/tests/baselines/reference/generatorTypeCheck51.errors.txt b/tests/baselines/reference/generatorTypeCheck51.errors.txt deleted file mode 100644 index b717b51803e38..0000000000000 --- a/tests/baselines/reference/generatorTypeCheck51.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts(1,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.types b/tests/baselines/reference/generatorTypeCheck51.types index 1563ee5e7d317..0ef7abf19cd3b 100644 --- a/tests/baselines/reference/generatorTypeCheck51.types +++ b/tests/baselines/reference/generatorTypeCheck51.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck51.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator function* h() { ->h : () => IterableIterator +>h : () => Generator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck52.types b/tests/baselines/reference/generatorTypeCheck52.types index 97ac442aa0e30..30ef8611f6949 100644 --- a/tests/baselines/reference/generatorTypeCheck52.types +++ b/tests/baselines/reference/generatorTypeCheck52.types @@ -8,7 +8,7 @@ class Baz { z: number } >z : number function* g() { ->g : () => IterableIterator +>g : () => Generator yield new Foo; >yield new Foo : any diff --git a/tests/baselines/reference/generatorTypeCheck53.types b/tests/baselines/reference/generatorTypeCheck53.types index b91974e98073e..ed9aeb685462c 100644 --- a/tests/baselines/reference/generatorTypeCheck53.types +++ b/tests/baselines/reference/generatorTypeCheck53.types @@ -8,7 +8,7 @@ class Baz { z: number } >z : number function* g() { ->g : () => IterableIterator +>g : () => Generator yield new Foo; >yield new Foo : any @@ -16,7 +16,7 @@ function* g() { >Foo : typeof Foo yield* [new Baz]; ->yield* [new Baz] : any +>yield* [new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck54.types b/tests/baselines/reference/generatorTypeCheck54.types index 1cdbde67498f0..972608bcb465c 100644 --- a/tests/baselines/reference/generatorTypeCheck54.types +++ b/tests/baselines/reference/generatorTypeCheck54.types @@ -8,16 +8,16 @@ class Baz { z: number } >z : number function* g() { ->g : () => IterableIterator +>g : () => Generator yield* [new Foo]; ->yield* [new Foo] : any +>yield* [new Foo] : void >[new Foo] : Foo[] >new Foo : Foo >Foo : typeof Foo yield* [new Baz]; ->yield* [new Baz] : any +>yield* [new Baz] : void >[new Baz] : Baz[] >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck55.types b/tests/baselines/reference/generatorTypeCheck55.types index c45f169013101..15c3303b4386c 100644 --- a/tests/baselines/reference/generatorTypeCheck55.types +++ b/tests/baselines/reference/generatorTypeCheck55.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck55.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator var x = class C extends (yield) {}; >x : typeof C diff --git a/tests/baselines/reference/generatorTypeCheck56.types b/tests/baselines/reference/generatorTypeCheck56.types index 718e5d0d79289..6f05396a1f106 100644 --- a/tests/baselines/reference/generatorTypeCheck56.types +++ b/tests/baselines/reference/generatorTypeCheck56.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator var x = class C { >x : typeof C @@ -8,7 +8,7 @@ function* g() { >C : typeof C *[yield 0]() { ->[yield 0] : () => IterableIterator +>[yield 0] : () => Generator >yield 0 : any >0 : 0 diff --git a/tests/baselines/reference/generatorTypeCheck57.types b/tests/baselines/reference/generatorTypeCheck57.types index b852efe62f442..9e660521dfba4 100644 --- a/tests/baselines/reference/generatorTypeCheck57.types +++ b/tests/baselines/reference/generatorTypeCheck57.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator class C { >C : C diff --git a/tests/baselines/reference/generatorTypeCheck58.types b/tests/baselines/reference/generatorTypeCheck58.types index a04691cb4ba73..69d1723be9661 100644 --- a/tests/baselines/reference/generatorTypeCheck58.types +++ b/tests/baselines/reference/generatorTypeCheck58.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator class C { >C : C diff --git a/tests/baselines/reference/generatorTypeCheck59.types b/tests/baselines/reference/generatorTypeCheck59.types index 35b9b7e66f16c..d04b829fba8e9 100644 --- a/tests/baselines/reference/generatorTypeCheck59.types +++ b/tests/baselines/reference/generatorTypeCheck59.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator class C { >C : C diff --git a/tests/baselines/reference/generatorTypeCheck6.errors.txt b/tests/baselines/reference/generatorTypeCheck6.errors.txt index 35f2cc2016dbc..7084844c48ffa 100644 --- a/tests/baselines/reference/generatorTypeCheck6.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck6.errors.txt @@ -1,7 +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,17): error TS2322: Type 'Generator' 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 +!!! error TS2322: Type 'Generator' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck60.types b/tests/baselines/reference/generatorTypeCheck60.types index 9073f604be6fb..b10101b6f41d6 100644 --- a/tests/baselines/reference/generatorTypeCheck60.types +++ b/tests/baselines/reference/generatorTypeCheck60.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck60.ts === function* g() { ->g : () => IterableIterator +>g : () => Generator class C extends (yield) {}; >C : C diff --git a/tests/baselines/reference/generatorTypeCheck61.types b/tests/baselines/reference/generatorTypeCheck61.types index a8093e1bbe116..91874ffa58dfb 100644 --- a/tests/baselines/reference/generatorTypeCheck61.types +++ b/tests/baselines/reference/generatorTypeCheck61.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck61.ts === function * g() { ->g : () => IterableIterator +>g : () => Generator @(yield 0) >(yield 0) : any diff --git a/tests/baselines/reference/generatorTypeCheck62.types b/tests/baselines/reference/generatorTypeCheck62.types index 90d34fa8513f7..be5635a07fc66 100644 --- a/tests/baselines/reference/generatorTypeCheck62.types +++ b/tests/baselines/reference/generatorTypeCheck62.types @@ -12,7 +12,7 @@ export function strategy(stratName: string, gen: (a: T >a : T return function*(state) { ->function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => IterableIterator +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator >state : T for (const next of gen(state)) { @@ -53,7 +53,7 @@ export const Nothing1: Strategy = strategy("Nothing", function*(state: St >strategy("Nothing", function*(state: State) { return state;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function*(state: State) { return state;} : (state: State) => IterableIterator +>function*(state: State) { return state;} : (state: State) => Generator >state : State return state; @@ -66,7 +66,7 @@ export const Nothing2: Strategy = strategy("Nothing", function*(state: St >strategy("Nothing", function*(state: State) { yield state;}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function*(state: State) { yield state;} : (state: State) => IterableIterator +>function*(state: State) { yield state;} : (state: State) => Generator >state : State yield state; @@ -77,10 +77,10 @@ export const Nothing2: Strategy = strategy("Nothing", function*(state: St export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { >Nothing3 : Strategy ->strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: State) => IterableIterator +>strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: any) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield ; return state;} : (state: State) => IterableIterator +>function* (state: State) { yield ; return state;} : (state: State) => Generator >state : State yield ; diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt index 2a1935fd90633..8b50dd4f559d2 100644 --- a/tests/baselines/reference/generatorTypeCheck63.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -1,16 +1,29 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. - Type 'IterableIterator' is not assignable to type 'IterableIterator'. - Type 'State | 1' is not assignable to type 'StrategicState'. - Type '1' has no properties in common with type 'StrategicState'. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(29,70): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: State) => IterableIterator'. - Type 'IterableIterator' is not assignable to type 'IterableIterator'. - Type 'number' is not assignable to type 'State'. -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. - Type 'IterableIterator' is not assignable to type 'IterableIterator'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'Generator' is not assignable to type 'IterableIterator'. + Types of property 'next' are incompatible. + Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'number' is not assignable to type 'State'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'Generator' is not assignable to type 'IterableIterator'. + Types of property 'next' are incompatible. + Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorReturnResult' is not assignable to type 'IteratorResult'. + Type 'IteratorReturnResult' is not assignable to type 'IteratorReturnResult'. + Type 'number' is not assignable to type 'void | State'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'Generator' is not assignable to type 'IterableIterator'. + Types of property 'next' are incompatible. + Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorReturnResult' is not assignable to type 'IteratorResult'. + Type 'IteratorReturnResult' is not assignable to type 'IteratorReturnResult'. -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (4 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (3 errors) ==== export interface StrategicState { lastStrategyApplied?: string; } @@ -36,31 +49,43 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): err export const Nothing: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. -!!! error TS2345: Type 'IterableIterator' is not assignable to type 'IterableIterator'. -!!! error TS2345: Type 'State | 1' is not assignable to type 'StrategicState'. -!!! error TS2345: Type '1' has no properties in common with type 'StrategicState'. +!!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Types of property 'next' are incompatible. +!!! error TS2345: Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2345: Type 'number' is not assignable to type 'State'. yield 1; return state; }); export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { - ~ -!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. }); export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: State) => IterableIterator'. -!!! error TS2345: Type 'IterableIterator' is not assignable to type 'IterableIterator'. -!!! error TS2345: Type 'number' is not assignable to type 'State'. +!!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Types of property 'next' are incompatible. +!!! error TS2345: Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorReturnResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorReturnResult' is not assignable to type 'IteratorReturnResult'. +!!! error TS2345: Type 'number' is not assignable to type 'void | State'. return 1; }); export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. -!!! error TS2345: Type 'IterableIterator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Argument of type '(state: State) => Generator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'Generator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Types of property 'next' are incompatible. +!!! error TS2345: Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2345: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorReturnResult' is not assignable to type 'IteratorResult'. +!!! error TS2345: Type 'IteratorReturnResult' is not assignable to type 'IteratorReturnResult'. yield state; return 1; }); \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck63.types b/tests/baselines/reference/generatorTypeCheck63.types index 67f9717162df8..e65e217790b36 100644 --- a/tests/baselines/reference/generatorTypeCheck63.types +++ b/tests/baselines/reference/generatorTypeCheck63.types @@ -12,7 +12,7 @@ export function strategy(stratName: string, gen: (a: T >a : T return function*(state) { ->function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => IterableIterator +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => Generator >state : T for (const next of gen(state)) { @@ -53,7 +53,7 @@ export const Nothing: Strategy = strategy("Nothing", function* (state: St >strategy("Nothing", function* (state: State) { yield 1; return state;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield 1; return state;} : (state: State) => IterableIterator +>function* (state: State) { yield 1; return state;} : (state: State) => Generator >state : State yield 1; @@ -67,10 +67,10 @@ export const Nothing: Strategy = strategy("Nothing", function* (state: St export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { >Nothing1 : Strategy ->strategy("Nothing", function* (state: State) {}) : (a: any) => IterableIterator +>strategy("Nothing", function* (state: State) {}) : (a: State) => IterableIterator >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) {} : (state: State) => IterableIterator +>function* (state: State) {} : (state: State) => Generator >state : State }); @@ -80,7 +80,7 @@ export const Nothing2: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { return 1;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { return 1;} : (state: State) => IterableIterator +>function* (state: State) { return 1;} : (state: State) => Generator >state : State return 1; @@ -93,7 +93,7 @@ export const Nothing3: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { yield state; return 1;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { yield state; return 1;} : (state: State) => IterableIterator +>function* (state: State) { yield state; return 1;} : (state: State) => Generator >state : State yield state; diff --git a/tests/baselines/reference/generatorTypeCheck7.errors.txt b/tests/baselines/reference/generatorTypeCheck7.errors.txt index 96e226fe827be..d7669620c5728 100644 --- a/tests/baselines/reference/generatorTypeCheck7.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts(4,17): error TS2741: Property 'hello' is missing in type 'IterableIterator' but required in type 'WeirdIter'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts(4,17): error TS2741: Property 'hello' is missing in type 'Generator' but required in type 'WeirdIter'. ==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts(4,17): error } function* g1(): WeirdIter { } ~~~~~~~~~ -!!! error TS2741: Property 'hello' is missing in type 'IterableIterator' but required in type 'WeirdIter'. +!!! error TS2741: Property 'hello' is missing in type 'Generator' but required in type 'WeirdIter'. !!! related TS2728 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck7.ts:2:5: 'hello' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck8.errors.txt b/tests/baselines/reference/generatorTypeCheck8.errors.txt index cedfecda60b94..69ada9962c7f1 100644 --- a/tests/baselines/reference/generatorTypeCheck8.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck8.errors.txt @@ -1,16 +1,20 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error TS2322: Type 'IterableIterator' is not assignable to type 'BadGenerator'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck8.ts(2,17): error TS2322: Type 'Generator' 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'. + Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + 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: Type 'Generator' 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 +!!! error TS2322: Type '(value?: unknown) => IteratorResult' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.types b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.types index f932f2c339da8..b5f526adc8e89 100644 --- a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.types +++ b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.types @@ -93,7 +93,7 @@ var p3: Promise = import(j=getSpecifier()); >getSpecifier : () => string function * loadModule(directories: string[]) { ->loadModule : (directories: string[]) => IterableIterator +>loadModule : (directories: string[]) => Generator >directories : string[] for (const directory of directories) { diff --git a/tests/baselines/reference/importHelpersNoHelpersForAsyncGenerators.types b/tests/baselines/reference/importHelpersNoHelpersForAsyncGenerators.types index cb646e5a15e17..cba7dad577b99 100644 --- a/tests/baselines/reference/importHelpersNoHelpersForAsyncGenerators.types +++ b/tests/baselines/reference/importHelpersNoHelpersForAsyncGenerators.types @@ -1,6 +1,6 @@ === tests/cases/compiler/main.ts === export async function * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator await 1; >await 1 : 1 @@ -11,7 +11,7 @@ export async function * f() { >2 : 2 yield* [3]; ->yield* [3] : any +>yield* [3] : void >[3] : number[] >3 : 3 } diff --git a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt index b1278354ba2d8..338d168be9daa 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt @@ -3,8 +3,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(13,17): error TS232 Type '() => SymbolIterator' is not assignable to type '() => Iterator'. Type 'SymbolIterator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. - Property 'done' is missing in type '{ value: symbol; }' but required in type 'IteratorResult'. + Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. + Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. + Property 'done' is missing in type '{ value: symbol; }' but required in type 'IteratorReturnResult'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts (1 errors) ==== @@ -27,6 +28,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(13,17): error TS232 !!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. !!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }' but required in type 'IteratorResult'. -!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:32:5: 'done' is declared here. \ No newline at end of file +!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }' but required in type 'IteratorReturnResult'. +!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:37:5: 'done' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall12.js b/tests/baselines/reference/iteratorSpreadInCall12.js index ba8149e29d60c..10f1a7cf0c7cc 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.js +++ b/tests/baselines/reference/iteratorSpreadInCall12.js @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,7 +29,7 @@ class StringIterator { } } -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]); //// [iteratorSpreadInCall12.js] class Foo { @@ -46,7 +46,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -57,4 +57,4 @@ class StringIterator { return this; } } -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]); diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index 935f37bef2af0..99b4c3a1f3271 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -36,11 +36,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall12.ts, 17, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall12.ts, 17, 23)) return { value: "", @@ -53,18 +53,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall12.ts, 23, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall12.ts, 23, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) } } -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]); >Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index 5e3d2f722369e..5f0f0a34ccec6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -38,8 +38,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -69,17 +69,17 @@ class StringIterator { } } -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo +new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]); +>new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]) : Foo >Foo : typeof Foo ->...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol ->[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] +>...[...new SymbolIterator, ...[...new _StringIterator]] : string | symbol +>[...new SymbolIterator, ...[...new _StringIterator]] : (string | symbol)[] >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...[...new StringIterator] : string ->[...new StringIterator] : string[] ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...[...new _StringIterator] : string +>[...new _StringIterator] : string[] +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall5.js b/tests/baselines/reference/iteratorSpreadInCall5.js index b17054363ed33..b6c3a5c2cfd8b 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.js +++ b/tests/baselines/reference/iteratorSpreadInCall5.js @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,7 +26,7 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); //// [iteratorSpreadInCall5.js] function foo(...s) { } @@ -41,7 +41,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -52,4 +52,4 @@ class StringIterator { return this; } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index f3be9a2855736..a4d55eaf8cea7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -31,11 +31,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall5.ts, 14, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall5.ts, 14, 23)) return { value: "", @@ -48,18 +48,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall5.ts, 20, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall5.ts, 20, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); >foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index 5d70581cacb8c..6120f036645f9 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -35,8 +35,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -66,13 +66,13 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); ->foo(...new SymbolIterator, ...new StringIterator) : void +foo(...new SymbolIterator, ...new _StringIterator); +>foo(...new SymbolIterator, ...new _StringIterator) : void >foo : (...s: (string | symbol)[]) => void >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt index 2c89c7bb493cc..9a25e387be8e3 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt @@ -16,7 +16,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(28,28): error TS2345 } } - class StringIterator { + class _StringIterator { next() { return { value: "", @@ -29,6 +29,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(28,28): error TS2345 } } - foo(...new SymbolIterator, ...new StringIterator); - ~~~~~~~~~~~~~~~~~~~~~ + foo(...new SymbolIterator, ...new _StringIterator); + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall6.js b/tests/baselines/reference/iteratorSpreadInCall6.js index 161f420ce0ec3..cf24c0cddfe6b 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.js +++ b/tests/baselines/reference/iteratorSpreadInCall6.js @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,7 +26,7 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); //// [iteratorSpreadInCall6.js] function foo(...s) { } @@ -41,7 +41,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -52,4 +52,4 @@ class StringIterator { return this; } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall6.symbols b/tests/baselines/reference/iteratorSpreadInCall6.symbols index 7eff762853480..b6c02dc570eb5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall6.symbols @@ -31,11 +31,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall6.ts, 14, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall6.ts, 14, 23)) return { value: "", @@ -48,18 +48,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall6.ts, 20, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall6.ts, 20, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); >foo : Symbol(foo, Decl(iteratorSpreadInCall6.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall6.ts, 0, 43)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall6.ts, 12, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall6.types b/tests/baselines/reference/iteratorSpreadInCall6.types index 6a040d25e6d15..619946030574c 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.types +++ b/tests/baselines/reference/iteratorSpreadInCall6.types @@ -35,8 +35,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -66,13 +66,13 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); ->foo(...new SymbolIterator, ...new StringIterator) : void +foo(...new SymbolIterator, ...new _StringIterator); +>foo(...new SymbolIterator, ...new _StringIterator) : void >foo : (...s: (number | symbol)[]) => void >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt index 5494d1e7070c6..2cb302849ccd6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt @@ -16,7 +16,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,28): error TS2345 } } - class StringIterator { + class _StringIterator { next() { return { value: "", @@ -29,6 +29,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,28): error TS2345 } } - foo(...new SymbolIterator, ...new StringIterator); - ~~~~~~~~~~~~~~~~~~~~~ + foo(...new SymbolIterator, ...new _StringIterator); + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall7.js b/tests/baselines/reference/iteratorSpreadInCall7.js index e7c354413dfcc..81fceda02a593 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.js +++ b/tests/baselines/reference/iteratorSpreadInCall7.js @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,7 +26,7 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); //// [iteratorSpreadInCall7.js] function foo(...s) { return s[0]; } @@ -41,7 +41,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -52,4 +52,4 @@ class StringIterator { return this; } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall7.symbols b/tests/baselines/reference/iteratorSpreadInCall7.symbols index 98c93f98b6485..2c8e523dc4aea 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall7.symbols @@ -34,11 +34,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall7.ts, 14, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall7.ts, 14, 23)) return { value: "", @@ -51,18 +51,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall7.ts, 20, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall7.ts, 20, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) } } -foo(...new SymbolIterator, ...new StringIterator); +foo(...new SymbolIterator, ...new _StringIterator); >foo : Symbol(foo, Decl(iteratorSpreadInCall7.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall7.ts, 0, 43)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall7.ts, 12, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall7.types b/tests/baselines/reference/iteratorSpreadInCall7.types index 2f6f0ff06dbc8..d8f820ca804ad 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.types +++ b/tests/baselines/reference/iteratorSpreadInCall7.types @@ -38,8 +38,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -69,13 +69,13 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); ->foo(...new SymbolIterator, ...new StringIterator) : any +foo(...new SymbolIterator, ...new _StringIterator); +>foo(...new SymbolIterator, ...new _StringIterator) : any >foo : (...s: T[]) => T >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt index 73dc6d5185ebc..03a67c4e0e158 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,32): error TS2345 } } - class StringIterator { + class _StringIterator { next() { return { value: "", @@ -32,6 +32,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,32): error TS2345 } } - new Foo(...new SymbolIterator, ...new StringIterator); - ~~~~~~~~~~~~~~~~~~~~~ + new Foo(...new SymbolIterator, ...new _StringIterator); + ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall8.js b/tests/baselines/reference/iteratorSpreadInCall8.js index a591fd363ab0d..7eb5cca25d21d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.js +++ b/tests/baselines/reference/iteratorSpreadInCall8.js @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,7 +29,7 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...new StringIterator); +new Foo(...new SymbolIterator, ...new _StringIterator); //// [iteratorSpreadInCall8.js] class Foo { @@ -46,7 +46,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -57,4 +57,4 @@ class StringIterator { return this; } } -new Foo(...new SymbolIterator, ...new StringIterator); +new Foo(...new SymbolIterator, ...new _StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall8.symbols b/tests/baselines/reference/iteratorSpreadInCall8.symbols index 7c547419d1730..51b7542c22baf 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall8.symbols @@ -36,11 +36,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall8.ts, 17, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall8.ts, 17, 23)) return { value: "", @@ -53,18 +53,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall8.ts, 23, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall8.ts, 23, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) } } -new Foo(...new SymbolIterator, ...new StringIterator); +new Foo(...new SymbolIterator, ...new _StringIterator); >Foo : Symbol(Foo, Decl(iteratorSpreadInCall8.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall8.ts, 2, 1)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall8.ts, 15, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall8.types b/tests/baselines/reference/iteratorSpreadInCall8.types index 58f3ea70809ee..c124a5e8dd7d8 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.types +++ b/tests/baselines/reference/iteratorSpreadInCall8.types @@ -38,8 +38,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -69,13 +69,13 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...new StringIterator); ->new Foo(...new SymbolIterator, ...new StringIterator) : any +new Foo(...new SymbolIterator, ...new _StringIterator); +>new Foo(...new SymbolIterator, ...new _StringIterator) : any >Foo : typeof Foo >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt index 773eb2a9fc84f..42fd65c1ce795 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,32): error TS2345 } } - class StringIterator { + class _StringIterator { next() { return { value: "", @@ -32,7 +32,7 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,32): error TS2345 } } - new Foo(...new SymbolIterator, ...[...new StringIterator]); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ + new Foo(...new SymbolIterator, ...[...new _StringIterator]); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall9.js b/tests/baselines/reference/iteratorSpreadInCall9.js index 3f54728fd8898..a29f1ec76d243 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.js +++ b/tests/baselines/reference/iteratorSpreadInCall9.js @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,7 +29,7 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...[...new StringIterator]); +new Foo(...new SymbolIterator, ...[...new _StringIterator]); //// [iteratorSpreadInCall9.js] @@ -47,7 +47,7 @@ class SymbolIterator { return this; } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -58,4 +58,4 @@ class StringIterator { return this; } } -new Foo(...new SymbolIterator, ...[...new StringIterator]); +new Foo(...new SymbolIterator, ...[...new _StringIterator]); diff --git a/tests/baselines/reference/iteratorSpreadInCall9.symbols b/tests/baselines/reference/iteratorSpreadInCall9.symbols index 5db65829f1380..79e6515e09578 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall9.symbols @@ -36,11 +36,11 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) +class _StringIterator { +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall9.ts, 17, 22)) +>next : Symbol(_StringIterator.next, Decl(iteratorSpreadInCall9.ts, 17, 23)) return { value: "", @@ -53,18 +53,18 @@ class StringIterator { } [Symbol.iterator]() { ->[Symbol.iterator] : Symbol(StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall9.ts, 23, 5)) +>[Symbol.iterator] : Symbol(_StringIterator[Symbol.iterator], Decl(iteratorSpreadInCall9.ts, 23, 5)) >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) +>this : Symbol(_StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) } } -new Foo(...new SymbolIterator, ...[...new StringIterator]); +new Foo(...new SymbolIterator, ...[...new _StringIterator]); >Foo : Symbol(Foo, Decl(iteratorSpreadInCall9.ts, 0, 0)) >SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall9.ts, 2, 1)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) +>_StringIterator : Symbol(_StringIterator, Decl(iteratorSpreadInCall9.ts, 15, 1)) diff --git a/tests/baselines/reference/iteratorSpreadInCall9.types b/tests/baselines/reference/iteratorSpreadInCall9.types index 1118a394bc4e8..2cc33ea3fddb5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.types +++ b/tests/baselines/reference/iteratorSpreadInCall9.types @@ -38,8 +38,8 @@ class SymbolIterator { } } -class StringIterator { ->StringIterator : StringIterator +class _StringIterator { +>_StringIterator : _StringIterator next() { >next : () => { value: string; done: boolean; } @@ -69,15 +69,15 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...[...new StringIterator]); ->new Foo(...new SymbolIterator, ...[...new StringIterator]) : any +new Foo(...new SymbolIterator, ...[...new _StringIterator]); +>new Foo(...new SymbolIterator, ...[...new _StringIterator]) : any >Foo : typeof Foo >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator ->...[...new StringIterator] : string ->[...new StringIterator] : string[] ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator +>...[...new _StringIterator] : string +>[...new _StringIterator] : string[] +>...new _StringIterator : string +>new _StringIterator : _StringIterator +>_StringIterator : typeof _StringIterator diff --git a/tests/baselines/reference/labeledStatementWithLabel.types b/tests/baselines/reference/labeledStatementWithLabel.types index 52ca74ddf1973..e5633ab12f356 100644 --- a/tests/baselines/reference/labeledStatementWithLabel.types +++ b/tests/baselines/reference/labeledStatementWithLabel.types @@ -5,7 +5,7 @@ label: function fn() { } label: function* gen() { } >label : any ->gen : () => IterableIterator +>gen : () => Generator label: async function gen1() { } >label : any diff --git a/tests/baselines/reference/labeledStatementWithLabel_es2015.types b/tests/baselines/reference/labeledStatementWithLabel_es2015.types index 570c3c4ad6d03..016ab09107cfb 100644 --- a/tests/baselines/reference/labeledStatementWithLabel_es2015.types +++ b/tests/baselines/reference/labeledStatementWithLabel_es2015.types @@ -5,7 +5,7 @@ label: function fn() { } label: function* gen() { } >label : any ->gen : () => IterableIterator +>gen : () => Generator label: async function gen1() { } >label : any diff --git a/tests/baselines/reference/labeledStatementWithLabel_strict.types b/tests/baselines/reference/labeledStatementWithLabel_strict.types index 9a8a4ef205cee..052a8fbe022c6 100644 --- a/tests/baselines/reference/labeledStatementWithLabel_strict.types +++ b/tests/baselines/reference/labeledStatementWithLabel_strict.types @@ -8,7 +8,7 @@ label: function fn() { } label: function* gen() { } >label : any ->gen : () => IterableIterator +>gen : () => Generator label: async function gen1() { } >label : any diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index c32e65901568e..1a357462e02ad 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -35,10 +35,10 @@ m.clear(); // Using ES6 iterable m.keys(); ->m.keys() : IterableIterator ->m.keys : () => IterableIterator +>m.keys() : MapIterator +>m.keys : () => MapIterator >m : Map ->keys : () => IterableIterator +>keys : () => MapIterator // Using ES6 function function Baz() { } @@ -51,7 +51,7 @@ Baz.name; // Using ES6 generator function* gen() { ->gen : () => IterableIterator +>gen : () => Generator let i = 0; >i : number @@ -73,7 +73,7 @@ function* gen() { } function* gen2() { ->gen2 : () => IterableIterator +>gen2 : () => Generator let i = 0; >i : number diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index a8dd60b1f8c51..4774d905c7b4a 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -35,10 +35,10 @@ m.clear(); // Using ES6 iterable m.keys(); ->m.keys() : IterableIterator ->m.keys : () => IterableIterator +>m.keys() : MapIterator +>m.keys : () => MapIterator >m : Map ->keys : () => IterableIterator +>keys : () => MapIterator // Using ES6 function function Baz() { } @@ -51,7 +51,7 @@ Baz.name; // Using ES6 generator function* gen() { ->gen : () => IterableIterator +>gen : () => Generator let i = 0; >i : number @@ -73,7 +73,7 @@ function* gen() { } function* gen2() { ->gen2 : () => IterableIterator +>gen2 : () => Generator let i = 0; >i : number diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 222c5ab0c11af..a1ce41ab551aa 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -35,10 +35,10 @@ m.clear(); // Using ES6 iterable m.keys(); ->m.keys() : IterableIterator ->m.keys : () => IterableIterator +>m.keys() : MapIterator +>m.keys : () => MapIterator >m : Map ->keys : () => IterableIterator +>keys : () => MapIterator // Using ES6 function function Baz() { } @@ -51,7 +51,7 @@ Baz.name; // Using ES6 generator function* gen() { ->gen : () => IterableIterator +>gen : () => Generator let i = 0; >i : number @@ -73,7 +73,7 @@ function* gen() { } function* gen2() { ->gen2 : () => IterableIterator +>gen2 : () => Generator let i = 0; >i : number diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types index f4eaba5875235..f0f2dd1bbef14 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types @@ -35,10 +35,10 @@ m.clear(); // Using ES6 iterable m.keys(); ->m.keys() : IterableIterator ->m.keys : () => IterableIterator +>m.keys() : MapIterator +>m.keys : () => MapIterator >m : Map ->keys : () => IterableIterator +>keys : () => MapIterator // Using ES6 function function Baz() { } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types index e921320363739..f18184101cff9 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types @@ -23,7 +23,7 @@ Reflect.ownKeys({}); >{} : {} function* idGen() { ->idGen : () => IterableIterator +>idGen : () => Generator let i = 10; >i : number diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types index 9252c2a22c19f..a897194d4ba4e 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.es2018.types @@ -3,7 +3,7 @@ class C1 { >C1 : C1 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMethodNameIsOk.ts === @@ -11,7 +11,7 @@ class C2 { >C2 : C2 async * await() { ->await : () => AsyncIterableIterator +>await : () => AsyncGenerator } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldMethodNameIsOk.ts === @@ -19,7 +19,7 @@ class C3 { >C3 : C3 async * yield() { ->yield : () => AsyncIterableIterator +>yield : () => AsyncGenerator } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === @@ -45,7 +45,7 @@ class C6 { >C6 : C6 async * f(a = await 1) { ->f : (a?: number) => AsyncIterableIterator +>f : (a?: number) => AsyncGenerator >a : number >await 1 : 1 >1 : 1 @@ -56,7 +56,7 @@ class C7 { >C7 : C7 async * f(a = yield) { ->f : (a?: any) => AsyncIterableIterator +>f : (a?: any) => AsyncGenerator >a : any >yield : any } @@ -66,10 +66,10 @@ class C8 { >C8 : C8 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator async function * g() { ->g : () => AsyncIterableIterator +>g : () => AsyncGenerator } } } @@ -78,7 +78,7 @@ class C9 { >C9 : C9 async * f() { ->f : () => AsyncIterableIterator<() => void> +>f : () => AsyncGenerator<() => void, void, unknown> function yield() { > : () => any @@ -92,7 +92,7 @@ class C10 { >C10 : C10 async * f() { ->f : () => AsyncIterableIterator<() => void> +>f : () => AsyncGenerator<() => void, void, unknown> const x = function yield() { >x : () => any @@ -108,7 +108,7 @@ class C11 { >C11 : C11 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator function await() { > : () => any @@ -123,7 +123,7 @@ class C12 { >C12 : C12 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = function await() { >x : () => any @@ -140,7 +140,7 @@ class C13 { >C13 : C13 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield; >yield : any @@ -151,7 +151,7 @@ class C14 { >C14 : C14 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield 1; >yield 1 : any @@ -163,7 +163,7 @@ class C15 { >C15 : C15 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield *; >yield * : any @@ -175,10 +175,10 @@ class C16 { >C16 : C16 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield * []; ->yield * [] : any +>yield * [] : void >[] : undefined[] } } @@ -187,7 +187,7 @@ class C17 { >C17 : C17 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator await 1; >await 1 : 1 @@ -199,7 +199,7 @@ class C18 { >C18 : C18 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator await; >await : any @@ -212,7 +212,7 @@ class C19 { >C19 : C19 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator let x: await; >x : await @@ -224,7 +224,7 @@ class C20 { >C20 : C20 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator let x: yield; >x : yield @@ -235,7 +235,7 @@ class C21 { >C21 : C21 async * [yield]() { ->[yield] : () => AsyncIterableIterator +>[yield] : () => AsyncGenerator >yield : any } } @@ -244,7 +244,7 @@ class C22 { >C22 : C22 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = { [yield]: 1 }; >x : { [x: number]: number; } diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types index 8804529efd287..1fd2c6e5219e6 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.es2018.types @@ -1,49 +1,49 @@ === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/functionDeclarationIsOk.ts === async function * f1() { ->f1 : () => AsyncIterableIterator +>f1 : () => AsyncGenerator } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsOk.ts === async function * await() { ->await : () => AsyncIterableIterator +>await : () => AsyncGenerator } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldNameIsOk.ts === async function * yield() { ->yield : () => AsyncIterableIterator +>yield : () => AsyncGenerator } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === async function * f4(await) { >f4 : () => any ->await : () => AsyncIterableIterator +>await : () => AsyncGenerator } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldParameterIsError.ts === async function * f5(yield) { >f5 : () => any ->yield : () => AsyncIterableIterator +>yield : () => AsyncGenerator } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === async function * f6(a = await 1) { ->f6 : (a?: number) => AsyncIterableIterator +>f6 : (a?: number) => AsyncGenerator >a : number >await 1 : 1 >1 : 1 } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts === async function * f7(a = yield) { ->f7 : (a?: any) => AsyncIterableIterator +>f7 : (a?: any) => AsyncGenerator >a : any >yield : any } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedAsyncGeneratorIsOk.ts === async function * f8() { ->f8 : () => AsyncIterableIterator +>f8 : () => AsyncGenerator async function * g() { ->g : () => AsyncIterableIterator +>g : () => AsyncGenerator } } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === async function * f9() { ->f9 : () => AsyncIterableIterator<() => void> +>f9 : () => AsyncGenerator<() => void, void, unknown> function yield() { > : () => any @@ -53,7 +53,7 @@ async function * f9() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === async function * f10() { ->f10 : () => AsyncIterableIterator<() => void> +>f10 : () => AsyncGenerator<() => void, void, unknown> const x = function yield() { >x : () => any @@ -65,7 +65,7 @@ async function * f10() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts === async function * f11() { ->f11 : () => AsyncIterableIterator +>f11 : () => AsyncGenerator function await() { > : () => any @@ -76,7 +76,7 @@ async function * f11() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === async function * f12() { ->f12 : () => AsyncIterableIterator<() => void> +>f12 : () => AsyncGenerator<() => void, void, unknown> const x = function yield() { >x : () => any @@ -88,14 +88,14 @@ async function * f12() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldIsOk.ts === async function * f13() { ->f13 : () => AsyncIterableIterator +>f13 : () => AsyncGenerator yield; >yield : any } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldWithValueIsOk.ts === async function * f14() { ->f14 : () => AsyncIterableIterator +>f14 : () => AsyncGenerator yield 1; >yield 1 : any @@ -103,7 +103,7 @@ async function * f14() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts === async function * f15() { ->f15 : () => AsyncIterableIterator +>f15 : () => AsyncGenerator yield *; >yield * : any @@ -111,15 +111,15 @@ async function * f15() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarWithValueIsOk.ts === async function * f16() { ->f16 : () => AsyncIterableIterator +>f16 : () => AsyncGenerator yield * []; ->yield * [] : any +>yield * [] : void >[] : undefined[] } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitWithValueIsOk.ts === async function * f17() { ->f17 : () => AsyncIterableIterator +>f17 : () => AsyncGenerator await 1; >await 1 : 1 @@ -127,7 +127,7 @@ async function * f17() { } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts === async function * f18() { ->f18 : () => AsyncIterableIterator +>f18 : () => AsyncGenerator await; >await : any @@ -136,7 +136,7 @@ async function * f18() { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitAsTypeIsOk.ts === interface await {} async function * f19() { ->f19 : () => AsyncIterableIterator +>f19 : () => AsyncGenerator let x: await; >x : await @@ -144,14 +144,14 @@ async function * f19() { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldAsTypeIsOk.ts === interface yield {} async function * f20() { ->f20 : () => AsyncIterableIterator +>f20 : () => AsyncGenerator let x: yield; >x : yield } === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts === async function * f21() { ->f21 : () => AsyncIterableIterator +>f21 : () => AsyncGenerator const x = { [yield]: 1 }; >x : { [x: number]: number; } diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types index 277b79a3a3916..0cf99f9c67477 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.es2018.types @@ -1,8 +1,8 @@ === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/functionExpressionIsOk.ts === const f1 = async function * f() { ->f1 : () => AsyncIterableIterator ->async function * f() {} : () => AsyncIterableIterator ->f : () => AsyncIterableIterator +>f1 : () => AsyncGenerator +>async function * f() {} : () => AsyncGenerator +>f : () => AsyncGenerator }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitNameIsError.ts === @@ -37,8 +37,8 @@ const f5 = async function * (yield) { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === const f6 = async function * (a = await 1) { ->f6 : (a?: number) => AsyncIterableIterator ->async function * (a = await 1) {} : (a?: number) => AsyncIterableIterator +>f6 : (a?: number) => AsyncGenerator +>async function * (a = await 1) {} : (a?: number) => AsyncGenerator >a : number >await 1 : 1 >1 : 1 @@ -46,25 +46,25 @@ const f6 = async function * (a = await 1) { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts === const f7 = async function * (a = yield) { ->f7 : (a?: any) => AsyncIterableIterator ->async function * (a = yield) {} : (a?: any) => AsyncIterableIterator +>f7 : (a?: any) => AsyncGenerator +>async function * (a = yield) {} : (a?: any) => AsyncGenerator >a : any >yield : any }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedAsyncGeneratorIsOk.ts === const f8 = async function * () { ->f8 : () => AsyncIterableIterator ->async function * () { async function * g() { }} : () => AsyncIterableIterator +>f8 : () => AsyncGenerator +>async function * () { async function * g() { }} : () => AsyncGenerator async function * g() { ->g : () => AsyncIterableIterator +>g : () => AsyncGenerator } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === const f9 = async function * () { ->f9 : () => AsyncIterableIterator<() => void> ->async function * () { function yield() { }} : () => AsyncIterableIterator<() => void> +>f9 : () => AsyncGenerator<() => void, void, unknown> +>async function * () { function yield() { }} : () => AsyncGenerator<() => void, void, unknown> function yield() { > : () => any @@ -74,8 +74,8 @@ const f9 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === const f10 = async function * () { ->f10 : () => AsyncIterableIterator<() => void> ->async function * () { const x = function yield() { };} : () => AsyncIterableIterator<() => void> +>f10 : () => AsyncGenerator<() => void, void, unknown> +>async function * () { const x = function yield() { };} : () => AsyncGenerator<() => void, void, unknown> const x = function yield() { >x : () => any @@ -87,8 +87,8 @@ const f10 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts === const f11 = async function * () { ->f11 : () => AsyncIterableIterator ->async function * () { function await() { }} : () => AsyncIterableIterator +>f11 : () => AsyncGenerator +>async function * () { function await() { }} : () => AsyncGenerator function await() { > : () => any @@ -99,8 +99,8 @@ const f11 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === const f12 = async function * () { ->f12 : () => AsyncIterableIterator ->async function * () { const x = function await() { };} : () => AsyncIterableIterator +>f12 : () => AsyncGenerator +>async function * () { const x = function await() { };} : () => AsyncGenerator const x = function await() { >x : () => any @@ -113,8 +113,8 @@ const f12 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldIsOk.ts === const f13 = async function * () { ->f13 : () => AsyncIterableIterator ->async function * () { yield;} : () => AsyncIterableIterator +>f13 : () => AsyncGenerator +>async function * () { yield;} : () => AsyncGenerator yield; >yield : any @@ -122,8 +122,8 @@ const f13 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldWithValueIsOk.ts === const f14 = async function * () { ->f14 : () => AsyncIterableIterator ->async function * () { yield 1;} : () => AsyncIterableIterator +>f14 : () => AsyncGenerator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : any @@ -132,8 +132,8 @@ const f14 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts === const f15 = async function * () { ->f15 : () => AsyncIterableIterator ->async function * () { yield *;} : () => AsyncIterableIterator +>f15 : () => AsyncGenerator +>async function * () { yield *;} : () => AsyncGenerator yield *; >yield * : any @@ -142,18 +142,18 @@ const f15 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarWithValueIsOk.ts === const f16 = async function * () { ->f16 : () => AsyncIterableIterator ->async function * () { yield * [];} : () => AsyncIterableIterator +>f16 : () => AsyncGenerator +>async function * () { yield * [];} : () => AsyncGenerator yield * []; ->yield * [] : any +>yield * [] : void >[] : undefined[] }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitWithValueIsOk.ts === const f17 = async function * () { ->f17 : () => AsyncIterableIterator ->async function * () { await 1;} : () => AsyncIterableIterator +>f17 : () => AsyncGenerator +>async function * () { await 1;} : () => AsyncGenerator await 1; >await 1 : 1 @@ -162,8 +162,8 @@ const f17 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts === const f18 = async function * () { ->f18 : () => AsyncIterableIterator ->async function * () { await;} : () => AsyncIterableIterator +>f18 : () => AsyncGenerator +>async function * () { await;} : () => AsyncGenerator await; >await : any @@ -173,8 +173,8 @@ const f18 = async function * () { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitAsTypeIsOk.ts === interface await {} const f19 = async function * () { ->f19 : () => AsyncIterableIterator ->async function * () { let x: await;} : () => AsyncIterableIterator +>f19 : () => AsyncGenerator +>async function * () { let x: await;} : () => AsyncGenerator let x: await; >x : await @@ -183,8 +183,8 @@ const f19 = async function * () { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldAsTypeIsOk.ts === interface yield {} const f20 = async function * () { ->f20 : () => AsyncIterableIterator ->async function * () { let x: yield;} : () => AsyncIterableIterator +>f20 : () => AsyncGenerator +>async function * () { let x: yield;} : () => AsyncGenerator let x: yield; >x : yield @@ -192,8 +192,8 @@ const f20 = async function * () { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts === const f21 = async function *() { ->f21 : () => AsyncIterableIterator ->async function *() { const x = { [yield]: 1 };} : () => AsyncIterableIterator +>f21 : () => AsyncGenerator +>async function *() { const x = { [yield]: 1 };} : () => AsyncGenerator const x = { [yield]: 1 }; >x : { [x: number]: number; } diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types index 655ecb3e6a0d7..3219a194b3f6f 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.es2018.types @@ -1,28 +1,28 @@ === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/methodIsOk.ts === const o1 = { ->o1 : { f(): AsyncIterableIterator; } ->{ async * f() { }} : { f(): AsyncIterableIterator; } +>o1 : { f(): AsyncGenerator; } +>{ async * f() { }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMethodNameIsOk.ts === const o2 = { ->o2 : { await(): AsyncIterableIterator; } ->{ async * await() { }} : { await(): AsyncIterableIterator; } +>o2 : { await(): AsyncGenerator; } +>{ async * await() { }} : { await(): AsyncGenerator; } async * await() { ->await : () => AsyncIterableIterator +>await : () => AsyncGenerator } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldMethodNameIsOk.ts === const o3 = { ->o3 : { yield(): AsyncIterableIterator; } ->{ async * yield() { }} : { yield(): AsyncIterableIterator; } +>o3 : { yield(): AsyncGenerator; } +>{ async * yield() { }} : { yield(): AsyncGenerator; } async * yield() { ->yield : () => AsyncIterableIterator +>yield : () => AsyncGenerator } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitParameterIsError.ts === @@ -47,11 +47,11 @@ const o5 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitInParameterInitializerIsError.ts === const o6 = { ->o6 : { f(a?: number): AsyncIterableIterator; } ->{ async * f(a = await 1) { }} : { f(a?: number): AsyncIterableIterator; } +>o6 : { f(a?: number): AsyncGenerator; } +>{ async * f(a = await 1) { }} : { f(a?: number): AsyncGenerator; } async * f(a = await 1) { ->f : (a?: number) => AsyncIterableIterator +>f : (a?: number) => AsyncGenerator >a : number >await 1 : 1 >1 : 1 @@ -59,35 +59,35 @@ const o6 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInParameterInitializerIsError.ts === const o7 = { ->o7 : { f(a?: any): AsyncIterableIterator; } ->{ async * f(a = yield) { }} : { f(a?: any): AsyncIterableIterator; } +>o7 : { f(a?: any): AsyncGenerator; } +>{ async * f(a = yield) { }} : { f(a?: any): AsyncGenerator; } async * f(a = yield) { ->f : (a?: any) => AsyncIterableIterator +>f : (a?: any) => AsyncGenerator >a : any >yield : any } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedAsyncGeneratorIsOk.ts === const o8 = { ->o8 : { f(): AsyncIterableIterator; } ->{ async * f() { async function * g() { } }} : { f(): AsyncIterableIterator; } +>o8 : { f(): AsyncGenerator; } +>{ async * f() { async function * g() { } }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator async function * g() { ->g : () => AsyncIterableIterator +>g : () => AsyncGenerator } } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedYieldIsError.ts === const o9 = { ->o9 : { f(): AsyncIterableIterator<() => void>; } ->{ async * f() { function yield() { } }} : { f(): AsyncIterableIterator<() => void>; } +>o9 : { f(): AsyncGenerator<() => void, void, unknown>; } +>{ async * f() { function yield() { } }} : { f(): AsyncGenerator<() => void, void, unknown>; } async * f() { ->f : () => AsyncIterableIterator<() => void> +>f : () => AsyncGenerator<() => void, void, unknown> function yield() { > : () => any @@ -98,11 +98,11 @@ const o9 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedYieldIsError.ts === const o10 = { ->o10 : { f(): AsyncIterableIterator<() => void>; } ->{ async * f() { const x = function yield() { }; }} : { f(): AsyncIterableIterator<() => void>; } +>o10 : { f(): AsyncGenerator<() => void, void, unknown>; } +>{ async * f() { const x = function yield() { }; }} : { f(): AsyncGenerator<() => void, void, unknown>; } async * f() { ->f : () => AsyncIterableIterator<() => void> +>f : () => AsyncGenerator<() => void, void, unknown> const x = function yield() { >x : () => any @@ -115,11 +115,11 @@ const o10 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionDeclarationNamedAwaitIsError.ts === const o11 = { ->o11 : { f(): AsyncIterableIterator; } ->{ async * f() { function await() { } }} : { f(): AsyncIterableIterator; } +>o11 : { f(): AsyncGenerator; } +>{ async * f() { function await() { } }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator function await() { > : () => any @@ -131,11 +131,11 @@ const o11 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/nestedFunctionExpressionNamedAwaitIsError.ts === const o12 = { ->o12 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = function await() { }; }} : { f(): AsyncIterableIterator; } +>o12 : { f(): AsyncGenerator; } +>{ async * f() { const x = function await() { }; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = function await() { >x : () => any @@ -149,11 +149,11 @@ const o12 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldIsOk.ts === const o13 = { ->o13 : { f(): AsyncIterableIterator; } ->{ async * f() { yield; }} : { f(): AsyncIterableIterator; } +>o13 : { f(): AsyncGenerator; } +>{ async * f() { yield; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield; >yield : any @@ -161,11 +161,11 @@ const o13 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldWithValueIsOk.ts === const o14 = { ->o14 : { f(): AsyncIterableIterator; } ->{ async * f() { yield 1; }} : { f(): AsyncIterableIterator; } +>o14 : { f(): AsyncGenerator; } +>{ async * f() { yield 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield 1; >yield 1 : any @@ -174,11 +174,11 @@ const o14 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarMissingValueIsError.ts === const o15 = { ->o15 : { f(): AsyncIterableIterator; } ->{ async * f() { yield *; }} : { f(): AsyncIterableIterator; } +>o15 : { f(): AsyncGenerator; } +>{ async * f() { yield *; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield *; >yield * : any @@ -187,24 +187,24 @@ const o15 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldStarWithValueIsOk.ts === const o16 = { ->o16 : { f(): AsyncIterableIterator; } ->{ async * f() { yield * []; }} : { f(): AsyncIterableIterator; } +>o16 : { f(): AsyncGenerator; } +>{ async * f() { yield * []; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator yield * []; ->yield * [] : any +>yield * [] : void >[] : undefined[] } }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitWithValueIsOk.ts === const o17 = { ->o17 : { f(): AsyncIterableIterator; } ->{ async * f() { await 1; }} : { f(): AsyncIterableIterator; } +>o17 : { f(): AsyncGenerator; } +>{ async * f() { await 1; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator await 1; >await 1 : 1 @@ -213,11 +213,11 @@ const o17 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitMissingValueIsError.ts === const o18 = { ->o18 : { f(): AsyncIterableIterator; } ->{ async * f() { await; }} : { f(): AsyncIterableIterator; } +>o18 : { f(): AsyncGenerator; } +>{ async * f() { await; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator await; >await : any @@ -227,11 +227,11 @@ const o18 = { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/awaitAsTypeIsOk.ts === interface await {} const o19 = { ->o19 : { f(): AsyncIterableIterator; } ->{ async * f() { let x: await; }} : { f(): AsyncIterableIterator; } +>o19 : { f(): AsyncGenerator; } +>{ async * f() { let x: await; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator let x: await; >x : await @@ -240,11 +240,11 @@ const o19 = { === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldAsTypeIsOk.ts === interface yield {} const o20 = { ->o20 : { f(): AsyncIterableIterator; } ->{ async * f() { let x: yield; }} : { f(): AsyncIterableIterator; } +>o20 : { f(): AsyncGenerator; } +>{ async * f() { let x: yield; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator let x: yield; >x : yield @@ -252,11 +252,11 @@ const o20 = { }; === tests/cases/conformance/parser/ecmascript2018/asyncGenerators/yieldInNestedComputedPropertyIsOk.ts === const o21 = { ->o21 : { f(): AsyncIterableIterator; } ->{ async * f() { const x = { [yield]: 1 }; }} : { f(): AsyncIterableIterator; } +>o21 : { f(): AsyncGenerator; } +>{ async * f() { const x = { [yield]: 1 }; }} : { f(): AsyncGenerator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncGenerator const x = { [yield]: 1 }; >x : { [x: number]: number; } diff --git a/tests/baselines/reference/parser.forAwait.es2018.types b/tests/baselines/reference/parser.forAwait.es2018.types index 672d063883d2b..ea677dd97390f 100644 --- a/tests/baselines/reference/parser.forAwait.es2018.types +++ b/tests/baselines/reference/parser.forAwait.es2018.types @@ -70,7 +70,7 @@ async function f8() { } === tests/cases/conformance/parser/ecmascript2018/forAwait/inAsyncGeneratorWithDeclIsOk.ts === async function* f9() { ->f9 : () => AsyncIterableIterator +>f9 : () => AsyncGenerator let y: any; >y : any @@ -82,7 +82,7 @@ async function* f9() { } === tests/cases/conformance/parser/ecmascript2018/forAwait/inAsyncGeneratorWithExpressionIsOk.ts === async function* f10() { ->f10 : () => AsyncIterableIterator +>f10 : () => AsyncGenerator let x: any, y: any; >x : any @@ -95,7 +95,7 @@ async function* f10() { } === tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithDeclIsError.ts === function* f11() { ->f11 : () => IterableIterator +>f11 : () => Generator let y: any; >y : any @@ -107,7 +107,7 @@ function* f11() { } === tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithExprIsError.ts === function* f12() { ->f12 : () => IterableIterator +>f12 : () => Generator let x: any, y: any; >x : any diff --git a/tests/baselines/reference/restParameterInDownlevelGenerator.types b/tests/baselines/reference/restParameterInDownlevelGenerator.types index e0b85e1a0ff87..0345af14c239d 100644 --- a/tests/baselines/reference/restParameterInDownlevelGenerator.types +++ b/tests/baselines/reference/restParameterInDownlevelGenerator.types @@ -1,7 +1,7 @@ === tests/cases/conformance/generators/restParameterInDownlevelGenerator.ts === // https://github.com/Microsoft/TypeScript/issues/30653 function * mergeStringLists(...strings: string[]) { ->mergeStringLists : (...strings: string[]) => IterableIterator +>mergeStringLists : (...strings: string[]) => Generator >strings : string[] for (var str of strings); diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/strictGeneratorTypes/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/strictGeneratorTypes/tsconfig.json new file mode 100644 index 0000000000000..91f667ef73951 --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/strictGeneratorTypes/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strictGeneratorTypes": true + } +} diff --git a/tests/baselines/reference/sourceMapValidationVarInDownLevelGenerator.types b/tests/baselines/reference/sourceMapValidationVarInDownLevelGenerator.types index cac2f03d8e437..0323d78394d45 100644 --- a/tests/baselines/reference/sourceMapValidationVarInDownLevelGenerator.types +++ b/tests/baselines/reference/sourceMapValidationVarInDownLevelGenerator.types @@ -1,6 +1,6 @@ === tests/cases/compiler/sourceMapValidationVarInDownLevelGenerator.ts === function * f() { ->f : () => IterableIterator +>f : () => Generator var x = 1, y; >x : number diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt index 393e21edb6c53..1b1f93ffc3f5f 100644 --- a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'IterableIterator'. +error TS2318: Cannot find global type 'Generator'. tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts(6,1): error TS2554: Expected 2 arguments, but got 1. -!!! error TS2318: Cannot find global type 'IterableIterator'. +!!! error TS2318: Cannot find global type 'Generator'. ==== tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts (1 errors) ==== declare function call any>( fn: Fn, diff --git a/tests/baselines/reference/templateStringInYieldKeyword.types b/tests/baselines/reference/templateStringInYieldKeyword.types index 3eff79cf79632..71cce7b74eb1b 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.types +++ b/tests/baselines/reference/templateStringInYieldKeyword.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts === function* gen() { ->gen : () => IterableIterator +>gen : () => Generator // 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/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt index ce0d781d8246c..a96993063732a 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'IterableIterator'. +error TS2318: Cannot find global type 'Generator'. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: '(' expected. -!!! error TS2318: Cannot find global type 'IterableIterator'. +!!! error TS2318: Cannot find global type 'Generator'. ==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (1 errors) ==== function* gen { ~ diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types index dfd4e522def17..a4226bc3f4400 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === function* gen() { ->gen : () => IterableIterator +>gen : () => Generator // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.1.types b/tests/baselines/reference/types.asyncGenerators.es2018.1.types index 0f3b775331345..f7452e8f96085 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.1.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.1.types @@ -1,22 +1,22 @@ === tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.1.ts === async function * inferReturnType1() { ->inferReturnType1 : () => AsyncIterableIterator +>inferReturnType1 : () => AsyncGenerator } async function * inferReturnType2() { ->inferReturnType2 : () => AsyncIterableIterator +>inferReturnType2 : () => AsyncGenerator yield; >yield : any } async function * inferReturnType3() { ->inferReturnType3 : () => AsyncIterableIterator +>inferReturnType3 : () => AsyncGenerator yield 1; >yield 1 : any >1 : 1 } async function * inferReturnType4() { ->inferReturnType4 : () => AsyncIterableIterator +>inferReturnType4 : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : any @@ -27,7 +27,7 @@ async function * inferReturnType4() { >1 : 1 } async function * inferReturnType5() { ->inferReturnType5 : () => AsyncIterableIterator +>inferReturnType5 : () => AsyncGenerator yield 1; >yield 1 : any @@ -42,19 +42,19 @@ async function * inferReturnType5() { >2 : 2 } async function * inferReturnType6() { ->inferReturnType6 : () => AsyncIterableIterator +>inferReturnType6 : () => AsyncGenerator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 } async function * inferReturnType7() { ->inferReturnType7 : () => AsyncIterableIterator +>inferReturnType7 : () => AsyncGenerator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -63,19 +63,19 @@ async function * inferReturnType7() { >1 : 1 } async function * inferReturnType8() { ->inferReturnType8 : () => AsyncIterableIterator +>inferReturnType8 : () => AsyncGenerator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator ->async function * () { yield 1;} : () => AsyncIterableIterator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : any @@ -84,7 +84,7 @@ const assignability1: () => AsyncIterableIterator = async function * () }; const assignability2: () => AsyncIterableIterator = async function * () { >assignability2 : () => AsyncIterableIterator ->async function * () { yield Promise.resolve(1);} : () => AsyncIterableIterator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : any @@ -97,10 +97,10 @@ const assignability2: () => AsyncIterableIterator = async function * () }; const assignability3: () => AsyncIterableIterator = async function * () { >assignability3 : () => AsyncIterableIterator ->async function * () { yield* [1, 2];} : () => AsyncIterableIterator +>async function * () { yield* [1, 2];} : () => AsyncGenerator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -108,10 +108,10 @@ const assignability3: () => AsyncIterableIterator = async function * () }; const assignability4: () => AsyncIterableIterator = async function * () { >assignability4 : () => AsyncIterableIterator ->async function * () { yield* [Promise.resolve(1)];} : () => AsyncIterableIterator +>async function * () { yield* [Promise.resolve(1)];} : () => AsyncGenerator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -122,20 +122,20 @@ const assignability4: () => AsyncIterableIterator = async function * () }; const assignability5: () => AsyncIterableIterator = async function * () { >assignability5 : () => AsyncIterableIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncGenerator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 }; const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable ->async function * () { yield 1;} : () => AsyncIterableIterator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : any @@ -144,7 +144,7 @@ const assignability6: () => AsyncIterable = async function * () { }; const assignability7: () => AsyncIterable = async function * () { >assignability7 : () => AsyncIterable ->async function * () { yield Promise.resolve(1);} : () => AsyncIterableIterator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : any @@ -157,10 +157,10 @@ const assignability7: () => AsyncIterable = async function * () { }; const assignability8: () => AsyncIterable = async function * () { >assignability8 : () => AsyncIterable ->async function * () { yield* [1, 2];} : () => AsyncIterableIterator +>async function * () { yield* [1, 2];} : () => AsyncGenerator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -168,10 +168,10 @@ const assignability8: () => AsyncIterable = async function * () { }; const assignability9: () => AsyncIterable = async function * () { >assignability9 : () => AsyncIterable ->async function * () { yield* [Promise.resolve(1)];} : () => AsyncIterableIterator +>async function * () { yield* [Promise.resolve(1)];} : () => AsyncGenerator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -182,20 +182,20 @@ const assignability9: () => AsyncIterable = async function * () { }; const assignability10: () => AsyncIterable = async function * () { >assignability10 : () => AsyncIterable ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncGenerator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 }; const assignability11: () => AsyncIterator = async function * () { >assignability11 : () => AsyncIterator ->async function * () { yield 1;} : () => AsyncIterableIterator +>async function * () { yield 1;} : () => AsyncGenerator yield 1; >yield 1 : any @@ -204,7 +204,7 @@ const assignability11: () => AsyncIterator = async function * () { }; const assignability12: () => AsyncIterator = async function * () { >assignability12 : () => AsyncIterator ->async function * () { yield Promise.resolve(1);} : () => AsyncIterableIterator +>async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); >yield Promise.resolve(1) : any @@ -217,10 +217,10 @@ const assignability12: () => AsyncIterator = async function * () { }; const assignability13: () => AsyncIterator = async function * () { >assignability13 : () => AsyncIterator ->async function * () { yield* [1, 2];} : () => AsyncIterableIterator +>async function * () { yield* [1, 2];} : () => AsyncGenerator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -228,10 +228,10 @@ const assignability13: () => AsyncIterator = async function * () { }; const assignability14: () => AsyncIterator = async function * () { >assignability14 : () => AsyncIterator ->async function * () { yield* [Promise.resolve(1)];} : () => AsyncIterableIterator +>async function * () { yield* [Promise.resolve(1)];} : () => AsyncGenerator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -242,13 +242,13 @@ const assignability14: () => AsyncIterator = async function * () { }; const assignability15: () => AsyncIterator = async function * () { >assignability15 : () => AsyncIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncGenerator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 @@ -275,7 +275,7 @@ async function * explicitReturnType3(): AsyncIterableIterator { >explicitReturnType3 : () => AsyncIterableIterator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -284,7 +284,7 @@ async function * explicitReturnType4(): AsyncIterableIterator { >explicitReturnType4 : () => AsyncIterableIterator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -296,10 +296,10 @@ async function * explicitReturnType5(): AsyncIterableIterator { >explicitReturnType5 : () => AsyncIterableIterator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -325,7 +325,7 @@ async function * explicitReturnType8(): AsyncIterable { >explicitReturnType8 : () => AsyncIterable yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -334,7 +334,7 @@ async function * explicitReturnType9(): AsyncIterable { >explicitReturnType9 : () => AsyncIterable yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -346,10 +346,10 @@ async function * explicitReturnType10(): AsyncIterable { >explicitReturnType10 : () => AsyncIterable yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -375,7 +375,7 @@ async function * explicitReturnType13(): AsyncIterator { >explicitReturnType13 : () => AsyncIterator yield* [1, 2]; ->yield* [1, 2] : any +>yield* [1, 2] : void >[1, 2] : number[] >1 : 1 >2 : 2 @@ -384,7 +384,7 @@ async function * explicitReturnType14(): AsyncIterator { >explicitReturnType14 : () => AsyncIterator yield* [Promise.resolve(1)]; ->yield* [Promise.resolve(1)] : any +>yield* [Promise.resolve(1)] : void >[Promise.resolve(1)] : Promise[] >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } @@ -396,10 +396,10 @@ async function * explicitReturnType15(): AsyncIterator { >explicitReturnType15 : () => AsyncIterator yield* (async function * () { yield 1; })(); ->yield* (async function * () { yield 1; })() : any ->(async function * () { yield 1; })() : AsyncIterableIterator ->(async function * () { yield 1; }) : () => AsyncIterableIterator ->async function * () { yield 1; } : () => AsyncIterableIterator +>yield* (async function * () { yield 1; })() : void +>(async function * () { yield 1; })() : AsyncGenerator +>(async function * () { yield 1; }) : () => AsyncGenerator +>async function * () { yield 1; } : () => AsyncGenerator >yield 1 : any >1 : 1 } @@ -411,7 +411,7 @@ async function * explicitReturnType16(): {} { >1 : 1 } async function * awaitedType1() { ->awaitedType1 : () => AsyncIterableIterator +>awaitedType1 : () => AsyncGenerator const x = await 1; >x : 1 @@ -419,7 +419,7 @@ async function * awaitedType1() { >1 : 1 } async function * awaitedType2() { ->awaitedType2 : () => AsyncIterableIterator +>awaitedType2 : () => AsyncGenerator const x = await Promise.resolve(1); >x : number diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt index 471cf39bed29c..322f913336a5c 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.errors.txt @@ -1,32 +1,36 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(2,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(8,12): error TS2504: Type 'Promise' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(10,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. + Types of property 'next' are incompatible. + Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => Promise>'. + Type 'Promise>' is not assignable to type 'Promise>'. + Type 'IteratorResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. + Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(13,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(16,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(19,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. Types of property '[Symbol.asyncIterator]' are incompatible. - Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. + Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. Types of property 'next' are incompatible. - Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. - Type 'Promise>' is not assignable to type 'Promise>'. - Type 'IteratorResult' is not assignable to type 'IteratorResult'. - Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(31,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. + Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => Promise>'. + Type 'Promise>' is not assignable to type 'Promise>'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(22,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(25,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(28,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(31,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(34,7): error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(38,11): error TS2322: Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(41,12): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(44,12): error TS2322: Type 'string' is not assignable to type 'number'. @@ -36,12 +40,13 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(56,11): error TS2322: Type '"a"' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(59,12): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(62,12): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(64,42): error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator' but required in type 'IterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(67,42): error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator' but required in type 'Iterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(70,42): error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'Iterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(64,42): error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncGenerator' but required in type 'IterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(67,42): error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncGenerator' but required in type 'Iterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(70,42): error TS2322: Type 'AsyncGenerator' is not assignable to type 'Iterator'. Types of property 'next' are incompatible. - Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => IteratorResult'. - Type 'Promise>' is missing the following properties from type 'IteratorResult': done, value + Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => IteratorResult'. + Type 'Promise>' is not assignable to type 'IteratorResult'. + Type 'Promise>' is missing the following properties from type 'IteratorReturnResult': done, value tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts(74,12): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. @@ -61,65 +66,69 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( } const assignability1: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => Promise>'. +!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. +!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'IteratorYieldResult' is not assignable to type 'IteratorYieldResult'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. yield "a"; }; const assignability2: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. yield* ["a", "b"]; }; const assignability3: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterableIterator'. yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. !!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. -!!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => Promise>'. +!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. yield "a"; }; const assignability5: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. yield* ["a", "b"]; }; const assignability6: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterable'. yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. yield "a"; }; const assignability8: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. yield* ["a", "b"]; }; const assignability9: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncGenerator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'AsyncIterator'. yield* (async function * () { yield "a"; })(); }; async function * explicitReturnType1(): AsyncIterableIterator { @@ -169,22 +178,23 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts( } async function * explicitReturnType10(): IterableIterator { ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator' but required in type 'IterableIterator'. -!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:47:5: '[Symbol.iterator]' is declared here. +!!! error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncGenerator' but required in type 'IterableIterator'. +!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:54:5: '[Symbol.iterator]' is declared here. yield 1; } async function * explicitReturnType11(): Iterable { ~~~~~~~~~~~~~~~~ -!!! error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator' but required in type 'Iterable'. -!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:43:5: '[Symbol.iterator]' is declared here. +!!! error TS2741: Property '[Symbol.iterator]' is missing in type 'AsyncGenerator' but required in type 'Iterable'. +!!! related TS2728 /.ts/lib.es2015.iterable.d.ts:50:5: '[Symbol.iterator]' is declared here. yield 1; } async function * explicitReturnType12(): Iterator { ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Type 'AsyncGenerator' is not assignable to type 'Iterator'. !!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Type 'Promise>' is missing the following properties from type 'IteratorResult': done, value +!!! error TS2322: Type '(value?: unknown) => Promise>' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type 'Promise>' is not assignable to type 'IteratorResult'. +!!! error TS2322: Type 'Promise>' is missing the following properties from type 'IteratorReturnResult': done, value yield 1; } async function * yieldStar() { diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.types b/tests/baselines/reference/types.asyncGenerators.es2018.2.types index 6bcc95297a986..c0fbee1a25080 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.es2018.2.ts === async function * inferReturnType1() { ->inferReturnType1 : () => AsyncIterableIterator +>inferReturnType1 : () => AsyncGenerator yield* {}; >yield* {} : any @@ -15,7 +15,7 @@ async function * inferReturnType2() { >inferReturnType2 : () => any } async function * inferReturnType3() { ->inferReturnType3 : () => AsyncIterableIterator +>inferReturnType3 : () => AsyncGenerator yield* Promise.resolve([1, 2]); >yield* Promise.resolve([1, 2]) : any @@ -29,7 +29,7 @@ async function * inferReturnType3() { } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator ->async function * () { yield "a";} : () => AsyncIterableIterator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : any @@ -38,10 +38,10 @@ const assignability1: () => AsyncIterableIterator = async function * () }; const assignability2: () => AsyncIterableIterator = async function * () { >assignability2 : () => AsyncIterableIterator ->async function * () { yield* ["a", "b"];} : () => AsyncIterableIterator +>async function * () { yield* ["a", "b"];} : () => AsyncGenerator yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -49,20 +49,20 @@ const assignability2: () => AsyncIterableIterator = async function * () }; const assignability3: () => AsyncIterableIterator = async function * () { >assignability3 : () => AsyncIterableIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncGenerator yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" }; const assignability4: () => AsyncIterable = async function * () { >assignability4 : () => AsyncIterable ->async function * () { yield "a";} : () => AsyncIterableIterator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : any @@ -71,10 +71,10 @@ const assignability4: () => AsyncIterable = async function * () { }; const assignability5: () => AsyncIterable = async function * () { >assignability5 : () => AsyncIterable ->async function * () { yield* ["a", "b"];} : () => AsyncIterableIterator +>async function * () { yield* ["a", "b"];} : () => AsyncGenerator yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -82,20 +82,20 @@ const assignability5: () => AsyncIterable = async function * () { }; const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncGenerator yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" }; const assignability7: () => AsyncIterator = async function * () { >assignability7 : () => AsyncIterator ->async function * () { yield "a";} : () => AsyncIterableIterator +>async function * () { yield "a";} : () => AsyncGenerator yield "a"; >yield "a" : any @@ -104,10 +104,10 @@ const assignability7: () => AsyncIterator = async function * () { }; const assignability8: () => AsyncIterator = async function * () { >assignability8 : () => AsyncIterator ->async function * () { yield* ["a", "b"];} : () => AsyncIterableIterator +>async function * () { yield* ["a", "b"];} : () => AsyncGenerator yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -115,13 +115,13 @@ const assignability8: () => AsyncIterator = async function * () { }; const assignability9: () => AsyncIterator = async function * () { >assignability9 : () => AsyncIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncGenerator yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" @@ -137,7 +137,7 @@ async function * explicitReturnType2(): AsyncIterableIterator { >explicitReturnType2 : () => AsyncIterableIterator yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -146,10 +146,10 @@ async function * explicitReturnType3(): AsyncIterableIterator { >explicitReturnType3 : () => AsyncIterableIterator yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" } @@ -164,7 +164,7 @@ async function * explicitReturnType5(): AsyncIterable { >explicitReturnType5 : () => AsyncIterable yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -173,10 +173,10 @@ async function * explicitReturnType6(): AsyncIterable { >explicitReturnType6 : () => AsyncIterable yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" } @@ -191,7 +191,7 @@ async function * explicitReturnType8(): AsyncIterator { >explicitReturnType8 : () => AsyncIterator yield* ["a", "b"]; ->yield* ["a", "b"] : any +>yield* ["a", "b"] : void >["a", "b"] : string[] >"a" : "a" >"b" : "b" @@ -200,10 +200,10 @@ async function * explicitReturnType9(): AsyncIterator { >explicitReturnType9 : () => AsyncIterator yield* (async function * () { yield "a"; })(); ->yield* (async function * () { yield "a"; })() : any ->(async function * () { yield "a"; })() : AsyncIterableIterator ->(async function * () { yield "a"; }) : () => AsyncIterableIterator ->async function * () { yield "a"; } : () => AsyncIterableIterator +>yield* (async function * () { yield "a"; })() : void +>(async function * () { yield "a"; })() : AsyncGenerator +>(async function * () { yield "a"; }) : () => AsyncGenerator +>async function * () { yield "a"; } : () => AsyncGenerator >yield "a" : any >"a" : "a" } @@ -229,7 +229,7 @@ async function * explicitReturnType12(): Iterator { >1 : 1 } async function * yieldStar() { ->yieldStar : () => AsyncIterableIterator +>yieldStar : () => AsyncGenerator yield* {}; >yield* {} : any diff --git a/tests/baselines/reference/types.forAwait.es2018.1.types b/tests/baselines/reference/types.forAwait.es2018.1.types index aa1035b87cb67..a606238658c14 100644 --- a/tests/baselines/reference/types.forAwait.es2018.1.types +++ b/tests/baselines/reference/types.forAwait.es2018.1.types @@ -40,7 +40,7 @@ async function f1() { } } async function * f2() { ->f2 : () => AsyncIterableIterator +>f2 : () => AsyncGenerator let y: number; >y : number diff --git a/tests/baselines/reference/types.forAwait.es2018.3.errors.txt b/tests/baselines/reference/types.forAwait.es2018.3.errors.txt index 296ac0d066bc1..1aca869fb0c68 100644 --- a/tests/baselines/reference/types.forAwait.es2018.3.errors.txt +++ b/tests/baselines/reference/types.forAwait.es2018.3.errors.txt @@ -1,11 +1,11 @@ -error TS2318: Cannot find global type 'AsyncIterableIterator'. +error TS2318: Cannot find global type 'AsyncGenerator'. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(3,27): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(5,21): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(10,27): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(12,21): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. -!!! error TS2318: Cannot find global type 'AsyncIterableIterator'. +!!! error TS2318: Cannot find global type 'AsyncGenerator'. ==== tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts (4 errors) ==== async function f1() { let y: number; diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index 9ee3be1cb285d..f81adb95ff9a0 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -113,17 +113,17 @@ function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall // generator function yield inference function* genFuncYieldConstCall() { yield constCall; } ->genFuncYieldConstCall : () => IterableIterator +>genFuncYieldConstCall : () => Generator >yield constCall : any >constCall : unique symbol function* genFuncYieldLetCall() { yield letCall; } ->genFuncYieldLetCall : () => IterableIterator +>genFuncYieldLetCall : () => Generator >yield letCall : any >letCall : symbol function* genFuncYieldVarCall() { yield varCall; } ->genFuncYieldVarCall : () => IterableIterator +>genFuncYieldVarCall : () => Generator >yield varCall : any >varCall : symbol @@ -149,17 +149,17 @@ async function asyncFuncReturnVarCall() { return varCall; } // async generator function yield inference async function* asyncGenFuncYieldConstCall() { yield constCall; } ->asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>asyncGenFuncYieldConstCall : () => AsyncGenerator >yield constCall : any >constCall : unique symbol async function* asyncGenFuncYieldLetCall() { yield letCall; } ->asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>asyncGenFuncYieldLetCall : () => AsyncGenerator >yield letCall : any >letCall : symbol async function* asyncGenFuncYieldVarCall() { yield varCall; } ->asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>asyncGenFuncYieldVarCall : () => AsyncGenerator >yield varCall : any >varCall : symbol @@ -484,8 +484,8 @@ f(N["s"]); // property assignments/methods const o2 = { ->o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } ->{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; },} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } +>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: symbol): symbol; } +>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; },} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: symbol): symbol; } a: s, >a : symbol @@ -512,12 +512,12 @@ const o2 = { >s : unique symbol async * method3() { yield s; }, ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator >yield s : any >s : unique symbol * method4() { yield s; }, ->method4 : () => IterableIterator +>method4 : () => Generator >yield s : any >s : unique symbol @@ -606,12 +606,12 @@ class C0 { >s : unique symbol async * method3() { yield s; } ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator >yield s : any >s : unique symbol * method4() { yield s; } ->method4 : () => IterableIterator +>method4 : () => Generator >yield s : any >s : unique symbol @@ -819,7 +819,7 @@ interface Context { const o3: Context = { >o3 : Context ->{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: unique symbol): unique symbol; } +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } method1() { >method1 : () => unique symbol @@ -836,7 +836,7 @@ const o3: Context = { }, async * method3() { ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type >yield s : any @@ -844,7 +844,7 @@ const o3: Context = { }, * method4() { ->method4 : () => IterableIterator +>method4 : () => Generator yield s; // yield type should not widen due to contextual type >yield s : any diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.js b/tests/baselines/reference/uniqueSymbolsDeclarations.js index 02a692aa9ff63..15342a0bd97fc 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.js +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.js @@ -430,16 +430,16 @@ declare function funcReturnConstCall(): symbol; declare function funcReturnLetCall(): symbol; declare function funcReturnVarCall(): symbol; declare function funcReturnConstCallWithTypeQuery(): typeof constCall; -declare function genFuncYieldConstCall(): IterableIterator; -declare function genFuncYieldLetCall(): IterableIterator; -declare function genFuncYieldVarCall(): IterableIterator; +declare function genFuncYieldConstCall(): Generator; +declare function genFuncYieldLetCall(): Generator; +declare function genFuncYieldVarCall(): Generator; declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator; declare function asyncFuncReturnConstCall(): Promise; declare function asyncFuncReturnLetCall(): Promise; declare function asyncFuncReturnVarCall(): Promise; -declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; -declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; -declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldConstCall(): AsyncGenerator; +declare function asyncGenFuncYieldLetCall(): AsyncGenerator; +declare function asyncGenFuncYieldVarCall(): AsyncGenerator; declare class C { static readonly readonlyStaticCall: unique symbol; static readonly readonlyStaticType: unique symbol; @@ -502,8 +502,8 @@ declare const o2: { c: symbol; method1(): symbol; method2(): Promise; - method3(): AsyncIterableIterator; - method4(): IterableIterator; + method3(): AsyncGenerator; + method4(): Generator; method5(p?: symbol): symbol; }; declare class C0 { @@ -521,8 +521,8 @@ declare class C0 { f: symbol; method1(): symbol; method2(): Promise; - method3(): AsyncIterableIterator; - method4(): IterableIterator; + method3(): AsyncGenerator; + method4(): Generator; method5(p?: symbol): symbol; } declare class C1 { diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types index a741802e83f78..7df90140bb7ce 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.types +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -106,17 +106,17 @@ function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall // generator function yield inference function* genFuncYieldConstCall() { yield constCall; } ->genFuncYieldConstCall : () => IterableIterator +>genFuncYieldConstCall : () => Generator >yield constCall : any >constCall : unique symbol function* genFuncYieldLetCall() { yield letCall; } ->genFuncYieldLetCall : () => IterableIterator +>genFuncYieldLetCall : () => Generator >yield letCall : any >letCall : symbol function* genFuncYieldVarCall() { yield varCall; } ->genFuncYieldVarCall : () => IterableIterator +>genFuncYieldVarCall : () => Generator >yield varCall : any >varCall : symbol @@ -142,17 +142,17 @@ async function asyncFuncReturnVarCall() { return varCall; } // async generator function yield inference async function* asyncGenFuncYieldConstCall() { yield constCall; } ->asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>asyncGenFuncYieldConstCall : () => AsyncGenerator >yield constCall : any >constCall : unique symbol async function* asyncGenFuncYieldLetCall() { yield letCall; } ->asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>asyncGenFuncYieldLetCall : () => AsyncGenerator >yield letCall : any >letCall : symbol async function* asyncGenFuncYieldVarCall() { yield varCall; } ->asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>asyncGenFuncYieldVarCall : () => AsyncGenerator >yield varCall : any >varCall : symbol @@ -477,8 +477,8 @@ f(N["s"]); // property assignments/methods const o2 = { ->o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } ->{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; }} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: symbol): symbol; } +>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: symbol): symbol; } +>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; }} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: symbol): symbol; } a: s, >a : symbol @@ -505,12 +505,12 @@ const o2 = { >s : unique symbol async * method3() { yield s; }, ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator >yield s : any >s : unique symbol * method4() { yield s; }, ->method4 : () => IterableIterator +>method4 : () => Generator >yield s : any >s : unique symbol @@ -599,12 +599,12 @@ class C0 { >s : unique symbol async * method3() { yield s; } ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator >yield s : any >s : unique symbol * method4() { yield s; } ->method4 : () => IterableIterator +>method4 : () => Generator >yield s : any >s : unique symbol @@ -812,7 +812,7 @@ interface Context { const o4: Context = { >o4 : Context ->{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise; method3(): AsyncIterableIterator; method4(): IterableIterator; method5(p?: unique symbol): unique symbol; } +>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise; method3(): AsyncGenerator; method4(): Generator; method5(p?: unique symbol): unique symbol; } method1() { >method1 : () => unique symbol @@ -829,7 +829,7 @@ const o4: Context = { }, async * method3() { ->method3 : () => AsyncIterableIterator +>method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type >yield s : any @@ -837,7 +837,7 @@ const o4: Context = { }, * method4() { ->method4 : () => IterableIterator +>method4 : () => Generator yield s; // yield type should not widen due to contextual type >yield s : any diff --git a/tests/baselines/reference/vExplicitReturnType.symbols b/tests/baselines/reference/vExplicitReturnType.symbols new file mode 100644 index 0000000000000..d40b813c85e7f --- /dev/null +++ b/tests/baselines/reference/vExplicitReturnType.symbols @@ -0,0 +1,48 @@ +=== tests/cases/conformance/generators/strictGeneratorTypesExplicitReturnType.ts === +function* g1(): Generator { +>g1 : Symbol(g1, Decl(strictGeneratorTypesExplicitReturnType.ts, 0, 0)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + yield; // error + yield "a"; // error + const x: number = yield 1; // error +>x : Symbol(x, Decl(strictGeneratorTypesExplicitReturnType.ts, 3, 9)) + + return 10; // error +} + +function* g2(): Generator { +>g2 : Symbol(g2, Decl(strictGeneratorTypesExplicitReturnType.ts, 5, 1)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x = yield 1; +>x : Symbol(x, Decl(strictGeneratorTypesExplicitReturnType.ts, 8, 9)) + + return true; +} + +declare const generator: Generator; +>generator : Symbol(generator, Decl(strictGeneratorTypesExplicitReturnType.ts, 12, 13)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + +function* g3(): Generator { +>g3 : Symbol(g3, Decl(strictGeneratorTypesExplicitReturnType.ts, 12, 59)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x: number = yield* generator; // error +>x : Symbol(x, Decl(strictGeneratorTypesExplicitReturnType.ts, 15, 9)) +>generator : Symbol(generator, Decl(strictGeneratorTypesExplicitReturnType.ts, 12, 13)) + + return true; +} + +function* g4(): Generator { +>g4 : Symbol(g4, Decl(strictGeneratorTypesExplicitReturnType.ts, 17, 1)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) + + const x = yield* generator; +>x : Symbol(x, Decl(strictGeneratorTypesExplicitReturnType.ts, 20, 9)) +>generator : Symbol(generator, Decl(strictGeneratorTypesExplicitReturnType.ts, 12, 13)) + + return true; +} diff --git a/tests/baselines/reference/yieldExpression1.types b/tests/baselines/reference/yieldExpression1.types index 5f7a1c2f69bdb..d2444176cac51 100644 --- a/tests/baselines/reference/yieldExpression1.types +++ b/tests/baselines/reference/yieldExpression1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/yieldExpression1.ts === function* a() { ->a : () => IterableIterator<0 | undefined> +>a : () => Generator<0 | undefined, void, unknown> yield; >yield : any diff --git a/tests/baselines/reference/yieldExpressionInControlFlow.errors.txt b/tests/baselines/reference/yieldExpressionInControlFlow.errors.txt index b571231172d53..ff920160b9e22 100644 --- a/tests/baselines/reference/yieldExpressionInControlFlow.errors.txt +++ b/tests/baselines/reference/yieldExpressionInControlFlow.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/es6/yieldExpressions/alsoFails.ts(3,9): error TS7034: Variable 'o' implicitly has type 'any[]' in some locations where its type cannot be determined. +tests/cases/conformance/es6/yieldExpressions/alsoFails.ts(5,9): error TS2322: Type 'void' is not assignable to type 'any[]'. tests/cases/conformance/es6/yieldExpressions/alsoFails.ts(5,20): error TS7005: Variable 'o' implicitly has an 'any[]' type. @@ -10,7 +11,7 @@ tests/cases/conformance/es6/yieldExpressions/alsoFails.ts(5,20): error TS7005: V } } -==== tests/cases/conformance/es6/yieldExpressions/alsoFails.ts (2 errors) ==== +==== tests/cases/conformance/es6/yieldExpressions/alsoFails.ts (3 errors) ==== // fails in Typescript too function* g() { var o = [] @@ -18,6 +19,8 @@ tests/cases/conformance/es6/yieldExpressions/alsoFails.ts(5,20): error TS7005: V !!! error TS7034: Variable 'o' implicitly has type 'any[]' in some locations where its type cannot be determined. while (true) { o = yield* o + ~ +!!! error TS2322: Type 'void' is not assignable to type 'any[]'. ~ !!! error TS7005: Variable 'o' implicitly has an 'any[]' type. } diff --git a/tests/baselines/reference/yieldExpressionInControlFlow.types b/tests/baselines/reference/yieldExpressionInControlFlow.types index 14650ef05829c..497bb7eb29884 100644 --- a/tests/baselines/reference/yieldExpressionInControlFlow.types +++ b/tests/baselines/reference/yieldExpressionInControlFlow.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/bug25149.js === function* f() { ->f : () => IterableIterator +>f : () => Generator var o >o : any @@ -19,7 +19,7 @@ function* f() { === tests/cases/conformance/es6/yieldExpressions/alsoFails.ts === // fails in Typescript too function* g() { ->g : () => IterableIterator +>g : () => Generator var o = [] >o : any[] @@ -29,10 +29,10 @@ function* g() { >true : true o = yield* o ->o = yield* o : any +>o = yield* o : void +>o : any[] +>yield* o : void >o : any[] ->yield* o : any ->o : any } } diff --git a/tests/baselines/reference/yieldExpressionInFlowLoop.types b/tests/baselines/reference/yieldExpressionInFlowLoop.types index a178d4b5ce762..9af0ffd590111 100644 --- a/tests/baselines/reference/yieldExpressionInFlowLoop.types +++ b/tests/baselines/reference/yieldExpressionInFlowLoop.types @@ -1,6 +1,6 @@ === tests/cases/compiler/yieldExpressionInFlowLoop.ts === function* f() { ->f : () => IterableIterator +>f : () => Generator let result; >result : any diff --git a/tests/baselines/reference/yieldExpressionInnerCommentEmit.types b/tests/baselines/reference/yieldExpressionInnerCommentEmit.types index d6d384712f799..cb592a092928c 100644 --- a/tests/baselines/reference/yieldExpressionInnerCommentEmit.types +++ b/tests/baselines/reference/yieldExpressionInnerCommentEmit.types @@ -1,6 +1,6 @@ === tests/cases/compiler/yieldExpressionInnerCommentEmit.ts === function * foo2() { ->foo2 : () => IterableIterator +>foo2 : () => Generator /*comment1*/ yield 1; >yield 1 : any @@ -15,12 +15,12 @@ function * foo2() { >3 : 3 yield */*comment4*/ [4]; ->yield */*comment4*/ [4] : any +>yield */*comment4*/ [4] : void >[4] : number[] >4 : 4 yield /*comment5*/* [5]; ->yield /*comment5*/* [5] : any +>yield /*comment5*/* [5] : void >[5] : number[] >5 : 5 } diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts index f79794d59d507..a2cf189da7674 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts @@ -1,9 +1,9 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return ""; } } var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable \ No newline at end of file +for (v of new _StringIterator) { } // Should fail because the iterator is not iterable \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts index b2e788bdef247..a792556717ea0 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts @@ -1,5 +1,5 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return ""; } @@ -9,4 +9,4 @@ class StringIterator { } var v: string; -for (v of new StringIterator) { } // Should fail \ No newline at end of file +for (v of new _StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts index fe78bae2aefad..aeab53a1a9f2f 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts @@ -1,9 +1,9 @@ //@target: ES6 -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return this; } } var v: string; -for (v of new StringIterator) { } // Should fail \ No newline at end of file +for (v of new _StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts index 647ae314b4d86..fba2fb1b8fa37 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts @@ -1,5 +1,5 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -12,4 +12,4 @@ class StringIterator { } var v: string; -for (v of new StringIterator) { } // Should succeed \ No newline at end of file +for (v of new _StringIterator) { } // Should succeed \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts index 61e6a58ce30fd..8efb472e28786 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts @@ -1,9 +1,9 @@ //@target: ES6 -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return x; } } var x: any; -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts index 4414fdc1592a3..e0eb986191d2f 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts @@ -1,5 +1,5 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return x; } @@ -9,4 +9,4 @@ class StringIterator { } var x: any; -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts index f7244eed34c22..e14af1cecea5b 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts @@ -1,6 +1,6 @@ //@target: ES6 -class StringIterator { +class _StringIterator { [Symbol.iterator]: any; } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts index e1b86f6135f05..217c114dc223c 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts @@ -1,9 +1,9 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next: any; [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts index 67e1e3da70a28..a2564972574a5 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts @@ -1,17 +1,17 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return { done: false, value: "" } } - + return = 0; - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts index 701fcb50ed0a5..071f89ebc60fe 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts @@ -1,15 +1,15 @@ //@target: ES6 -class StringIterator { +class _StringIterator { next() { return { // no done property value: "" } } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts index f0af5c4a40820..be8124ca5e2f7 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts @@ -1,9 +1,9 @@ //@target: ES6 //@noImplicitAny: true -class StringIterator { +class _StringIterator { [Symbol.iterator]() { return v; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts index 63b88223996bf..9b3f617a7180c 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts @@ -1,13 +1,13 @@ //@target: ES6 //@noImplicitAny: true -class StringIterator { +class _StringIterator { next() { return v; } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts index ab6e26d6d60a5..c23fbcb80bd7f 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts @@ -1,16 +1,16 @@ //@target: ES6 //@noImplicitAny: true -class StringIterator { +class _StringIterator { next() { return { done: true, value: v } } - + [Symbol.iterator]() { return this; } } -for (var v of new StringIterator) { } \ No newline at end of file +for (var v of new _StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts index 06bceec84f565..d34f3b3b1645d 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,4 +29,4 @@ class StringIterator { } } -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); \ No newline at end of file +new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts index 53b0e660379fc..0bc67491e94e1 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,4 +26,4 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file +foo(...new SymbolIterator, ...new _StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts index c48260e97eacc..d5a49882e4566 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,4 +26,4 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file +foo(...new SymbolIterator, ...new _StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts index 6893cd9d8a48d..be057412abd57 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts @@ -13,7 +13,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -26,4 +26,4 @@ class StringIterator { } } -foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file +foo(...new SymbolIterator, ...new _StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts index c81a475d7de1d..9f84a5b2bdeab 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,4 +29,4 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file +new Foo(...new SymbolIterator, ...new _StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts index 41ee21a564557..7f3f02eafb338 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts @@ -16,7 +16,7 @@ class SymbolIterator { } } -class StringIterator { +class _StringIterator { next() { return { value: "", @@ -29,4 +29,4 @@ class StringIterator { } } -new Foo(...new SymbolIterator, ...[...new StringIterator]); +new Foo(...new SymbolIterator, ...[...new _StringIterator]); diff --git a/tests/cases/conformance/generators/generatorExplicitReturnType.ts b/tests/cases/conformance/generators/generatorExplicitReturnType.ts new file mode 100644 index 0000000000000..affcc01146796 --- /dev/null +++ b/tests/cases/conformance/generators/generatorExplicitReturnType.ts @@ -0,0 +1,28 @@ +// @target: esnext +// @strictNullChecks: true +// @noImplicitReturns: true +// @noImplicitAny: true + +function* g1(): Generator { + yield; // error + yield "a"; // error + const x: number = yield 1; // error + return 10; // error +} + +function* g2(): Generator { + const x = yield 1; + return true; +} + +declare const generator: Generator; + +function* g3(): Generator { + const x: number = yield* generator; // error + return true; +} + +function* g4(): Generator { + const x = yield* generator; + return true; +} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorImplicitAny.ts b/tests/cases/conformance/generators/generatorImplicitAny.ts new file mode 100644 index 0000000000000..441107defe55c --- /dev/null +++ b/tests/cases/conformance/generators/generatorImplicitAny.ts @@ -0,0 +1,6 @@ +// @target: esnext +// @strictNullChecks: true +// @noImplicitReturns: true +// @noImplicitAny: true + +function* g() {} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorReturnTypeInference.ts b/tests/cases/conformance/generators/generatorReturnTypeInference.ts new file mode 100644 index 0000000000000..df625ed6cca76 --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeInference.ts @@ -0,0 +1,96 @@ +// @target: esnext +// @strictNullChecks: true +// @noImplicitReturns: true +// @noImplicitAny: true + +declare const iterableIterator: IterableIterator; +declare const generator: Generator; +declare const never: never; + +// 'yield' iteration type inference +function* g001() { // Generator + yield; +} + +function* g002() { // Generator + yield 1; +} + +function* g003() { // Generator + yield* []; +} + +function* g004() { // Generator + yield* iterableIterator; +} + +function* g005() { // Generator + yield* generator; +} + +function* g006() { // Generator<1 | 2, void, unknown> + yield 1; + yield 2; +} + +function* g007() { // Generator + yield never; +} + +// 'return' iteration type inference +function* g102() { // Generator + return 1; +} + +function* g103() { // Generator + if (Math.random()) return 1; + return 2; +} + +function* g104() { // Generator + return never; +} + +// 'next' iteration type inference +function* g201() { // Generator + let a: string = yield 1; +} + +function* g202() { // Generator<1 | 2, void, string & number> + let a: string = yield 1; + let b: number = yield 2; +} + +// mixed iteration types inference + +function* g301() { // Generator + yield; + return; +} + +function* g302() { // Generator + yield 1; + return; +} + +function* g303() { // Generator + yield; + return "a"; +} + +function* g304() { // Generator + yield 1; + return "a"; +} + +function* g305() { // Generator<1 | 2, "a" | "b", unknown> + if (Math.random()) yield 1; + yield 2; + if (Math.random()) return "a"; + return "b"; +} + +function* g306() { // Generator + const a: "hi" = yield 1; + return true; +}