typescript 5.5.0-dev.20240408 → 5.5.0-dev.20240410

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/typescript.js CHANGED
@@ -414,6 +414,7 @@ __export(typescript_exports, {
414
414
  createFileDiagnosticFromMessageChain: () => createFileDiagnosticFromMessageChain,
415
415
  createFlowNode: () => createFlowNode,
416
416
  createForOfBindingStatement: () => createForOfBindingStatement,
417
+ createFutureSourceFile: () => createFutureSourceFile,
417
418
  createGetCanonicalFileName: () => createGetCanonicalFileName,
418
419
  createGetSourceFile: () => createGetSourceFile,
419
420
  createGetSymbolAccessibilityDiagnosticForNode: () => createGetSymbolAccessibilityDiagnosticForNode,
@@ -1185,6 +1186,7 @@ __export(typescript_exports, {
1185
1186
  isAnyDirectorySeparator: () => isAnyDirectorySeparator,
1186
1187
  isAnyImportOrBareOrAccessedRequire: () => isAnyImportOrBareOrAccessedRequire,
1187
1188
  isAnyImportOrReExport: () => isAnyImportOrReExport,
1189
+ isAnyImportOrRequireStatement: () => isAnyImportOrRequireStatement,
1188
1190
  isAnyImportSyntax: () => isAnyImportSyntax,
1189
1191
  isAnySupportedFileExtension: () => isAnySupportedFileExtension,
1190
1192
  isApplicableVersionedTypesKey: () => isApplicableVersionedTypesKey,
@@ -1375,6 +1377,7 @@ __export(typescript_exports, {
1375
1377
  isForInitializer: () => isForInitializer,
1376
1378
  isForOfStatement: () => isForOfStatement,
1377
1379
  isForStatement: () => isForStatement,
1380
+ isFullSourceFile: () => isFullSourceFile,
1378
1381
  isFunctionBlock: () => isFunctionBlock,
1379
1382
  isFunctionBody: () => isFunctionBody,
1380
1383
  isFunctionDeclaration: () => isFunctionDeclaration,
@@ -2335,7 +2338,7 @@ module.exports = __toCommonJS(typescript_exports);
2335
2338
 
2336
2339
  // src/compiler/corePublic.ts
2337
2340
  var versionMajorMinor = "5.5";
2338
- var version = `${versionMajorMinor}.0-dev.20240408`;
2341
+ var version = `${versionMajorMinor}.0-dev.20240410`;
2339
2342
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2340
2343
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2341
2344
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -16246,6 +16249,9 @@ function isAnyImportSyntax(node) {
16246
16249
  function isAnyImportOrBareOrAccessedRequire(node) {
16247
16250
  return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
16248
16251
  }
16252
+ function isAnyImportOrRequireStatement(node) {
16253
+ return isAnyImportSyntax(node) || isRequireVariableStatement(node);
16254
+ }
16249
16255
  function isLateVisibilityPaintedStatement(node) {
16250
16256
  switch (node.kind) {
16251
16257
  case 272 /* ImportDeclaration */:
@@ -17282,6 +17288,9 @@ function getExternalModuleRequireArgument(node) {
17282
17288
  function isInternalModuleImportEqualsDeclaration(node) {
17283
17289
  return node.kind === 271 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 283 /* ExternalModuleReference */;
17284
17290
  }
17291
+ function isFullSourceFile(sourceFile) {
17292
+ return (sourceFile == null ? void 0 : sourceFile.kind) === 307 /* SourceFile */;
17293
+ }
17285
17294
  function isSourceFileJS(file) {
17286
17295
  return isInJSFile(file);
17287
17296
  }
@@ -21249,12 +21258,12 @@ function getModuleSpecifierEndingPreference(preference, resolutionMode, compiler
21249
21258
  return 1 /* Index */;
21250
21259
  }
21251
21260
  if (!shouldAllowImportingTsExtension(compilerOptions)) {
21252
- return usesExtensionsOnImports(sourceFile) ? 2 /* JsExtension */ : 0 /* Minimal */;
21261
+ return sourceFile && usesExtensionsOnImports(sourceFile) ? 2 /* JsExtension */ : 0 /* Minimal */;
21253
21262
  }
21254
21263
  return inferPreference();
21255
21264
  function inferPreference() {
21256
21265
  let usesJsExtensions = false;
21257
- const specifiers = sourceFile.imports.length ? sourceFile.imports : isSourceFileJS(sourceFile) ? getRequiresAtTopOfFile(sourceFile).map((r) => r.arguments[0]) : emptyArray;
21266
+ const specifiers = (sourceFile == null ? void 0 : sourceFile.imports.length) ? sourceFile.imports : sourceFile && isSourceFileJS(sourceFile) ? getRequiresAtTopOfFile(sourceFile).map((r) => r.arguments[0]) : emptyArray;
21258
21267
  for (const specifier of specifiers) {
21259
21268
  if (pathIsRelative(specifier.text)) {
21260
21269
  if (moduleResolutionIsNodeNext && resolutionMode === 1 /* CommonJS */ && getModeForUsageLocation(sourceFile, specifier, compilerOptions) === 99 /* ESNext */) {
@@ -47310,6 +47319,7 @@ __export(ts_moduleSpecifiers_exports, {
47310
47319
  RelativePreference: () => RelativePreference,
47311
47320
  countPathComponents: () => countPathComponents,
47312
47321
  forEachFileNameOfModule: () => forEachFileNameOfModule,
47322
+ getLocalModuleSpecifierBetweenFileNames: () => getLocalModuleSpecifierBetweenFileNames,
47313
47323
  getModuleSpecifier: () => getModuleSpecifier,
47314
47324
  getModuleSpecifierPreferences: () => getModuleSpecifierPreferences,
47315
47325
  getModuleSpecifiers: () => getModuleSpecifiers,
@@ -47370,7 +47380,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
47370
47380
  importModuleSpecifierEnding,
47371
47381
  resolutionMode ?? importingSourceFile.impliedNodeFormat,
47372
47382
  compilerOptions,
47373
- importingSourceFile
47383
+ isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
47374
47384
  );
47375
47385
  }
47376
47386
  }
@@ -47475,10 +47485,22 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
47475
47485
  cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result);
47476
47486
  return { moduleSpecifiers: result, computedWithoutCache };
47477
47487
  }
47488
+ function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName, compilerOptions, host, options = {}) {
47489
+ const info = getInfo(importingFile.fileName, host);
47490
+ const importMode = options.overrideImportMode ?? importingFile.impliedNodeFormat;
47491
+ return getLocalModuleSpecifier(
47492
+ targetFileName,
47493
+ info,
47494
+ compilerOptions,
47495
+ host,
47496
+ importMode,
47497
+ getModuleSpecifierPreferences({}, compilerOptions, importingFile)
47498
+ );
47499
+ }
47478
47500
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
47479
47501
  const info = getInfo(importingSourceFile.fileName, host);
47480
47502
  const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
47481
- const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
47503
+ const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
47482
47504
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
47483
47505
  (reason) => {
47484
47506
  if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path)
@@ -52891,7 +52913,7 @@ function createTypeChecker(host) {
52891
52913
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
52892
52914
  typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
52893
52915
  expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
52894
- serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined)),
52916
+ serializeTypeForDeclaration: (declaration, type, symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, declaration, type, symbol)),
52895
52917
  serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
52896
52918
  indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
52897
52919
  indexInfo,
@@ -52914,6 +52936,18 @@ function createTypeChecker(host) {
52914
52936
  symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
52915
52937
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
52916
52938
  };
52939
+ function setTextRange2(context, range, location) {
52940
+ if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
52941
+ range = factory.cloneNode(range);
52942
+ }
52943
+ if (!location) {
52944
+ return range;
52945
+ }
52946
+ if (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(getOriginalNode(location))) {
52947
+ return setOriginalNode(range, location);
52948
+ }
52949
+ return setTextRange(setOriginalNode(range, location), location);
52950
+ }
52917
52951
  function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
52918
52952
  if (expr) {
52919
52953
  const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
@@ -52978,6 +53012,7 @@ function createTypeChecker(host) {
52978
53012
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
52979
53013
  const context = {
52980
53014
  enclosingDeclaration,
53015
+ enclosingFile: enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration),
52981
53016
  flags: flags || 0 /* None */,
52982
53017
  tracker: void 0,
52983
53018
  encounteredError: false,
@@ -53510,7 +53545,7 @@ function createTypeChecker(host) {
53510
53545
  if (!nodeIsSynthesized(node) && getParseTreeNode(node) === node) {
53511
53546
  return node;
53512
53547
  }
53513
- return setTextRange(factory.cloneNode(visitEachChild(
53548
+ return setTextRange2(context, factory.cloneNode(visitEachChild(
53514
53549
  node,
53515
53550
  deepCloneOrReuseNode,
53516
53551
  /*context*/
@@ -53852,7 +53887,13 @@ function createTypeChecker(host) {
53852
53887
  context.reverseMappedStack || (context.reverseMappedStack = []);
53853
53888
  context.reverseMappedStack.push(propertySymbol);
53854
53889
  }
53855
- propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
53890
+ propertyTypeNode = propertyType ? serializeTypeForDeclaration(
53891
+ context,
53892
+ /*declaration*/
53893
+ void 0,
53894
+ propertyType,
53895
+ propertySymbol
53896
+ ) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
53856
53897
  if (propertyIsReverseMapped) {
53857
53898
  context.reverseMappedStack.pop();
53858
53899
  }
@@ -54241,8 +54282,7 @@ function createTypeChecker(host) {
54241
54282
  function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
54242
54283
  const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
54243
54284
  const parameterType = getTypeOfSymbol(parameterSymbol);
54244
- const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
54245
- const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, addUndefined);
54285
+ const parameterTypeNode = serializeTypeForDeclaration(context, parameterDeclaration, parameterType, parameterSymbol);
54246
54286
  const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
54247
54287
  const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
54248
54288
  const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
@@ -54834,10 +54874,12 @@ function createTypeChecker(host) {
54834
54874
  }
54835
54875
  return enclosingDeclaration;
54836
54876
  }
54837
- function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined) {
54877
+ function serializeTypeForDeclaration(context, declaration, type, symbol) {
54838
54878
  var _a;
54879
+ const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
54880
+ const enclosingDeclaration = context.enclosingDeclaration;
54839
54881
  if (!isErrorType(type) && enclosingDeclaration) {
54840
- const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54882
+ const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54841
54883
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
54842
54884
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
54843
54885
  const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
@@ -54850,7 +54892,7 @@ function createTypeChecker(host) {
54850
54892
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
54851
54893
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
54852
54894
  }
54853
- const decl = symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
54895
+ const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
54854
54896
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
54855
54897
  const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
54856
54898
  context.flags = oldFlags;
@@ -54964,7 +55006,7 @@ function createTypeChecker(host) {
54964
55006
  const type = getDeclaredTypeOfSymbol(sym);
54965
55007
  const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
54966
55008
  name.symbol = sym;
54967
- return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
55009
+ return setTextRange2(context, setEmitFlags(name, 16777216 /* NoAsciiEscaping */), node2);
54968
55010
  }
54969
55011
  const updated = visitEachChild(
54970
55012
  node2,
@@ -54973,7 +55015,7 @@ function createTypeChecker(host) {
54973
55015
  void 0
54974
55016
  );
54975
55017
  if (updated !== node2) {
54976
- setTextRange(updated, node2);
55018
+ setTextRange2(context, updated, node2);
54977
55019
  }
54978
55020
  return updated;
54979
55021
  }
@@ -54987,12 +55029,12 @@ function createTypeChecker(host) {
54987
55029
  if (hadError) {
54988
55030
  return void 0;
54989
55031
  }
54990
- return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
55032
+ return transformed;
54991
55033
  function visitExistingNodeTreeSymbols(node) {
54992
55034
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
54993
55035
  const result = visitExistingNodeTreeSymbolsWorker(node);
54994
55036
  onExitNewScope == null ? void 0 : onExitNewScope();
54995
- return result;
55037
+ return result === node ? setTextRange2(context, factory.cloneNode(result), node) : result;
54996
55038
  }
54997
55039
  function onEnterNewScope(node) {
54998
55040
  const oldContex = context;
@@ -55128,7 +55170,7 @@ function createTypeChecker(host) {
55128
55170
  void 0
55129
55171
  );
55130
55172
  if (visited === node) {
55131
- visited = setTextRange(factory.cloneNode(node), node);
55173
+ visited = setTextRange2(context, factory.cloneNode(node), node);
55132
55174
  }
55133
55175
  visited.type = factory.createKeywordTypeNode(133 /* AnyKeyword */);
55134
55176
  if (isParameter(node)) {
@@ -55151,11 +55193,16 @@ function createTypeChecker(host) {
55151
55193
  /*context*/
55152
55194
  void 0
55153
55195
  );
55154
- const clone2 = setTextRange(visited === node ? factory.cloneNode(node) : visited, node);
55196
+ const clone2 = setTextRange2(context, visited === node ? factory.cloneNode(node) : visited, node);
55155
55197
  const flags = getEmitFlags(clone2);
55156
55198
  setEmitFlags(clone2, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
55157
55199
  return clone2;
55158
55200
  }
55201
+ if (isStringLiteral(node) && !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */) && !node.singleQuote) {
55202
+ const clone2 = factory.cloneNode(node);
55203
+ clone2.singleQuote = true;
55204
+ return clone2;
55205
+ }
55159
55206
  if (isConditionalTypeNode(node)) {
55160
55207
  const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
55161
55208
  const disposeScope = onEnterNewScope(node);
@@ -55534,7 +55581,8 @@ function createTypeChecker(host) {
55534
55581
  );
55535
55582
  context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
55536
55583
  } else {
55537
- const statement = setTextRange(
55584
+ const statement = setTextRange2(
55585
+ context,
55538
55586
  factory.createVariableStatement(
55539
55587
  /*modifiers*/
55540
55588
  void 0,
@@ -55543,7 +55591,13 @@ function createTypeChecker(host) {
55543
55591
  name,
55544
55592
  /*exclamationToken*/
55545
55593
  void 0,
55546
- serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration)
55594
+ serializeTypeForDeclaration(
55595
+ context,
55596
+ /*declaration*/
55597
+ void 0,
55598
+ type,
55599
+ symbol
55600
+ )
55547
55601
  )
55548
55602
  ], flags)
55549
55603
  ),
@@ -55816,7 +55870,7 @@ function createTypeChecker(host) {
55816
55870
  const signatures = getSignaturesOfType(type, 0 /* Call */);
55817
55871
  for (const sig of signatures) {
55818
55872
  const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
55819
- addResult(setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags);
55873
+ addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
55820
55874
  }
55821
55875
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
55822
55876
  const props = filter(getPropertiesOfType(type), isNamespaceMember);
@@ -55994,7 +56048,8 @@ function createTypeChecker(host) {
55994
56048
  const indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
55995
56049
  context.enclosingDeclaration = oldEnclosing;
55996
56050
  addResult(
55997
- setTextRange(
56051
+ setTextRange2(
56052
+ context,
55998
56053
  factory.createClassDeclaration(
55999
56054
  /*modifiers*/
56000
56055
  void 0,
@@ -56354,7 +56409,13 @@ function createTypeChecker(host) {
56354
56409
  varName,
56355
56410
  /*exclamationToken*/
56356
56411
  void 0,
56357
- serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration)
56412
+ serializeTypeForDeclaration(
56413
+ context,
56414
+ /*declaration*/
56415
+ void 0,
56416
+ typeToSerialize,
56417
+ symbol
56418
+ )
56358
56419
  )
56359
56420
  ], flags)
56360
56421
  );
@@ -56426,7 +56487,8 @@ function createTypeChecker(host) {
56426
56487
  });
56427
56488
  Debug.assert(!!setter);
56428
56489
  const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
56429
- result.push(setTextRange(
56490
+ result.push(setTextRange2(
56491
+ context,
56430
56492
  factory.createSetAccessorDeclaration(
56431
56493
  factory.createModifiersFromModifierFlags(flag),
56432
56494
  name,
@@ -56438,7 +56500,13 @@ function createTypeChecker(host) {
56438
56500
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
56439
56501
  /*questionToken*/
56440
56502
  void 0,
56441
- isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration)
56503
+ isPrivate ? void 0 : serializeTypeForDeclaration(
56504
+ context,
56505
+ /*declaration*/
56506
+ void 0,
56507
+ getTypeOfSymbol(p),
56508
+ p
56509
+ )
56442
56510
  )],
56443
56511
  /*body*/
56444
56512
  void 0
@@ -56448,12 +56516,19 @@ function createTypeChecker(host) {
56448
56516
  }
56449
56517
  if (p.flags & 32768 /* GetAccessor */) {
56450
56518
  const isPrivate2 = modifierFlags & 2 /* Private */;
56451
- result.push(setTextRange(
56519
+ result.push(setTextRange2(
56520
+ context,
56452
56521
  factory.createGetAccessorDeclaration(
56453
56522
  factory.createModifiersFromModifierFlags(flag),
56454
56523
  name,
56455
56524
  [],
56456
- isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration),
56525
+ isPrivate2 ? void 0 : serializeTypeForDeclaration(
56526
+ context,
56527
+ /*declaration*/
56528
+ void 0,
56529
+ getTypeOfSymbol(p),
56530
+ p
56531
+ ),
56457
56532
  /*body*/
56458
56533
  void 0
56459
56534
  ),
@@ -56462,12 +56537,19 @@ function createTypeChecker(host) {
56462
56537
  }
56463
56538
  return result;
56464
56539
  } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
56465
- return setTextRange(
56540
+ return setTextRange2(
56541
+ context,
56466
56542
  createProperty2(
56467
56543
  factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
56468
56544
  name,
56469
56545
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
56470
- isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration),
56546
+ isPrivate ? void 0 : serializeTypeForDeclaration(
56547
+ context,
56548
+ /*declaration*/
56549
+ void 0,
56550
+ getWriteTypeOfSymbol(p),
56551
+ p
56552
+ ),
56471
56553
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
56472
56554
  // interface members can't have initializers, however class members _can_
56473
56555
  /*initializer*/
@@ -56480,7 +56562,8 @@ function createTypeChecker(host) {
56480
56562
  const type = getTypeOfSymbol(p);
56481
56563
  const signatures = getSignaturesOfType(type, 0 /* Call */);
56482
56564
  if (flag & 2 /* Private */) {
56483
- return setTextRange(
56565
+ return setTextRange2(
56566
+ context,
56484
56567
  createProperty2(
56485
56568
  factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
56486
56569
  name,
@@ -56506,7 +56589,7 @@ function createTypeChecker(host) {
56506
56589
  }
56507
56590
  );
56508
56591
  const location = sig.declaration && isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration;
56509
- results2.push(setTextRange(decl, location));
56592
+ results2.push(setTextRange2(context, decl, location));
56510
56593
  }
56511
56594
  return results2;
56512
56595
  }
@@ -56562,7 +56645,8 @@ function createTypeChecker(host) {
56562
56645
  }
56563
56646
  }
56564
56647
  if (privateProtected) {
56565
- return [setTextRange(
56648
+ return [setTextRange2(
56649
+ context,
56566
56650
  factory.createConstructorDeclaration(
56567
56651
  factory.createModifiersFromModifierFlags(privateProtected),
56568
56652
  /*parameters*/
@@ -56577,7 +56661,7 @@ function createTypeChecker(host) {
56577
56661
  const results2 = [];
56578
56662
  for (const sig of signatures) {
56579
56663
  const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
56580
- results2.push(setTextRange(decl, sig.declaration));
56664
+ results2.push(setTextRange2(context, decl, sig.declaration));
56581
56665
  }
56582
56666
  return results2;
56583
56667
  }
@@ -60260,12 +60344,10 @@ function createTypeChecker(host) {
60260
60344
  const target = type.target ?? type;
60261
60345
  const typeVariable = getHomomorphicTypeVariable(target);
60262
60346
  if (typeVariable && !target.declaration.nameType) {
60263
- const constraint = getConstraintTypeFromMappedType(type);
60264
- if (constraint.flags & 4194304 /* Index */) {
60265
- const baseConstraint = getBaseConstraintOfType(constraint.type);
60266
- if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
60267
- return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
60268
- }
60347
+ const modifiersType = getModifiersTypeFromMappedType(type);
60348
+ const baseConstraint = isGenericMappedType(modifiersType) ? getApparentTypeOfMappedType(modifiersType) : getBaseConstraintOfType(modifiersType);
60349
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
60350
+ return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
60269
60351
  }
60270
60352
  }
60271
60353
  return type;
@@ -60426,13 +60508,13 @@ function createTypeChecker(host) {
60426
60508
  }
60427
60509
  function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
60428
60510
  var _a, _b, _c;
60429
- let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
60511
+ let property = skipObjectFunctionPropertyAugment ? (_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name) : (_b = type.propertyCache) == null ? void 0 : _b.get(name);
60430
60512
  if (!property) {
60431
60513
  property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
60432
60514
  if (property) {
60433
60515
  const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
60434
60516
  properties.set(name, property);
60435
- if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
60517
+ if (skipObjectFunctionPropertyAugment && !(getCheckFlags(property) & 48 /* Partial */) && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
60436
60518
  const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
60437
60519
  properties2.set(name, property);
60438
60520
  }
@@ -65695,7 +65777,7 @@ function createTypeChecker(host) {
65695
65777
  const sourceTypePredicate = getTypePredicateOfSignature(source);
65696
65778
  if (sourceTypePredicate) {
65697
65779
  result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes);
65698
- } else if (isIdentifierTypePredicate(targetTypePredicate)) {
65780
+ } else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
65699
65781
  if (reportErrors2) {
65700
65782
  errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
65701
65783
  }
@@ -88079,9 +88161,10 @@ function createTypeChecker(host) {
88079
88161
  return false;
88080
88162
  }
88081
88163
  function declaredParameterTypeContainsUndefined(parameter) {
88082
- if (!parameter.type)
88164
+ const typeNode = getNonlocalEffectiveTypeAnnotationNode(parameter);
88165
+ if (!typeNode)
88083
88166
  return false;
88084
- const type = getTypeFromTypeNode(parameter.type);
88167
+ const type = getTypeFromTypeNode(typeNode);
88085
88168
  return containsUndefinedType(type);
88086
88169
  }
88087
88170
  function requiresAddingImplicitUndefined(parameter) {
@@ -88091,7 +88174,7 @@ function createTypeChecker(host) {
88091
88174
  return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88092
88175
  }
88093
88176
  function isOptionalUninitializedParameterProperty(parameter) {
88094
- return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88177
+ return strictNullChecks && isOptionalParameter(parameter) && (isJSDocParameterTag(parameter) || !parameter.initializer) && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88095
88178
  }
88096
88179
  function isExpandoFunctionDeclaration(node) {
88097
88180
  const declaration = getParseTreeNode(node, isFunctionDeclaration);
@@ -88241,14 +88324,14 @@ function createTypeChecker(host) {
88241
88324
  return 11 /* ObjectType */;
88242
88325
  }
88243
88326
  }
88244
- function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
88327
+ function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker) {
88245
88328
  const declaration = getParseTreeNode(declarationIn, isVariableLikeOrAccessor);
88246
88329
  if (!declaration) {
88247
88330
  return factory.createToken(133 /* AnyKeyword */);
88248
88331
  }
88249
88332
  const symbol = getSymbolOfDeclaration(declaration);
88250
88333
  const type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
88251
- return nodeBuilder.serializeTypeForDeclaration(type, symbol, addUndefined, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
88334
+ return nodeBuilder.serializeTypeForDeclaration(declaration, type, symbol, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
88252
88335
  }
88253
88336
  function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
88254
88337
  return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
@@ -114088,7 +114171,7 @@ function transformDeclarations(context) {
114088
114171
  case 172 /* PropertyDeclaration */:
114089
114172
  case 208 /* BindingElement */:
114090
114173
  case 260 /* VariableDeclaration */:
114091
- typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldAddImplicitUndefined);
114174
+ typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker);
114092
114175
  break;
114093
114176
  case 262 /* FunctionDeclaration */:
114094
114177
  case 180 /* ConstructSignature */:
@@ -134627,7 +134710,7 @@ function getQuotePreference(sourceFile, preferences) {
134627
134710
  if (preferences.quotePreference && preferences.quotePreference !== "auto") {
134628
134711
  return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */;
134629
134712
  } else {
134630
- const firstModuleSpecifier = sourceFile.imports && find(sourceFile.imports, (n) => isStringLiteral(n) && !nodeIsSynthesized(n.parent));
134713
+ const firstModuleSpecifier = isFullSourceFile(sourceFile) && sourceFile.imports && find(sourceFile.imports, (n) => isStringLiteral(n) && !nodeIsSynthesized(n.parent));
134631
134714
  return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */;
134632
134715
  }
134633
134716
  }
@@ -134685,14 +134768,24 @@ function findModifier(node, kind) {
134685
134768
  return canHaveModifiers(node) ? find(node.modifiers, (m) => m.kind === kind) : void 0;
134686
134769
  }
134687
134770
  function insertImports(changes, sourceFile, imports, blankLineBetween, preferences) {
134771
+ var _a;
134688
134772
  const decl = isArray(imports) ? imports[0] : imports;
134689
134773
  const importKindPredicate = decl.kind === 243 /* VariableStatement */ ? isRequireVariableStatement : isAnyImportSyntax;
134690
134774
  const existingImportStatements = filter(sourceFile.statements, importKindPredicate);
134691
134775
  const { comparer, isSorted } = ts_OrganizeImports_exports.getOrganizeImportsStringComparerWithDetection(existingImportStatements, preferences);
134692
134776
  const sortedNewImports = isArray(imports) ? stableSort(imports, (a, b) => ts_OrganizeImports_exports.compareImportsOrRequireStatements(a, b, comparer)) : [imports];
134693
- if (!existingImportStatements.length) {
134694
- changes.insertNodesAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween);
134695
- } else if (existingImportStatements && isSorted) {
134777
+ if (!(existingImportStatements == null ? void 0 : existingImportStatements.length)) {
134778
+ if (isFullSourceFile(sourceFile)) {
134779
+ changes.insertNodesAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween);
134780
+ } else {
134781
+ for (const newImport of sortedNewImports) {
134782
+ changes.insertStatementsInNewFile(sourceFile.fileName, [newImport], (_a = getOriginalNode(newImport)) == null ? void 0 : _a.getSourceFile());
134783
+ }
134784
+ }
134785
+ return;
134786
+ }
134787
+ Debug.assert(isFullSourceFile(sourceFile));
134788
+ if (existingImportStatements && isSorted) {
134696
134789
  for (const newImport of sortedNewImports) {
134697
134790
  const insertionIndex = ts_OrganizeImports_exports.getImportDeclarationInsertionIndex(existingImportStatements, newImport, comparer);
134698
134791
  if (insertionIndex === 0) {
@@ -135618,7 +135711,7 @@ function createPackageJsonImportFilter(fromFile, preferences, host) {
135618
135711
  return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier);
135619
135712
  }
135620
135713
  function isAllowedCoreNodeModulesImport(moduleSpecifier) {
135621
- if (isSourceFileJS(fromFile) && ts_JsTyping_exports.nodeCoreModules.has(moduleSpecifier)) {
135714
+ if (isFullSourceFile(fromFile) && isSourceFileJS(fromFile) && ts_JsTyping_exports.nodeCoreModules.has(moduleSpecifier)) {
135622
135715
  if (usesNodeCoreModules === void 0) {
135623
135716
  usesNodeCoreModules = consumesNodeCoreModules(fromFile);
135624
135717
  }
@@ -135925,6 +136018,25 @@ function isBlockLike(node) {
135925
136018
  return false;
135926
136019
  }
135927
136020
  }
136021
+ function createFutureSourceFile(fileName, syntaxModuleIndicator, program, moduleResolutionHost) {
136022
+ var _a;
136023
+ const result = getImpliedNodeFormatForFileWorker(fileName, (_a = program.getPackageJsonInfoCache) == null ? void 0 : _a.call(program), moduleResolutionHost, program.getCompilerOptions());
136024
+ let impliedNodeFormat, packageJsonScope;
136025
+ if (typeof result === "object") {
136026
+ impliedNodeFormat = result.impliedNodeFormat;
136027
+ packageJsonScope = result.packageJsonScope;
136028
+ }
136029
+ return {
136030
+ path: toPath(fileName, program.getCurrentDirectory(), program.getCanonicalFileName),
136031
+ fileName,
136032
+ externalModuleIndicator: syntaxModuleIndicator === 99 /* ESNext */ ? true : void 0,
136033
+ commonJsModuleIndicator: syntaxModuleIndicator === 1 /* CommonJS */ ? true : void 0,
136034
+ impliedNodeFormat,
136035
+ packageJsonScope,
136036
+ statements: emptyArray,
136037
+ imports: emptyArray
136038
+ };
136039
+ }
135928
136040
 
135929
136041
  // src/services/exportInfoMap.ts
135930
136042
  var ImportKind = /* @__PURE__ */ ((ImportKind2) => {
@@ -152102,15 +152214,27 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152102
152214
  const addToNamespace = [];
152103
152215
  const importType = [];
152104
152216
  const addToExisting = /* @__PURE__ */ new Map();
152217
+ const removeExisting = /* @__PURE__ */ new Set();
152218
+ const verbatimImports = /* @__PURE__ */ new Set();
152105
152219
  const newImports = /* @__PURE__ */ new Map();
152106
- return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes, hasFixes };
152220
+ return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes, hasFixes, addImportForUnresolvedIdentifier, addImportForNonExistentExport, removeExistingImport, addVerbatimImport };
152221
+ function addVerbatimImport(declaration) {
152222
+ verbatimImports.add(declaration);
152223
+ }
152224
+ function addImportForUnresolvedIdentifier(context, symbolToken, useAutoImportProvider2) {
152225
+ const info = getFixInfosWithoutDiagnostic(context, symbolToken, useAutoImportProvider2);
152226
+ if (!info || !info.length)
152227
+ return;
152228
+ addImport(first(info));
152229
+ }
152107
152230
  function addImportFromDiagnostic(diagnostic, context) {
152108
152231
  const info = getFixInfos(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
152109
152232
  if (!info || !info.length)
152110
152233
  return;
152111
152234
  addImport(first(info));
152112
152235
  }
152113
- function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) {
152236
+ function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite, referenceImport) {
152237
+ var _a;
152114
152238
  const moduleSymbol = Debug.checkDefined(exportedSymbol.parent);
152115
152239
  const symbolName2 = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions));
152116
152240
  const checker = program.getTypeChecker();
@@ -152128,7 +152252,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152128
152252
  cancellationToken
152129
152253
  );
152130
152254
  const useRequire = shouldUseRequire(sourceFile, program);
152131
- const fix = getImportFixForSymbol(
152255
+ let fix = getImportFixForSymbol(
152132
152256
  sourceFile,
152133
152257
  Debug.checkDefined(exportInfo),
152134
152258
  program,
@@ -152140,9 +152264,72 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152140
152264
  preferences
152141
152265
  );
152142
152266
  if (fix) {
152143
- addImport({ fix, symbolName: symbolName2, errorIdentifierText: void 0 });
152267
+ const localName = ((_a = tryCast(referenceImport == null ? void 0 : referenceImport.name, isIdentifier)) == null ? void 0 : _a.text) ?? symbolName2;
152268
+ if (referenceImport && isTypeOnlyImportDeclaration(referenceImport) && (fix.kind === 3 /* AddNew */ || fix.kind === 2 /* AddToExisting */) && fix.addAsTypeOnly === 1 /* Allowed */) {
152269
+ fix = { ...fix, addAsTypeOnly: 2 /* Required */ };
152270
+ }
152271
+ addImport({ fix, symbolName: localName ?? symbolName2, errorIdentifierText: void 0 });
152272
+ }
152273
+ }
152274
+ function addImportForNonExistentExport(exportName, exportingFileName, exportKind, exportedMeanings, isImportUsageValidAsTypeOnly) {
152275
+ const exportingSourceFile = program.getSourceFile(exportingFileName);
152276
+ const useRequire = shouldUseRequire(sourceFile, program);
152277
+ if (exportingSourceFile && exportingSourceFile.symbol) {
152278
+ const { fixes } = getImportFixes(
152279
+ [{
152280
+ exportKind,
152281
+ isFromPackageJson: false,
152282
+ moduleFileName: exportingFileName,
152283
+ moduleSymbol: exportingSourceFile.symbol,
152284
+ targetFlags: exportedMeanings
152285
+ }],
152286
+ /*usagePosition*/
152287
+ void 0,
152288
+ isImportUsageValidAsTypeOnly,
152289
+ useRequire,
152290
+ program,
152291
+ sourceFile,
152292
+ host,
152293
+ preferences
152294
+ );
152295
+ if (fixes.length) {
152296
+ addImport({ fix: fixes[0], symbolName: exportName, errorIdentifierText: exportName });
152297
+ }
152298
+ } else {
152299
+ const futureExportingSourceFile = createFutureSourceFile(exportingFileName, 99 /* ESNext */, program, host);
152300
+ const moduleSpecifier = ts_moduleSpecifiers_exports.getLocalModuleSpecifierBetweenFileNames(
152301
+ sourceFile,
152302
+ exportingFileName,
152303
+ compilerOptions,
152304
+ createModuleSpecifierResolutionHost(program, host)
152305
+ );
152306
+ const importKind = getImportKind(futureExportingSourceFile, exportKind, compilerOptions);
152307
+ const addAsTypeOnly = getAddAsTypeOnly(
152308
+ isImportUsageValidAsTypeOnly,
152309
+ /*isForNewImportDeclaration*/
152310
+ true,
152311
+ /*symbol*/
152312
+ void 0,
152313
+ exportedMeanings,
152314
+ program.getTypeChecker(),
152315
+ compilerOptions
152316
+ );
152317
+ const fix = {
152318
+ kind: 3 /* AddNew */,
152319
+ moduleSpecifier,
152320
+ importKind,
152321
+ addAsTypeOnly,
152322
+ useRequire
152323
+ };
152324
+ addImport({ fix, symbolName: exportName, errorIdentifierText: exportName });
152144
152325
  }
152145
152326
  }
152327
+ function removeExistingImport(declaration) {
152328
+ if (declaration.kind === 273 /* ImportClause */) {
152329
+ Debug.assertIsDefined(declaration.name, "ImportClause should have a name if it's being removed");
152330
+ }
152331
+ removeExisting.add(declaration);
152332
+ }
152146
152333
  function addImport(info) {
152147
152334
  var _a, _b;
152148
152335
  const { fix, symbolName: symbolName2 } = info;
@@ -152155,10 +152342,9 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152155
152342
  break;
152156
152343
  case 2 /* AddToExisting */: {
152157
152344
  const { importClauseOrBindingPattern, importKind, addAsTypeOnly } = fix;
152158
- const key = String(getNodeId(importClauseOrBindingPattern));
152159
- let entry = addToExisting.get(key);
152345
+ let entry = addToExisting.get(importClauseOrBindingPattern);
152160
152346
  if (!entry) {
152161
- addToExisting.set(key, entry = { importClauseOrBindingPattern, defaultImport: void 0, namedImports: /* @__PURE__ */ new Map() });
152347
+ addToExisting.set(importClauseOrBindingPattern, entry = { importClauseOrBindingPattern, defaultImport: void 0, namedImports: /* @__PURE__ */ new Map() });
152162
152348
  }
152163
152349
  if (importKind === 0 /* Named */) {
152164
152350
  const prevValue = entry == null ? void 0 : entry.namedImports.get(symbolName2);
@@ -152240,8 +152426,9 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152240
152426
  }
152241
152427
  }
152242
152428
  function writeFixes(changeTracker, oldFileQuotePreference) {
152429
+ var _a, _b;
152243
152430
  let quotePreference;
152244
- if (sourceFile.imports.length === 0 && oldFileQuotePreference !== void 0) {
152431
+ if (isFullSourceFile(sourceFile) && sourceFile.imports.length === 0 && oldFileQuotePreference !== void 0) {
152245
152432
  quotePreference = oldFileQuotePreference;
152246
152433
  } else {
152247
152434
  quotePreference = getQuotePreference(sourceFile, preferences);
@@ -152252,6 +152439,82 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152252
152439
  for (const fix of importType) {
152253
152440
  addImportType(changeTracker, sourceFile, fix, quotePreference);
152254
152441
  }
152442
+ let importSpecifiersToRemoveWhileAdding;
152443
+ if (removeExisting.size) {
152444
+ Debug.assert(isFullSourceFile(sourceFile), "Cannot remove imports from a future source file");
152445
+ const importDeclarationsWithRemovals = new Set(mapDefined([...removeExisting], (d) => findAncestor(d, isImportDeclaration)));
152446
+ const variableDeclarationsWithRemovals = new Set(mapDefined([...removeExisting], (d) => findAncestor(d, isVariableDeclarationInitializedToRequire)));
152447
+ const emptyImportDeclarations = [...importDeclarationsWithRemovals].filter(
152448
+ (d) => {
152449
+ var _a2, _b2, _c;
152450
+ return (
152451
+ // nothing added to the import declaration
152452
+ !addToExisting.has(d.importClause) && // no default, or default is being removed
152453
+ (!((_a2 = d.importClause) == null ? void 0 : _a2.name) || removeExisting.has(d.importClause)) && // no namespace import, or namespace import is being removed
152454
+ (!tryCast((_b2 = d.importClause) == null ? void 0 : _b2.namedBindings, isNamespaceImport) || removeExisting.has(d.importClause.namedBindings)) && // no named imports, or all named imports are being removed
152455
+ (!tryCast((_c = d.importClause) == null ? void 0 : _c.namedBindings, isNamedImports) || every(d.importClause.namedBindings.elements, (e) => removeExisting.has(e)))
152456
+ );
152457
+ }
152458
+ );
152459
+ const emptyVariableDeclarations = [...variableDeclarationsWithRemovals].filter(
152460
+ (d) => (
152461
+ // no binding elements being added to the variable declaration
152462
+ (d.name.kind !== 206 /* ObjectBindingPattern */ || !addToExisting.has(d.name)) && // no binding elements, or all binding elements are being removed
152463
+ (d.name.kind !== 206 /* ObjectBindingPattern */ || every(d.name.elements, (e) => removeExisting.has(e)))
152464
+ )
152465
+ );
152466
+ const namedBindingsToDelete = [...importDeclarationsWithRemovals].filter(
152467
+ (d) => {
152468
+ var _a2, _b2;
152469
+ return (
152470
+ // has named bindings
152471
+ ((_a2 = d.importClause) == null ? void 0 : _a2.namedBindings) && // is not being fully removed
152472
+ emptyImportDeclarations.indexOf(d) === -1 && // is not gaining named imports
152473
+ !((_b2 = addToExisting.get(d.importClause)) == null ? void 0 : _b2.namedImports) && // all named imports are being removed
152474
+ (d.importClause.namedBindings.kind === 274 /* NamespaceImport */ || every(d.importClause.namedBindings.elements, (e) => removeExisting.has(e)))
152475
+ );
152476
+ }
152477
+ );
152478
+ for (const declaration of [...emptyImportDeclarations, ...emptyVariableDeclarations]) {
152479
+ changeTracker.delete(sourceFile, declaration);
152480
+ }
152481
+ for (const declaration of namedBindingsToDelete) {
152482
+ changeTracker.replaceNode(
152483
+ sourceFile,
152484
+ declaration.importClause,
152485
+ factory.updateImportClause(
152486
+ declaration.importClause,
152487
+ declaration.importClause.isTypeOnly,
152488
+ declaration.importClause.name,
152489
+ /*namedBindings*/
152490
+ void 0
152491
+ )
152492
+ );
152493
+ }
152494
+ for (const declaration of removeExisting) {
152495
+ const importDeclaration = findAncestor(declaration, isImportDeclaration);
152496
+ if (importDeclaration && emptyImportDeclarations.indexOf(importDeclaration) === -1 && namedBindingsToDelete.indexOf(importDeclaration) === -1) {
152497
+ if (declaration.kind === 273 /* ImportClause */) {
152498
+ changeTracker.delete(sourceFile, declaration.name);
152499
+ } else {
152500
+ Debug.assert(declaration.kind === 276 /* ImportSpecifier */, "NamespaceImport should have been handled earlier");
152501
+ if ((_a = addToExisting.get(importDeclaration.importClause)) == null ? void 0 : _a.namedImports) {
152502
+ (importSpecifiersToRemoveWhileAdding ?? (importSpecifiersToRemoveWhileAdding = /* @__PURE__ */ new Set())).add(declaration);
152503
+ } else {
152504
+ changeTracker.delete(sourceFile, declaration);
152505
+ }
152506
+ }
152507
+ } else if (declaration.kind === 208 /* BindingElement */) {
152508
+ if ((_b = addToExisting.get(declaration.parent)) == null ? void 0 : _b.namedImports) {
152509
+ (importSpecifiersToRemoveWhileAdding ?? (importSpecifiersToRemoveWhileAdding = /* @__PURE__ */ new Set())).add(declaration);
152510
+ } else {
152511
+ changeTracker.delete(sourceFile, declaration);
152512
+ }
152513
+ } else if (declaration.kind === 271 /* ImportEqualsDeclaration */) {
152514
+ changeTracker.delete(sourceFile, declaration);
152515
+ }
152516
+ }
152517
+ }
152255
152518
  addToExisting.forEach(({ importClauseOrBindingPattern, defaultImport, namedImports }) => {
152256
152519
  doAddExistingFix(
152257
152520
  changeTracker,
@@ -152259,6 +152522,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152259
152522
  importClauseOrBindingPattern,
152260
152523
  defaultImport,
152261
152524
  arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
152525
+ importSpecifiersToRemoveWhileAdding,
152262
152526
  preferences
152263
152527
  );
152264
152528
  });
@@ -152277,6 +152541,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152277
152541
  );
152278
152542
  newDeclarations = combine(newDeclarations, declarations);
152279
152543
  });
152544
+ newDeclarations = combine(newDeclarations, getCombinedVerbatimImports());
152280
152545
  if (newDeclarations) {
152281
152546
  insertImports(
152282
152547
  changeTracker,
@@ -152288,8 +152553,85 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152288
152553
  );
152289
152554
  }
152290
152555
  }
152556
+ function getCombinedVerbatimImports() {
152557
+ if (!verbatimImports.size)
152558
+ return void 0;
152559
+ const importDeclarations = new Set(mapDefined([...verbatimImports], (d) => findAncestor(d, isImportDeclaration)));
152560
+ const requireStatements = new Set(mapDefined([...verbatimImports], (d) => findAncestor(d, isRequireVariableStatement)));
152561
+ return [
152562
+ ...mapDefined([...verbatimImports], (d) => d.kind === 271 /* ImportEqualsDeclaration */ ? getSynthesizedDeepClone(
152563
+ d,
152564
+ /*includeTrivia*/
152565
+ true
152566
+ ) : void 0),
152567
+ ...[...importDeclarations].map((d) => {
152568
+ var _a;
152569
+ if (verbatimImports.has(d)) {
152570
+ return getSynthesizedDeepClone(
152571
+ d,
152572
+ /*includeTrivia*/
152573
+ true
152574
+ );
152575
+ }
152576
+ return getSynthesizedDeepClone(
152577
+ factory.updateImportDeclaration(
152578
+ d,
152579
+ d.modifiers,
152580
+ d.importClause && factory.updateImportClause(
152581
+ d.importClause,
152582
+ d.importClause.isTypeOnly,
152583
+ verbatimImports.has(d.importClause) ? d.importClause.name : void 0,
152584
+ verbatimImports.has(d.importClause.namedBindings) ? d.importClause.namedBindings : ((_a = tryCast(d.importClause.namedBindings, isNamedImports)) == null ? void 0 : _a.elements.some((e) => verbatimImports.has(e))) ? factory.updateNamedImports(
152585
+ d.importClause.namedBindings,
152586
+ d.importClause.namedBindings.elements.filter((e) => verbatimImports.has(e))
152587
+ ) : void 0
152588
+ ),
152589
+ d.moduleSpecifier,
152590
+ d.attributes
152591
+ ),
152592
+ /*includeTrivia*/
152593
+ true
152594
+ );
152595
+ }),
152596
+ ...[...requireStatements].map((s) => {
152597
+ if (verbatimImports.has(s)) {
152598
+ return getSynthesizedDeepClone(
152599
+ s,
152600
+ /*includeTrivia*/
152601
+ true
152602
+ );
152603
+ }
152604
+ return getSynthesizedDeepClone(
152605
+ factory.updateVariableStatement(
152606
+ s,
152607
+ s.modifiers,
152608
+ factory.updateVariableDeclarationList(
152609
+ s.declarationList,
152610
+ mapDefined(s.declarationList.declarations, (d) => {
152611
+ if (verbatimImports.has(d)) {
152612
+ return d;
152613
+ }
152614
+ return factory.updateVariableDeclaration(
152615
+ d,
152616
+ d.name.kind === 206 /* ObjectBindingPattern */ ? factory.updateObjectBindingPattern(
152617
+ d.name,
152618
+ d.name.elements.filter((e) => verbatimImports.has(e))
152619
+ ) : d.name,
152620
+ d.exclamationToken,
152621
+ d.type,
152622
+ d.initializer
152623
+ );
152624
+ })
152625
+ )
152626
+ ),
152627
+ /*includeTrivia*/
152628
+ true
152629
+ );
152630
+ })
152631
+ ];
152632
+ }
152291
152633
  function hasFixes() {
152292
- return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
152634
+ return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0 || verbatimImports.size > 0 || removeExisting.size > 0;
152293
152635
  }
152294
152636
  }
152295
152637
  function createImportSpecifierResolver(importingFile, program, host, preferences) {
@@ -152398,9 +152740,12 @@ function getSingleExportInfoForSymbol(symbol, symbolName2, moduleSymbol, program
152398
152740
  }
152399
152741
  }
152400
152742
  }
152401
- function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()), fromCacheOnly) {
152743
+ function isFutureSymbolExportInfoArray(info) {
152744
+ return info[0].symbol === void 0;
152745
+ }
152746
+ function getImportFixes(exportInfos, usagePosition, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, importMap = isFullSourceFile(sourceFile) ? createExistingImportMap(program.getTypeChecker(), sourceFile, program.getCompilerOptions()) : void 0, fromCacheOnly) {
152402
152747
  const checker = program.getTypeChecker();
152403
- const existingImports = flatMap(exportInfos, importMap.getImportsForExportInfo);
152748
+ const existingImports = importMap && !isFutureSymbolExportInfoArray(exportInfos) ? flatMap(exportInfos, importMap.getImportsForExportInfo) : emptyArray;
152404
152749
  const useNamespace = usagePosition !== void 0 && tryUseExistingNamespaceImport(existingImports, usagePosition);
152405
152750
  const addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152406
152751
  if (addToExisting) {
@@ -152456,7 +152801,7 @@ function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, sym
152456
152801
  if (!isValidTypeOnlyUseSite) {
152457
152802
  return 4 /* NotAllowed */;
152458
152803
  }
152459
- if (compilerOptions.verbatimModuleSyntax && (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
152804
+ if (symbol && compilerOptions.verbatimModuleSyntax && (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
152460
152805
  return 2 /* Required */;
152461
152806
  }
152462
152807
  return 1 /* Allowed */;
@@ -152543,7 +152888,7 @@ function createExistingImportMap(checker, importingFile, compilerOptions) {
152543
152888
  };
152544
152889
  }
152545
152890
  function shouldUseRequire(sourceFile, program) {
152546
- if (!isSourceFileJS(sourceFile)) {
152891
+ if (!hasJSFileExtension(sourceFile.fileName)) {
152547
152892
  return false;
152548
152893
  }
152549
152894
  if (sourceFile.commonJsModuleIndicator && !sourceFile.externalModuleIndicator)
@@ -152572,14 +152917,14 @@ function createGetChecker(program, host) {
152572
152917
  return memoizeOne((isFromPackageJson) => isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker());
152573
152918
  }
152574
152919
  function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
152575
- const isJs = isSourceFileJS(sourceFile);
152920
+ const isJs = hasJSFileExtension(sourceFile.fileName);
152576
152921
  const compilerOptions = program.getCompilerOptions();
152577
152922
  const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
152578
152923
  const getChecker = createGetChecker(program, host);
152579
152924
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
152580
152925
  const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution);
152581
- const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
152582
- moduleSymbol,
152926
+ const getModuleSpecifiers2 = fromCacheOnly ? (exportInfo2) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(exportInfo2.moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (exportInfo2, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
152927
+ exportInfo2.moduleSymbol,
152583
152928
  checker,
152584
152929
  compilerOptions,
152585
152930
  sourceFile,
@@ -152593,7 +152938,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
152593
152938
  let computedWithoutCacheCount = 0;
152594
152939
  const fixes = flatMap(exportInfo, (exportInfo2, i) => {
152595
152940
  const checker = getChecker(exportInfo2.isFromPackageJson);
152596
- const { computedWithoutCache, moduleSpecifiers } = getModuleSpecifiers2(exportInfo2.moduleSymbol, checker);
152941
+ const { computedWithoutCache, moduleSpecifiers } = getModuleSpecifiers2(exportInfo2, checker);
152597
152942
  const importedSymbolHasValueMeaning = !!(exportInfo2.targetFlags & 111551 /* Value */);
152598
152943
  const addAsTypeOnly = getAddAsTypeOnly(
152599
152944
  isValidTypeOnlyUseSite,
@@ -152684,6 +153029,11 @@ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host)
152684
153029
  const _toPath = (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
152685
153030
  return sort(fixes, (a, b) => compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) || compareValues(a.fix.kind, b.fix.kind) || compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath));
152686
153031
  }
153032
+ function getFixInfosWithoutDiagnostic(context, symbolToken, useAutoImportProvider) {
153033
+ const info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
153034
+ const packageJsonImportFilter = createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
153035
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
153036
+ }
152687
153037
  function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
152688
153038
  if (!some(fixes))
152689
153039
  return;
@@ -152707,17 +153057,17 @@ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
152707
153057
  function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath3) {
152708
153058
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
152709
153059
  return compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || compareBooleans(
152710
- isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath3),
152711
- isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath3)
153060
+ isFixPossiblyReExportingImportingFile(a, importingFile.path, toPath3),
153061
+ isFixPossiblyReExportingImportingFile(b, importingFile.path, toPath3)
152712
153062
  ) || compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
152713
153063
  }
152714
153064
  return 0 /* EqualTo */;
152715
153065
  }
152716
- function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath3) {
153066
+ function isFixPossiblyReExportingImportingFile(fix, importingFilePath, toPath3) {
152717
153067
  var _a;
152718
153068
  if (fix.isReExport && ((_a = fix.exportInfo) == null ? void 0 : _a.moduleFileName) && isIndexFileName(fix.exportInfo.moduleFileName)) {
152719
153069
  const reExportDir = toPath3(getDirectoryPath(fix.exportInfo.moduleFileName));
152720
- return startsWith(importingFile.path, reExportDir);
153070
+ return startsWith(importingFilePath, reExportDir);
152721
153071
  }
152722
153072
  return false;
152723
153073
  }
@@ -152807,8 +153157,8 @@ function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
152807
153157
  case 2 /* AMD */:
152808
153158
  case 1 /* CommonJS */:
152809
153159
  case 3 /* UMD */:
152810
- if (isInJSFile(importingFile)) {
152811
- return isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */;
153160
+ if (hasJSFileExtension(importingFile.fileName)) {
153161
+ return importingFile.externalModuleIndicator || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */;
152812
153162
  }
152813
153163
  return 3 /* CommonJS */;
152814
153164
  case 4 /* System */:
@@ -152919,14 +153269,14 @@ function getExportInfos(symbolName2, isJsxTagName, currentTokenMeaning, cancella
152919
153269
  }
152920
153270
  function getExportEqualsImportKind(importingFile, compilerOptions, forceImportKeyword) {
152921
153271
  const allowSyntheticDefaults = getAllowSyntheticDefaultImports(compilerOptions);
152922
- const isJS = isInJSFile(importingFile);
153272
+ const isJS = hasJSFileExtension(importingFile.fileName);
152923
153273
  if (!isJS && getEmitModuleKind(compilerOptions) >= 5 /* ES2015 */) {
152924
153274
  return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */;
152925
153275
  }
152926
153276
  if (isJS) {
152927
- return isExternalModule(importingFile) || forceImportKeyword ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ : 3 /* CommonJS */;
153277
+ return importingFile.externalModuleIndicator || forceImportKeyword ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ : 3 /* CommonJS */;
152928
153278
  }
152929
- for (const statement of importingFile.statements) {
153279
+ for (const statement of importingFile.statements ?? emptyArray) {
152930
153280
  if (isImportEqualsDeclaration(statement) && !nodeIsMissing(statement.moduleReference)) {
152931
153281
  return 3 /* CommonJS */;
152932
153282
  }
@@ -152957,6 +153307,8 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy
152957
153307
  importClauseOrBindingPattern,
152958
153308
  importKind === 1 /* Default */ ? { name: symbolName2, addAsTypeOnly } : void 0,
152959
153309
  importKind === 0 /* Named */ ? [{ name: symbolName2, addAsTypeOnly }] : emptyArray,
153310
+ /*removeExistingImportSpecifiers*/
153311
+ void 0,
152960
153312
  preferences
152961
153313
  );
152962
153314
  const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier);
@@ -153071,9 +153423,33 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
153071
153423
  }
153072
153424
  }
153073
153425
  }
153074
- function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, preferences) {
153426
+ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, removeExistingImportSpecifiers, preferences) {
153075
153427
  var _a;
153076
153428
  if (clause.kind === 206 /* ObjectBindingPattern */) {
153429
+ if (removeExistingImportSpecifiers && clause.elements.some((e) => removeExistingImportSpecifiers.has(e))) {
153430
+ changes.replaceNode(
153431
+ sourceFile,
153432
+ clause,
153433
+ factory.createObjectBindingPattern([
153434
+ ...clause.elements.filter((e) => !removeExistingImportSpecifiers.has(e)),
153435
+ ...defaultImport ? [factory.createBindingElement(
153436
+ /*dotDotDotToken*/
153437
+ void 0,
153438
+ /*propertyName*/
153439
+ "default",
153440
+ defaultImport.name
153441
+ )] : emptyArray,
153442
+ ...namedImports.map((i) => factory.createBindingElement(
153443
+ /*dotDotDotToken*/
153444
+ void 0,
153445
+ /*propertyName*/
153446
+ void 0,
153447
+ i.name
153448
+ ))
153449
+ ])
153450
+ );
153451
+ return;
153452
+ }
153077
153453
  if (defaultImport) {
153078
153454
  addElementToBindingPattern(clause, defaultImport.name, "default");
153079
153455
  }
@@ -153106,7 +153482,16 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
153106
153482
  ),
153107
153483
  specifierComparer
153108
153484
  );
153109
- if ((existingSpecifiers == null ? void 0 : existingSpecifiers.length) && isSorted !== false) {
153485
+ if (removeExistingImportSpecifiers) {
153486
+ changes.replaceNode(
153487
+ sourceFile,
153488
+ clause.namedBindings,
153489
+ factory.updateNamedImports(
153490
+ clause.namedBindings,
153491
+ stableSort([...existingSpecifiers.filter((s) => !removeExistingImportSpecifiers.has(s)), ...newSpecifiers], specifierComparer)
153492
+ )
153493
+ );
153494
+ } else if ((existingSpecifiers == null ? void 0 : existingSpecifiers.length) && isSorted !== false) {
153110
153495
  const transformedExistingSpecifiers = promoteFromTypeOnly2 && existingSpecifiers ? factory.updateNamedImports(
153111
153496
  clause.namedBindings,
153112
153497
  sameMap(existingSpecifiers, (e) => factory.updateImportSpecifier(
@@ -161942,13 +162327,13 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
161942
162327
  ({ exportInfo: exportInfo2 = info[0], moduleSpecifier } = result);
161943
162328
  }
161944
162329
  const isDefaultExport = exportInfo2.exportKind === 1 /* Default */;
161945
- const symbol = isDefaultExport && getLocalSymbolForExportDefault(exportInfo2.symbol) || exportInfo2.symbol;
162330
+ const symbol = isDefaultExport && getLocalSymbolForExportDefault(Debug.checkDefined(exportInfo2.symbol)) || Debug.checkDefined(exportInfo2.symbol);
161946
162331
  pushAutoImportSymbol(symbol, {
161947
162332
  kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
161948
162333
  moduleSpecifier,
161949
162334
  symbolName: symbolName2,
161950
162335
  exportMapKey,
161951
- exportName: exportInfo2.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo2.symbol.name,
162336
+ exportName: exportInfo2.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : Debug.checkDefined(exportInfo2.symbol).name,
161952
162337
  fileName: exportInfo2.moduleFileName,
161953
162338
  isDefaultExport,
161954
162339
  moduleSymbol: exportInfo2.moduleSymbol,
@@ -175402,6 +175787,7 @@ __export(ts_exports2, {
175402
175787
  createFileDiagnosticFromMessageChain: () => createFileDiagnosticFromMessageChain,
175403
175788
  createFlowNode: () => createFlowNode,
175404
175789
  createForOfBindingStatement: () => createForOfBindingStatement,
175790
+ createFutureSourceFile: () => createFutureSourceFile,
175405
175791
  createGetCanonicalFileName: () => createGetCanonicalFileName,
175406
175792
  createGetSourceFile: () => createGetSourceFile,
175407
175793
  createGetSymbolAccessibilityDiagnosticForNode: () => createGetSymbolAccessibilityDiagnosticForNode,
@@ -176173,6 +176559,7 @@ __export(ts_exports2, {
176173
176559
  isAnyDirectorySeparator: () => isAnyDirectorySeparator,
176174
176560
  isAnyImportOrBareOrAccessedRequire: () => isAnyImportOrBareOrAccessedRequire,
176175
176561
  isAnyImportOrReExport: () => isAnyImportOrReExport,
176562
+ isAnyImportOrRequireStatement: () => isAnyImportOrRequireStatement,
176176
176563
  isAnyImportSyntax: () => isAnyImportSyntax,
176177
176564
  isAnySupportedFileExtension: () => isAnySupportedFileExtension,
176178
176565
  isApplicableVersionedTypesKey: () => isApplicableVersionedTypesKey,
@@ -176363,6 +176750,7 @@ __export(ts_exports2, {
176363
176750
  isForInitializer: () => isForInitializer,
176364
176751
  isForOfStatement: () => isForOfStatement,
176365
176752
  isForStatement: () => isForStatement,
176753
+ isFullSourceFile: () => isFullSourceFile,
176366
176754
  isFunctionBlock: () => isFunctionBlock,
176367
176755
  isFunctionBody: () => isFunctionBody,
176368
176756
  isFunctionDeclaration: () => isFunctionDeclaration,
@@ -181118,6 +181506,13 @@ var ConfiguredProject2 = class extends Project3 {
181118
181506
  this.compilerHost = void 0;
181119
181507
  this.projectService.sendProjectLoadingFinishEvent(this);
181120
181508
  this.projectService.sendProjectTelemetry(this);
181509
+ if (!this.skipConfigDiagEvent && !result) {
181510
+ this.projectService.sendConfigFileDiagEvent(
181511
+ this,
181512
+ /*triggerFile*/
181513
+ void 0
181514
+ );
181515
+ }
181121
181516
  return result;
181122
181517
  }
181123
181518
  /** @internal */
@@ -181572,7 +181967,12 @@ function projectContainsInfoDirectly(project, info) {
181572
181967
  }
181573
181968
  function updateProjectIfDirty(project) {
181574
181969
  project.invalidateResolutionsOfFailedLookupLocations();
181575
- return project.dirty && project.updateGraph();
181970
+ return project.dirty && !project.updateGraph();
181971
+ }
181972
+ function updateConfiguredProjectWithoutConfigDiagIfDirty(project) {
181973
+ project.skipConfigDiagEvent = true;
181974
+ updateProjectIfDirty(project);
181975
+ project.skipConfigDiagEvent = void 0;
181576
181976
  }
181577
181977
  function setProjectOptionsUsed(project) {
181578
181978
  if (isConfiguredProject(project)) {
@@ -182864,6 +183264,7 @@ var _ProjectService = class _ProjectService {
182864
183264
  /** @internal */
182865
183265
  createLoadAndUpdateConfiguredProject(configFileName, reason) {
182866
183266
  const project = this.createAndLoadConfiguredProject(configFileName, reason);
183267
+ project.skipConfigDiagEvent = true;
182867
183268
  project.updateGraph();
182868
183269
  return project;
182869
183270
  }
@@ -183156,6 +183557,7 @@ var _ProjectService = class _ProjectService {
183156
183557
  const configFileName = project.getConfigFilePath();
183157
183558
  this.logger.info(`${isInitialLoad ? "Loading" : "Reloading"} configured project ${configFileName}`);
183158
183559
  this.loadConfiguredProject(project, reason);
183560
+ project.skipConfigDiagEvent = true;
183159
183561
  project.updateGraph();
183160
183562
  this.sendConfigFileDiagEvent(project, configFileName);
183161
183563
  }
@@ -183169,16 +183571,20 @@ var _ProjectService = class _ProjectService {
183169
183571
  project.cleanupProgram();
183170
183572
  project.markAsDirty();
183171
183573
  }
183574
+ /** @internal */
183172
183575
  sendConfigFileDiagEvent(project, triggerFile) {
183173
183576
  if (!this.eventHandler || this.suppressDiagnosticEvents) {
183174
183577
  return;
183175
183578
  }
183176
183579
  const diagnostics = project.getLanguageService().getCompilerOptionsDiagnostics();
183177
183580
  diagnostics.push(...project.getAllProjectErrors());
183581
+ if (!triggerFile && !!diagnostics.length === !!project.hasConfigFileDiagnostics)
183582
+ return;
183583
+ project.hasConfigFileDiagnostics = !!diagnostics.length;
183178
183584
  this.eventHandler(
183179
183585
  {
183180
183586
  eventName: ConfigFileDiagEvent,
183181
- data: { configFileName: project.getConfigFilePath(), diagnostics, triggerFile }
183587
+ data: { configFileName: project.getConfigFilePath(), diagnostics, triggerFile: triggerFile ?? project.getConfigFilePath() }
183182
183588
  }
183183
183589
  );
183184
183590
  }
@@ -183968,7 +184374,7 @@ Dynamic files must always be opened with service's current directory or service
183968
184374
  project = this.createLoadAndUpdateConfiguredProject(configFileName, `Creating possible configured project for ${info.fileName} to open`);
183969
184375
  defaultConfigProjectIsCreated = true;
183970
184376
  } else {
183971
- updateProjectIfDirty(project);
184377
+ updateConfiguredProjectWithoutConfigDiagIfDirty(project);
183972
184378
  }
183973
184379
  projectForConfigFileDiag = project.containsScriptInfo(info) ? project : void 0;
183974
184380
  retainProjects = project;
@@ -183977,7 +184383,7 @@ Dynamic files must always be opened with service's current directory or service
183977
184383
  project,
183978
184384
  info.path,
183979
184385
  (child) => {
183980
- updateProjectIfDirty(child);
184386
+ updateConfiguredProjectWithoutConfigDiagIfDirty(child);
183981
184387
  if (!isArray(retainProjects)) {
183982
184388
  retainProjects = [project, child];
183983
184389
  } else {
@@ -189625,6 +190031,7 @@ if (typeof console !== "undefined") {
189625
190031
  createFileDiagnosticFromMessageChain,
189626
190032
  createFlowNode,
189627
190033
  createForOfBindingStatement,
190034
+ createFutureSourceFile,
189628
190035
  createGetCanonicalFileName,
189629
190036
  createGetSourceFile,
189630
190037
  createGetSymbolAccessibilityDiagnosticForNode,
@@ -190396,6 +190803,7 @@ if (typeof console !== "undefined") {
190396
190803
  isAnyDirectorySeparator,
190397
190804
  isAnyImportOrBareOrAccessedRequire,
190398
190805
  isAnyImportOrReExport,
190806
+ isAnyImportOrRequireStatement,
190399
190807
  isAnyImportSyntax,
190400
190808
  isAnySupportedFileExtension,
190401
190809
  isApplicableVersionedTypesKey,
@@ -190586,6 +190994,7 @@ if (typeof console !== "undefined") {
190586
190994
  isForInitializer,
190587
190995
  isForOfStatement,
190588
190996
  isForStatement,
190997
+ isFullSourceFile,
190589
190998
  isFunctionBlock,
190590
190999
  isFunctionBody,
190591
191000
  isFunctionDeclaration,