@typescript-deploys/pr-build 5.5.0-pr-58703-2 → 5.5.0-pr-57842-25

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.5";
21
- var version = `${versionMajorMinor}.0-insiders.20240529`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240530`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -11047,8 +11047,8 @@ function textSpanIsEmpty(span) {
11047
11047
  function textSpanContainsPosition(span, position) {
11048
11048
  return position >= span.start && position < textSpanEnd(span);
11049
11049
  }
11050
- function textRangeContainsPositionInclusive(span, position) {
11051
- return position >= span.pos && position <= span.end;
11050
+ function textRangeContainsPositionInclusive(range, position) {
11051
+ return position >= range.pos && position <= range.end;
11052
11052
  }
11053
11053
  function createTextSpan(start, length2) {
11054
11054
  if (start < 0) {
@@ -18254,6 +18254,13 @@ function rangeOfTypeParameters(sourceFile, typeParameters) {
18254
18254
  function skipTypeChecking(sourceFile, options, host) {
18255
18255
  return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib || options.noCheck || host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
18256
18256
  }
18257
+ function shouldIncludeBindAndCheckDiagnostics(sourceFile, options) {
18258
+ const isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
18259
+ const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
18260
+ const isPlainJs = isPlainJsFile(sourceFile, options.checkJs);
18261
+ const isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
18262
+ return !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
18263
+ }
18257
18264
  function isJsonEqual(a, b) {
18258
18265
  return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a, b, isJsonEqual);
18259
18266
  }
@@ -45032,6 +45039,9 @@ function createTypeChecker(host) {
45032
45039
  deferredDiagnosticsCallbacks.push(arg);
45033
45040
  };
45034
45041
  var cancellationToken;
45042
+ var requestedExternalEmitHelperNames = /* @__PURE__ */ new Set();
45043
+ var requestedExternalEmitHelpers;
45044
+ var externalHelpersModule;
45035
45045
  var scanner;
45036
45046
  var Symbol12 = objectAllocator.getSymbolConstructor();
45037
45047
  var Type7 = objectAllocator.getTypeConstructor();
@@ -59679,6 +59689,7 @@ function createTypeChecker(host) {
59679
59689
  return links.resolvedType;
59680
59690
  }
59681
59691
  function getTemplateLiteralType(texts, types) {
59692
+ var _a, _b;
59682
59693
  const unionIndex = findIndex(types, (t) => !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)));
59683
59694
  if (unionIndex >= 0) {
59684
59695
  return checkCrossProductUnion(types) ? mapType(types[unionIndex], (t) => getTemplateLiteralType(texts, replaceElement(types, unionIndex, t))) : errorType;
@@ -59686,7 +59697,7 @@ function createTypeChecker(host) {
59686
59697
  if (contains(types, wildcardType)) {
59687
59698
  return wildcardType;
59688
59699
  }
59689
- if (texts.length === 2 && texts[0] === "" && texts[1] === "" && types[0].flags & 268435456 /* StringMapping */) {
59700
+ if (texts.length === 2 && texts[0] === "" && texts[1] === "" && !(types[0].flags & 2944 /* Literal */) && !((_b = (_a = types[0].symbol) == null ? void 0 : _a.declarations) == null ? void 0 : _b.some((d) => d.parent.kind === 195 /* InferType */)) && isTypeAssignableTo(types[0], stringType)) {
59690
59701
  return types[0];
59691
59702
  }
59692
59703
  const newTypes = [];
@@ -66068,13 +66079,6 @@ function createTypeChecker(host) {
66068
66079
  }
66069
66080
  return false;
66070
66081
  }
66071
- function isTemplateLiteralTypeWithSinglePlaceholderAndNoExtraTexts(type) {
66072
- if (!(type.flags & 134217728 /* TemplateLiteral */)) {
66073
- return false;
66074
- }
66075
- const texts = type.texts;
66076
- return texts.length === 2 && texts[0] === "" && texts[1] === "";
66077
- }
66078
66082
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
66079
66083
  if (target.flags & 2097152 /* Intersection */) {
66080
66084
  return every(target.types, (t) => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
@@ -66554,10 +66558,6 @@ function createTypeChecker(host) {
66554
66558
  }
66555
66559
  }
66556
66560
  function inferToTemplateLiteralType(source, target) {
66557
- if (isTemplateLiteralTypeWithSinglePlaceholderAndNoExtraTexts(source) && isTemplateLiteralTypeWithSinglePlaceholderAndNoExtraTexts(target)) {
66558
- inferFromTypes(source.types[0], target.types[0]);
66559
- return;
66560
- }
66561
66561
  const matches = inferTypesFromTemplateLiteralType(source, target);
66562
66562
  const types = target.types;
66563
66563
  if (matches || every(target.texts, (s) => s.length === 0)) {
@@ -83369,6 +83369,9 @@ function createTypeChecker(host) {
83369
83369
  }
83370
83370
  }
83371
83371
  function checkSourceElementWorker(node) {
83372
+ if (getNodeCheckFlags(node) & 8388608 /* PartiallyTypeChecked */) {
83373
+ return;
83374
+ }
83372
83375
  if (canHaveJSDoc(node)) {
83373
83376
  forEach(node.jsDoc, ({ comment, tags }) => {
83374
83377
  checkJSDocCommentWorker(comment);
@@ -83712,19 +83715,21 @@ function createTypeChecker(host) {
83712
83715
  currentNode = saveCurrentNode;
83713
83716
  (_b = tracing) == null ? void 0 : _b.pop();
83714
83717
  }
83715
- function checkSourceFile(node) {
83718
+ function checkSourceFile(node, nodesToCheck) {
83716
83719
  var _a, _b;
83717
83720
  (_a = tracing) == null ? void 0 : _a.push(
83718
83721
  tracing.Phase.Check,
83719
- "checkSourceFile",
83722
+ nodesToCheck ? "checkSourceFileNodes" : "checkSourceFile",
83720
83723
  { path: node.path },
83721
83724
  /*separateBeginAndEnd*/
83722
83725
  true
83723
83726
  );
83724
- mark("beforeCheck");
83725
- checkSourceFileWorker(node);
83726
- mark("afterCheck");
83727
- measure("Check", "beforeCheck", "afterCheck");
83727
+ const beforeMark = nodesToCheck ? "beforeCheckNodes" : "beforeCheck";
83728
+ const afterMark = nodesToCheck ? "afterCheckNodes" : "afterCheck";
83729
+ mark(beforeMark);
83730
+ nodesToCheck ? checkSourceFileNodesWorker(node, nodesToCheck) : checkSourceFileWorker(node);
83731
+ mark(afterMark);
83732
+ measure("Check", beforeMark, afterMark);
83728
83733
  (_b = tracing) == null ? void 0 : _b.pop();
83729
83734
  }
83730
83735
  function unusedIsError(kind, isAmbient) {
@@ -83755,6 +83760,13 @@ function createTypeChecker(host) {
83755
83760
  clear(potentialWeakMapSetCollisions);
83756
83761
  clear(potentialReflectCollisions);
83757
83762
  clear(potentialUnusedRenamedBindingElementsInTypes);
83763
+ if (links.flags & 8388608 /* PartiallyTypeChecked */) {
83764
+ potentialThisCollisions = links.potentialThisCollisions;
83765
+ potentialNewTargetCollisions = links.potentialNewTargetCollisions;
83766
+ potentialWeakMapSetCollisions = links.potentialWeakMapSetCollisions;
83767
+ potentialReflectCollisions = links.potentialReflectCollisions;
83768
+ potentialUnusedRenamedBindingElementsInTypes = links.potentialUnusedRenamedBindingElementsInTypes;
83769
+ }
83758
83770
  forEach(node.statements, checkSourceElement);
83759
83771
  checkSourceElement(node.endOfFileToken);
83760
83772
  checkDeferredNodes(node);
@@ -83795,10 +83807,38 @@ function createTypeChecker(host) {
83795
83807
  links.flags |= 1 /* TypeChecked */;
83796
83808
  }
83797
83809
  }
83798
- function getDiagnostics(sourceFile, ct) {
83810
+ function checkSourceFileNodesWorker(file, nodes) {
83811
+ const links = getNodeLinks(file);
83812
+ if (!(links.flags & 1 /* TypeChecked */)) {
83813
+ if (skipTypeChecking(file, compilerOptions, host)) {
83814
+ return;
83815
+ }
83816
+ checkGrammarSourceFile(file);
83817
+ clear(potentialThisCollisions);
83818
+ clear(potentialNewTargetCollisions);
83819
+ clear(potentialWeakMapSetCollisions);
83820
+ clear(potentialReflectCollisions);
83821
+ clear(potentialUnusedRenamedBindingElementsInTypes);
83822
+ forEach(nodes, checkSourceElement);
83823
+ checkDeferredNodes(file);
83824
+ (links.potentialThisCollisions || (links.potentialThisCollisions = [])).push(...potentialThisCollisions);
83825
+ (links.potentialNewTargetCollisions || (links.potentialNewTargetCollisions = [])).push(...potentialNewTargetCollisions);
83826
+ (links.potentialWeakMapSetCollisions || (links.potentialWeakMapSetCollisions = [])).push(...potentialWeakMapSetCollisions);
83827
+ (links.potentialReflectCollisions || (links.potentialReflectCollisions = [])).push(...potentialReflectCollisions);
83828
+ (links.potentialUnusedRenamedBindingElementsInTypes || (links.potentialUnusedRenamedBindingElementsInTypes = [])).push(
83829
+ ...potentialUnusedRenamedBindingElementsInTypes
83830
+ );
83831
+ links.flags |= 8388608 /* PartiallyTypeChecked */;
83832
+ for (const node of nodes) {
83833
+ const nodeLinks2 = getNodeLinks(node);
83834
+ nodeLinks2.flags |= 8388608 /* PartiallyTypeChecked */;
83835
+ }
83836
+ }
83837
+ }
83838
+ function getDiagnostics(sourceFile, ct, nodesToCheck) {
83799
83839
  try {
83800
83840
  cancellationToken = ct;
83801
- return getDiagnosticsWorker(sourceFile);
83841
+ return getDiagnosticsWorker(sourceFile, nodesToCheck);
83802
83842
  } finally {
83803
83843
  cancellationToken = void 0;
83804
83844
  }
@@ -83809,20 +83849,23 @@ function createTypeChecker(host) {
83809
83849
  }
83810
83850
  deferredDiagnosticsCallbacks = [];
83811
83851
  }
83812
- function checkSourceFileWithEagerDiagnostics(sourceFile) {
83852
+ function checkSourceFileWithEagerDiagnostics(sourceFile, nodesToCheck) {
83813
83853
  ensurePendingDiagnosticWorkComplete();
83814
83854
  const oldAddLazyDiagnostics = addLazyDiagnostic;
83815
83855
  addLazyDiagnostic = (cb) => cb();
83816
- checkSourceFile(sourceFile);
83856
+ checkSourceFile(sourceFile, nodesToCheck);
83817
83857
  addLazyDiagnostic = oldAddLazyDiagnostics;
83818
83858
  }
83819
- function getDiagnosticsWorker(sourceFile) {
83859
+ function getDiagnosticsWorker(sourceFile, nodesToCheck) {
83820
83860
  if (sourceFile) {
83821
83861
  ensurePendingDiagnosticWorkComplete();
83822
83862
  const previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
83823
83863
  const previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
83824
- checkSourceFileWithEagerDiagnostics(sourceFile);
83864
+ checkSourceFileWithEagerDiagnostics(sourceFile, nodesToCheck);
83825
83865
  const semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
83866
+ if (nodesToCheck) {
83867
+ return semanticDiagnostics;
83868
+ }
83826
83869
  const currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
83827
83870
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
83828
83871
  const deferredGlobalDiagnostics = relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, compareDiagnostics);
@@ -83832,7 +83875,7 @@ function createTypeChecker(host) {
83832
83875
  }
83833
83876
  return semanticDiagnostics;
83834
83877
  }
83835
- forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
83878
+ forEach(host.getSourceFiles(), (file) => checkSourceFileWithEagerDiagnostics(file));
83836
83879
  return diagnostics.getDiagnostics();
83837
83880
  }
83838
83881
  function getGlobalDiagnostics() {
@@ -85425,40 +85468,38 @@ function createTypeChecker(host) {
85425
85468
  amalgamatedDuplicates = void 0;
85426
85469
  }
85427
85470
  function checkExternalEmitHelpers(location, helpers) {
85428
- if (compilerOptions.importHelpers) {
85471
+ if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
85429
85472
  const sourceFile = getSourceFileOfNode(location);
85430
85473
  if (isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 33554432 /* Ambient */)) {
85431
85474
  const helpersModule = resolveHelpersModule(sourceFile, location);
85432
85475
  if (helpersModule !== unknownSymbol) {
85433
- const links = getSymbolLinks(helpersModule);
85434
- links.requestedExternalEmitHelpers ?? (links.requestedExternalEmitHelpers = 0);
85435
- if ((links.requestedExternalEmitHelpers & helpers) !== helpers) {
85436
- const uncheckedHelpers = helpers & ~links.requestedExternalEmitHelpers;
85437
- for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
85438
- if (uncheckedHelpers & helper) {
85439
- for (const name of getHelperNames(helper)) {
85440
- const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
85441
- if (!symbol) {
85442
- error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
85443
- } else if (helper & 524288 /* ClassPrivateFieldGet */) {
85444
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
85445
- error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 4);
85446
- }
85447
- } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
85448
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
85449
- error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 5);
85450
- }
85451
- } else if (helper & 1024 /* SpreadArray */) {
85452
- if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
85453
- error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 3);
85454
- }
85476
+ const uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
85477
+ for (let helper = 1 /* FirstEmitHelper */; helper <= 16777216 /* LastEmitHelper */; helper <<= 1) {
85478
+ if (uncheckedHelpers & helper) {
85479
+ for (const name of getHelperNames(helper)) {
85480
+ if (requestedExternalEmitHelperNames.has(name)) continue;
85481
+ requestedExternalEmitHelperNames.add(name);
85482
+ const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
85483
+ if (!symbol) {
85484
+ error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
85485
+ } else if (helper & 524288 /* ClassPrivateFieldGet */) {
85486
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 3)) {
85487
+ error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 4);
85488
+ }
85489
+ } else if (helper & 1048576 /* ClassPrivateFieldSet */) {
85490
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 4)) {
85491
+ error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 5);
85492
+ }
85493
+ } else if (helper & 1024 /* SpreadArray */) {
85494
+ if (!some(getSignaturesOfSymbol(symbol), (signature) => getParameterCount(signature) > 2)) {
85495
+ error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name, 3);
85455
85496
  }
85456
85497
  }
85457
85498
  }
85458
85499
  }
85459
85500
  }
85460
- links.requestedExternalEmitHelpers |= helpers;
85461
85501
  }
85502
+ requestedExternalEmitHelpers |= helpers;
85462
85503
  }
85463
85504
  }
85464
85505
  }
@@ -85519,11 +85560,10 @@ function createTypeChecker(host) {
85519
85560
  }
85520
85561
  }
85521
85562
  function resolveHelpersModule(file, errorNode) {
85522
- const links = getNodeLinks(file);
85523
- if (!links.externalHelpersModule) {
85524
- links.externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
85563
+ if (!externalHelpersModule) {
85564
+ externalHelpersModule = resolveExternalModule(getImportHelpersImportSpecifier(file), externalHelpersModuleNameText, Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
85525
85565
  }
85526
- return links.externalHelpersModule;
85566
+ return externalHelpersModule;
85527
85567
  }
85528
85568
  function checkGrammarModifiers(node) {
85529
85569
  var _a;
@@ -88913,8 +88953,8 @@ function collectExternalModuleInfo(context, sourceFile) {
88913
88953
  const exportSpecifiers = new IdentifierNameMultiMap();
88914
88954
  const exportedBindings = [];
88915
88955
  const uniqueExports = /* @__PURE__ */ new Map();
88916
- const exportedFunctions = /* @__PURE__ */ new Set();
88917
88956
  let exportedNames;
88957
+ let exportedFunctions;
88918
88958
  let hasExportDefault = false;
88919
88959
  let exportEquals;
88920
88960
  let hasExportStarsToExportValues = false;
@@ -88974,12 +89014,19 @@ function collectExternalModuleInfo(context, sourceFile) {
88974
89014
  break;
88975
89015
  case 262 /* FunctionDeclaration */:
88976
89016
  if (hasSyntacticModifier(node, 32 /* Export */)) {
88977
- addExportedFunctionDeclaration(
88978
- node,
88979
- /*name*/
88980
- void 0,
88981
- hasSyntacticModifier(node, 2048 /* Default */)
88982
- );
89017
+ exportedFunctions = append(exportedFunctions, node);
89018
+ if (hasSyntacticModifier(node, 2048 /* Default */)) {
89019
+ if (!hasExportDefault) {
89020
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
89021
+ hasExportDefault = true;
89022
+ }
89023
+ } else {
89024
+ const name = node.name;
89025
+ if (!uniqueExports.get(idText(name))) {
89026
+ multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89027
+ uniqueExports.set(idText(name), true);
89028
+ }
89029
+ }
88983
89030
  }
88984
89031
  break;
88985
89032
  case 263 /* ClassDeclaration */:
@@ -89015,10 +89062,6 @@ function collectExternalModuleInfo(context, sourceFile) {
89015
89062
  }
89016
89063
  const decl = resolver.getReferencedImportDeclaration(name) || resolver.getReferencedValueDeclaration(name);
89017
89064
  if (decl) {
89018
- if (decl.kind === 262 /* FunctionDeclaration */) {
89019
- addExportedFunctionDeclaration(decl, specifier.name, specifier.name.escapedText === "default" /* Default */);
89020
- continue;
89021
- }
89022
89065
  multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
89023
89066
  }
89024
89067
  uniqueExports.set(idText(specifier.name), true);
@@ -89026,21 +89069,6 @@ function collectExternalModuleInfo(context, sourceFile) {
89026
89069
  }
89027
89070
  }
89028
89071
  }
89029
- function addExportedFunctionDeclaration(node, name, isDefault) {
89030
- exportedFunctions.add(node);
89031
- if (isDefault) {
89032
- if (!hasExportDefault) {
89033
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name ?? context.factory.getDeclarationName(node));
89034
- hasExportDefault = true;
89035
- }
89036
- } else {
89037
- name ?? (name = node.name);
89038
- if (!uniqueExports.get(idText(name))) {
89039
- multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
89040
- uniqueExports.set(idText(name), true);
89041
- }
89042
- }
89043
- }
89044
89072
  }
89045
89073
  function collectExportedVariableInfo(decl, uniqueExports, exportedNames, exportedBindings) {
89046
89074
  if (isBindingPattern(decl.name)) {
@@ -106323,8 +106351,10 @@ function transformModule(context) {
106323
106351
  );
106324
106352
  }
106325
106353
  }
106326
- for (const f of currentModuleInfo.exportedFunctions) {
106327
- appendExportsOfHoistedDeclaration(statements, f);
106354
+ if (some(currentModuleInfo.exportedFunctions)) {
106355
+ for (const f of currentModuleInfo.exportedFunctions) {
106356
+ appendExportsOfHoistedDeclaration(statements, f);
106357
+ }
106328
106358
  }
106329
106359
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
106330
106360
  addRange(statements, visitNodes2(node.statements, topLevelVisitor, isStatement, statementOffset));
@@ -106641,8 +106671,10 @@ function transformModule(context) {
106641
106671
  if (some(currentModuleInfo.exportedNames)) {
106642
106672
  append(statements, factory2.createExpressionStatement(reduceLeft(currentModuleInfo.exportedNames, (prev, nextId) => factory2.createAssignment(factory2.createPropertyAccessExpression(factory2.createIdentifier("exports"), factory2.createIdentifier(idText(nextId))), prev), factory2.createVoidZero())));
106643
106673
  }
106644
- for (const f of currentModuleInfo.exportedFunctions) {
106645
- appendExportsOfHoistedDeclaration(statements, f);
106674
+ if (some(currentModuleInfo.exportedFunctions)) {
106675
+ for (const f of currentModuleInfo.exportedFunctions) {
106676
+ appendExportsOfHoistedDeclaration(statements, f);
106677
+ }
106646
106678
  }
106647
106679
  append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, isStatement));
106648
106680
  if (moduleKind === 2 /* AMD */) {
@@ -108356,7 +108388,7 @@ function transformSystemModule(context) {
108356
108388
  if (!moduleInfo.hasExportStarsToExportValues) {
108357
108389
  return;
108358
108390
  }
108359
- if (!some(moduleInfo.exportedNames) && moduleInfo.exportedFunctions.size === 0 && moduleInfo.exportSpecifiers.size === 0) {
108391
+ if (!some(moduleInfo.exportedNames) && !some(moduleInfo.exportedFunctions) && moduleInfo.exportSpecifiers.size === 0) {
108360
108392
  let hasExportDeclarationWithExportClause = false;
108361
108393
  for (const externalImport of moduleInfo.externalImports) {
108362
108394
  if (externalImport.kind === 278 /* ExportDeclaration */ && externalImport.exportClause) {
@@ -108387,17 +108419,19 @@ function transformSystemModule(context) {
108387
108419
  );
108388
108420
  }
108389
108421
  }
108390
- for (const f of moduleInfo.exportedFunctions) {
108391
- if (hasSyntacticModifier(f, 2048 /* Default */)) {
108392
- continue;
108422
+ if (moduleInfo.exportedFunctions) {
108423
+ for (const f of moduleInfo.exportedFunctions) {
108424
+ if (hasSyntacticModifier(f, 2048 /* Default */)) {
108425
+ continue;
108426
+ }
108427
+ Debug.assert(!!f.name);
108428
+ exportedNames.push(
108429
+ factory2.createPropertyAssignment(
108430
+ factory2.createStringLiteralFromNode(f.name),
108431
+ factory2.createTrue()
108432
+ )
108433
+ );
108393
108434
  }
108394
- Debug.assert(!!f.name);
108395
- exportedNames.push(
108396
- factory2.createPropertyAssignment(
108397
- factory2.createStringLiteralFromNode(f.name),
108398
- factory2.createTrue()
108399
- )
108400
- );
108401
108435
  }
108402
108436
  const exportedNamesStorageRef = factory2.createUniqueName("exportedNames");
108403
108437
  statements.push(
@@ -119668,15 +119702,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119668
119702
  function getSyntacticDiagnostics(sourceFile, cancellationToken) {
119669
119703
  return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
119670
119704
  }
119671
- function getSemanticDiagnostics(sourceFile, cancellationToken) {
119672
- return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
119705
+ function getSemanticDiagnostics(sourceFile, cancellationToken, nodesToCheck) {
119706
+ return getDiagnosticsHelper(
119707
+ sourceFile,
119708
+ (sourceFile2, cancellationToken2) => getSemanticDiagnosticsForFile(sourceFile2, cancellationToken2, nodesToCheck),
119709
+ cancellationToken
119710
+ );
119673
119711
  }
119674
119712
  function getCachedSemanticDiagnostics(sourceFile) {
119675
119713
  var _a2;
119676
119714
  return sourceFile ? (_a2 = cachedBindAndCheckDiagnosticsForFile.perFile) == null ? void 0 : _a2.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
119677
119715
  }
119678
119716
  function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
119679
- return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
119717
+ return getBindAndCheckDiagnosticsForFile(
119718
+ sourceFile,
119719
+ cancellationToken,
119720
+ /*nodesToCheck*/
119721
+ void 0
119722
+ );
119680
119723
  }
119681
119724
  function getProgramDiagnostics(sourceFile) {
119682
119725
  var _a2;
@@ -119716,16 +119759,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119716
119759
  throw e;
119717
119760
  }
119718
119761
  }
119719
- function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
119762
+ function getSemanticDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck) {
119720
119763
  return concatenate(
119721
- filterSemanticDiagnostics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options),
119764
+ filterSemanticDiagnostics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck), options),
119722
119765
  getProgramDiagnostics(sourceFile)
119723
119766
  );
119724
119767
  }
119725
- function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
119768
+ function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken, nodesToCheck) {
119769
+ if (nodesToCheck) {
119770
+ return getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck);
119771
+ }
119726
119772
  return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
119727
119773
  }
119728
- function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
119774
+ function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken, nodesToCheck) {
119729
119775
  return runWithCancellationToken(() => {
119730
119776
  if (skipTypeChecking(sourceFile, options, program)) {
119731
119777
  return emptyArray;
@@ -119733,26 +119779,35 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119733
119779
  const typeChecker2 = getTypeChecker();
119734
119780
  Debug.assert(!!sourceFile.bindDiagnostics);
119735
119781
  const isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
119736
- const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
119737
119782
  const isPlainJs = isPlainJsFile(sourceFile, options.checkJs);
119738
- const isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
119739
- const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */);
119783
+ const isCheckJs = isJs && isCheckJsEnabledForFile(sourceFile, options);
119784
+ const includeBindAndCheckDiagnostics = shouldIncludeBindAndCheckDiagnostics(sourceFile, options);
119740
119785
  let bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
119741
- let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker2.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
119786
+ let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker2.getDiagnostics(sourceFile, cancellationToken, nodesToCheck) : emptyArray;
119742
119787
  if (isPlainJs) {
119743
119788
  bindDiagnostics = filter(bindDiagnostics, (d) => plainJSErrors.has(d.code));
119744
119789
  checkDiagnostics = filter(checkDiagnostics, (d) => plainJSErrors.has(d.code));
119745
119790
  }
119746
- return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics && !isPlainJs, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : void 0);
119791
+ return getMergedBindAndCheckDiagnostics(
119792
+ sourceFile,
119793
+ includeBindAndCheckDiagnostics && !isPlainJs,
119794
+ !!nodesToCheck,
119795
+ bindDiagnostics,
119796
+ checkDiagnostics,
119797
+ isCheckJs ? sourceFile.jsDocDiagnostics : void 0
119798
+ );
119747
119799
  });
119748
119800
  }
119749
- function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, ...allDiagnostics) {
119801
+ function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, partialCheck, ...allDiagnostics) {
119750
119802
  var _a2;
119751
119803
  const flatDiagnostics = flatten(allDiagnostics);
119752
119804
  if (!includeBindAndCheckDiagnostics || !((_a2 = sourceFile.commentDirectives) == null ? void 0 : _a2.length)) {
119753
119805
  return flatDiagnostics;
119754
119806
  }
119755
119807
  const { diagnostics, directives } = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics);
119808
+ if (partialCheck) {
119809
+ return diagnostics;
119810
+ }
119756
119811
  for (const errorExpectation of directives.getUnusedExpectations()) {
119757
119812
  diagnostics.push(createDiagnosticForRange(sourceFile, errorExpectation.range, Diagnostics.Unused_ts_expect_error_directive));
119758
119813
  }