@typescript-deploys/pr-build 5.1.0-pr-53406-2 → 5.1.0-pr-53406-15

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
@@ -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 {
@@ -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) {
@@ -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);
@@ -115617,8 +115650,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115617
115650
  if (!referenceInfo)
115618
115651
  return void 0;
115619
115652
  const { sourceFile, index } = referenceInfo;
115620
- const referencesSyntax = firstDefined(
115621
- getTsConfigPropArray(sourceFile, "references"),
115653
+ const referencesSyntax = forEachTsConfigPropArray(
115654
+ sourceFile,
115655
+ "references",
115622
115656
  (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0
115623
115657
  );
115624
115658
  return referencesSyntax && referencesSyntax.elements.length > index ? createDiagnosticForNodeInSourceFile(
@@ -115689,26 +115723,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115689
115723
  }
115690
115724
  function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, ...args) {
115691
115725
  let needCompilerDiagnostic = true;
115692
- const pathsSyntax = getOptionPathsSyntax();
115693
- for (const pathProp of pathsSyntax) {
115726
+ forEachOptionPathsSyntax((pathProp) => {
115694
115727
  if (isObjectLiteralExpression(pathProp.initializer)) {
115695
- for (const keyProps of getPropertyAssignment(pathProp.initializer, key)) {
115728
+ forEachPropertyAssignment(pathProp.initializer, key, (keyProps) => {
115696
115729
  const initializer = keyProps.initializer;
115697
115730
  if (isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
115698
115731
  programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, ...args));
115699
115732
  needCompilerDiagnostic = false;
115700
115733
  }
115701
- }
115734
+ });
115702
115735
  }
115703
- }
115736
+ });
115704
115737
  if (needCompilerDiagnostic) {
115705
115738
  programDiagnostics.add(createCompilerDiagnostic(message, ...args));
115706
115739
  }
115707
115740
  }
115708
115741
  function createDiagnosticForOptionPaths(onKey, key, message, ...args) {
115709
115742
  let needCompilerDiagnostic = true;
115710
- const pathsSyntax = getOptionPathsSyntax();
115711
- for (const pathProp of pathsSyntax) {
115743
+ forEachOptionPathsSyntax((pathProp) => {
115712
115744
  if (isObjectLiteralExpression(pathProp.initializer) && createOptionDiagnosticInObjectLiteralSyntax(
115713
115745
  pathProp.initializer,
115714
115746
  onKey,
@@ -115720,21 +115752,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115720
115752
  )) {
115721
115753
  needCompilerDiagnostic = false;
115722
115754
  }
115723
- }
115755
+ });
115724
115756
  if (needCompilerDiagnostic) {
115725
115757
  programDiagnostics.add(createCompilerDiagnostic(message, ...args));
115726
115758
  }
115727
115759
  }
115728
- function getOptionsSyntaxByName(name) {
115729
- const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
115730
- return compilerOptionsObjectLiteralSyntax && getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
115760
+ function forEachOptionsSyntaxByName(name, callback) {
115761
+ return forEachPropertyAssignment(getCompilerOptionsObjectLiteralSyntax(), name, callback);
115731
115762
  }
115732
- function getOptionPathsSyntax() {
115733
- return getOptionsSyntaxByName("paths") || emptyArray;
115763
+ function forEachOptionPathsSyntax(callback) {
115764
+ return forEachOptionsSyntaxByName("paths", callback);
115734
115765
  }
115735
115766
  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);
115767
+ return forEachOptionsSyntaxByName(name, (property) => isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : void 0);
115738
115768
  }
115739
115769
  function getOptionsSyntaxByArrayElementValue(name, value) {
115740
115770
  const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
@@ -115764,8 +115794,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115764
115794
  );
115765
115795
  }
115766
115796
  function createDiagnosticForReference(sourceFile, index, message, ...args) {
115767
- const referencesSyntax = firstDefined(
115768
- getTsConfigPropArray(sourceFile || options.configFile, "references"),
115797
+ const referencesSyntax = forEachTsConfigPropArray(
115798
+ sourceFile || options.configFile,
115799
+ "references",
115769
115800
  (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0
115770
115801
  );
115771
115802
  if (referencesSyntax && referencesSyntax.elements.length > index) {
@@ -115787,29 +115818,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
115787
115818
  }
115788
115819
  function getCompilerOptionsObjectLiteralSyntax() {
115789
115820
  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
- }
115821
+ _compilerOptionsObjectLiteralSyntax = forEachPropertyAssignment(
115822
+ getTsConfigObjectLiteralExpression(options.configFile),
115823
+ "compilerOptions",
115824
+ (prop) => isObjectLiteralExpression(prop.initializer) ? prop.initializer : void 0
115825
+ ) || false;
115800
115826
  }
115801
115827
  return _compilerOptionsObjectLiteralSyntax || void 0;
115802
115828
  }
115803
115829
  function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, ...args) {
115804
- const props = getPropertyAssignment(objectLiteral, key1, key2);
115805
- for (const prop of props) {
115830
+ let needsCompilerDiagnostic = false;
115831
+ forEachPropertyAssignment(objectLiteral, key1, (prop) => {
115806
115832
  if ("messageText" in message) {
115807
115833
  programDiagnostics.add(createDiagnosticForNodeFromMessageChain(options.configFile, onKey ? prop.name : prop.initializer, message));
115808
115834
  } else {
115809
115835
  programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, ...args));
115810
115836
  }
115811
- }
115812
- return !!props.length;
115837
+ needsCompilerDiagnostic = true;
115838
+ }, key2);
115839
+ return needsCompilerDiagnostic;
115813
115840
  }
115814
115841
  function createRedundantOptionDiagnostic(errorOnOption, redundantWithOption) {
115815
115842
  const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();