@typescript-deploys/pr-build 5.5.0-pr-57649-11 → 5.5.0-pr-58124-21

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-insiders.20240408`;
2341
+ var version = `${versionMajorMinor}.0-insiders.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)
@@ -49980,7 +50002,6 @@ function createTypeChecker(host) {
49980
50002
  let result;
49981
50003
  let lastLocation;
49982
50004
  let lastSelfReferenceLocation;
49983
- let seenAsUsedOutsideOfSelf = false;
49984
50005
  let propertyWithInvalidInitializer;
49985
50006
  let associatedDeclarationForContainingInitializerOrBindingName;
49986
50007
  let withinDeferredContext = false;
@@ -50192,9 +50213,6 @@ function createTypeChecker(host) {
50192
50213
  location = location.parent.parent.parent;
50193
50214
  }
50194
50215
  break;
50195
- case 175 /* ClassStaticBlockDeclaration */:
50196
- seenAsUsedOutsideOfSelf = true;
50197
- break;
50198
50216
  }
50199
50217
  if (isSelfReferenceLocation(location)) {
50200
50218
  lastSelfReferenceLocation = location;
@@ -50202,7 +50220,7 @@ function createTypeChecker(host) {
50202
50220
  lastLocation = location;
50203
50221
  location = isJSDocTemplateTag(location) ? getEffectiveContainerForJSDocTemplateTag(location) || location.parent : isJSDocParameterTag(location) || isJSDocReturnTag(location) ? getHostSignatureFromJSDoc(location) || location.parent : location.parent;
50204
50222
  }
50205
- if (isUse && result && (seenAsUsedOutsideOfSelf || !lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
50223
+ if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
50206
50224
  result.isReferenced |= meaning;
50207
50225
  }
50208
50226
  if (!result) {
@@ -52895,7 +52913,7 @@ function createTypeChecker(host) {
52895
52913
  typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
52896
52914
  typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
52897
52915
  expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
52898
- 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)),
52899
52917
  serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
52900
52918
  indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
52901
52919
  indexInfo,
@@ -52918,6 +52936,18 @@ function createTypeChecker(host) {
52918
52936
  symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
52919
52937
  symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
52920
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
+ }
52921
52951
  function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
52922
52952
  if (expr) {
52923
52953
  const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
@@ -52982,6 +53012,7 @@ function createTypeChecker(host) {
52982
53012
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
52983
53013
  const context = {
52984
53014
  enclosingDeclaration,
53015
+ enclosingFile: enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration),
52985
53016
  flags: flags || 0 /* None */,
52986
53017
  tracker: void 0,
52987
53018
  encounteredError: false,
@@ -53514,7 +53545,7 @@ function createTypeChecker(host) {
53514
53545
  if (!nodeIsSynthesized(node) && getParseTreeNode(node) === node) {
53515
53546
  return node;
53516
53547
  }
53517
- return setTextRange(factory.cloneNode(visitEachChild(
53548
+ return setTextRange2(context, factory.cloneNode(visitEachChild(
53518
53549
  node,
53519
53550
  deepCloneOrReuseNode,
53520
53551
  /*context*/
@@ -53856,7 +53887,13 @@ function createTypeChecker(host) {
53856
53887
  context.reverseMappedStack || (context.reverseMappedStack = []);
53857
53888
  context.reverseMappedStack.push(propertySymbol);
53858
53889
  }
53859
- 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 */);
53860
53897
  if (propertyIsReverseMapped) {
53861
53898
  context.reverseMappedStack.pop();
53862
53899
  }
@@ -54245,8 +54282,7 @@ function createTypeChecker(host) {
54245
54282
  function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
54246
54283
  const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
54247
54284
  const parameterType = getTypeOfSymbol(parameterSymbol);
54248
- const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
54249
- const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, addUndefined);
54285
+ const parameterTypeNode = serializeTypeForDeclaration(context, parameterDeclaration, parameterType, parameterSymbol);
54250
54286
  const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
54251
54287
  const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
54252
54288
  const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
@@ -54838,10 +54874,12 @@ function createTypeChecker(host) {
54838
54874
  }
54839
54875
  return enclosingDeclaration;
54840
54876
  }
54841
- function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined) {
54877
+ function serializeTypeForDeclaration(context, declaration, type, symbol) {
54842
54878
  var _a;
54879
+ const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
54880
+ const enclosingDeclaration = context.enclosingDeclaration;
54843
54881
  if (!isErrorType(type) && enclosingDeclaration) {
54844
- const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54882
+ const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
54845
54883
  if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
54846
54884
  const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
54847
54885
  const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
@@ -54854,7 +54892,7 @@ function createTypeChecker(host) {
54854
54892
  if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
54855
54893
  context.flags |= 1048576 /* AllowUniqueESSymbolType */;
54856
54894
  }
54857
- 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]);
54858
54896
  const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
54859
54897
  const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
54860
54898
  context.flags = oldFlags;
@@ -54968,7 +55006,7 @@ function createTypeChecker(host) {
54968
55006
  const type = getDeclaredTypeOfSymbol(sym);
54969
55007
  const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node2);
54970
55008
  name.symbol = sym;
54971
- return setTextRange(setEmitFlags(setOriginalNode(name, node2), 16777216 /* NoAsciiEscaping */), node2);
55009
+ return setTextRange2(context, setEmitFlags(name, 16777216 /* NoAsciiEscaping */), node2);
54972
55010
  }
54973
55011
  const updated = visitEachChild(
54974
55012
  node2,
@@ -54977,7 +55015,7 @@ function createTypeChecker(host) {
54977
55015
  void 0
54978
55016
  );
54979
55017
  if (updated !== node2) {
54980
- setTextRange(updated, node2);
55018
+ setTextRange2(context, updated, node2);
54981
55019
  }
54982
55020
  return updated;
54983
55021
  }
@@ -54991,12 +55029,12 @@ function createTypeChecker(host) {
54991
55029
  if (hadError) {
54992
55030
  return void 0;
54993
55031
  }
54994
- return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
55032
+ return transformed;
54995
55033
  function visitExistingNodeTreeSymbols(node) {
54996
55034
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
54997
55035
  const result = visitExistingNodeTreeSymbolsWorker(node);
54998
55036
  onExitNewScope == null ? void 0 : onExitNewScope();
54999
- return result;
55037
+ return result === node ? setTextRange2(context, factory.cloneNode(result), node) : result;
55000
55038
  }
55001
55039
  function onEnterNewScope(node) {
55002
55040
  const oldContex = context;
@@ -55132,7 +55170,7 @@ function createTypeChecker(host) {
55132
55170
  void 0
55133
55171
  );
55134
55172
  if (visited === node) {
55135
- visited = setTextRange(factory.cloneNode(node), node);
55173
+ visited = setTextRange2(context, factory.cloneNode(node), node);
55136
55174
  }
55137
55175
  visited.type = factory.createKeywordTypeNode(133 /* AnyKeyword */);
55138
55176
  if (isParameter(node)) {
@@ -55155,11 +55193,16 @@ function createTypeChecker(host) {
55155
55193
  /*context*/
55156
55194
  void 0
55157
55195
  );
55158
- const clone2 = setTextRange(visited === node ? factory.cloneNode(node) : visited, node);
55196
+ const clone2 = setTextRange2(context, visited === node ? factory.cloneNode(node) : visited, node);
55159
55197
  const flags = getEmitFlags(clone2);
55160
55198
  setEmitFlags(clone2, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
55161
55199
  return clone2;
55162
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
+ }
55163
55206
  if (isConditionalTypeNode(node)) {
55164
55207
  const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
55165
55208
  const disposeScope = onEnterNewScope(node);
@@ -55538,7 +55581,8 @@ function createTypeChecker(host) {
55538
55581
  );
55539
55582
  context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
55540
55583
  } else {
55541
- const statement = setTextRange(
55584
+ const statement = setTextRange2(
55585
+ context,
55542
55586
  factory.createVariableStatement(
55543
55587
  /*modifiers*/
55544
55588
  void 0,
@@ -55547,7 +55591,13 @@ function createTypeChecker(host) {
55547
55591
  name,
55548
55592
  /*exclamationToken*/
55549
55593
  void 0,
55550
- serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration)
55594
+ serializeTypeForDeclaration(
55595
+ context,
55596
+ /*declaration*/
55597
+ void 0,
55598
+ type,
55599
+ symbol
55600
+ )
55551
55601
  )
55552
55602
  ], flags)
55553
55603
  ),
@@ -55820,7 +55870,7 @@ function createTypeChecker(host) {
55820
55870
  const signatures = getSignaturesOfType(type, 0 /* Call */);
55821
55871
  for (const sig of signatures) {
55822
55872
  const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
55823
- addResult(setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags);
55873
+ addResult(setTextRange2(context, decl, getSignatureTextRangeLocation(sig)), modifierFlags);
55824
55874
  }
55825
55875
  if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
55826
55876
  const props = filter(getPropertiesOfType(type), isNamespaceMember);
@@ -55998,7 +56048,8 @@ function createTypeChecker(host) {
55998
56048
  const indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
55999
56049
  context.enclosingDeclaration = oldEnclosing;
56000
56050
  addResult(
56001
- setTextRange(
56051
+ setTextRange2(
56052
+ context,
56002
56053
  factory.createClassDeclaration(
56003
56054
  /*modifiers*/
56004
56055
  void 0,
@@ -56358,7 +56409,13 @@ function createTypeChecker(host) {
56358
56409
  varName,
56359
56410
  /*exclamationToken*/
56360
56411
  void 0,
56361
- serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration)
56412
+ serializeTypeForDeclaration(
56413
+ context,
56414
+ /*declaration*/
56415
+ void 0,
56416
+ typeToSerialize,
56417
+ symbol
56418
+ )
56362
56419
  )
56363
56420
  ], flags)
56364
56421
  );
@@ -56430,7 +56487,8 @@ function createTypeChecker(host) {
56430
56487
  });
56431
56488
  Debug.assert(!!setter);
56432
56489
  const paramSymbol = isFunctionLikeDeclaration(setter) ? getSignatureFromDeclaration(setter).parameters[0] : void 0;
56433
- result.push(setTextRange(
56490
+ result.push(setTextRange2(
56491
+ context,
56434
56492
  factory.createSetAccessorDeclaration(
56435
56493
  factory.createModifiersFromModifierFlags(flag),
56436
56494
  name,
@@ -56442,7 +56500,13 @@ function createTypeChecker(host) {
56442
56500
  paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
56443
56501
  /*questionToken*/
56444
56502
  void 0,
56445
- 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
+ )
56446
56510
  )],
56447
56511
  /*body*/
56448
56512
  void 0
@@ -56452,12 +56516,19 @@ function createTypeChecker(host) {
56452
56516
  }
56453
56517
  if (p.flags & 32768 /* GetAccessor */) {
56454
56518
  const isPrivate2 = modifierFlags & 2 /* Private */;
56455
- result.push(setTextRange(
56519
+ result.push(setTextRange2(
56520
+ context,
56456
56521
  factory.createGetAccessorDeclaration(
56457
56522
  factory.createModifiersFromModifierFlags(flag),
56458
56523
  name,
56459
56524
  [],
56460
- 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
+ ),
56461
56532
  /*body*/
56462
56533
  void 0
56463
56534
  ),
@@ -56466,12 +56537,19 @@ function createTypeChecker(host) {
56466
56537
  }
56467
56538
  return result;
56468
56539
  } else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) {
56469
- return setTextRange(
56540
+ return setTextRange2(
56541
+ context,
56470
56542
  createProperty2(
56471
56543
  factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
56472
56544
  name,
56473
56545
  p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
56474
- 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
+ ),
56475
56553
  // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
56476
56554
  // interface members can't have initializers, however class members _can_
56477
56555
  /*initializer*/
@@ -56484,7 +56562,8 @@ function createTypeChecker(host) {
56484
56562
  const type = getTypeOfSymbol(p);
56485
56563
  const signatures = getSignaturesOfType(type, 0 /* Call */);
56486
56564
  if (flag & 2 /* Private */) {
56487
- return setTextRange(
56565
+ return setTextRange2(
56566
+ context,
56488
56567
  createProperty2(
56489
56568
  factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
56490
56569
  name,
@@ -56510,7 +56589,7 @@ function createTypeChecker(host) {
56510
56589
  }
56511
56590
  );
56512
56591
  const location = sig.declaration && isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration;
56513
- results2.push(setTextRange(decl, location));
56592
+ results2.push(setTextRange2(context, decl, location));
56514
56593
  }
56515
56594
  return results2;
56516
56595
  }
@@ -56566,7 +56645,8 @@ function createTypeChecker(host) {
56566
56645
  }
56567
56646
  }
56568
56647
  if (privateProtected) {
56569
- return [setTextRange(
56648
+ return [setTextRange2(
56649
+ context,
56570
56650
  factory.createConstructorDeclaration(
56571
56651
  factory.createModifiersFromModifierFlags(privateProtected),
56572
56652
  /*parameters*/
@@ -56581,7 +56661,7 @@ function createTypeChecker(host) {
56581
56661
  const results2 = [];
56582
56662
  for (const sig of signatures) {
56583
56663
  const decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
56584
- results2.push(setTextRange(decl, sig.declaration));
56664
+ results2.push(setTextRange2(context, decl, sig.declaration));
56585
56665
  }
56586
56666
  return results2;
56587
56667
  }
@@ -60264,12 +60344,10 @@ function createTypeChecker(host) {
60264
60344
  const target = type.target ?? type;
60265
60345
  const typeVariable = getHomomorphicTypeVariable(target);
60266
60346
  if (typeVariable && !target.declaration.nameType) {
60267
- const constraint = getConstraintTypeFromMappedType(type);
60268
- if (constraint.flags & 4194304 /* Index */) {
60269
- const baseConstraint = getBaseConstraintOfType(constraint.type);
60270
- if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t))) {
60271
- return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
60272
- }
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));
60273
60351
  }
60274
60352
  }
60275
60353
  return type;
@@ -60430,13 +60508,13 @@ function createTypeChecker(host) {
60430
60508
  }
60431
60509
  function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
60432
60510
  var _a, _b, _c;
60433
- 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);
60434
60512
  if (!property) {
60435
60513
  property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
60436
60514
  if (property) {
60437
60515
  const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
60438
60516
  properties.set(name, property);
60439
- 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))) {
60440
60518
  const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
60441
60519
  properties2.set(name, property);
60442
60520
  }
@@ -65699,7 +65777,7 @@ function createTypeChecker(host) {
65699
65777
  const sourceTypePredicate = getTypePredicateOfSignature(source);
65700
65778
  if (sourceTypePredicate) {
65701
65779
  result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors2, errorReporter, compareTypes);
65702
- } else if (isIdentifierTypePredicate(targetTypePredicate)) {
65780
+ } else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
65703
65781
  if (reportErrors2) {
65704
65782
  errorReporter(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
65705
65783
  }
@@ -71419,7 +71497,7 @@ function createTypeChecker(host) {
71419
71497
  case 80 /* Identifier */:
71420
71498
  if (!isThisInTypeQuery(node)) {
71421
71499
  const symbol = getResolvedSymbol(node);
71422
- return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
71500
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol) || !!symbol.valueDeclaration && isFunctionExpression(symbol.valueDeclaration);
71423
71501
  }
71424
71502
  break;
71425
71503
  case 211 /* PropertyAccessExpression */:
@@ -79431,7 +79509,7 @@ function createTypeChecker(host) {
79431
79509
  true
79432
79510
  );
79433
79511
  }
79434
- if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === func.symbol) {
79512
+ if (expr.kind === 213 /* CallExpression */ && expr.expression.kind === 80 /* Identifier */ && checkExpressionCached(expr.expression).symbol === getMergedSymbol(func.symbol) && (!isFunctionExpressionOrArrowFunction(func.symbol.valueDeclaration) || isConstantReference(expr.expression))) {
79435
79513
  hasReturnOfTypeNever = true;
79436
79514
  return;
79437
79515
  }
@@ -88083,9 +88161,10 @@ function createTypeChecker(host) {
88083
88161
  return false;
88084
88162
  }
88085
88163
  function declaredParameterTypeContainsUndefined(parameter) {
88086
- if (!parameter.type)
88164
+ const typeNode = getNonlocalEffectiveTypeAnnotationNode(parameter);
88165
+ if (!typeNode)
88087
88166
  return false;
88088
- const type = getTypeFromTypeNode(parameter.type);
88167
+ const type = getTypeFromTypeNode(typeNode);
88089
88168
  return containsUndefinedType(type);
88090
88169
  }
88091
88170
  function requiresAddingImplicitUndefined(parameter) {
@@ -88095,7 +88174,7 @@ function createTypeChecker(host) {
88095
88174
  return !!strictNullChecks && !isOptionalParameter(parameter) && !isJSDocParameterTag(parameter) && !!parameter.initializer && !hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88096
88175
  }
88097
88176
  function isOptionalUninitializedParameterProperty(parameter) {
88098
- return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88177
+ return strictNullChecks && isOptionalParameter(parameter) && (isJSDocParameterTag(parameter) || !parameter.initializer) && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
88099
88178
  }
88100
88179
  function isExpandoFunctionDeclaration(node) {
88101
88180
  const declaration = getParseTreeNode(node, isFunctionDeclaration);
@@ -88245,14 +88324,14 @@ function createTypeChecker(host) {
88245
88324
  return 11 /* ObjectType */;
88246
88325
  }
88247
88326
  }
88248
- function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
88327
+ function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker) {
88249
88328
  const declaration = getParseTreeNode(declarationIn, isVariableLikeOrAccessor);
88250
88329
  if (!declaration) {
88251
88330
  return factory.createToken(133 /* AnyKeyword */);
88252
88331
  }
88253
88332
  const symbol = getSymbolOfDeclaration(declaration);
88254
88333
  const type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
88255
- return nodeBuilder.serializeTypeForDeclaration(type, symbol, addUndefined, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
88334
+ return nodeBuilder.serializeTypeForDeclaration(declaration, type, symbol, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
88256
88335
  }
88257
88336
  function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
88258
88337
  return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
@@ -114092,7 +114171,7 @@ function transformDeclarations(context) {
114092
114171
  case 172 /* PropertyDeclaration */:
114093
114172
  case 208 /* BindingElement */:
114094
114173
  case 260 /* VariableDeclaration */:
114095
- typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldAddImplicitUndefined);
114174
+ typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker);
114096
114175
  break;
114097
114176
  case 262 /* FunctionDeclaration */:
114098
114177
  case 180 /* ConstructSignature */:
@@ -134631,7 +134710,7 @@ function getQuotePreference(sourceFile, preferences) {
134631
134710
  if (preferences.quotePreference && preferences.quotePreference !== "auto") {
134632
134711
  return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */;
134633
134712
  } else {
134634
- 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));
134635
134714
  return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */;
134636
134715
  }
134637
134716
  }
@@ -134689,14 +134768,24 @@ function findModifier(node, kind) {
134689
134768
  return canHaveModifiers(node) ? find(node.modifiers, (m) => m.kind === kind) : void 0;
134690
134769
  }
134691
134770
  function insertImports(changes, sourceFile, imports, blankLineBetween, preferences) {
134771
+ var _a;
134692
134772
  const decl = isArray(imports) ? imports[0] : imports;
134693
134773
  const importKindPredicate = decl.kind === 243 /* VariableStatement */ ? isRequireVariableStatement : isAnyImportSyntax;
134694
134774
  const existingImportStatements = filter(sourceFile.statements, importKindPredicate);
134695
134775
  const { comparer, isSorted } = ts_OrganizeImports_exports.getOrganizeImportsStringComparerWithDetection(existingImportStatements, preferences);
134696
134776
  const sortedNewImports = isArray(imports) ? stableSort(imports, (a, b) => ts_OrganizeImports_exports.compareImportsOrRequireStatements(a, b, comparer)) : [imports];
134697
- if (!existingImportStatements.length) {
134698
- changes.insertNodesAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween);
134699
- } 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) {
134700
134789
  for (const newImport of sortedNewImports) {
134701
134790
  const insertionIndex = ts_OrganizeImports_exports.getImportDeclarationInsertionIndex(existingImportStatements, newImport, comparer);
134702
134791
  if (insertionIndex === 0) {
@@ -135622,7 +135711,7 @@ function createPackageJsonImportFilter(fromFile, preferences, host) {
135622
135711
  return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier);
135623
135712
  }
135624
135713
  function isAllowedCoreNodeModulesImport(moduleSpecifier) {
135625
- if (isSourceFileJS(fromFile) && ts_JsTyping_exports.nodeCoreModules.has(moduleSpecifier)) {
135714
+ if (isFullSourceFile(fromFile) && isSourceFileJS(fromFile) && ts_JsTyping_exports.nodeCoreModules.has(moduleSpecifier)) {
135626
135715
  if (usesNodeCoreModules === void 0) {
135627
135716
  usesNodeCoreModules = consumesNodeCoreModules(fromFile);
135628
135717
  }
@@ -135929,6 +136018,25 @@ function isBlockLike(node) {
135929
136018
  return false;
135930
136019
  }
135931
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
+ }
135932
136040
 
135933
136041
  // src/services/exportInfoMap.ts
135934
136042
  var ImportKind = /* @__PURE__ */ ((ImportKind2) => {
@@ -152106,15 +152214,27 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152106
152214
  const addToNamespace = [];
152107
152215
  const importType = [];
152108
152216
  const addToExisting = /* @__PURE__ */ new Map();
152217
+ const removeExisting = /* @__PURE__ */ new Set();
152218
+ const verbatimImports = /* @__PURE__ */ new Set();
152109
152219
  const newImports = /* @__PURE__ */ new Map();
152110
- 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
+ }
152111
152230
  function addImportFromDiagnostic(diagnostic, context) {
152112
152231
  const info = getFixInfos(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
152113
152232
  if (!info || !info.length)
152114
152233
  return;
152115
152234
  addImport(first(info));
152116
152235
  }
152117
- function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) {
152236
+ function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite, referenceImport) {
152237
+ var _a;
152118
152238
  const moduleSymbol = Debug.checkDefined(exportedSymbol.parent);
152119
152239
  const symbolName2 = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions));
152120
152240
  const checker = program.getTypeChecker();
@@ -152132,7 +152252,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152132
152252
  cancellationToken
152133
152253
  );
152134
152254
  const useRequire = shouldUseRequire(sourceFile, program);
152135
- const fix = getImportFixForSymbol(
152255
+ let fix = getImportFixForSymbol(
152136
152256
  sourceFile,
152137
152257
  Debug.checkDefined(exportInfo),
152138
152258
  program,
@@ -152144,9 +152264,72 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152144
152264
  preferences
152145
152265
  );
152146
152266
  if (fix) {
152147
- 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 });
152148
152325
  }
152149
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
+ }
152150
152333
  function addImport(info) {
152151
152334
  var _a, _b;
152152
152335
  const { fix, symbolName: symbolName2 } = info;
@@ -152159,10 +152342,9 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152159
152342
  break;
152160
152343
  case 2 /* AddToExisting */: {
152161
152344
  const { importClauseOrBindingPattern, importKind, addAsTypeOnly } = fix;
152162
- const key = String(getNodeId(importClauseOrBindingPattern));
152163
- let entry = addToExisting.get(key);
152345
+ let entry = addToExisting.get(importClauseOrBindingPattern);
152164
152346
  if (!entry) {
152165
- 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() });
152166
152348
  }
152167
152349
  if (importKind === 0 /* Named */) {
152168
152350
  const prevValue = entry == null ? void 0 : entry.namedImports.get(symbolName2);
@@ -152244,8 +152426,9 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152244
152426
  }
152245
152427
  }
152246
152428
  function writeFixes(changeTracker, oldFileQuotePreference) {
152429
+ var _a, _b;
152247
152430
  let quotePreference;
152248
- if (sourceFile.imports.length === 0 && oldFileQuotePreference !== void 0) {
152431
+ if (isFullSourceFile(sourceFile) && sourceFile.imports.length === 0 && oldFileQuotePreference !== void 0) {
152249
152432
  quotePreference = oldFileQuotePreference;
152250
152433
  } else {
152251
152434
  quotePreference = getQuotePreference(sourceFile, preferences);
@@ -152256,6 +152439,82 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152256
152439
  for (const fix of importType) {
152257
152440
  addImportType(changeTracker, sourceFile, fix, quotePreference);
152258
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
+ }
152259
152518
  addToExisting.forEach(({ importClauseOrBindingPattern, defaultImport, namedImports }) => {
152260
152519
  doAddExistingFix(
152261
152520
  changeTracker,
@@ -152263,6 +152522,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152263
152522
  importClauseOrBindingPattern,
152264
152523
  defaultImport,
152265
152524
  arrayFrom(namedImports.entries(), ([name, addAsTypeOnly]) => ({ addAsTypeOnly, name })),
152525
+ importSpecifiersToRemoveWhileAdding,
152266
152526
  preferences
152267
152527
  );
152268
152528
  });
@@ -152281,6 +152541,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152281
152541
  );
152282
152542
  newDeclarations = combine(newDeclarations, declarations);
152283
152543
  });
152544
+ newDeclarations = combine(newDeclarations, getCombinedVerbatimImports());
152284
152545
  if (newDeclarations) {
152285
152546
  insertImports(
152286
152547
  changeTracker,
@@ -152292,8 +152553,85 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
152292
152553
  );
152293
152554
  }
152294
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
+ }
152295
152633
  function hasFixes() {
152296
- 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;
152297
152635
  }
152298
152636
  }
152299
152637
  function createImportSpecifierResolver(importingFile, program, host, preferences) {
@@ -152402,9 +152740,12 @@ function getSingleExportInfoForSymbol(symbol, symbolName2, moduleSymbol, program
152402
152740
  }
152403
152741
  }
152404
152742
  }
152405
- 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) {
152406
152747
  const checker = program.getTypeChecker();
152407
- const existingImports = flatMap(exportInfos, importMap.getImportsForExportInfo);
152748
+ const existingImports = importMap && !isFutureSymbolExportInfoArray(exportInfos) ? flatMap(exportInfos, importMap.getImportsForExportInfo) : emptyArray;
152408
152749
  const useNamespace = usagePosition !== void 0 && tryUseExistingNamespaceImport(existingImports, usagePosition);
152409
152750
  const addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152410
152751
  if (addToExisting) {
@@ -152460,7 +152801,7 @@ function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, sym
152460
152801
  if (!isValidTypeOnlyUseSite) {
152461
152802
  return 4 /* NotAllowed */;
152462
152803
  }
152463
- if (compilerOptions.verbatimModuleSyntax && (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
152804
+ if (symbol && compilerOptions.verbatimModuleSyntax && (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) {
152464
152805
  return 2 /* Required */;
152465
152806
  }
152466
152807
  return 1 /* Allowed */;
@@ -152547,7 +152888,7 @@ function createExistingImportMap(checker, importingFile, compilerOptions) {
152547
152888
  };
152548
152889
  }
152549
152890
  function shouldUseRequire(sourceFile, program) {
152550
- if (!isSourceFileJS(sourceFile)) {
152891
+ if (!hasJSFileExtension(sourceFile.fileName)) {
152551
152892
  return false;
152552
152893
  }
152553
152894
  if (sourceFile.commonJsModuleIndicator && !sourceFile.externalModuleIndicator)
@@ -152576,14 +152917,14 @@ function createGetChecker(program, host) {
152576
152917
  return memoizeOne((isFromPackageJson) => isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker());
152577
152918
  }
152578
152919
  function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUseSite, useRequire, exportInfo, host, preferences, fromCacheOnly) {
152579
- const isJs = isSourceFileJS(sourceFile);
152920
+ const isJs = hasJSFileExtension(sourceFile.fileName);
152580
152921
  const compilerOptions = program.getCompilerOptions();
152581
152922
  const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
152582
152923
  const getChecker = createGetChecker(program, host);
152583
152924
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
152584
152925
  const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution);
152585
- const getModuleSpecifiers2 = fromCacheOnly ? (moduleSymbol) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
152586
- 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,
152587
152928
  checker,
152588
152929
  compilerOptions,
152589
152930
  sourceFile,
@@ -152597,7 +152938,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
152597
152938
  let computedWithoutCacheCount = 0;
152598
152939
  const fixes = flatMap(exportInfo, (exportInfo2, i) => {
152599
152940
  const checker = getChecker(exportInfo2.isFromPackageJson);
152600
- const { computedWithoutCache, moduleSpecifiers } = getModuleSpecifiers2(exportInfo2.moduleSymbol, checker);
152941
+ const { computedWithoutCache, moduleSpecifiers } = getModuleSpecifiers2(exportInfo2, checker);
152601
152942
  const importedSymbolHasValueMeaning = !!(exportInfo2.targetFlags & 111551 /* Value */);
152602
152943
  const addAsTypeOnly = getAddAsTypeOnly(
152603
152944
  isValidTypeOnlyUseSite,
@@ -152688,6 +153029,11 @@ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host)
152688
153029
  const _toPath = (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
152689
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));
152690
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
+ }
152691
153037
  function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
152692
153038
  if (!some(fixes))
152693
153039
  return;
@@ -152711,17 +153057,17 @@ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
152711
153057
  function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath3) {
152712
153058
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
152713
153059
  return compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || compareBooleans(
152714
- isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath3),
152715
- isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath3)
153060
+ isFixPossiblyReExportingImportingFile(a, importingFile.path, toPath3),
153061
+ isFixPossiblyReExportingImportingFile(b, importingFile.path, toPath3)
152716
153062
  ) || compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
152717
153063
  }
152718
153064
  return 0 /* EqualTo */;
152719
153065
  }
152720
- function isFixPossiblyReExportingImportingFile(fix, importingFile, compilerOptions, toPath3) {
153066
+ function isFixPossiblyReExportingImportingFile(fix, importingFilePath, toPath3) {
152721
153067
  var _a;
152722
153068
  if (fix.isReExport && ((_a = fix.exportInfo) == null ? void 0 : _a.moduleFileName) && isIndexFileName(fix.exportInfo.moduleFileName)) {
152723
153069
  const reExportDir = toPath3(getDirectoryPath(fix.exportInfo.moduleFileName));
152724
- return startsWith(importingFile.path, reExportDir);
153070
+ return startsWith(importingFilePath, reExportDir);
152725
153071
  }
152726
153072
  return false;
152727
153073
  }
@@ -152811,8 +153157,8 @@ function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
152811
153157
  case 2 /* AMD */:
152812
153158
  case 1 /* CommonJS */:
152813
153159
  case 3 /* UMD */:
152814
- if (isInJSFile(importingFile)) {
152815
- return isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */;
153160
+ if (hasJSFileExtension(importingFile.fileName)) {
153161
+ return importingFile.externalModuleIndicator || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */;
152816
153162
  }
152817
153163
  return 3 /* CommonJS */;
152818
153164
  case 4 /* System */:
@@ -152923,14 +153269,14 @@ function getExportInfos(symbolName2, isJsxTagName, currentTokenMeaning, cancella
152923
153269
  }
152924
153270
  function getExportEqualsImportKind(importingFile, compilerOptions, forceImportKeyword) {
152925
153271
  const allowSyntheticDefaults = getAllowSyntheticDefaultImports(compilerOptions);
152926
- const isJS = isInJSFile(importingFile);
153272
+ const isJS = hasJSFileExtension(importingFile.fileName);
152927
153273
  if (!isJS && getEmitModuleKind(compilerOptions) >= 5 /* ES2015 */) {
152928
153274
  return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */;
152929
153275
  }
152930
153276
  if (isJS) {
152931
- return isExternalModule(importingFile) || forceImportKeyword ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ : 3 /* CommonJS */;
153277
+ return importingFile.externalModuleIndicator || forceImportKeyword ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ : 3 /* CommonJS */;
152932
153278
  }
152933
- for (const statement of importingFile.statements) {
153279
+ for (const statement of importingFile.statements ?? emptyArray) {
152934
153280
  if (isImportEqualsDeclaration(statement) && !nodeIsMissing(statement.moduleReference)) {
152935
153281
  return 3 /* CommonJS */;
152936
153282
  }
@@ -152961,6 +153307,8 @@ function codeActionForFixWorker(changes, sourceFile, symbolName2, fix, includeSy
152961
153307
  importClauseOrBindingPattern,
152962
153308
  importKind === 1 /* Default */ ? { name: symbolName2, addAsTypeOnly } : void 0,
152963
153309
  importKind === 0 /* Named */ ? [{ name: symbolName2, addAsTypeOnly }] : emptyArray,
153310
+ /*removeExistingImportSpecifiers*/
153311
+ void 0,
152964
153312
  preferences
152965
153313
  );
152966
153314
  const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier);
@@ -153075,9 +153423,33 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
153075
153423
  }
153076
153424
  }
153077
153425
  }
153078
- function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, preferences) {
153426
+ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, removeExistingImportSpecifiers, preferences) {
153079
153427
  var _a;
153080
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
+ }
153081
153453
  if (defaultImport) {
153082
153454
  addElementToBindingPattern(clause, defaultImport.name, "default");
153083
153455
  }
@@ -153110,7 +153482,16 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
153110
153482
  ),
153111
153483
  specifierComparer
153112
153484
  );
153113
- 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) {
153114
153495
  const transformedExistingSpecifiers = promoteFromTypeOnly2 && existingSpecifiers ? factory.updateNamedImports(
153115
153496
  clause.namedBindings,
153116
153497
  sameMap(existingSpecifiers, (e) => factory.updateImportSpecifier(
@@ -161946,13 +162327,13 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
161946
162327
  ({ exportInfo: exportInfo2 = info[0], moduleSpecifier } = result);
161947
162328
  }
161948
162329
  const isDefaultExport = exportInfo2.exportKind === 1 /* Default */;
161949
- const symbol = isDefaultExport && getLocalSymbolForExportDefault(exportInfo2.symbol) || exportInfo2.symbol;
162330
+ const symbol = isDefaultExport && getLocalSymbolForExportDefault(Debug.checkDefined(exportInfo2.symbol)) || Debug.checkDefined(exportInfo2.symbol);
161950
162331
  pushAutoImportSymbol(symbol, {
161951
162332
  kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
161952
162333
  moduleSpecifier,
161953
162334
  symbolName: symbolName2,
161954
162335
  exportMapKey,
161955
- exportName: exportInfo2.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo2.symbol.name,
162336
+ exportName: exportInfo2.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : Debug.checkDefined(exportInfo2.symbol).name,
161956
162337
  fileName: exportInfo2.moduleFileName,
161957
162338
  isDefaultExport,
161958
162339
  moduleSymbol: exportInfo2.moduleSymbol,
@@ -175406,6 +175787,7 @@ __export(ts_exports2, {
175406
175787
  createFileDiagnosticFromMessageChain: () => createFileDiagnosticFromMessageChain,
175407
175788
  createFlowNode: () => createFlowNode,
175408
175789
  createForOfBindingStatement: () => createForOfBindingStatement,
175790
+ createFutureSourceFile: () => createFutureSourceFile,
175409
175791
  createGetCanonicalFileName: () => createGetCanonicalFileName,
175410
175792
  createGetSourceFile: () => createGetSourceFile,
175411
175793
  createGetSymbolAccessibilityDiagnosticForNode: () => createGetSymbolAccessibilityDiagnosticForNode,
@@ -176177,6 +176559,7 @@ __export(ts_exports2, {
176177
176559
  isAnyDirectorySeparator: () => isAnyDirectorySeparator,
176178
176560
  isAnyImportOrBareOrAccessedRequire: () => isAnyImportOrBareOrAccessedRequire,
176179
176561
  isAnyImportOrReExport: () => isAnyImportOrReExport,
176562
+ isAnyImportOrRequireStatement: () => isAnyImportOrRequireStatement,
176180
176563
  isAnyImportSyntax: () => isAnyImportSyntax,
176181
176564
  isAnySupportedFileExtension: () => isAnySupportedFileExtension,
176182
176565
  isApplicableVersionedTypesKey: () => isApplicableVersionedTypesKey,
@@ -176367,6 +176750,7 @@ __export(ts_exports2, {
176367
176750
  isForInitializer: () => isForInitializer,
176368
176751
  isForOfStatement: () => isForOfStatement,
176369
176752
  isForStatement: () => isForStatement,
176753
+ isFullSourceFile: () => isFullSourceFile,
176370
176754
  isFunctionBlock: () => isFunctionBlock,
176371
176755
  isFunctionBody: () => isFunctionBody,
176372
176756
  isFunctionDeclaration: () => isFunctionDeclaration,
@@ -181122,6 +181506,13 @@ var ConfiguredProject2 = class extends Project3 {
181122
181506
  this.compilerHost = void 0;
181123
181507
  this.projectService.sendProjectLoadingFinishEvent(this);
181124
181508
  this.projectService.sendProjectTelemetry(this);
181509
+ if (!this.skipConfigDiagEvent && !result) {
181510
+ this.projectService.sendConfigFileDiagEvent(
181511
+ this,
181512
+ /*triggerFile*/
181513
+ void 0
181514
+ );
181515
+ }
181125
181516
  return result;
181126
181517
  }
181127
181518
  /** @internal */
@@ -181576,7 +181967,12 @@ function projectContainsInfoDirectly(project, info) {
181576
181967
  }
181577
181968
  function updateProjectIfDirty(project) {
181578
181969
  project.invalidateResolutionsOfFailedLookupLocations();
181579
- 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;
181580
181976
  }
181581
181977
  function setProjectOptionsUsed(project) {
181582
181978
  if (isConfiguredProject(project)) {
@@ -182868,6 +183264,7 @@ var _ProjectService = class _ProjectService {
182868
183264
  /** @internal */
182869
183265
  createLoadAndUpdateConfiguredProject(configFileName, reason) {
182870
183266
  const project = this.createAndLoadConfiguredProject(configFileName, reason);
183267
+ project.skipConfigDiagEvent = true;
182871
183268
  project.updateGraph();
182872
183269
  return project;
182873
183270
  }
@@ -183160,6 +183557,7 @@ var _ProjectService = class _ProjectService {
183160
183557
  const configFileName = project.getConfigFilePath();
183161
183558
  this.logger.info(`${isInitialLoad ? "Loading" : "Reloading"} configured project ${configFileName}`);
183162
183559
  this.loadConfiguredProject(project, reason);
183560
+ project.skipConfigDiagEvent = true;
183163
183561
  project.updateGraph();
183164
183562
  this.sendConfigFileDiagEvent(project, configFileName);
183165
183563
  }
@@ -183173,16 +183571,20 @@ var _ProjectService = class _ProjectService {
183173
183571
  project.cleanupProgram();
183174
183572
  project.markAsDirty();
183175
183573
  }
183574
+ /** @internal */
183176
183575
  sendConfigFileDiagEvent(project, triggerFile) {
183177
183576
  if (!this.eventHandler || this.suppressDiagnosticEvents) {
183178
183577
  return;
183179
183578
  }
183180
183579
  const diagnostics = project.getLanguageService().getCompilerOptionsDiagnostics();
183181
183580
  diagnostics.push(...project.getAllProjectErrors());
183581
+ if (!triggerFile && !!diagnostics.length === !!project.hasConfigFileDiagnostics)
183582
+ return;
183583
+ project.hasConfigFileDiagnostics = !!diagnostics.length;
183182
183584
  this.eventHandler(
183183
183585
  {
183184
183586
  eventName: ConfigFileDiagEvent,
183185
- data: { configFileName: project.getConfigFilePath(), diagnostics, triggerFile }
183587
+ data: { configFileName: project.getConfigFilePath(), diagnostics, triggerFile: triggerFile ?? project.getConfigFilePath() }
183186
183588
  }
183187
183589
  );
183188
183590
  }
@@ -183972,7 +184374,7 @@ Dynamic files must always be opened with service's current directory or service
183972
184374
  project = this.createLoadAndUpdateConfiguredProject(configFileName, `Creating possible configured project for ${info.fileName} to open`);
183973
184375
  defaultConfigProjectIsCreated = true;
183974
184376
  } else {
183975
- updateProjectIfDirty(project);
184377
+ updateConfiguredProjectWithoutConfigDiagIfDirty(project);
183976
184378
  }
183977
184379
  projectForConfigFileDiag = project.containsScriptInfo(info) ? project : void 0;
183978
184380
  retainProjects = project;
@@ -183981,7 +184383,7 @@ Dynamic files must always be opened with service's current directory or service
183981
184383
  project,
183982
184384
  info.path,
183983
184385
  (child) => {
183984
- updateProjectIfDirty(child);
184386
+ updateConfiguredProjectWithoutConfigDiagIfDirty(child);
183985
184387
  if (!isArray(retainProjects)) {
183986
184388
  retainProjects = [project, child];
183987
184389
  } else {
@@ -189629,6 +190031,7 @@ if (typeof console !== "undefined") {
189629
190031
  createFileDiagnosticFromMessageChain,
189630
190032
  createFlowNode,
189631
190033
  createForOfBindingStatement,
190034
+ createFutureSourceFile,
189632
190035
  createGetCanonicalFileName,
189633
190036
  createGetSourceFile,
189634
190037
  createGetSymbolAccessibilityDiagnosticForNode,
@@ -190400,6 +190803,7 @@ if (typeof console !== "undefined") {
190400
190803
  isAnyDirectorySeparator,
190401
190804
  isAnyImportOrBareOrAccessedRequire,
190402
190805
  isAnyImportOrReExport,
190806
+ isAnyImportOrRequireStatement,
190403
190807
  isAnyImportSyntax,
190404
190808
  isAnySupportedFileExtension,
190405
190809
  isApplicableVersionedTypesKey,
@@ -190590,6 +190994,7 @@ if (typeof console !== "undefined") {
190590
190994
  isForInitializer,
190591
190995
  isForOfStatement,
190592
190996
  isForStatement,
190997
+ isFullSourceFile,
190593
190998
  isFunctionBlock,
190594
190999
  isFunctionBody,
190595
191000
  isFunctionDeclaration,