@@ -53,7 +53,6 @@ namespace ts {
5353
5454 const compilerOptions = host.getCompilerOptions();
5555 const languageVersion = getEmitScriptTarget(compilerOptions);
56- const iterationMode = getEmitIterationMode(compilerOptions);
5756 const modulekind = getEmitModuleKind(compilerOptions);
5857 const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters;
5958 const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
@@ -11444,7 +11443,7 @@ namespace ts {
1144411443 }
1144511444
1144611445 function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type {
11447- if (languageVersion < ScriptTarget.ES2015 && iterationMode === IterationMode.Iterable ) {
11446+ if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration ) {
1144811447 checkExternalEmitHelpers(node, ExternalEmitHelpers.SpreadIncludes);
1144911448 }
1145011449
@@ -14713,7 +14712,7 @@ namespace ts {
1471314712 }
1471414713
1471514714 function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
14716- if (languageVersion < ScriptTarget.ES2015 && iterationMode === IterationMode.Iterable ) {
14715+ if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration ) {
1471714716 checkExternalEmitHelpers(node, ExternalEmitHelpers.Read);
1471814717 }
1471914718
@@ -15148,7 +15147,7 @@ namespace ts {
1514815147 checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncDelegator);
1514915148 }
1515015149 }
15151- else if (languageVersion < ScriptTarget.ES2015 && iterationMode === IterationMode.Iterable ) {
15150+ else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration ) {
1515215151 checkExternalEmitHelpers(node, ExternalEmitHelpers.Values);
1515315152 }
1515415153 }
@@ -17440,7 +17439,7 @@ namespace ts {
1744017439
1744117440 // For a binding pattern, check contained binding elements
1744217441 if (isBindingPattern(node.name)) {
17443- if (node.name.kind === SyntaxKind.ArrayBindingPattern && languageVersion < ScriptTarget.ES2015 && iterationMode === IterationMode.Iterable ) {
17442+ if (node.name.kind === SyntaxKind.ArrayBindingPattern && languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration ) {
1744417443 checkExternalEmitHelpers(node, ExternalEmitHelpers.Read);
1744517444 }
1744617445
@@ -17622,7 +17621,7 @@ namespace ts {
1762217621 checkExternalEmitHelpers(node, ExternalEmitHelpers.ForAwaitOfIncludes);
1762317622 }
1762417623 }
17625- else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.iterationMode === IterationMode.Iterable ) {
17624+ else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration ) {
1762617625 checkExternalEmitHelpers(node, ExternalEmitHelpers.ForOfIncludes);
1762717626 }
1762817627 }
@@ -18061,7 +18060,7 @@ namespace ts {
1806118060 * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
1806218061 */
1806318062 function getIteratedTypeOfIterableOrElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node, checkAssignability: boolean): Type {
18064- const iteratedType = iterationMode === IterationMode.Iterable && getIteratedTypeOfIterable(arrayOrStringType, /*errorNode*/ undefined);
18063+ const iteratedType = compilerOptions.downlevelIteration && getIteratedTypeOfIterable(arrayOrStringType, /*errorNode*/ undefined);
1806518064 if (iteratedType) {
1806618065 if (checkAssignability && errorNode) {
1806718066 checkTypeAssignableTo(arrayOrStringType, createIterableType(iteratedType), errorNode);
@@ -18108,10 +18107,10 @@ namespace ts {
1810818107 // But if the input was just number, we want to say that number is not an array type
1810918108 // or a string type.
1811018109 const diagnostic = hasStringConstituent
18111- ? iterationMode === IterationMode.Iterable
18110+ ? compilerOptions.downlevelIteration
1811218111 ? Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator
1811318112 : Diagnostics.Type_0_is_not_an_array_type
18114- : iterationMode === IterationMode.Iterable
18113+ : compilerOptions.downlevelIteration
1811518114 ? Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator
1811618115 : Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
1811718116 error(errorNode, diagnostic, typeToString(arrayType));
@@ -18134,7 +18133,7 @@ namespace ts {
1813418133 }
1813518134
1813618135 function getIteratedTypeOfIterableOrElementTypeOfArray(inputType: Type, errorNode: Node, checkAssignability: boolean): Type {
18137- const iteratedType = iterationMode === IterationMode.Iterable && getIteratedTypeOfIterable(inputType, /*errorNode*/ undefined);
18136+ const iteratedType = compilerOptions.downlevelIteration && getIteratedTypeOfIterable(inputType, /*errorNode*/ undefined);
1813818137 if (iteratedType) {
1813918138 if (checkAssignability && errorNode) {
1814018139 checkTypeAssignableTo(inputType, createIterableType(iteratedType), errorNode);
@@ -18145,7 +18144,7 @@ namespace ts {
1814518144 return getIndexTypeOfType(inputType, IndexKind.Number);
1814618145 }
1814718146 if (errorNode) {
18148- const diagnostic = iterationMode === IterationMode.Iterable
18147+ const diagnostic = compilerOptions.downlevelIteration
1814918148 ? Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator
1815018149 : Diagnostics.Type_0_is_not_an_array_type;
1815118150 error(errorNode, diagnostic, typeToString(inputType));
0 commit comments