typescript 5.1.0-dev.20230321 → 5.1.0-dev.20230322

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.1";
21
- var version = `${versionMajorMinor}.0-dev.20230321`;
21
+ var version = `${versionMajorMinor}.0-dev.20230322`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6634,6 +6634,7 @@ var Diagnostics = {
6634
6634
  A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
6635
6635
  A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
6636
6636
  The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
6637
+ Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
6637
6638
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6638
6639
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6639
6640
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -12711,17 +12712,20 @@ function isObjectLiteralOrClassExpressionMethodOrAccessor(node) {
12711
12712
  function isIdentifierTypePredicate(predicate) {
12712
12713
  return predicate && predicate.kind === 1 /* Identifier */;
12713
12714
  }
12714
- function getPropertyAssignment(objectLiteral, key, key2) {
12715
- return objectLiteral.properties.filter((property) => {
12716
- if (property.kind === 300 /* PropertyAssignment */) {
12717
- const propName = tryGetTextOfPropertyName(property.name);
12718
- return key === propName || !!key2 && key2 === propName;
12719
- }
12720
- return false;
12715
+ function forEachPropertyAssignment(objectLiteral, key, callback, key2) {
12716
+ return forEach(objectLiteral == null ? void 0 : objectLiteral.properties, (property) => {
12717
+ if (!isPropertyAssignment(property))
12718
+ return void 0;
12719
+ const propName = tryGetTextOfPropertyName(property.name);
12720
+ return key === propName || key2 && key2 === propName ? callback(property) : void 0;
12721
12721
  });
12722
12722
  }
12723
12723
  function getPropertyArrayElementValue(objectLiteral, propKey, elementValue) {
12724
- return firstDefined(getPropertyAssignment(objectLiteral, propKey), (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
12724
+ return forEachPropertyAssignment(
12725
+ objectLiteral,
12726
+ propKey,
12727
+ (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0
12728
+ );
12725
12729
  }
12726
12730
  function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
12727
12731
  if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
@@ -12730,11 +12734,10 @@ function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
12730
12734
  }
12731
12735
  }
12732
12736
  function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
12733
- return firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
12737
+ return forEachTsConfigPropArray(tsConfigSourceFile, propKey, (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
12734
12738
  }
12735
- function getTsConfigPropArray(tsConfigSourceFile, propKey) {
12736
- const jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
12737
- return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : emptyArray;
12739
+ function forEachTsConfigPropArray(tsConfigSourceFile, propKey, callback) {
12740
+ return forEachPropertyAssignment(getTsConfigObjectLiteralExpression(tsConfigSourceFile), propKey, callback);
12738
12741
  }
12739
12742
  function getContainingFunction(node) {
12740
12743
  return findAncestor(node.parent, isFunctionLike);
@@ -35496,7 +35499,7 @@ function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, exis
35496
35499
  if (sourceFile) {
35497
35500
  const fileName = configFileName || "tsconfig.json";
35498
35501
  const diagnosticMessage = Diagnostics.The_files_list_in_config_file_0_is_empty;
35499
- const nodeValue = firstDefined(getTsConfigPropArray(sourceFile, "files"), (property) => property.initializer);
35502
+ const nodeValue = forEachTsConfigPropArray(sourceFile, "files", (property) => property.initializer);
35500
35503
  const error = createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, nodeValue, diagnosticMessage, fileName);
35501
35504
  errors.push(error);
35502
35505
  } else {
@@ -45479,7 +45482,7 @@ function createTypeChecker(host) {
45479
45482
  return void 0;
45480
45483
  }
45481
45484
  } else {
45482
- throw Debug.assertNever(name, "Unknown entity name kind.");
45485
+ Debug.assertNever(name, "Unknown entity name kind.");
45483
45486
  }
45484
45487
  Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
45485
45488
  if (!nodeIsSynthesized(name) && isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 275 /* ExportAssignment */)) {
@@ -53364,7 +53367,7 @@ function createTypeChecker(host) {
53364
53367
  return simplified !== type ? simplified : getConstraintOfType(type);
53365
53368
  }
53366
53369
  function getConstraintFromIndexedAccess(type) {
53367
- if (isMappedTypeGenericIndexedAccess(type)) {
53370
+ if (isMappedTypeGenericIndexedAccess(type) || isGenericMappedType(type.objectType)) {
53368
53371
  return substituteIndexedMappedType(type.objectType, type.indexType);
53369
53372
  }
53370
53373
  const indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
@@ -55752,6 +55755,12 @@ function createTypeChecker(host) {
55752
55755
  i--;
55753
55756
  const source = types[i];
55754
55757
  if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) {
55758
+ if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) {
55759
+ if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) {
55760
+ orderedRemoveItemAt(types, i);
55761
+ }
55762
+ continue;
55763
+ }
55755
55764
  const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0;
55756
55765
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
55757
55766
  for (const target of types) {
@@ -56319,7 +56328,7 @@ function createTypeChecker(host) {
56319
56328
  links.resolvedType = getTypeFromTypeNode(node.type);
56320
56329
  break;
56321
56330
  default:
56322
- throw Debug.assertNever(node.operator);
56331
+ Debug.assertNever(node.operator);
56323
56332
  }
56324
56333
  }
56325
56334
  return links.resolvedType;
@@ -57286,7 +57295,10 @@ function createTypeChecker(host) {
57286
57295
  const declarations = concatenate(leftProp.declarations, rightProp.declarations);
57287
57296
  const flags = 4 /* Property */ | leftProp.flags & 16777216 /* Optional */;
57288
57297
  const result = createSymbol(flags, leftProp.escapedName);
57289
- result.links.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */);
57298
+ const leftType = getTypeOfSymbol(leftProp);
57299
+ const leftTypeWithoutUndefined = removeMissingOrUndefinedType(leftType);
57300
+ const rightTypeWithoutUndefined = removeMissingOrUndefinedType(rightType);
57301
+ result.links.type = leftTypeWithoutUndefined === rightTypeWithoutUndefined ? leftType : getUnionType([leftType, rightTypeWithoutUndefined], 2 /* Subtype */);
57290
57302
  result.links.leftSpread = leftProp;
57291
57303
  result.links.rightSpread = rightProp;
57292
57304
  result.declarations = declarations;
@@ -58709,6 +58721,9 @@ function createTypeChecker(host) {
58709
58721
  const targetCount = getParameterCount(target);
58710
58722
  const sourceHasMoreParameters = !hasEffectiveRestParameter(target) && (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
58711
58723
  if (sourceHasMoreParameters) {
58724
+ if (reportErrors2 && !(checkMode & 8 /* StrictArity */)) {
58725
+ errorReporter(Diagnostics.Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1, getMinArgumentCount(source), targetCount);
58726
+ }
58712
58727
  return 0 /* False */;
58713
58728
  }
58714
58729
  if (source.typeParameters && source.typeParameters !== target.typeParameters) {
@@ -60417,6 +60432,26 @@ function createTypeChecker(host) {
60417
60432
  )) {
60418
60433
  return result2;
60419
60434
  }
60435
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
60436
+ const indexType = source2.indexType;
60437
+ if (indexType.flags & 4194304 /* Index */) {
60438
+ const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
60439
+ const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
60440
+ const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
60441
+ if (result2 = isRelatedTo(
60442
+ constraint2,
60443
+ target2,
60444
+ 1 /* Source */,
60445
+ /*reportErrors*/
60446
+ false,
60447
+ /*headMessage*/
60448
+ void 0,
60449
+ intersectionState
60450
+ )) {
60451
+ return result2;
60452
+ }
60453
+ }
60454
+ }
60420
60455
  if (isMappedTypeGenericIndexedAccess(source2)) {
60421
60456
  const indexConstraint = getConstraintOfType(source2.indexType);
60422
60457
  if (indexConstraint) {
@@ -61608,7 +61643,7 @@ function createTypeChecker(host) {
61608
61643
  return type.symbol;
61609
61644
  }
61610
61645
  if (isTupleType(type)) {
61611
- return type;
61646
+ return type.target;
61612
61647
  }
61613
61648
  }
61614
61649
  if (type.flags & 262144 /* TypeParameter */) {
@@ -62851,21 +62886,19 @@ function createTypeChecker(host) {
62851
62886
  const saveInferencePriority = inferencePriority;
62852
62887
  inferencePriority = 2048 /* MaxValue */;
62853
62888
  const saveExpandingFlags = expandingFlags;
62854
- const sourceIdentity = getRecursionIdentity(source);
62855
- const targetIdentity = getRecursionIdentity(target);
62856
- if (contains(sourceStack, sourceIdentity))
62889
+ (sourceStack != null ? sourceStack : sourceStack = []).push(source);
62890
+ (targetStack != null ? targetStack : targetStack = []).push(target);
62891
+ if (isDeeplyNestedType(source, sourceStack, sourceStack.length, 2))
62857
62892
  expandingFlags |= 1 /* Source */;
62858
- if (contains(targetStack, targetIdentity))
62893
+ if (isDeeplyNestedType(target, targetStack, targetStack.length, 2))
62859
62894
  expandingFlags |= 2 /* Target */;
62860
62895
  if (expandingFlags !== 3 /* Both */) {
62861
- (sourceStack || (sourceStack = [])).push(sourceIdentity);
62862
- (targetStack || (targetStack = [])).push(targetIdentity);
62863
62896
  action(source, target);
62864
- targetStack.pop();
62865
- sourceStack.pop();
62866
62897
  } else {
62867
62898
  inferencePriority = -1 /* Circularity */;
62868
62899
  }
62900
+ targetStack.pop();
62901
+ sourceStack.pop();
62869
62902
  expandingFlags = saveExpandingFlags;
62870
62903
  visited.set(key, inferencePriority);
62871
62904
  inferencePriority = Math.min(inferencePriority, saveInferencePriority);
@@ -70593,7 +70626,7 @@ function createTypeChecker(host) {
70593
70626
  case 283 /* JsxSelfClosingElement */:
70594
70627
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
70595
70628
  }
70596
- throw Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
70629
+ Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
70597
70630
  }
70598
70631
  function getResolvedSignature(node, candidatesOutArray, checkMode) {
70599
70632
  const links = getNodeLinks(node);
@@ -81868,7 +81901,7 @@ function createTypeChecker(host) {
81868
81901
  currentKind = 2 /* SetAccessor */;
81869
81902
  break;
81870
81903
  default:
81871
- throw Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
81904
+ Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
81872
81905
  }
81873
81906
  if (!inDestructuring) {
81874
81907
  const effectiveName = getEffectivePropertyNameForPropertyNameNode(name);
@@ -94579,10 +94612,13 @@ function transformJsx(context) {
94579
94612
  return Debug.failBadSyntaxKind(node);
94580
94613
  }
94581
94614
  }
94615
+ function hasProto(obj) {
94616
+ return obj.properties.some((p) => isPropertyAssignment(p) && (isIdentifier(p.name) && idText(p.name) === "__proto__" || isStringLiteral(p.name) && p.name.text === "__proto__"));
94617
+ }
94582
94618
  function hasKeyAfterPropsSpread(node) {
94583
94619
  let spread = false;
94584
94620
  for (const elem of node.attributes.properties) {
94585
- if (isJsxSpreadAttribute(elem)) {
94621
+ if (isJsxSpreadAttribute(elem) && (!isObjectLiteralExpression(elem.expression) || elem.expression.properties.some(isSpreadAssignment))) {
94586
94622
  spread = true;
94587
94623
  } else if (spread && isJsxAttribute(elem) && elem.name.escapedText === "key") {
94588
94624
  return true;
@@ -94748,7 +94784,10 @@ function transformJsx(context) {
94748
94784
  }
94749
94785
  return element;
94750
94786
  }
94751
- function transformJsxSpreadAttributeToSpreadAssignment(node) {
94787
+ function transformJsxSpreadAttributeToProps(node) {
94788
+ if (isObjectLiteralExpression(node.expression) && !hasProto(node.expression)) {
94789
+ return node.expression.properties;
94790
+ }
94752
94791
  return factory2.createSpreadAssignment(Debug.checkDefined(visitNode(node.expression, visitor, isExpression)));
94753
94792
  }
94754
94793
  function transformJsxAttributesToObjectProps(attrs, children) {
@@ -94756,30 +94795,48 @@ function transformJsx(context) {
94756
94795
  return target && target >= 5 /* ES2018 */ ? factory2.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children);
94757
94796
  }
94758
94797
  function transformJsxAttributesToProps(attrs, children) {
94759
- const props = flatten(spanMap(attrs, isJsxSpreadAttribute, (attrs2, isSpread) => map(attrs2, (attr) => isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr))));
94798
+ const props = flatten(spanMap(attrs, isJsxSpreadAttribute, (attrs2, isSpread) => flatten(map(attrs2, (attr) => isSpread ? transformJsxSpreadAttributeToProps(attr) : transformJsxAttributeToObjectLiteralElement(attr)))));
94760
94799
  if (children) {
94761
94800
  props.push(children);
94762
94801
  }
94763
94802
  return props;
94764
94803
  }
94765
94804
  function transformJsxAttributesToExpression(attrs, children) {
94766
- const expressions = flatten(
94767
- spanMap(
94768
- attrs,
94769
- isJsxSpreadAttribute,
94770
- (attrs2, isSpread) => isSpread ? map(attrs2, transformJsxSpreadAttributeToExpression) : factory2.createObjectLiteralExpression(map(attrs2, transformJsxAttributeToObjectLiteralElement))
94771
- )
94772
- );
94773
- if (isJsxSpreadAttribute(attrs[0])) {
94774
- expressions.unshift(factory2.createObjectLiteralExpression());
94805
+ const expressions = [];
94806
+ let properties = [];
94807
+ for (const attr of attrs) {
94808
+ if (isJsxSpreadAttribute(attr)) {
94809
+ if (isObjectLiteralExpression(attr.expression) && !hasProto(attr.expression)) {
94810
+ for (const prop of attr.expression.properties) {
94811
+ if (isSpreadAssignment(prop)) {
94812
+ finishObjectLiteralIfNeeded();
94813
+ expressions.push(prop.expression);
94814
+ continue;
94815
+ }
94816
+ properties.push(prop);
94817
+ }
94818
+ continue;
94819
+ }
94820
+ finishObjectLiteralIfNeeded();
94821
+ expressions.push(attr.expression);
94822
+ continue;
94823
+ }
94824
+ properties.push(transformJsxAttributeToObjectLiteralElement(attr));
94775
94825
  }
94776
94826
  if (children) {
94777
- expressions.push(factory2.createObjectLiteralExpression([children]));
94827
+ properties.push(children);
94828
+ }
94829
+ finishObjectLiteralIfNeeded();
94830
+ if (expressions.length && !isObjectLiteralExpression(expressions[0])) {
94831
+ expressions.unshift(factory2.createObjectLiteralExpression());
94778
94832
  }
94779
94833
  return singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
94780
- }
94781
- function transformJsxSpreadAttributeToExpression(node) {
94782
- return Debug.checkDefined(visitNode(node.expression, visitor, isExpression));
94834
+ function finishObjectLiteralIfNeeded() {
94835
+ if (properties.length) {
94836
+ expressions.push(factory2.createObjectLiteralExpression(properties));
94837
+ properties = [];
94838
+ }
94839
+ }
94783
94840
  }
94784
94841
  function transformJsxAttributeToObjectLiteralElement(node) {
94785
94842
  const name = getAttributeName(node);
@@ -115617,8 +115674,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115617
115674
  if (!referenceInfo)
115618
115675
  return void 0;
115619
115676
  const { sourceFile, index } = referenceInfo;
115620
- const referencesSyntax = firstDefined(
115621
- getTsConfigPropArray(sourceFile, "references"),
115677
+ const referencesSyntax = forEachTsConfigPropArray(
115678
+ sourceFile,
115679
+ "references",
115622
115680
  (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0
115623
115681
  );
115624
115682
  return referencesSyntax && referencesSyntax.elements.length > index ? createDiagnosticForNodeInSourceFile(
@@ -115689,26 +115747,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115689
115747
  }
115690
115748
  function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, ...args) {
115691
115749
  let needCompilerDiagnostic = true;
115692
- const pathsSyntax = getOptionPathsSyntax();
115693
- for (const pathProp of pathsSyntax) {
115750
+ forEachOptionPathsSyntax((pathProp) => {
115694
115751
  if (isObjectLiteralExpression(pathProp.initializer)) {
115695
- for (const keyProps of getPropertyAssignment(pathProp.initializer, key)) {
115752
+ forEachPropertyAssignment(pathProp.initializer, key, (keyProps) => {
115696
115753
  const initializer = keyProps.initializer;
115697
115754
  if (isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
115698
115755
  programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, ...args));
115699
115756
  needCompilerDiagnostic = false;
115700
115757
  }
115701
- }
115758
+ });
115702
115759
  }
115703
- }
115760
+ });
115704
115761
  if (needCompilerDiagnostic) {
115705
115762
  programDiagnostics.add(createCompilerDiagnostic(message, ...args));
115706
115763
  }
115707
115764
  }
115708
115765
  function createDiagnosticForOptionPaths(onKey, key, message, ...args) {
115709
115766
  let needCompilerDiagnostic = true;
115710
- const pathsSyntax = getOptionPathsSyntax();
115711
- for (const pathProp of pathsSyntax) {
115767
+ forEachOptionPathsSyntax((pathProp) => {
115712
115768
  if (isObjectLiteralExpression(pathProp.initializer) && createOptionDiagnosticInObjectLiteralSyntax(
115713
115769
  pathProp.initializer,
115714
115770
  onKey,
@@ -115720,21 +115776,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115720
115776
  )) {
115721
115777
  needCompilerDiagnostic = false;
115722
115778
  }
115723
- }
115779
+ });
115724
115780
  if (needCompilerDiagnostic) {
115725
115781
  programDiagnostics.add(createCompilerDiagnostic(message, ...args));
115726
115782
  }
115727
115783
  }
115728
- function getOptionsSyntaxByName(name) {
115729
- const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
115730
- return compilerOptionsObjectLiteralSyntax && getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
115784
+ function forEachOptionsSyntaxByName(name, callback) {
115785
+ return forEachPropertyAssignment(getCompilerOptionsObjectLiteralSyntax(), name, callback);
115731
115786
  }
115732
- function getOptionPathsSyntax() {
115733
- return getOptionsSyntaxByName("paths") || emptyArray;
115787
+ function forEachOptionPathsSyntax(callback) {
115788
+ return forEachOptionsSyntaxByName("paths", callback);
115734
115789
  }
115735
115790
  function getOptionsSyntaxByValue(name, value) {
115736
- const syntaxByName = getOptionsSyntaxByName(name);
115737
- return syntaxByName && firstDefined(syntaxByName, (property) => isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : void 0);
115791
+ return forEachOptionsSyntaxByName(name, (property) => isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : void 0);
115738
115792
  }
115739
115793
  function getOptionsSyntaxByArrayElementValue(name, value) {
115740
115794
  const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
@@ -115764,8 +115818,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115764
115818
  );
115765
115819
  }
115766
115820
  function createDiagnosticForReference(sourceFile, index, message, ...args) {
115767
- const referencesSyntax = firstDefined(
115768
- getTsConfigPropArray(sourceFile || options.configFile, "references"),
115821
+ const referencesSyntax = forEachTsConfigPropArray(
115822
+ sourceFile || options.configFile,
115823
+ "references",
115769
115824
  (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0
115770
115825
  );
115771
115826
  if (referencesSyntax && referencesSyntax.elements.length > index) {
@@ -115787,29 +115842,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115787
115842
  }
115788
115843
  function getCompilerOptionsObjectLiteralSyntax() {
115789
115844
  if (_compilerOptionsObjectLiteralSyntax === void 0) {
115790
- _compilerOptionsObjectLiteralSyntax = false;
115791
- const jsonObjectLiteral = getTsConfigObjectLiteralExpression(options.configFile);
115792
- if (jsonObjectLiteral) {
115793
- for (const prop of getPropertyAssignment(jsonObjectLiteral, "compilerOptions")) {
115794
- if (isObjectLiteralExpression(prop.initializer)) {
115795
- _compilerOptionsObjectLiteralSyntax = prop.initializer;
115796
- break;
115797
- }
115798
- }
115799
- }
115845
+ _compilerOptionsObjectLiteralSyntax = forEachPropertyAssignment(
115846
+ getTsConfigObjectLiteralExpression(options.configFile),
115847
+ "compilerOptions",
115848
+ (prop) => isObjectLiteralExpression(prop.initializer) ? prop.initializer : void 0
115849
+ ) || false;
115800
115850
  }
115801
115851
  return _compilerOptionsObjectLiteralSyntax || void 0;
115802
115852
  }
115803
115853
  function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, ...args) {
115804
- const props = getPropertyAssignment(objectLiteral, key1, key2);
115805
- for (const prop of props) {
115854
+ let needsCompilerDiagnostic = false;
115855
+ forEachPropertyAssignment(objectLiteral, key1, (prop) => {
115806
115856
  if ("messageText" in message) {
115807
115857
  programDiagnostics.add(createDiagnosticForNodeFromMessageChain(options.configFile, onKey ? prop.name : prop.initializer, message));
115808
115858
  } else {
115809
115859
  programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, ...args));
115810
115860
  }
115811
- }
115812
- return !!props.length;
115861
+ needsCompilerDiagnostic = true;
115862
+ }, key2);
115863
+ return needsCompilerDiagnostic;
115813
115864
  }
115814
115865
  function createRedundantOptionDiagnostic(errorOnOption, redundantWithOption) {
115815
115866
  const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();