typescript 5.5.0-dev.20240510 → 5.5.0-dev.20240511

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240510`;
21
+ var version = `${versionMajorMinor}.0-dev.20240511`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12182,7 +12182,7 @@ function canHaveLocals(node) {
12182
12182
  }
12183
12183
  }
12184
12184
  function isDeclarationKind(kind) {
12185
- return kind === 219 /* ArrowFunction */ || kind === 208 /* BindingElement */ || kind === 263 /* ClassDeclaration */ || kind === 231 /* ClassExpression */ || kind === 175 /* ClassStaticBlockDeclaration */ || kind === 176 /* Constructor */ || kind === 266 /* EnumDeclaration */ || kind === 306 /* EnumMember */ || kind === 281 /* ExportSpecifier */ || kind === 262 /* FunctionDeclaration */ || kind === 218 /* FunctionExpression */ || kind === 177 /* GetAccessor */ || kind === 273 /* ImportClause */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 276 /* ImportSpecifier */ || kind === 264 /* InterfaceDeclaration */ || kind === 291 /* JsxAttribute */ || kind === 174 /* MethodDeclaration */ || kind === 173 /* MethodSignature */ || kind === 267 /* ModuleDeclaration */ || kind === 270 /* NamespaceExportDeclaration */ || kind === 274 /* NamespaceImport */ || kind === 280 /* NamespaceExport */ || kind === 169 /* Parameter */ || kind === 303 /* PropertyAssignment */ || kind === 172 /* PropertyDeclaration */ || kind === 171 /* PropertySignature */ || kind === 178 /* SetAccessor */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 265 /* TypeAliasDeclaration */ || kind === 168 /* TypeParameter */ || kind === 260 /* VariableDeclaration */ || kind === 346 /* JSDocTypedefTag */ || kind === 338 /* JSDocCallbackTag */ || kind === 348 /* JSDocPropertyTag */;
12185
+ return kind === 219 /* ArrowFunction */ || kind === 208 /* BindingElement */ || kind === 263 /* ClassDeclaration */ || kind === 231 /* ClassExpression */ || kind === 175 /* ClassStaticBlockDeclaration */ || kind === 176 /* Constructor */ || kind === 266 /* EnumDeclaration */ || kind === 306 /* EnumMember */ || kind === 281 /* ExportSpecifier */ || kind === 262 /* FunctionDeclaration */ || kind === 218 /* FunctionExpression */ || kind === 177 /* GetAccessor */ || kind === 273 /* ImportClause */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 276 /* ImportSpecifier */ || kind === 264 /* InterfaceDeclaration */ || kind === 291 /* JsxAttribute */ || kind === 174 /* MethodDeclaration */ || kind === 173 /* MethodSignature */ || kind === 267 /* ModuleDeclaration */ || kind === 270 /* NamespaceExportDeclaration */ || kind === 274 /* NamespaceImport */ || kind === 280 /* NamespaceExport */ || kind === 169 /* Parameter */ || kind === 303 /* PropertyAssignment */ || kind === 172 /* PropertyDeclaration */ || kind === 171 /* PropertySignature */ || kind === 178 /* SetAccessor */ || kind === 304 /* ShorthandPropertyAssignment */ || kind === 265 /* TypeAliasDeclaration */ || kind === 168 /* TypeParameter */ || kind === 260 /* VariableDeclaration */ || kind === 346 /* JSDocTypedefTag */ || kind === 338 /* JSDocCallbackTag */ || kind === 348 /* JSDocPropertyTag */ || kind === 202 /* NamedTupleMember */;
12186
12186
  }
12187
12187
  function isDeclarationStatementKind(kind) {
12188
12188
  return kind === 262 /* FunctionDeclaration */ || kind === 282 /* MissingDeclaration */ || kind === 263 /* ClassDeclaration */ || kind === 264 /* InterfaceDeclaration */ || kind === 265 /* TypeAliasDeclaration */ || kind === 266 /* EnumDeclaration */ || kind === 267 /* ModuleDeclaration */ || kind === 272 /* ImportDeclaration */ || kind === 271 /* ImportEqualsDeclaration */ || kind === 278 /* ExportDeclaration */ || kind === 277 /* ExportAssignment */ || kind === 270 /* NamespaceExportDeclaration */;
@@ -18881,13 +18881,15 @@ function createNameResolver({
18881
18881
  let useResult = true;
18882
18882
  if (isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
18883
18883
  if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) {
18884
- useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || lastLocation.kind === 169 /* Parameter */ || lastLocation.kind === 341 /* JSDocParameterTag */ || lastLocation.kind === 342 /* JSDocReturnTag */ || lastLocation.kind === 168 /* TypeParameter */ : false;
18884
+ useResult = result.flags & 262144 /* TypeParameter */ ? !!(lastLocation.flags & 16 /* Synthesized */) || // Synthetic fake scopes are added for signatures so type parameters are accessible from them
18885
+ lastLocation === location.type || lastLocation.kind === 169 /* Parameter */ || lastLocation.kind === 341 /* JSDocParameterTag */ || lastLocation.kind === 342 /* JSDocReturnTag */ || lastLocation.kind === 168 /* TypeParameter */ : false;
18885
18886
  }
18886
18887
  if (meaning & result.flags & 3 /* Variable */) {
18887
18888
  if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
18888
18889
  useResult = false;
18889
18890
  } else if (result.flags & 1 /* FunctionScopedVariable */) {
18890
- useResult = lastLocation.kind === 169 /* Parameter */ || lastLocation === location.type && !!findAncestor(result.valueDeclaration, isParameter);
18891
+ useResult = lastLocation.kind === 169 /* Parameter */ || !!(lastLocation.flags & 16 /* Synthesized */) || // Synthetic fake scopes are added for signatures so parameters are accessible from them
18892
+ lastLocation === location.type && !!findAncestor(result.valueDeclaration, isParameter);
18891
18893
  }
18892
18894
  }
18893
18895
  } else if (location.kind === 194 /* ConditionalType */) {
@@ -46410,7 +46412,6 @@ function createTypeChecker(host) {
46410
46412
  if (meaning) {
46411
46413
  const symbol = getMergedSymbol(symbols.get(name));
46412
46414
  if (symbol) {
46413
- Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
46414
46415
  if (symbol.flags & meaning) {
46415
46416
  return symbol;
46416
46417
  }
@@ -47814,7 +47815,6 @@ function createTypeChecker(host) {
47814
47815
  } else {
47815
47816
  Debug.assertNever(name, "Unknown entity name kind.");
47816
47817
  }
47817
- Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
47818
47818
  if (!nodeIsSynthesized(name) && isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 277 /* ExportAssignment */)) {
47819
47819
  markSymbolOfAliasDeclarationIfTypeOnly(
47820
47820
  getAliasDeclarationFromName(name),
@@ -49235,7 +49235,6 @@ function createTypeChecker(host) {
49235
49235
  return symbolToExpression(symbol, context, meaning);
49236
49236
  }
49237
49237
  function withContext(enclosingDeclaration, flags, tracker, cb) {
49238
- Debug.assert(enclosingDeclaration === void 0 || (enclosingDeclaration.flags & 16 /* Synthesized */) === 0);
49239
49238
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
49240
49239
  const context = {
49241
49240
  enclosingDeclaration,
@@ -49249,7 +49248,18 @@ function createTypeChecker(host) {
49249
49248
  inferTypeParameters: void 0,
49250
49249
  approximateLength: 0,
49251
49250
  trackedSymbols: void 0,
49252
- bundled: !!compilerOptions.outFile && !!enclosingDeclaration && isExternalOrCommonJsModule(getSourceFileOfNode(enclosingDeclaration))
49251
+ bundled: !!compilerOptions.outFile && !!enclosingDeclaration && isExternalOrCommonJsModule(getSourceFileOfNode(enclosingDeclaration)),
49252
+ truncating: false,
49253
+ usedSymbolNames: void 0,
49254
+ remappedSymbolNames: void 0,
49255
+ remappedSymbolReferences: void 0,
49256
+ reverseMappedStack: void 0,
49257
+ mustCreateTypeParameterSymbolList: true,
49258
+ typeParameterSymbolList: void 0,
49259
+ mustCreateTypeParametersNamesLookups: true,
49260
+ typeParameterNames: void 0,
49261
+ typeParameterNamesByText: void 0,
49262
+ typeParameterNamesByTextNextNameCount: void 0
49253
49263
  };
49254
49264
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
49255
49265
  const resultingNode = cb(context);
@@ -50244,22 +50254,22 @@ function createTypeChecker(host) {
50244
50254
  }
50245
50255
  function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
50246
50256
  var _a;
50247
- const flags = context.flags;
50248
- context.flags &= ~256 /* SuppressAnyReturnType */;
50249
- context.approximateLength += 3;
50250
50257
  let typeParameters;
50251
50258
  let typeArguments;
50252
- if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
50253
- typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
50254
- } else {
50255
- typeParameters = signature.typeParameters && signature.typeParameters.map((parameter) => typeParameterToDeclaration(parameter, context));
50256
- }
50257
50259
  const expandedParams = getExpandedParameters(
50258
50260
  signature,
50259
50261
  /*skipUnionExpanding*/
50260
50262
  true
50261
50263
  )[0];
50262
- const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
50264
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters);
50265
+ context.approximateLength += 3;
50266
+ if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
50267
+ typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
50268
+ } else {
50269
+ typeParameters = signature.typeParameters && signature.typeParameters.map((parameter) => typeParameterToDeclaration(parameter, context));
50270
+ }
50271
+ const flags = context.flags;
50272
+ context.flags &= ~256 /* SuppressAnyReturnType */;
50263
50273
  const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */));
50264
50274
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
50265
50275
  if (thisParameter) {
@@ -50357,15 +50367,14 @@ function createTypeChecker(host) {
50357
50367
  return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
50358
50368
  }
50359
50369
  function getParametersInScope(node) {
50360
- return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
50361
- getSignatureFromDeclaration(node),
50362
- /*skipUnionExpanding*/
50363
- true
50364
- )[0] : void 0;
50365
- }
50366
- function enterNewScope(context, declaration, expandedParams, typeParameters) {
50367
- let cleanup;
50368
- if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
50370
+ return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).parameters : void 0;
50371
+ }
50372
+ function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters) {
50373
+ const cleanupContext = cloneNodeBuilderContext(context);
50374
+ let cleanupParams;
50375
+ let cleanupTypeParams;
50376
+ const oldEnclosingDecl = context.enclosingDeclaration;
50377
+ if (context.enclosingDeclaration && declaration) {
50369
50378
  let pushFakeScope2 = function(kind, addAll) {
50370
50379
  Debug.assert(context.enclosingDeclaration);
50371
50380
  let existingFakeScope;
@@ -50377,39 +50386,45 @@ function createTypeChecker(host) {
50377
50386
  Debug.assertOptionalNode(existingFakeScope, isBlock);
50378
50387
  const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
50379
50388
  let newLocals;
50389
+ let oldLocals;
50380
50390
  addAll((name, symbol) => {
50381
- if (!locals.has(name)) {
50382
- newLocals = append(newLocals, name);
50383
- locals.set(name, symbol);
50391
+ if (existingFakeScope) {
50392
+ const oldSymbol = locals.get(name);
50393
+ if (!oldSymbol) {
50394
+ newLocals = append(newLocals, name);
50395
+ } else {
50396
+ oldLocals = append(oldLocals, { name, oldSymbol });
50397
+ }
50384
50398
  }
50399
+ locals.set(name, symbol);
50385
50400
  });
50386
- if (!newLocals) return;
50387
- const oldCleanup = cleanup;
50388
- function undo() {
50389
- forEach(newLocals, (s) => locals.delete(s));
50390
- oldCleanup == null ? void 0 : oldCleanup();
50391
- }
50392
- if (existingFakeScope) {
50393
- cleanup = undo;
50394
- } else {
50395
- const fakeScope = parseNodeFactory.createBlock(emptyArray);
50401
+ if (!existingFakeScope) {
50402
+ const fakeScope = factory.createBlock(emptyArray);
50396
50403
  getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
50397
50404
  fakeScope.locals = locals;
50398
- const saveEnclosingDeclaration = context.enclosingDeclaration;
50399
- setParent(fakeScope, saveEnclosingDeclaration);
50405
+ setParent(fakeScope, context.enclosingDeclaration);
50400
50406
  context.enclosingDeclaration = fakeScope;
50401
- cleanup = () => {
50402
- context.enclosingDeclaration = saveEnclosingDeclaration;
50403
- undo();
50407
+ } else {
50408
+ return function undo() {
50409
+ forEach(newLocals, (s) => locals.delete(s));
50410
+ forEach(oldLocals, (s) => locals.set(s.name, s.oldSymbol));
50404
50411
  };
50405
50412
  }
50406
50413
  };
50407
50414
  var pushFakeScope = pushFakeScope2;
50408
- pushFakeScope2(
50415
+ cleanupParams = !some(expandedParams) ? void 0 : pushFakeScope2(
50409
50416
  "params",
50410
50417
  (add) => {
50411
- for (const param of expandedParams ?? emptyArray) {
50412
- if (!forEach(param.declarations, (d) => {
50418
+ if (!expandedParams) return;
50419
+ for (let pIndex = 0; pIndex < expandedParams.length; pIndex++) {
50420
+ const param = expandedParams[pIndex];
50421
+ const originalParam = originalParameters == null ? void 0 : originalParameters[pIndex];
50422
+ if (originalParameters && originalParam !== param) {
50423
+ add(param.escapedName, unknownSymbol);
50424
+ if (originalParam) {
50425
+ add(originalParam.escapedName, unknownSymbol);
50426
+ }
50427
+ } else if (!forEach(param.declarations, (d) => {
50413
50428
  if (isParameter(d) && isBindingPattern(d.name)) {
50414
50429
  bindPattern(d.name);
50415
50430
  return true;
@@ -50440,8 +50455,8 @@ function createTypeChecker(host) {
50440
50455
  }
50441
50456
  }
50442
50457
  );
50443
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
50444
- pushFakeScope2(
50458
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && some(typeParameters)) {
50459
+ cleanupTypeParams = pushFakeScope2(
50445
50460
  "typeParams",
50446
50461
  (add) => {
50447
50462
  for (const typeParam of typeParameters ?? emptyArray) {
@@ -50451,8 +50466,13 @@ function createTypeChecker(host) {
50451
50466
  }
50452
50467
  );
50453
50468
  }
50454
- return cleanup;
50455
50469
  }
50470
+ return () => {
50471
+ cleanupParams == null ? void 0 : cleanupParams();
50472
+ cleanupTypeParams == null ? void 0 : cleanupTypeParams();
50473
+ cleanupContext();
50474
+ context.enclosingDeclaration = oldEnclosingDecl;
50475
+ };
50456
50476
  }
50457
50477
  function tryGetThisParameterDeclaration(signature, context) {
50458
50478
  if (signature.thisParameter) {
@@ -50670,7 +50690,11 @@ function createTypeChecker(host) {
50670
50690
  if ((_a = context.typeParameterSymbolList) == null ? void 0 : _a.has(symbolId)) {
50671
50691
  return void 0;
50672
50692
  }
50673
- (context.typeParameterSymbolList || (context.typeParameterSymbolList = /* @__PURE__ */ new Set())).add(symbolId);
50693
+ if (context.mustCreateTypeParameterSymbolList) {
50694
+ context.mustCreateTypeParameterSymbolList = false;
50695
+ context.typeParameterSymbolList = new Set(context.typeParameterSymbolList);
50696
+ }
50697
+ context.typeParameterSymbolList.add(symbolId);
50674
50698
  let typeParameterNodes;
50675
50699
  if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < chain.length - 1) {
50676
50700
  const parentSymbol = symbol;
@@ -50931,9 +50955,15 @@ function createTypeChecker(host) {
50931
50955
  result = factory.createIdentifier(text);
50932
50956
  setIdentifierTypeArguments(result, typeArguments);
50933
50957
  }
50934
- (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
50935
- (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
50936
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
50958
+ if (context.mustCreateTypeParametersNamesLookups) {
50959
+ context.mustCreateTypeParametersNamesLookups = false;
50960
+ context.typeParameterNames = new Map(context.typeParameterNames);
50961
+ context.typeParameterNamesByTextNextNameCount = new Map(context.typeParameterNamesByTextNextNameCount);
50962
+ context.typeParameterNamesByText = new Set(context.typeParameterNamesByText);
50963
+ }
50964
+ context.typeParameterNamesByTextNextNameCount.set(rawtext, i);
50965
+ context.typeParameterNames.set(getTypeId(type), result);
50966
+ context.typeParameterNamesByText.add(text);
50937
50967
  }
50938
50968
  return result;
50939
50969
  }
@@ -51055,21 +51085,22 @@ function createTypeChecker(host) {
51055
51085
  }
51056
51086
  }
51057
51087
  function cloneNodeBuilderContext(context) {
51058
- const initial = { ...context };
51059
- if (initial.typeParameterNames) {
51060
- initial.typeParameterNames = new Map(initial.typeParameterNames);
51061
- }
51062
- if (initial.typeParameterNamesByText) {
51063
- initial.typeParameterNamesByText = new Set(initial.typeParameterNamesByText);
51064
- }
51065
- if (initial.typeParameterSymbolList) {
51066
- initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
51067
- }
51068
- if (initial.typeParameterNamesByTextNextNameCount) {
51069
- initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
51070
- }
51071
- initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
51072
- return initial;
51088
+ const oldMustCreateTypeParameterSymbolList = context.mustCreateTypeParameterSymbolList;
51089
+ const oldMustCreateTypeParametersNamesLookups = context.mustCreateTypeParametersNamesLookups;
51090
+ context.mustCreateTypeParameterSymbolList = true;
51091
+ context.mustCreateTypeParametersNamesLookups = true;
51092
+ const oldTypeParameterNames = context.typeParameterNames;
51093
+ const oldTypeParameterNamesByText = context.typeParameterNamesByText;
51094
+ const oldTypeParameterNamesByTextNextNameCount = context.typeParameterNamesByTextNextNameCount;
51095
+ const oldTypeParameterSymbolList = context.typeParameterSymbolList;
51096
+ return () => {
51097
+ context.typeParameterNames = oldTypeParameterNames;
51098
+ context.typeParameterNamesByText = oldTypeParameterNamesByText;
51099
+ context.typeParameterNamesByTextNextNameCount = oldTypeParameterNamesByTextNextNameCount;
51100
+ context.typeParameterSymbolList = oldTypeParameterSymbolList;
51101
+ context.mustCreateTypeParameterSymbolList = oldMustCreateTypeParameterSymbolList;
51102
+ context.mustCreateTypeParametersNamesLookups = oldMustCreateTypeParametersNamesLookups;
51103
+ };
51073
51104
  }
51074
51105
  function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
51075
51106
  return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
@@ -51202,13 +51233,34 @@ function createTypeChecker(host) {
51202
51233
  /*dontResolveAlias*/
51203
51234
  true
51204
51235
  );
51236
+ if (context.enclosingDeclaration && (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration || !findAncestor(node, (n) => n === context.enclosingDeclaration)) && !(sym && sym.flags & 262144 /* TypeParameter */)) {
51237
+ sym = getExportSymbolOfValueSymbolIfExported(sym);
51238
+ const symAtLocation = resolveEntityName(
51239
+ leftmost,
51240
+ meaning,
51241
+ /*ignoreErrors*/
51242
+ true,
51243
+ /*dontResolveAlias*/
51244
+ true,
51245
+ context.enclosingDeclaration
51246
+ );
51247
+ if (
51248
+ // Check for unusable parameters symbols
51249
+ symAtLocation === unknownSymbol || // If the symbol is not found, but was not found in the original scope either we probably have an error, don't reuse the node
51250
+ symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
51251
+ symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
51252
+ ) {
51253
+ introducesError = true;
51254
+ return { introducesError, node, sym };
51255
+ }
51256
+ }
51205
51257
  if (sym) {
51206
51258
  if (sym.flags & 1 /* FunctionScopedVariable */ && sym.valueDeclaration) {
51207
- if (isPartOfParameterDeclaration(sym.valueDeclaration)) {
51259
+ if (isPartOfParameterDeclaration(sym.valueDeclaration) || isJSDocParameterTag(sym.valueDeclaration)) {
51208
51260
  return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
51209
51261
  }
51210
51262
  }
51211
- if (!(sym.flags & 262144 /* TypeParameter */) && // Type parameters are visible in the curent context if they are are resolvable
51263
+ if (!(sym.flags & 262144 /* TypeParameter */) && // Type parameters are visible in the current context if they are are resolvable
51212
51264
  !isDeclarationName(node) && isSymbolAccessible(
51213
51265
  sym,
51214
51266
  context.enclosingDeclaration,
@@ -51259,14 +51311,7 @@ function createTypeChecker(host) {
51259
51311
  return result === node ? setTextRange2(context, factory.cloneNode(result), node) : result;
51260
51312
  }
51261
51313
  function onEnterNewScope(node) {
51262
- const oldContex = context;
51263
- context = cloneNodeBuilderContext(context);
51264
- const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51265
- return onExitNewScope;
51266
- function onExitNewScope() {
51267
- cleanup == null ? void 0 : cleanup();
51268
- context = oldContex;
51269
- }
51314
+ return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51270
51315
  }
51271
51316
  function visitExistingNodeTreeSymbolsWorker(node) {
51272
51317
  if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
@@ -51716,17 +51761,9 @@ function createTypeChecker(host) {
51716
51761
  visitedSymbols.add(getSymbolId(visitedSym));
51717
51762
  const skipMembershipCheck = !isPrivate;
51718
51763
  if (skipMembershipCheck || !!length(symbol.declarations) && some(symbol.declarations, (d) => !!findAncestor(d, (n) => n === enclosingDeclaration))) {
51719
- const oldContext = context;
51720
- context = cloneNodeBuilderContext(context);
51764
+ const scopeCleanup = cloneNodeBuilderContext(context);
51721
51765
  serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
51722
- if (context.reportedDiagnostic) {
51723
- oldcontext.reportedDiagnostic = context.reportedDiagnostic;
51724
- }
51725
- if (context.trackedSymbols) {
51726
- if (!oldContext.trackedSymbols) oldContext.trackedSymbols = context.trackedSymbols;
51727
- else Debug.assert(context.trackedSymbols === oldContext.trackedSymbols);
51728
- }
51729
- context = oldContext;
51766
+ scopeCleanup();
51730
51767
  }
51731
51768
  }
51732
51769
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
@@ -53293,8 +53330,6 @@ function createTypeChecker(host) {
53293
53330
  switch (propertyName) {
53294
53331
  case 0 /* Type */:
53295
53332
  return !!getSymbolLinks(target).type;
53296
- case 5 /* EnumTagType */:
53297
- return !!getNodeLinks(target).resolvedEnumType;
53298
53333
  case 2 /* DeclaredType */:
53299
53334
  return !!getSymbolLinks(target).declaredType;
53300
53335
  case 1 /* ResolvedBaseConstructorType */:
@@ -53303,13 +53338,13 @@ function createTypeChecker(host) {
53303
53338
  return !!target.resolvedReturnType;
53304
53339
  case 4 /* ImmediateBaseConstraint */:
53305
53340
  return !!target.immediateBaseConstraint;
53306
- case 6 /* ResolvedTypeArguments */:
53341
+ case 5 /* ResolvedTypeArguments */:
53307
53342
  return !!target.resolvedTypeArguments;
53308
- case 7 /* ResolvedBaseTypes */:
53343
+ case 6 /* ResolvedBaseTypes */:
53309
53344
  return !!target.baseTypesResolved;
53310
- case 8 /* WriteType */:
53345
+ case 7 /* WriteType */:
53311
53346
  return !!getSymbolLinks(target).writeType;
53312
- case 9 /* ParameterInitializerContainsUndefined */:
53347
+ case 8 /* ParameterInitializerContainsUndefined */:
53313
53348
  return getNodeLinks(target).parameterInitializerContainsUndefined !== void 0;
53314
53349
  }
53315
53350
  return Debug.assertNever(propertyName);
@@ -54328,7 +54363,7 @@ function createTypeChecker(host) {
54328
54363
  function getWriteTypeOfAccessors(symbol) {
54329
54364
  const links = getSymbolLinks(symbol);
54330
54365
  if (!links.writeType) {
54331
- if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
54366
+ if (!pushTypeResolution(symbol, 7 /* WriteType */)) {
54332
54367
  return errorType;
54333
54368
  }
54334
54369
  const setter = getDeclarationOfKind(symbol, 178 /* SetAccessor */) ?? tryCast(getDeclarationOfKind(symbol, 172 /* PropertyDeclaration */), isAutoAccessorPropertyDeclaration);
@@ -54738,7 +54773,7 @@ function createTypeChecker(host) {
54738
54773
  }
54739
54774
  function getBaseTypes(type) {
54740
54775
  if (!type.baseTypesResolved) {
54741
- if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) {
54776
+ if (pushTypeResolution(type, 6 /* ResolvedBaseTypes */)) {
54742
54777
  if (type.objectFlags & 8 /* Tuple */) {
54743
54778
  type.resolvedBaseTypes = [getTupleBaseType(type)];
54744
54779
  } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
@@ -57633,7 +57668,7 @@ function createTypeChecker(host) {
57633
57668
  function getTypeArguments(type) {
57634
57669
  var _a, _b;
57635
57670
  if (!type.resolvedTypeArguments) {
57636
- if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) {
57671
+ if (!pushTypeResolution(type, 5 /* ResolvedTypeArguments */)) {
57637
57672
  return ((_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
57638
57673
  }
57639
57674
  const node = type.node;
@@ -68832,7 +68867,7 @@ function createTypeChecker(host) {
68832
68867
  function parameterInitializerContainsUndefined(declaration) {
68833
68868
  const links = getNodeLinks(declaration);
68834
68869
  if (links.parameterInitializerContainsUndefined === void 0) {
68835
- if (!pushTypeResolution(declaration, 9 /* ParameterInitializerContainsUndefined */)) {
68870
+ if (!pushTypeResolution(declaration, 8 /* ParameterInitializerContainsUndefined */)) {
68836
68871
  reportCircularityError(declaration.symbol);
68837
68872
  return true;
68838
68873
  }
@@ -2908,8 +2908,6 @@ declare namespace ts {
2908
2908
  */
2909
2909
  class ConfiguredProject extends Project {
2910
2910
  readonly canonicalConfigFilePath: NormalizedPath;
2911
- /** Ref count to the project when opened from external project */
2912
- private externalProjectRefCount;
2913
2911
  private projectReferences;
2914
2912
  /**
2915
2913
  * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph
@@ -3153,6 +3151,10 @@ declare namespace ts {
3153
3151
  * Open files: with value being project root path, and key being Path of the file that is open
3154
3152
  */
3155
3153
  readonly openFiles: Map<Path, NormalizedPath | undefined>;
3154
+ /** Config files looked up and cached config files for open script info */
3155
+ private readonly configFileForOpenFiles;
3156
+ /** Set of open script infos that are root of inferred project */
3157
+ private rootOfInferredProjects;
3156
3158
  /**
3157
3159
  * Map of open files that are opened without complete path but have projectRoot as current directory
3158
3160
  */
@@ -3171,6 +3173,11 @@ declare namespace ts {
3171
3173
  private safelist;
3172
3174
  private readonly legacySafelist;
3173
3175
  private pendingProjectUpdates;
3176
+ /**
3177
+ * All the open script info that needs recalculation of the default project,
3178
+ * this also caches config file info before config file change was detected to use it in case projects are not updated yet
3179
+ */
3180
+ private pendingOpenFileProjectUpdates?;
3174
3181
  readonly currentDirectory: NormalizedPath;
3175
3182
  readonly toCanonicalFileName: (f: string) => string;
3176
3183
  readonly host: ServerHost;
@@ -3202,6 +3209,11 @@ declare namespace ts {
3202
3209
  setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.InferredProjectCompilerOptions, projectRootPath?: string): void;
3203
3210
  findProject(projectName: string): Project | undefined;
3204
3211
  getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined;
3212
+ /**
3213
+ * If there is default project calculation pending for this file,
3214
+ * then it completes that calculation so that correct default project is used for the project
3215
+ */
3216
+ private tryGetDefaultProjectForEnsuringConfiguredProjectForFile;
3205
3217
  private doEnsureDefaultProjectForFile;
3206
3218
  getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined;
3207
3219
  /**
@@ -3221,13 +3233,6 @@ declare namespace ts {
3221
3233
  private delayUpdateSourceInfoProjects;
3222
3234
  private delayUpdateProjectsOfScriptInfoPath;
3223
3235
  private handleDeletedFile;
3224
- /**
3225
- * This function goes through all the openFiles and tries to file the config file for them.
3226
- * If the config file is found and it refers to existing project, it schedules the reload it for reload
3227
- * If there is no existing project it just opens the configured project for the config file
3228
- * shouldReloadProjectFor provides a way to filter out files to reload configured project for
3229
- */
3230
- private delayReloadConfiguredProjectsForFile;
3231
3236
  private removeProject;
3232
3237
  private assignOrphanScriptInfosToInferredProject;
3233
3238
  /**
@@ -3237,14 +3242,6 @@ declare namespace ts {
3237
3242
  private closeOpenFile;
3238
3243
  private deleteScriptInfo;
3239
3244
  private configFileExists;
3240
- /**
3241
- * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project
3242
- */
3243
- private configFileExistenceImpactsRootOfInferredProject;
3244
- /**
3245
- * This is called on file close, so that we stop watching the config file for this script info
3246
- */
3247
- private stopWatchingConfigFilesForClosedScriptInfo;
3248
3245
  /**
3249
3246
  * This function tries to search for a tsconfig.json for the given file.
3250
3247
  * This is different from the method the compiler uses because
@@ -3254,17 +3251,10 @@ declare namespace ts {
3254
3251
  * the newly opened file.
3255
3252
  */
3256
3253
  private forEachConfigFileLocation;
3257
- /**
3258
- * This function tries to search for a tsconfig.json for the given file.
3259
- * This is different from the method the compiler uses because
3260
- * the compiler can assume it will always start searching in the
3261
- * current directory (the directory in which tsc was invoked).
3262
- * The server must start searching from the directory containing
3263
- * the newly opened file.
3264
- * If script info is passed in, it is asserted to be open script info
3265
- * otherwise just file name
3266
- */
3267
- private getConfigFileNameForFile;
3254
+ /** Get cached configFileName for scriptInfo or ancestor of open script info */
3255
+ private getConfigFileNameForFileFromCache;
3256
+ /** Caches the configFilename for script info or ancestor of open script info */
3257
+ private setConfigFileNameForFileInCache;
3268
3258
  private printProjects;
3269
3259
  private getConfiguredProjectByCanonicalConfigFilePath;
3270
3260
  private findExternalProjectByProjectName;
@@ -3305,12 +3295,6 @@ declare namespace ts {
3305
3295
  * This does not reload contents of open files from disk. But we could do that if needed
3306
3296
  */
3307
3297
  reloadProjects(): void;
3308
- /**
3309
- * This function goes through all the openFiles and tries to file the config file for them.
3310
- * If the config file is found and it refers to existing project, it reloads it either immediately
3311
- * If there is no existing project it just opens the configured project for the config file
3312
- */
3313
- private reloadConfiguredProjectForFiles;
3314
3298
  /**
3315
3299
  * Remove the root of inferred project if script info is part of another project
3316
3300
  */
@@ -3332,11 +3316,21 @@ declare namespace ts {
3332
3316
  private findExternalProjectContainingOpenScriptInfo;
3333
3317
  private getOrCreateOpenScriptInfo;
3334
3318
  private assignProjectToOpenedScriptInfo;
3335
- private createAncestorProjects;
3319
+ /**
3320
+ * Finds the default configured project for given info
3321
+ * For any tsconfig found, it looks into that project, if not then all its references,
3322
+ * The search happens for all tsconfigs till projectRootPath
3323
+ */
3324
+ private tryFindDefaultConfiguredProjectForOpenScriptInfo;
3325
+ /**
3326
+ * Finds the default configured project, if found, it creates the solution projects (does not load them right away)
3327
+ * with Find: finds the projects even if the project is deferredClosed
3328
+ */
3329
+ private tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo;
3336
3330
  private ensureProjectChildren;
3337
- private cleanupAfterOpeningFile;
3331
+ private cleanupConfiguredProjects;
3332
+ private cleanupProjectsAndScriptInfos;
3338
3333
  openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult;
3339
- private removeOrphanConfiguredProjects;
3340
3334
  private removeOrphanScriptInfos;
3341
3335
  private telemetryOnOpenFile;
3342
3336
  /**
@@ -3345,7 +3339,6 @@ declare namespace ts {
3345
3339
  */
3346
3340
  closeClientFile(uncheckedFileName: string): void;
3347
3341
  private collectChanges;
3348
- private closeConfiguredProjectReferencedFromExternalProject;
3349
3342
  closeExternalProject(uncheckedFileName: string): void;
3350
3343
  openExternalProjects(projects: protocol.ExternalProject[]): void;
3351
3344
  /** Makes a filename safe to insert in a RegExp */