typescript 5.5.0-dev.20240320 → 5.5.0-dev.20240321

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-dev.20240320`;
21
+ var version = `${versionMajorMinor}.0-dev.20240321`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3880,7 +3880,8 @@ var commentPragmas = {
3880
3880
  { name: "lib", optional: true, captureSpan: true },
3881
3881
  { name: "path", optional: true, captureSpan: true },
3882
3882
  { name: "no-default-lib", optional: true },
3883
- { name: "resolution-mode", optional: true }
3883
+ { name: "resolution-mode", optional: true },
3884
+ { name: "preserve", optional: true }
3884
3885
  ],
3885
3886
  kind: 1 /* TripleSlashXML */
3886
3887
  },
@@ -7792,7 +7793,9 @@ var Diagnostics = {
7792
7793
  The_value_0_cannot_be_used_here: diag(18050, 1 /* Error */, "The_value_0_cannot_be_used_here_18050", "The value '{0}' cannot be used here."),
7793
7794
  Compiler_option_0_cannot_be_given_an_empty_string: diag(18051, 1 /* Error */, "Compiler_option_0_cannot_be_given_an_empty_string_18051", "Compiler option '{0}' cannot be given an empty string."),
7794
7795
  Its_type_0_is_not_a_valid_JSX_element_type: diag(18053, 1 /* Error */, "Its_type_0_is_not_a_valid_JSX_element_type_18053", "Its type '{0}' is not a valid JSX element type."),
7795
- await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block.")
7796
+ await_using_statements_cannot_be_used_inside_a_class_static_block: diag(18054, 1 /* Error */, "await_using_statements_cannot_be_used_inside_a_class_static_block_18054", "'await using' statements cannot be used inside a class static block."),
7797
+ _0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled: diag(18055, 1 /* Error */, "_0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is__18055", "'{0}' has a string type, but must have syntactically recognizable string syntax when 'isolatedModules' is enabled."),
7798
+ Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled: diag(18056, 1 /* Error */, "Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is__18056", "Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled.")
7796
7799
  };
7797
7800
 
7798
7801
  // src/compiler/scanner.ts
@@ -32546,7 +32549,7 @@ var Parser;
32546
32549
  80 /* Identifier */,
32547
32550
  /*reportAtCurrentPosition*/
32548
32551
  false
32549
- ) : parseIdentifier()), pos);
32552
+ ) : parseIdentifierName()), pos);
32550
32553
  }
32551
32554
  while (token() === 81 /* PrivateIdentifier */) {
32552
32555
  reScanHashToken();
@@ -33494,16 +33497,17 @@ function processPragmasIntoFields(context, reportDiagnostic) {
33494
33497
  const typeReferenceDirectives = context.typeReferenceDirectives;
33495
33498
  const libReferenceDirectives = context.libReferenceDirectives;
33496
33499
  forEach(toArray(entryOrList), (arg) => {
33497
- const { types, lib, path, ["resolution-mode"]: res } = arg.arguments;
33500
+ const { types, lib, path, ["resolution-mode"]: res, preserve: _preserve } = arg.arguments;
33501
+ const preserve = _preserve === "true" ? true : void 0;
33498
33502
  if (arg.arguments["no-default-lib"] === "true") {
33499
33503
  context.hasNoDefaultLib = true;
33500
33504
  } else if (types) {
33501
33505
  const parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
33502
- typeReferenceDirectives.push({ pos: types.pos, end: types.end, fileName: types.value, ...parsed ? { resolutionMode: parsed } : {} });
33506
+ typeReferenceDirectives.push({ pos: types.pos, end: types.end, fileName: types.value, ...parsed ? { resolutionMode: parsed } : {}, ...preserve ? { preserve } : {} });
33503
33507
  } else if (lib) {
33504
- libReferenceDirectives.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
33508
+ libReferenceDirectives.push({ pos: lib.pos, end: lib.end, fileName: lib.value, ...preserve ? { preserve } : {} });
33505
33509
  } else if (path) {
33506
- referencedFiles.push({ pos: path.pos, end: path.end, fileName: path.value });
33510
+ referencedFiles.push({ pos: path.pos, end: path.end, fileName: path.value, ...preserve ? { preserve } : {} });
33507
33511
  } else {
33508
33512
  reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, Diagnostics.Invalid_reference_directive_syntax);
33509
33513
  }
@@ -42308,24 +42312,6 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
42308
42312
  );
42309
42313
  }
42310
42314
  }
42311
- function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, options = {}) {
42312
- return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getModuleSpecifierPreferences({}, compilerOptions, importingSourceFile), {}, options);
42313
- }
42314
- function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, preferences, userPreferences, options = {}) {
42315
- const info = getInfo(importingSourceFileName, host);
42316
- const modulePaths = getAllModulePaths(info, toFileName2, host, userPreferences, options);
42317
- return firstDefined(modulePaths, (modulePath) => tryGetModuleNameAsNodeModule(
42318
- modulePath,
42319
- info,
42320
- importingSourceFile,
42321
- host,
42322
- compilerOptions,
42323
- userPreferences,
42324
- /*packageNameOnly*/
42325
- void 0,
42326
- options.overrideImportMode
42327
- )) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
42328
- }
42329
42315
  function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences, options = {}) {
42330
42316
  var _a;
42331
42317
  const moduleSourceFile = getSourceFileOfModule(moduleSymbol);
@@ -42562,22 +42548,6 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
42562
42548
  });
42563
42549
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
42564
42550
  }
42565
- function getAllModulePaths(info, importedFileName, host, preferences, options = {}) {
42566
- var _a;
42567
- const importingFilePath = toPath(info.importingSourceFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42568
- const importedFilePath = toPath(importedFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42569
- const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
42570
- if (cache) {
42571
- const cached = cache.get(importingFilePath, importedFilePath, preferences, options);
42572
- if (cached == null ? void 0 : cached.modulePaths)
42573
- return cached.modulePaths;
42574
- }
42575
- const modulePaths = getAllModulePathsWorker(info, importedFileName, host);
42576
- if (cache) {
42577
- cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
42578
- }
42579
- return modulePaths;
42580
- }
42581
42551
  function getAllModulePathsWorker(info, importedFileName, host) {
42582
42552
  const allFileNames = /* @__PURE__ */ new Map();
42583
42553
  let importedFileFromNodeModules = false;
@@ -49307,14 +49277,6 @@ function createTypeChecker(host) {
49307
49277
  return file.moduleName;
49308
49278
  }
49309
49279
  if (!file) {
49310
- if (context.tracker.trackReferencedAmbientModule) {
49311
- const ambientDecls = filter(symbol.declarations, isAmbientModule);
49312
- if (length(ambientDecls)) {
49313
- for (const decl of ambientDecls) {
49314
- context.tracker.trackReferencedAmbientModule(decl, symbol);
49315
- }
49316
- }
49317
- }
49318
49280
  if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
49319
49281
  return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
49320
49282
  }
@@ -49407,8 +49369,6 @@ function createTypeChecker(host) {
49407
49369
  }
49408
49370
  }
49409
49371
  const lit = factory.createLiteralTypeNode(factory.createStringLiteral(specifier));
49410
- if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
49411
- context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
49412
49372
  context.approximateLength += specifier.length + 10;
49413
49373
  if (!nonRootParts || isEntityName(nonRootParts)) {
49414
49374
  if (nonRootParts) {
@@ -49967,18 +49927,6 @@ function createTypeChecker(host) {
49967
49927
  return factory.createStringLiteral(newName);
49968
49928
  }
49969
49929
  }
49970
- } else {
49971
- if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
49972
- const moduleSym = resolveExternalModuleNameWorker(
49973
- lit,
49974
- lit,
49975
- /*moduleNotFoundError*/
49976
- void 0
49977
- );
49978
- if (moduleSym) {
49979
- context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
49980
- }
49981
- }
49982
49930
  }
49983
49931
  return lit;
49984
49932
  }
@@ -80543,14 +80491,16 @@ function createTypeChecker(host) {
80543
80491
  if (!(nodeLinks2.flags & 1024 /* EnumValuesComputed */)) {
80544
80492
  nodeLinks2.flags |= 1024 /* EnumValuesComputed */;
80545
80493
  let autoValue = 0;
80494
+ let previous;
80546
80495
  for (const member of node.members) {
80547
- const value = computeMemberValue(member, autoValue);
80496
+ const value = computeMemberValue(member, autoValue, previous);
80548
80497
  getNodeLinks(member).enumMemberValue = value;
80549
80498
  autoValue = typeof value === "number" ? value + 1 : void 0;
80499
+ previous = member;
80550
80500
  }
80551
80501
  }
80552
80502
  }
80553
- function computeMemberValue(member, autoValue) {
80503
+ function computeMemberValue(member, autoValue, previous) {
80554
80504
  if (isComputedNonLiteralName(member.name)) {
80555
80505
  error(member.name, Diagnostics.Computed_property_names_are_not_allowed_in_enums);
80556
80506
  } else {
@@ -80565,11 +80515,17 @@ function createTypeChecker(host) {
80565
80515
  if (member.parent.flags & 33554432 /* Ambient */ && !isEnumConst(member.parent)) {
80566
80516
  return void 0;
80567
80517
  }
80568
- if (autoValue !== void 0) {
80569
- return autoValue;
80518
+ if (autoValue === void 0) {
80519
+ error(member.name, Diagnostics.Enum_member_must_have_initializer);
80520
+ return void 0;
80570
80521
  }
80571
- error(member.name, Diagnostics.Enum_member_must_have_initializer);
80572
- return void 0;
80522
+ if (getIsolatedModules(compilerOptions) && (previous == null ? void 0 : previous.initializer) && !isSyntacticallyNumericConstant(previous.initializer)) {
80523
+ error(
80524
+ member.name,
80525
+ Diagnostics.Enum_member_following_a_non_literal_numeric_member_must_have_an_initializer_when_isolatedModules_is_enabled
80526
+ );
80527
+ }
80528
+ return autoValue;
80573
80529
  }
80574
80530
  function computeConstantValue(member) {
80575
80531
  const isConstEnum = isEnumConst(member.parent);
@@ -80581,6 +80537,12 @@ function createTypeChecker(host) {
80581
80537
  initializer,
80582
80538
  isNaN(value) ? Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN : Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value
80583
80539
  );
80540
+ } else if (getIsolatedModules(compilerOptions) && typeof value === "string" && !isSyntacticallyString(initializer)) {
80541
+ error(
80542
+ initializer,
80543
+ Diagnostics._0_has_a_string_type_but_must_have_syntactically_recognizable_string_syntax_when_isolatedModules_is_enabled,
80544
+ `${idText(member.parent.name)}.${getTextOfPropertyName(member.name)}`
80545
+ );
80584
80546
  }
80585
80547
  } else if (isConstEnum) {
80586
80548
  error(initializer, Diagnostics.const_enum_member_initializers_must_be_constant_expressions);
@@ -80591,6 +80553,18 @@ function createTypeChecker(host) {
80591
80553
  }
80592
80554
  return value;
80593
80555
  }
80556
+ function isSyntacticallyNumericConstant(expr) {
80557
+ expr = skipOuterExpressions(expr);
80558
+ switch (expr.kind) {
80559
+ case 224 /* PrefixUnaryExpression */:
80560
+ return isSyntacticallyNumericConstant(expr.operand);
80561
+ case 226 /* BinaryExpression */:
80562
+ return isSyntacticallyNumericConstant(expr.left) && isSyntacticallyNumericConstant(expr.right);
80563
+ case 9 /* NumericLiteral */:
80564
+ return true;
80565
+ }
80566
+ return false;
80567
+ }
80594
80568
  function evaluate(expr, location) {
80595
80569
  switch (expr.kind) {
80596
80570
  case 224 /* PrefixUnaryExpression */:
@@ -82620,23 +82594,6 @@ function createTypeChecker(host) {
82620
82594
  const isPropertyName2 = (isPropertyAccessExpression(parent) || isPropertyAssignment(parent)) && parent.name === node;
82621
82595
  return !isPropertyName2 && getReferencedValueSymbol(node) === argumentsSymbol;
82622
82596
  }
82623
- function moduleExportsSomeValue(moduleReferenceExpression) {
82624
- let moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
82625
- if (!moduleSymbol || isShorthandAmbientModuleSymbol(moduleSymbol)) {
82626
- return true;
82627
- }
82628
- const hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
82629
- moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
82630
- const symbolLinks2 = getSymbolLinks(moduleSymbol);
82631
- if (symbolLinks2.exportsSomeValue === void 0) {
82632
- symbolLinks2.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & 111551 /* Value */) : forEachEntry(getExportsOfModule(moduleSymbol), isValue);
82633
- }
82634
- return symbolLinks2.exportsSomeValue;
82635
- function isValue(s) {
82636
- s = resolveSymbol(s);
82637
- return s && !!(getSymbolFlags(s) & 111551 /* Value */);
82638
- }
82639
- }
82640
82597
  function isNameOfModuleOrEnumDeclaration(node) {
82641
82598
  return isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
82642
82599
  }
@@ -83213,20 +83170,6 @@ function createTypeChecker(host) {
83213
83170
  }
83214
83171
  }
83215
83172
  function createResolver() {
83216
- const resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
83217
- let fileToDirective;
83218
- if (resolvedTypeReferenceDirectives) {
83219
- fileToDirective = /* @__PURE__ */ new Map();
83220
- resolvedTypeReferenceDirectives.forEach(({ resolvedTypeReferenceDirective }, key, mode) => {
83221
- if (!(resolvedTypeReferenceDirective == null ? void 0 : resolvedTypeReferenceDirective.resolvedFileName)) {
83222
- return;
83223
- }
83224
- const file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
83225
- if (file) {
83226
- addReferencedFilesToTypeDirective(file, key, mode);
83227
- }
83228
- });
83229
- }
83230
83173
  return {
83231
83174
  getReferencedExportContainer,
83232
83175
  getReferencedImportDeclaration,
@@ -83266,14 +83209,11 @@ function createTypeChecker(host) {
83266
83209
  getReferencedValueDeclarations,
83267
83210
  getTypeReferenceSerializationKind,
83268
83211
  isOptionalParameter,
83269
- moduleExportsSomeValue,
83270
83212
  isArgumentsLocalBinding,
83271
83213
  getExternalModuleFileFromDeclaration: (nodeIn) => {
83272
83214
  const node = getParseTreeNode(nodeIn, hasPossibleExternalModuleReference);
83273
83215
  return node && getExternalModuleFileFromDeclaration(node);
83274
83216
  },
83275
- getTypeReferenceDirectivesForEntityName,
83276
- getTypeReferenceDirectivesForSymbol,
83277
83217
  isLiteralConstDeclaration,
83278
83218
  isLateBound: (nodeIn) => {
83279
83219
  const node = getParseTreeNode(nodeIn, isDeclaration);
@@ -83297,12 +83237,6 @@ function createTypeChecker(host) {
83297
83237
  getAccessor
83298
83238
  };
83299
83239
  },
83300
- getSymbolOfExternalModuleSpecifier: (moduleName) => resolveExternalModuleNameWorker(
83301
- moduleName,
83302
- moduleName,
83303
- /*moduleNotFoundError*/
83304
- void 0
83305
- ),
83306
83240
  isBindingCapturedByNode: (node, decl) => {
83307
83241
  const parseNode = getParseTreeNode(node);
83308
83242
  const parseDecl = getParseTreeNode(decl);
@@ -83317,16 +83251,7 @@ function createTypeChecker(host) {
83317
83251
  }
83318
83252
  return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
83319
83253
  },
83320
- isImportRequiredByAugmentation,
83321
- tryFindAmbientModule: (moduleReferenceExpression) => {
83322
- const node = getParseTreeNode(moduleReferenceExpression);
83323
- const moduleSpecifier = node && isStringLiteralLike(node) ? node.text : void 0;
83324
- return moduleSpecifier !== void 0 ? tryFindAmbientModule(
83325
- moduleSpecifier,
83326
- /*withAugmentations*/
83327
- true
83328
- ) : void 0;
83329
- }
83254
+ isImportRequiredByAugmentation
83330
83255
  };
83331
83256
  function isImportRequiredByAugmentation(node) {
83332
83257
  const file = getSourceFileOfNode(node);
@@ -83353,84 +83278,6 @@ function createTypeChecker(host) {
83353
83278
  }
83354
83279
  return false;
83355
83280
  }
83356
- function isInHeritageClause(node) {
83357
- return node.parent && node.parent.kind === 233 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 298 /* HeritageClause */;
83358
- }
83359
- function getTypeReferenceDirectivesForEntityName(node) {
83360
- if (!fileToDirective) {
83361
- return void 0;
83362
- }
83363
- let meaning;
83364
- if (node.parent.kind === 167 /* ComputedPropertyName */) {
83365
- meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
83366
- } else {
83367
- meaning = 788968 /* Type */ | 1920 /* Namespace */;
83368
- if (node.kind === 80 /* Identifier */ && isInTypeQuery(node) || node.kind === 211 /* PropertyAccessExpression */ && !isInHeritageClause(node)) {
83369
- meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
83370
- }
83371
- }
83372
- const symbol = resolveEntityName(
83373
- node,
83374
- meaning,
83375
- /*ignoreErrors*/
83376
- true
83377
- );
83378
- return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : void 0;
83379
- }
83380
- function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
83381
- if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) {
83382
- return void 0;
83383
- }
83384
- let typeReferenceDirectives;
83385
- for (const decl of symbol.declarations) {
83386
- if (decl.symbol && decl.symbol.flags & meaning) {
83387
- const file = getSourceFileOfNode(decl);
83388
- const typeReferenceDirective = fileToDirective.get(file.path);
83389
- if (typeReferenceDirective) {
83390
- (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
83391
- } else {
83392
- return void 0;
83393
- }
83394
- }
83395
- }
83396
- return typeReferenceDirectives;
83397
- }
83398
- function isSymbolFromTypeDeclarationFile(symbol) {
83399
- if (!symbol.declarations) {
83400
- return false;
83401
- }
83402
- let current = symbol;
83403
- while (true) {
83404
- const parent = getParentOfSymbol(current);
83405
- if (parent) {
83406
- current = parent;
83407
- } else {
83408
- break;
83409
- }
83410
- }
83411
- if (current.valueDeclaration && current.valueDeclaration.kind === 307 /* SourceFile */ && current.flags & 512 /* ValueModule */) {
83412
- return false;
83413
- }
83414
- for (const decl of symbol.declarations) {
83415
- const file = getSourceFileOfNode(decl);
83416
- if (fileToDirective.has(file.path)) {
83417
- return true;
83418
- }
83419
- }
83420
- return false;
83421
- }
83422
- function addReferencedFilesToTypeDirective(file, key, mode) {
83423
- if (fileToDirective.has(file.path))
83424
- return;
83425
- fileToDirective.set(file.path, [key, mode]);
83426
- for (const { fileName } of file.referencedFiles) {
83427
- const resolvedFile = resolveTripleslashReference(fileName, file.fileName);
83428
- const referencedFile = host.getSourceFile(resolvedFile);
83429
- if (referencedFile) {
83430
- addReferencedFilesToTypeDirective(referencedFile, key, mode || file.impliedNodeFormat);
83431
- }
83432
- }
83433
- }
83434
83281
  }
83435
83282
  function getExternalModuleFileFromDeclaration(declaration) {
83436
83283
  const specifier = declaration.kind === 267 /* ModuleDeclaration */ ? tryCast(declaration.name, isStringLiteral) : getExternalModuleName(declaration);
@@ -85354,20 +85201,6 @@ var SymbolTrackerImpl = class _SymbolTrackerImpl {
85354
85201
  this.inner.reportTruncationError();
85355
85202
  }
85356
85203
  }
85357
- trackReferencedAmbientModule(decl, symbol) {
85358
- var _a;
85359
- if ((_a = this.inner) == null ? void 0 : _a.trackReferencedAmbientModule) {
85360
- this.onDiagnosticReported();
85361
- this.inner.trackReferencedAmbientModule(decl, symbol);
85362
- }
85363
- }
85364
- trackExternalModuleSymbolOfImportTypeNode(symbol) {
85365
- var _a;
85366
- if ((_a = this.inner) == null ? void 0 : _a.trackExternalModuleSymbolOfImportTypeNode) {
85367
- this.onDiagnosticReported();
85368
- this.inner.trackExternalModuleSymbolOfImportTypeNode(symbol);
85369
- }
85370
- }
85371
85204
  reportNonlocalAugmentation(containingFile, parentSymbol, augmentingSymbol) {
85372
85205
  var _a;
85373
85206
  if ((_a = this.inner) == null ? void 0 : _a.reportNonlocalAugmentation) {
@@ -108372,11 +108205,9 @@ function transformDeclarations(context) {
108372
108205
  let needsScopeFixMarker = false;
108373
108206
  let resultHasScopeMarker = false;
108374
108207
  let enclosingDeclaration;
108375
- let necessaryTypeReferences;
108376
108208
  let lateMarkedStatements;
108377
108209
  let lateStatementReplacementMap;
108378
108210
  let suppressNewDiagnosticContexts;
108379
- let exportedModulesFromDeclarationEmit;
108380
108211
  const { factory: factory2 } = context;
108381
108212
  const host = context.getEmitHost();
108382
108213
  const symbolTracker = {
@@ -108388,49 +108219,19 @@ function transformDeclarations(context) {
108388
108219
  reportLikelyUnsafeImportRequiredError,
108389
108220
  reportTruncationError,
108390
108221
  moduleResolverHost: host,
108391
- trackReferencedAmbientModule,
108392
- trackExternalModuleSymbolOfImportTypeNode,
108393
108222
  reportNonlocalAugmentation,
108394
108223
  reportNonSerializableProperty
108395
108224
  };
108396
108225
  let errorNameNode;
108397
108226
  let errorFallbackNode;
108398
108227
  let currentSourceFile;
108399
- let refs;
108400
- let libs2;
108401
- let emittedImports;
108228
+ let rawReferencedFiles;
108229
+ let rawTypeReferenceDirectives;
108230
+ let rawLibReferenceDirectives;
108402
108231
  const resolver = context.getEmitResolver();
108403
108232
  const options = context.getCompilerOptions();
108404
- const { noResolve, stripInternal } = options;
108233
+ const { stripInternal } = options;
108405
108234
  return transformRoot;
108406
- function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
108407
- if (!typeReferenceDirectives) {
108408
- return;
108409
- }
108410
- necessaryTypeReferences = necessaryTypeReferences || /* @__PURE__ */ new Set();
108411
- for (const ref of typeReferenceDirectives) {
108412
- necessaryTypeReferences.add(ref);
108413
- }
108414
- }
108415
- function trackReferencedAmbientModule(node, symbol) {
108416
- const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, -1 /* All */);
108417
- if (length(directives)) {
108418
- return recordTypeReferenceDirectivesIfNecessary(directives);
108419
- }
108420
- const container = getSourceFileOfNode(node);
108421
- refs.set(getOriginalNodeId(container), container);
108422
- }
108423
- function trackReferencedAmbientModuleFromImport(node) {
108424
- const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(node);
108425
- const symbol = moduleSpecifier && resolver.tryFindAmbientModule(moduleSpecifier);
108426
- if (symbol == null ? void 0 : symbol.declarations) {
108427
- for (const decl of symbol.declarations) {
108428
- if (isAmbientModule(decl) && getSourceFileOfNode(decl) !== currentSourceFile) {
108429
- trackReferencedAmbientModule(decl, symbol);
108430
- }
108431
- }
108432
- }
108433
- }
108434
108235
  function handleSymbolAccessibilityError(symbolAccessibilityResult) {
108435
108236
  if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
108436
108237
  if (symbolAccessibilityResult.aliasesToMakeVisible) {
@@ -108455,11 +108256,6 @@ function transformDeclarations(context) {
108455
108256
  }
108456
108257
  return false;
108457
108258
  }
108458
- function trackExternalModuleSymbolOfImportTypeNode(symbol) {
108459
- if (!isBundledEmit) {
108460
- (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
108461
- }
108462
- }
108463
108259
  function trackSymbol(symbol, enclosingDeclaration2, meaning) {
108464
108260
  if (symbol.flags & 262144 /* TypeParameter */)
108465
108261
  return false;
@@ -108470,7 +108266,6 @@ function transformDeclarations(context) {
108470
108266
  /*shouldComputeAliasToMarkVisible*/
108471
108267
  true
108472
108268
  ));
108473
- recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
108474
108269
  return issuedDiagnostic;
108475
108270
  }
108476
108271
  function reportPrivateInBaseOfClassExpression(propertyName) {
@@ -108542,8 +108337,9 @@ function transformDeclarations(context) {
108542
108337
  }
108543
108338
  if (node.kind === 308 /* Bundle */) {
108544
108339
  isBundledEmit = true;
108545
- refs = /* @__PURE__ */ new Map();
108546
- libs2 = /* @__PURE__ */ new Map();
108340
+ rawReferencedFiles = [];
108341
+ rawTypeReferenceDirectives = [];
108342
+ rawLibReferenceDirectives = [];
108547
108343
  let hasNoDefaultLib = false;
108548
108344
  const bundle = factory2.createBundle(
108549
108345
  map(node.sourceFiles, (sourceFile) => {
@@ -108558,8 +108354,7 @@ function transformDeclarations(context) {
108558
108354
  getSymbolAccessibilityDiagnostic = throwDiagnostic;
108559
108355
  needsScopeFixMarker = false;
108560
108356
  resultHasScopeMarker = false;
108561
- collectReferences(sourceFile, refs);
108562
- collectLibs(sourceFile, libs2);
108357
+ collectFileReferences(sourceFile);
108563
108358
  if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) {
108564
108359
  resultHasExternalModuleIndicator = false;
108565
108360
  needsDeclare = false;
@@ -108606,18 +108401,16 @@ function transformDeclarations(context) {
108606
108401
  );
108607
108402
  })
108608
108403
  );
108609
- bundle.syntheticFileReferences = [];
108610
- bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
108611
- bundle.syntheticLibReferences = getLibReferences();
108612
- bundle.hasNoDefaultLib = hasNoDefaultLib;
108613
108404
  const outputFilePath2 = getDirectoryPath(normalizeSlashes(getOutputPathsFor(
108614
108405
  node,
108615
108406
  host,
108616
108407
  /*forceDtsPaths*/
108617
108408
  true
108618
108409
  ).declarationFilePath));
108619
- const referenceVisitor2 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath2);
108620
- refs.forEach(referenceVisitor2);
108410
+ bundle.syntheticFileReferences = getReferencedFiles(outputFilePath2);
108411
+ bundle.syntheticTypeReferences = getTypeReferences();
108412
+ bundle.syntheticLibReferences = getLibReferences();
108413
+ bundle.hasNoDefaultLib = hasNoDefaultLib;
108621
108414
  return bundle;
108622
108415
  }
108623
108416
  needsDeclare = true;
@@ -108631,66 +108424,68 @@ function transformDeclarations(context) {
108631
108424
  suppressNewDiagnosticContexts = false;
108632
108425
  lateMarkedStatements = void 0;
108633
108426
  lateStatementReplacementMap = /* @__PURE__ */ new Map();
108634
- necessaryTypeReferences = void 0;
108635
- refs = collectReferences(currentSourceFile, /* @__PURE__ */ new Map());
108636
- libs2 = collectLibs(currentSourceFile, /* @__PURE__ */ new Map());
108637
- const references = [];
108638
- const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(
108639
- node,
108640
- host,
108641
- /*forceDtsPaths*/
108642
- true
108643
- ).declarationFilePath));
108644
- const referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
108427
+ rawReferencedFiles = [];
108428
+ rawTypeReferenceDirectives = [];
108429
+ rawLibReferenceDirectives = [];
108430
+ collectFileReferences(currentSourceFile);
108645
108431
  let combinedStatements;
108646
108432
  if (isSourceFileJS(currentSourceFile)) {
108647
108433
  combinedStatements = factory2.createNodeArray(transformDeclarationsForJS(node));
108648
- refs.forEach(referenceVisitor);
108649
- emittedImports = filter(combinedStatements, isAnyImportSyntax);
108650
108434
  } else {
108651
108435
  const statements = visitNodes2(node.statements, visitDeclarationStatements, isStatement);
108652
108436
  combinedStatements = setTextRange(factory2.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
108653
- refs.forEach(referenceVisitor);
108654
- emittedImports = filter(combinedStatements, isAnyImportSyntax);
108655
108437
  if (isExternalModule(node) && (!resultHasExternalModuleIndicator || needsScopeFixMarker && !resultHasScopeMarker)) {
108656
108438
  combinedStatements = setTextRange(factory2.createNodeArray([...combinedStatements, createEmptyExports(factory2)]), combinedStatements);
108657
108439
  }
108658
108440
  }
108441
+ const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(
108442
+ node,
108443
+ host,
108444
+ /*forceDtsPaths*/
108445
+ true
108446
+ ).declarationFilePath));
108659
108447
  return factory2.updateSourceFile(
108660
108448
  node,
108661
108449
  combinedStatements,
108662
108450
  /*isDeclarationFile*/
108663
108451
  true,
108664
- references,
108665
- getFileReferencesForUsedTypeReferences(),
108452
+ getReferencedFiles(outputFilePath),
108453
+ getTypeReferences(),
108666
108454
  node.hasNoDefaultLib,
108667
108455
  getLibReferences()
108668
108456
  );
108669
- function getLibReferences() {
108670
- return arrayFrom(libs2.keys(), (lib) => ({ fileName: lib, pos: -1, end: -1 }));
108457
+ function collectFileReferences(sourceFile) {
108458
+ rawReferencedFiles = concatenate(rawReferencedFiles, map(sourceFile.referencedFiles, (f) => [sourceFile, f]));
108459
+ rawTypeReferenceDirectives = concatenate(rawTypeReferenceDirectives, sourceFile.typeReferenceDirectives);
108460
+ rawLibReferenceDirectives = concatenate(rawLibReferenceDirectives, sourceFile.libReferenceDirectives);
108671
108461
  }
108672
- function getFileReferencesForUsedTypeReferences() {
108673
- return necessaryTypeReferences ? mapDefined(arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
108462
+ function copyFileReferenceAsSynthetic(ref) {
108463
+ const newRef = { ...ref };
108464
+ newRef.pos = -1;
108465
+ newRef.end = -1;
108466
+ return newRef;
108674
108467
  }
108675
- function getFileReferenceForSpecifierModeTuple([typeName, mode]) {
108676
- if (emittedImports) {
108677
- for (const importStatement of emittedImports) {
108678
- if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) {
108679
- const expr = importStatement.moduleReference.expression;
108680
- if (isStringLiteralLike(expr) && expr.text === typeName) {
108681
- return void 0;
108682
- }
108683
- } else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
108684
- return void 0;
108685
- }
108686
- }
108687
- }
108688
- return { fileName: typeName, pos: -1, end: -1, ...mode ? { resolutionMode: mode } : void 0 };
108468
+ function getTypeReferences() {
108469
+ return mapDefined(rawTypeReferenceDirectives, (ref) => {
108470
+ if (!ref.preserve)
108471
+ return void 0;
108472
+ return copyFileReferenceAsSynthetic(ref);
108473
+ });
108689
108474
  }
108690
- function mapReferencesIntoArray(references2, outputFilePath2) {
108691
- return (file) => {
108692
- if (exportedModulesFromDeclarationEmit == null ? void 0 : exportedModulesFromDeclarationEmit.includes(file.symbol)) {
108693
- return;
108475
+ function getLibReferences() {
108476
+ return mapDefined(rawLibReferenceDirectives, (ref) => {
108477
+ if (!ref.preserve)
108478
+ return void 0;
108479
+ return copyFileReferenceAsSynthetic(ref);
108480
+ });
108481
+ }
108482
+ function getReferencedFiles(outputFilePath2) {
108483
+ return mapDefined(rawReferencedFiles, ([sourceFile, ref]) => {
108484
+ if (!ref.preserve)
108485
+ return void 0;
108486
+ const file = host.getSourceFileFromReference(sourceFile, ref);
108487
+ if (!file) {
108488
+ return void 0;
108694
108489
  }
108695
108490
  let declFileName;
108696
108491
  if (file.isDeclarationFile) {
@@ -108706,61 +108501,22 @@ function transformDeclarations(context) {
108706
108501
  );
108707
108502
  declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
108708
108503
  }
108709
- if (declFileName) {
108710
- const specifier = getModuleSpecifier(
108711
- options,
108712
- currentSourceFile,
108713
- getNormalizedAbsolutePath(outputFilePath2, host.getCurrentDirectory()),
108714
- getNormalizedAbsolutePath(declFileName, host.getCurrentDirectory()),
108715
- host
108716
- );
108717
- if (!pathIsRelative(specifier)) {
108718
- recordTypeReferenceDirectivesIfNecessary([[
108719
- specifier,
108720
- /*mode*/
108721
- void 0
108722
- ]]);
108723
- return;
108724
- }
108725
- let fileName = getRelativePathToDirectoryOrUrl(
108726
- outputFilePath2,
108727
- declFileName,
108728
- host.getCurrentDirectory(),
108729
- host.getCanonicalFileName,
108730
- /*isAbsolutePathAnUrl*/
108731
- false
108732
- );
108733
- if (startsWith(fileName, "./") && hasExtension(fileName)) {
108734
- fileName = fileName.substring(2);
108735
- }
108736
- if (startsWith(fileName, "node_modules/") || pathContainsNodeModules(fileName)) {
108737
- return;
108738
- }
108739
- references2.push({ pos: -1, end: -1, fileName });
108740
- }
108741
- };
108504
+ if (!declFileName)
108505
+ return void 0;
108506
+ const fileName = getRelativePathToDirectoryOrUrl(
108507
+ outputFilePath2,
108508
+ declFileName,
108509
+ host.getCurrentDirectory(),
108510
+ host.getCanonicalFileName,
108511
+ /*isAbsolutePathAnUrl*/
108512
+ false
108513
+ );
108514
+ const newRef = copyFileReferenceAsSynthetic(ref);
108515
+ newRef.fileName = fileName;
108516
+ return newRef;
108517
+ });
108742
108518
  }
108743
108519
  }
108744
- function collectReferences(sourceFile, ret) {
108745
- if (noResolve || isSourceFileJS(sourceFile))
108746
- return ret;
108747
- forEach(sourceFile.referencedFiles, (f) => {
108748
- const elem = host.getSourceFileFromReference(sourceFile, f);
108749
- if (elem) {
108750
- ret.set(getOriginalNodeId(elem), elem);
108751
- }
108752
- });
108753
- return ret;
108754
- }
108755
- function collectLibs(sourceFile, ret) {
108756
- forEach(sourceFile.libReferenceDirectives, (ref) => {
108757
- const lib = host.getLibFileFromReference(ref);
108758
- if (lib) {
108759
- ret.set(toFileNameLowerCase(ref.fileName), true);
108760
- }
108761
- });
108762
- return ret;
108763
- }
108764
108520
  function filterBindingPatternInitializers(name) {
108765
108521
  if (name.kind === 80 /* Identifier */) {
108766
108522
  return name;
@@ -108959,7 +108715,6 @@ function transformDeclarations(context) {
108959
108715
  function checkEntityNameVisibility(entityName, enclosingDeclaration2) {
108960
108716
  const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration2);
108961
108717
  handleSymbolAccessibilityError(visibilityResult);
108962
- recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
108963
108718
  }
108964
108719
  function preserveJsDoc(updated, original) {
108965
108720
  if (hasJSDocNodes(updated) && hasJSDocNodes(original)) {
@@ -108977,11 +108732,6 @@ function transformDeclarations(context) {
108977
108732
  if (newName) {
108978
108733
  return factory2.createStringLiteral(newName);
108979
108734
  }
108980
- } else {
108981
- const symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
108982
- if (symbol) {
108983
- (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
108984
- }
108985
108735
  }
108986
108736
  }
108987
108737
  return input;
@@ -109374,7 +109124,6 @@ function transformDeclarations(context) {
109374
109124
  case 205 /* ImportType */: {
109375
109125
  if (!isLiteralImportTypeNode(input))
109376
109126
  return cleanup(input);
109377
- trackReferencedAmbientModuleFromImport(input);
109378
109127
  return cleanup(factory2.updateImportTypeNode(
109379
109128
  input,
109380
109129
  factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
@@ -109426,7 +109175,6 @@ function transformDeclarations(context) {
109426
109175
  resultHasExternalModuleIndicator = true;
109427
109176
  }
109428
109177
  resultHasScopeMarker = true;
109429
- trackReferencedAmbientModuleFromImport(input);
109430
109178
  return factory2.updateExportDeclaration(
109431
109179
  input,
109432
109180
  input.modifiers,
@@ -109501,18 +109249,10 @@ function transformDeclarations(context) {
109501
109249
  return;
109502
109250
  switch (input.kind) {
109503
109251
  case 271 /* ImportEqualsDeclaration */: {
109504
- const transformed = transformImportEqualsDeclaration(input);
109505
- if (transformed) {
109506
- trackReferencedAmbientModuleFromImport(input);
109507
- }
109508
- return transformed;
109252
+ return transformImportEqualsDeclaration(input);
109509
109253
  }
109510
109254
  case 272 /* ImportDeclaration */: {
109511
- const transformed = transformImportDeclaration(input);
109512
- if (transformed) {
109513
- trackReferencedAmbientModuleFromImport(input);
109514
- }
109515
- return transformed;
109255
+ return transformImportDeclaration(input);
109516
109256
  }
109517
109257
  }
109518
109258
  if (isDeclaration(input) && isDeclarationAndNotVisible(input))
@@ -111071,20 +110811,15 @@ var notImplementedResolver = {
111071
110811
  getReferencedValueDeclarations: notImplemented,
111072
110812
  getTypeReferenceSerializationKind: notImplemented,
111073
110813
  isOptionalParameter: notImplemented,
111074
- moduleExportsSomeValue: notImplemented,
111075
110814
  isArgumentsLocalBinding: notImplemented,
111076
110815
  getExternalModuleFileFromDeclaration: notImplemented,
111077
- getTypeReferenceDirectivesForEntityName: notImplemented,
111078
- getTypeReferenceDirectivesForSymbol: notImplemented,
111079
110816
  isLiteralConstDeclaration: notImplemented,
111080
110817
  getJsxFactoryEntity: notImplemented,
111081
110818
  getJsxFragmentFactoryEntity: notImplemented,
111082
110819
  getAllAccessorDeclarations: notImplemented,
111083
- getSymbolOfExternalModuleSpecifier: notImplemented,
111084
110820
  isBindingCapturedByNode: notImplemented,
111085
110821
  getDeclarationStatementsForSourceFile: notImplemented,
111086
- isImportRequiredByAugmentation: notImplemented,
111087
- tryFindAmbientModule: notImplemented
110822
+ isImportRequiredByAugmentation: notImplemented
111088
110823
  };
111089
110824
  var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
111090
110825
  var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@@ -113839,19 +113574,17 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113839
113574
  writeLine();
113840
113575
  }
113841
113576
  }
113842
- for (const directive of files) {
113843
- writeComment(`/// <reference path="${directive.fileName}" />`);
113844
- writeLine();
113845
- }
113846
- for (const directive of types) {
113847
- const resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile == null ? void 0 : currentSourceFile.impliedNodeFormat) ? `resolution-mode="${directive.resolutionMode === 99 /* ESNext */ ? "import" : "require"}"` : "";
113848
- writeComment(`/// <reference types="${directive.fileName}" ${resolutionMode}/>`);
113849
- writeLine();
113850
- }
113851
- for (const directive of libs2) {
113852
- writeComment(`/// <reference lib="${directive.fileName}" />`);
113853
- writeLine();
113577
+ function writeDirectives(kind, directives) {
113578
+ for (const directive of directives) {
113579
+ const preserve = directive.preserve ? `preserve="true" ` : "";
113580
+ const resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile == null ? void 0 : currentSourceFile.impliedNodeFormat) ? `resolution-mode="${directive.resolutionMode === 99 /* ESNext */ ? "import" : "require"}" ` : "";
113581
+ writeComment(`/// <reference ${kind}="${directive.fileName}" ${resolutionMode}${preserve}/>`);
113582
+ writeLine();
113583
+ }
113854
113584
  }
113585
+ writeDirectives("path", files);
113586
+ writeDirectives("types", types);
113587
+ writeDirectives("lib", libs2);
113855
113588
  }
113856
113589
  function emitSourceFileWorker(node) {
113857
113590
  const statements = node.statements;
@@ -117688,7 +117421,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117688
117421
  getSourceFile: program.getSourceFile,
117689
117422
  getSourceFileByPath: program.getSourceFileByPath,
117690
117423
  getSourceFiles: program.getSourceFiles,
117691
- getLibFileFromReference: program.getLibFileFromReference,
117692
117424
  isSourceFileFromExternalLibrary,
117693
117425
  getResolvedProjectReferenceToRedirect,
117694
117426
  getProjectReferenceRedirect,