typescript 5.5.0-dev.20240509 → 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.20240509`;
21
+ var version = `${versionMajorMinor}.0-dev.20240511`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -11908,6 +11908,10 @@ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
11908
11908
  const kind = node.kind;
11909
11909
  return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */ || kind === 205 /* ImportType */;
11910
11910
  }
11911
+ function isPropertyAccessOrQualifiedName(node) {
11912
+ const kind = node.kind;
11913
+ return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */;
11914
+ }
11911
11915
  function isCallLikeOrFunctionLikeExpression(node) {
11912
11916
  return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node);
11913
11917
  }
@@ -12178,7 +12182,7 @@ function canHaveLocals(node) {
12178
12182
  }
12179
12183
  }
12180
12184
  function isDeclarationKind(kind) {
12181
- 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 */;
12182
12186
  }
12183
12187
  function isDeclarationStatementKind(kind) {
12184
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 */;
@@ -18877,13 +18881,15 @@ function createNameResolver({
18877
18881
  let useResult = true;
18878
18882
  if (isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
18879
18883
  if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) {
18880
- 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;
18881
18886
  }
18882
18887
  if (meaning & result.flags & 3 /* Variable */) {
18883
18888
  if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
18884
18889
  useResult = false;
18885
18890
  } else if (result.flags & 1 /* FunctionScopedVariable */) {
18886
- 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);
18887
18893
  }
18888
18894
  }
18889
18895
  } else if (location.kind === 194 /* ConditionalType */) {
@@ -46406,7 +46412,6 @@ function createTypeChecker(host) {
46406
46412
  if (meaning) {
46407
46413
  const symbol = getMergedSymbol(symbols.get(name));
46408
46414
  if (symbol) {
46409
- Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
46410
46415
  if (symbol.flags & meaning) {
46411
46416
  return symbol;
46412
46417
  }
@@ -47658,37 +47663,6 @@ function createTypeChecker(host) {
47658
47663
  }
47659
47664
  return void 0;
47660
47665
  }
47661
- function markExportAsReferenced(node) {
47662
- if (!canCollectSymbolAliasAccessabilityData) {
47663
- return;
47664
- }
47665
- const symbol = getSymbolOfDeclaration(node);
47666
- const target = resolveAlias(symbol);
47667
- if (target) {
47668
- const markAlias = target === unknownSymbol || getSymbolFlags(
47669
- symbol,
47670
- /*excludeTypeOnlyMeanings*/
47671
- true
47672
- ) & 111551 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target);
47673
- if (markAlias) {
47674
- markAliasSymbolAsReferenced(symbol);
47675
- }
47676
- }
47677
- }
47678
- function markAliasSymbolAsReferenced(symbol) {
47679
- Debug.assert(canCollectSymbolAliasAccessabilityData);
47680
- const links = getSymbolLinks(symbol);
47681
- if (!links.referenced) {
47682
- links.referenced = true;
47683
- const node = getDeclarationOfAliasSymbol(symbol);
47684
- if (!node) return Debug.fail();
47685
- if (isInternalModuleImportEqualsDeclaration(node)) {
47686
- if (getSymbolFlags(resolveSymbol(symbol)) & 111551 /* Value */) {
47687
- checkExpressionCached(node.moduleReference);
47688
- }
47689
- }
47690
- }
47691
- }
47692
47666
  function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
47693
47667
  if (entityName.kind === 80 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
47694
47668
  entityName = entityName.parent;
@@ -47841,7 +47815,6 @@ function createTypeChecker(host) {
47841
47815
  } else {
47842
47816
  Debug.assertNever(name, "Unknown entity name kind.");
47843
47817
  }
47844
- Debug.assert((getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here.");
47845
47818
  if (!nodeIsSynthesized(name) && isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 277 /* ExportAssignment */)) {
47846
47819
  markSymbolOfAliasDeclarationIfTypeOnly(
47847
47820
  getAliasDeclarationFromName(name),
@@ -49262,7 +49235,6 @@ function createTypeChecker(host) {
49262
49235
  return symbolToExpression(symbol, context, meaning);
49263
49236
  }
49264
49237
  function withContext(enclosingDeclaration, flags, tracker, cb) {
49265
- Debug.assert(enclosingDeclaration === void 0 || (enclosingDeclaration.flags & 16 /* Synthesized */) === 0);
49266
49238
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : flags & 134217728 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
49267
49239
  const context = {
49268
49240
  enclosingDeclaration,
@@ -49276,7 +49248,18 @@ function createTypeChecker(host) {
49276
49248
  inferTypeParameters: void 0,
49277
49249
  approximateLength: 0,
49278
49250
  trackedSymbols: void 0,
49279
- 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
49280
49263
  };
49281
49264
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
49282
49265
  const resultingNode = cb(context);
@@ -50271,22 +50254,22 @@ function createTypeChecker(host) {
50271
50254
  }
50272
50255
  function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
50273
50256
  var _a;
50274
- const flags = context.flags;
50275
- context.flags &= ~256 /* SuppressAnyReturnType */;
50276
- context.approximateLength += 3;
50277
50257
  let typeParameters;
50278
50258
  let typeArguments;
50279
- if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
50280
- typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
50281
- } else {
50282
- typeParameters = signature.typeParameters && signature.typeParameters.map((parameter) => typeParameterToDeclaration(parameter, context));
50283
- }
50284
50259
  const expandedParams = getExpandedParameters(
50285
50260
  signature,
50286
50261
  /*skipUnionExpanding*/
50287
50262
  true
50288
50263
  )[0];
50289
- 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 */;
50290
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 */));
50291
50274
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
50292
50275
  if (thisParameter) {
@@ -50384,15 +50367,14 @@ function createTypeChecker(host) {
50384
50367
  return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
50385
50368
  }
50386
50369
  function getParametersInScope(node) {
50387
- return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
50388
- getSignatureFromDeclaration(node),
50389
- /*skipUnionExpanding*/
50390
- true
50391
- )[0] : void 0;
50392
- }
50393
- function enterNewScope(context, declaration, expandedParams, typeParameters) {
50394
- let cleanup;
50395
- 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) {
50396
50378
  let pushFakeScope2 = function(kind, addAll) {
50397
50379
  Debug.assert(context.enclosingDeclaration);
50398
50380
  let existingFakeScope;
@@ -50404,39 +50386,45 @@ function createTypeChecker(host) {
50404
50386
  Debug.assertOptionalNode(existingFakeScope, isBlock);
50405
50387
  const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
50406
50388
  let newLocals;
50389
+ let oldLocals;
50407
50390
  addAll((name, symbol) => {
50408
- if (!locals.has(name)) {
50409
- newLocals = append(newLocals, name);
50410
- 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
+ }
50411
50398
  }
50399
+ locals.set(name, symbol);
50412
50400
  });
50413
- if (!newLocals) return;
50414
- const oldCleanup = cleanup;
50415
- function undo() {
50416
- forEach(newLocals, (s) => locals.delete(s));
50417
- oldCleanup == null ? void 0 : oldCleanup();
50418
- }
50419
- if (existingFakeScope) {
50420
- cleanup = undo;
50421
- } else {
50422
- const fakeScope = parseNodeFactory.createBlock(emptyArray);
50401
+ if (!existingFakeScope) {
50402
+ const fakeScope = factory.createBlock(emptyArray);
50423
50403
  getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
50424
50404
  fakeScope.locals = locals;
50425
- const saveEnclosingDeclaration = context.enclosingDeclaration;
50426
- setParent(fakeScope, saveEnclosingDeclaration);
50405
+ setParent(fakeScope, context.enclosingDeclaration);
50427
50406
  context.enclosingDeclaration = fakeScope;
50428
- cleanup = () => {
50429
- context.enclosingDeclaration = saveEnclosingDeclaration;
50430
- undo();
50407
+ } else {
50408
+ return function undo() {
50409
+ forEach(newLocals, (s) => locals.delete(s));
50410
+ forEach(oldLocals, (s) => locals.set(s.name, s.oldSymbol));
50431
50411
  };
50432
50412
  }
50433
50413
  };
50434
50414
  var pushFakeScope = pushFakeScope2;
50435
- pushFakeScope2(
50415
+ cleanupParams = !some(expandedParams) ? void 0 : pushFakeScope2(
50436
50416
  "params",
50437
50417
  (add) => {
50438
- for (const param of expandedParams ?? emptyArray) {
50439
- 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) => {
50440
50428
  if (isParameter(d) && isBindingPattern(d.name)) {
50441
50429
  bindPattern(d.name);
50442
50430
  return true;
@@ -50467,8 +50455,8 @@ function createTypeChecker(host) {
50467
50455
  }
50468
50456
  }
50469
50457
  );
50470
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
50471
- pushFakeScope2(
50458
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && some(typeParameters)) {
50459
+ cleanupTypeParams = pushFakeScope2(
50472
50460
  "typeParams",
50473
50461
  (add) => {
50474
50462
  for (const typeParam of typeParameters ?? emptyArray) {
@@ -50478,8 +50466,13 @@ function createTypeChecker(host) {
50478
50466
  }
50479
50467
  );
50480
50468
  }
50481
- return cleanup;
50482
50469
  }
50470
+ return () => {
50471
+ cleanupParams == null ? void 0 : cleanupParams();
50472
+ cleanupTypeParams == null ? void 0 : cleanupTypeParams();
50473
+ cleanupContext();
50474
+ context.enclosingDeclaration = oldEnclosingDecl;
50475
+ };
50483
50476
  }
50484
50477
  function tryGetThisParameterDeclaration(signature, context) {
50485
50478
  if (signature.thisParameter) {
@@ -50697,7 +50690,11 @@ function createTypeChecker(host) {
50697
50690
  if ((_a = context.typeParameterSymbolList) == null ? void 0 : _a.has(symbolId)) {
50698
50691
  return void 0;
50699
50692
  }
50700
- (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);
50701
50698
  let typeParameterNodes;
50702
50699
  if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < chain.length - 1) {
50703
50700
  const parentSymbol = symbol;
@@ -50958,9 +50955,15 @@ function createTypeChecker(host) {
50958
50955
  result = factory.createIdentifier(text);
50959
50956
  setIdentifierTypeArguments(result, typeArguments);
50960
50957
  }
50961
- (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
50962
- (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
50963
- (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);
50964
50967
  }
50965
50968
  return result;
50966
50969
  }
@@ -51082,21 +51085,22 @@ function createTypeChecker(host) {
51082
51085
  }
51083
51086
  }
51084
51087
  function cloneNodeBuilderContext(context) {
51085
- const initial = { ...context };
51086
- if (initial.typeParameterNames) {
51087
- initial.typeParameterNames = new Map(initial.typeParameterNames);
51088
- }
51089
- if (initial.typeParameterNamesByText) {
51090
- initial.typeParameterNamesByText = new Set(initial.typeParameterNamesByText);
51091
- }
51092
- if (initial.typeParameterSymbolList) {
51093
- initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
51094
- }
51095
- if (initial.typeParameterNamesByTextNextNameCount) {
51096
- initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
51097
- }
51098
- initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
51099
- 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
+ };
51100
51104
  }
51101
51105
  function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
51102
51106
  return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
@@ -51229,13 +51233,34 @@ function createTypeChecker(host) {
51229
51233
  /*dontResolveAlias*/
51230
51234
  true
51231
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
+ }
51232
51257
  if (sym) {
51233
51258
  if (sym.flags & 1 /* FunctionScopedVariable */ && sym.valueDeclaration) {
51234
- if (isPartOfParameterDeclaration(sym.valueDeclaration)) {
51259
+ if (isPartOfParameterDeclaration(sym.valueDeclaration) || isJSDocParameterTag(sym.valueDeclaration)) {
51235
51260
  return { introducesError, node: attachSymbolToLeftmostIdentifier(node) };
51236
51261
  }
51237
51262
  }
51238
- 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
51239
51264
  !isDeclarationName(node) && isSymbolAccessible(
51240
51265
  sym,
51241
51266
  context.enclosingDeclaration,
@@ -51286,14 +51311,7 @@ function createTypeChecker(host) {
51286
51311
  return result === node ? setTextRange2(context, factory.cloneNode(result), node) : result;
51287
51312
  }
51288
51313
  function onEnterNewScope(node) {
51289
- const oldContex = context;
51290
- context = cloneNodeBuilderContext(context);
51291
- const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51292
- return onExitNewScope;
51293
- function onExitNewScope() {
51294
- cleanup == null ? void 0 : cleanup();
51295
- context = oldContex;
51296
- }
51314
+ return enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
51297
51315
  }
51298
51316
  function visitExistingNodeTreeSymbolsWorker(node) {
51299
51317
  if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
@@ -51743,17 +51761,9 @@ function createTypeChecker(host) {
51743
51761
  visitedSymbols.add(getSymbolId(visitedSym));
51744
51762
  const skipMembershipCheck = !isPrivate;
51745
51763
  if (skipMembershipCheck || !!length(symbol.declarations) && some(symbol.declarations, (d) => !!findAncestor(d, (n) => n === enclosingDeclaration))) {
51746
- const oldContext = context;
51747
- context = cloneNodeBuilderContext(context);
51764
+ const scopeCleanup = cloneNodeBuilderContext(context);
51748
51765
  serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
51749
- if (context.reportedDiagnostic) {
51750
- oldcontext.reportedDiagnostic = context.reportedDiagnostic;
51751
- }
51752
- if (context.trackedSymbols) {
51753
- if (!oldContext.trackedSymbols) oldContext.trackedSymbols = context.trackedSymbols;
51754
- else Debug.assert(context.trackedSymbols === oldContext.trackedSymbols);
51755
- }
51756
- context = oldContext;
51766
+ scopeCleanup();
51757
51767
  }
51758
51768
  }
51759
51769
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias, escapedSymbolName = symbol.escapedName) {
@@ -53320,8 +53330,6 @@ function createTypeChecker(host) {
53320
53330
  switch (propertyName) {
53321
53331
  case 0 /* Type */:
53322
53332
  return !!getSymbolLinks(target).type;
53323
- case 5 /* EnumTagType */:
53324
- return !!getNodeLinks(target).resolvedEnumType;
53325
53333
  case 2 /* DeclaredType */:
53326
53334
  return !!getSymbolLinks(target).declaredType;
53327
53335
  case 1 /* ResolvedBaseConstructorType */:
@@ -53330,13 +53338,13 @@ function createTypeChecker(host) {
53330
53338
  return !!target.resolvedReturnType;
53331
53339
  case 4 /* ImmediateBaseConstraint */:
53332
53340
  return !!target.immediateBaseConstraint;
53333
- case 6 /* ResolvedTypeArguments */:
53341
+ case 5 /* ResolvedTypeArguments */:
53334
53342
  return !!target.resolvedTypeArguments;
53335
- case 7 /* ResolvedBaseTypes */:
53343
+ case 6 /* ResolvedBaseTypes */:
53336
53344
  return !!target.baseTypesResolved;
53337
- case 8 /* WriteType */:
53345
+ case 7 /* WriteType */:
53338
53346
  return !!getSymbolLinks(target).writeType;
53339
- case 9 /* ParameterInitializerContainsUndefined */:
53347
+ case 8 /* ParameterInitializerContainsUndefined */:
53340
53348
  return getNodeLinks(target).parameterInitializerContainsUndefined !== void 0;
53341
53349
  }
53342
53350
  return Debug.assertNever(propertyName);
@@ -54355,7 +54363,7 @@ function createTypeChecker(host) {
54355
54363
  function getWriteTypeOfAccessors(symbol) {
54356
54364
  const links = getSymbolLinks(symbol);
54357
54365
  if (!links.writeType) {
54358
- if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
54366
+ if (!pushTypeResolution(symbol, 7 /* WriteType */)) {
54359
54367
  return errorType;
54360
54368
  }
54361
54369
  const setter = getDeclarationOfKind(symbol, 178 /* SetAccessor */) ?? tryCast(getDeclarationOfKind(symbol, 172 /* PropertyDeclaration */), isAutoAccessorPropertyDeclaration);
@@ -54765,7 +54773,7 @@ function createTypeChecker(host) {
54765
54773
  }
54766
54774
  function getBaseTypes(type) {
54767
54775
  if (!type.baseTypesResolved) {
54768
- if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) {
54776
+ if (pushTypeResolution(type, 6 /* ResolvedBaseTypes */)) {
54769
54777
  if (type.objectFlags & 8 /* Tuple */) {
54770
54778
  type.resolvedBaseTypes = [getTupleBaseType(type)];
54771
54779
  } else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
@@ -57660,7 +57668,7 @@ function createTypeChecker(host) {
57660
57668
  function getTypeArguments(type) {
57661
57669
  var _a, _b;
57662
57670
  if (!type.resolvedTypeArguments) {
57663
- if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) {
57671
+ if (!pushTypeResolution(type, 5 /* ResolvedTypeArguments */)) {
57664
57672
  return ((_a = type.target.localTypeParameters) == null ? void 0 : _a.map(() => errorType)) || emptyArray;
57665
57673
  }
57666
57674
  const node = type.node;
@@ -68859,7 +68867,7 @@ function createTypeChecker(host) {
68859
68867
  function parameterInitializerContainsUndefined(declaration) {
68860
68868
  const links = getNodeLinks(declaration);
68861
68869
  if (links.parameterInitializerContainsUndefined === void 0) {
68862
- if (!pushTypeResolution(declaration, 9 /* ParameterInitializerContainsUndefined */)) {
68870
+ if (!pushTypeResolution(declaration, 8 /* ParameterInitializerContainsUndefined */)) {
68863
68871
  reportCircularityError(declaration.symbol);
68864
68872
  return true;
68865
68873
  }
@@ -68913,6 +68921,248 @@ function createTypeChecker(host) {
68913
68921
  return false;
68914
68922
  });
68915
68923
  }
68924
+ function markLinkedReferences(location, hint, propSymbol, parentType) {
68925
+ if (!canCollectSymbolAliasAccessabilityData) {
68926
+ return;
68927
+ }
68928
+ if (location.flags & 33554432 /* Ambient */) {
68929
+ return;
68930
+ }
68931
+ switch (hint) {
68932
+ case 1 /* Identifier */:
68933
+ return markIdentifierAliasReferenced(location);
68934
+ case 2 /* Property */:
68935
+ return markPropertyAliasReferenced(location, propSymbol, parentType);
68936
+ case 3 /* ExportAssignment */:
68937
+ return markExportAssignmentAliasReferenced(location);
68938
+ case 4 /* Jsx */:
68939
+ return markJsxAliasReferenced(location);
68940
+ case 5 /* AsyncFunction */:
68941
+ return markAsyncFunctionAliasReferenced(location);
68942
+ case 6 /* ExportImportEquals */:
68943
+ return markImportEqualsAliasReferenced(location);
68944
+ case 7 /* ExportSpecifier */:
68945
+ return markExportSpecifierAliasReferenced(location);
68946
+ case 8 /* Decorator */:
68947
+ return markDecoratorAliasReferenced(location);
68948
+ case 0 /* Unspecified */: {
68949
+ if (isIdentifier(location) && (isExpressionNode(location) || isShorthandPropertyAssignment(location.parent) || isImportEqualsDeclaration(location.parent) && location.parent.moduleReference === location) && shouldMarkIdentifierAliasReferenced(location)) {
68950
+ if (isPropertyAccessOrQualifiedName(location.parent)) {
68951
+ const left = isPropertyAccessExpression(location.parent) ? location.parent.expression : location.parent.left;
68952
+ if (left !== location) return;
68953
+ }
68954
+ markIdentifierAliasReferenced(location);
68955
+ return;
68956
+ }
68957
+ if (isPropertyAccessOrQualifiedName(location)) {
68958
+ let topProp = location;
68959
+ while (isPropertyAccessOrQualifiedName(topProp)) {
68960
+ if (isPartOfTypeNode(topProp)) return;
68961
+ topProp = topProp.parent;
68962
+ }
68963
+ return markPropertyAliasReferenced(location);
68964
+ }
68965
+ if (isExportAssignment(location)) {
68966
+ return markExportAssignmentAliasReferenced(location);
68967
+ }
68968
+ if (isJsxOpeningLikeElement(location) || isJsxOpeningFragment(location)) {
68969
+ return markJsxAliasReferenced(location);
68970
+ }
68971
+ if (isFunctionLikeDeclaration(location) || isMethodSignature(location)) {
68972
+ return markAsyncFunctionAliasReferenced(location);
68973
+ }
68974
+ if (isImportEqualsDeclaration(location)) {
68975
+ if (isInternalModuleImportEqualsDeclaration(location) || checkExternalImportOrExportDeclaration(location)) {
68976
+ return markImportEqualsAliasReferenced(location);
68977
+ }
68978
+ return;
68979
+ }
68980
+ if (isExportSpecifier(location)) {
68981
+ return markExportSpecifierAliasReferenced(location);
68982
+ }
68983
+ if (!compilerOptions.emitDecoratorMetadata) {
68984
+ return;
68985
+ }
68986
+ if (!canHaveDecorators(location) || !hasDecorators(location) || !location.modifiers || !nodeCanBeDecorated(legacyDecorators, location, location.parent, location.parent.parent)) {
68987
+ return;
68988
+ }
68989
+ return markDecoratorAliasReferenced(location);
68990
+ }
68991
+ default:
68992
+ Debug.assertNever(hint, `Unhandled reference hint: ${hint}`);
68993
+ }
68994
+ }
68995
+ function markIdentifierAliasReferenced(location) {
68996
+ const symbol = getResolvedSymbol(location);
68997
+ if (symbol && symbol !== argumentsSymbol && symbol !== unknownSymbol && !isThisInTypeQuery(location)) {
68998
+ markAliasReferenced(symbol, location);
68999
+ }
69000
+ }
69001
+ function markPropertyAliasReferenced(location, propSymbol, parentType) {
69002
+ const left = isPropertyAccessExpression(location) ? location.expression : location.left;
69003
+ if (isThisIdentifier(left) || !isIdentifier(left)) {
69004
+ return;
69005
+ }
69006
+ const parentSymbol = getResolvedSymbol(left);
69007
+ if (!parentSymbol || parentSymbol === unknownSymbol) {
69008
+ return;
69009
+ }
69010
+ if (getIsolatedModules(compilerOptions) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location)) {
69011
+ markAliasReferenced(parentSymbol, location);
69012
+ return;
69013
+ }
69014
+ const leftType = parentType || checkExpressionCached(left);
69015
+ if (isTypeAny(leftType) || leftType === silentNeverType) {
69016
+ markAliasReferenced(parentSymbol, location);
69017
+ return;
69018
+ }
69019
+ let prop = propSymbol;
69020
+ if (!prop && !parentType) {
69021
+ const right = isPropertyAccessExpression(location) ? location.name : location.right;
69022
+ const lexicallyScopedSymbol = isPrivateIdentifier(right) && lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
69023
+ const assignmentKind = getAssignmentTargetKind(location);
69024
+ const apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(location) ? getWidenedType(leftType) : leftType);
69025
+ prop = isPrivateIdentifier(right) ? lexicallyScopedSymbol && getPrivateIdentifierPropertyOfType(apparentType, lexicallyScopedSymbol) || void 0 : getPropertyOfType(apparentType, right.escapedText);
69026
+ }
69027
+ if (!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && location.parent.kind === 306 /* EnumMember */))) {
69028
+ markAliasReferenced(parentSymbol, location);
69029
+ }
69030
+ return;
69031
+ }
69032
+ function markExportAssignmentAliasReferenced(location) {
69033
+ if (isIdentifier(location.expression)) {
69034
+ const id = location.expression;
69035
+ const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
69036
+ id,
69037
+ -1 /* All */,
69038
+ /*ignoreErrors*/
69039
+ true,
69040
+ /*dontResolveAlias*/
69041
+ true,
69042
+ location
69043
+ ));
69044
+ if (sym) {
69045
+ markAliasReferenced(sym, id);
69046
+ }
69047
+ }
69048
+ }
69049
+ function markJsxAliasReferenced(node) {
69050
+ if (!getJsxNamespaceContainerForImplicitImport(node)) {
69051
+ const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.Cannot_find_name_0 : void 0;
69052
+ const jsxFactoryNamespace = getJsxNamespace(node);
69053
+ const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node;
69054
+ let jsxFactorySym;
69055
+ if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
69056
+ jsxFactorySym = resolveName(
69057
+ jsxFactoryLocation,
69058
+ jsxFactoryNamespace,
69059
+ 111551 /* Value */,
69060
+ jsxFactoryRefErr,
69061
+ /*isUse*/
69062
+ true
69063
+ );
69064
+ }
69065
+ if (jsxFactorySym) {
69066
+ jsxFactorySym.isReferenced = -1 /* All */;
69067
+ if (canCollectSymbolAliasAccessabilityData && jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
69068
+ markAliasSymbolAsReferenced(jsxFactorySym);
69069
+ }
69070
+ }
69071
+ if (isJsxOpeningFragment(node)) {
69072
+ const file = getSourceFileOfNode(node);
69073
+ const localJsxNamespace = getLocalJsxNamespace(file);
69074
+ if (localJsxNamespace) {
69075
+ resolveName(
69076
+ jsxFactoryLocation,
69077
+ localJsxNamespace,
69078
+ 111551 /* Value */,
69079
+ jsxFactoryRefErr,
69080
+ /*isUse*/
69081
+ true
69082
+ );
69083
+ }
69084
+ }
69085
+ }
69086
+ return;
69087
+ }
69088
+ function markAsyncFunctionAliasReferenced(location) {
69089
+ if (languageVersion < 2 /* ES2015 */) {
69090
+ if (getFunctionFlags(location) & 2 /* Async */) {
69091
+ const returnTypeNode = getEffectiveReturnTypeNode(location);
69092
+ markTypeNodeAsReferenced(returnTypeNode);
69093
+ }
69094
+ }
69095
+ }
69096
+ function markImportEqualsAliasReferenced(location) {
69097
+ if (hasSyntacticModifier(location, 32 /* Export */)) {
69098
+ markExportAsReferenced(location);
69099
+ }
69100
+ }
69101
+ function markExportSpecifierAliasReferenced(location) {
69102
+ if (!location.parent.parent.moduleSpecifier && !location.isTypeOnly && !location.parent.parent.isTypeOnly) {
69103
+ const exportedName = location.propertyName || location.name;
69104
+ const symbol = resolveName(
69105
+ exportedName,
69106
+ exportedName.escapedText,
69107
+ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */,
69108
+ /*nameNotFoundMessage*/
69109
+ void 0,
69110
+ /*isUse*/
69111
+ true
69112
+ );
69113
+ if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
69114
+ } else {
69115
+ const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
69116
+ if (!target || getSymbolFlags(target) & 111551 /* Value */) {
69117
+ markExportAsReferenced(location);
69118
+ markIdentifierAliasReferenced(location.propertyName || location.name);
69119
+ }
69120
+ }
69121
+ return;
69122
+ }
69123
+ }
69124
+ function markDecoratorAliasReferenced(node) {
69125
+ if (compilerOptions.emitDecoratorMetadata) {
69126
+ const firstDecorator = find(node.modifiers, isDecorator);
69127
+ if (!firstDecorator) {
69128
+ return;
69129
+ }
69130
+ checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */);
69131
+ switch (node.kind) {
69132
+ case 263 /* ClassDeclaration */:
69133
+ const constructor = getFirstConstructorWithBody(node);
69134
+ if (constructor) {
69135
+ for (const parameter of constructor.parameters) {
69136
+ markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
69137
+ }
69138
+ }
69139
+ break;
69140
+ case 177 /* GetAccessor */:
69141
+ case 178 /* SetAccessor */:
69142
+ const otherKind = node.kind === 177 /* GetAccessor */ ? 178 /* SetAccessor */ : 177 /* GetAccessor */;
69143
+ const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(node), otherKind);
69144
+ markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
69145
+ break;
69146
+ case 174 /* MethodDeclaration */:
69147
+ for (const parameter of node.parameters) {
69148
+ markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
69149
+ }
69150
+ markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node));
69151
+ break;
69152
+ case 172 /* PropertyDeclaration */:
69153
+ markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node));
69154
+ break;
69155
+ case 169 /* Parameter */:
69156
+ markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
69157
+ const containingSignature = node.parent;
69158
+ for (const parameter of containingSignature.parameters) {
69159
+ markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
69160
+ }
69161
+ markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(containingSignature));
69162
+ break;
69163
+ }
69164
+ }
69165
+ }
68916
69166
  function markAliasReferenced(symbol, location) {
68917
69167
  if (!canCollectSymbolAliasAccessabilityData) {
68918
69168
  return;
@@ -68934,6 +69184,77 @@ function createTypeChecker(host) {
68934
69184
  }
68935
69185
  }
68936
69186
  }
69187
+ function markAliasSymbolAsReferenced(symbol) {
69188
+ Debug.assert(canCollectSymbolAliasAccessabilityData);
69189
+ const links = getSymbolLinks(symbol);
69190
+ if (!links.referenced) {
69191
+ links.referenced = true;
69192
+ const node = getDeclarationOfAliasSymbol(symbol);
69193
+ if (!node) return Debug.fail();
69194
+ if (isInternalModuleImportEqualsDeclaration(node)) {
69195
+ if (getSymbolFlags(resolveSymbol(symbol)) & 111551 /* Value */) {
69196
+ const left = getFirstIdentifier(node.moduleReference);
69197
+ markIdentifierAliasReferenced(left);
69198
+ }
69199
+ }
69200
+ }
69201
+ }
69202
+ function markExportAsReferenced(node) {
69203
+ const symbol = getSymbolOfDeclaration(node);
69204
+ const target = resolveAlias(symbol);
69205
+ if (target) {
69206
+ const markAlias = target === unknownSymbol || getSymbolFlags(
69207
+ symbol,
69208
+ /*excludeTypeOnlyMeanings*/
69209
+ true
69210
+ ) & 111551 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target);
69211
+ if (markAlias) {
69212
+ markAliasSymbolAsReferenced(symbol);
69213
+ }
69214
+ }
69215
+ }
69216
+ function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
69217
+ if (!typeName) return;
69218
+ const rootName = getFirstIdentifier(typeName);
69219
+ const meaning = (typeName.kind === 80 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
69220
+ const rootSymbol = resolveName(
69221
+ rootName,
69222
+ rootName.escapedText,
69223
+ meaning,
69224
+ /*nameNotFoundMessage*/
69225
+ void 0,
69226
+ /*isUse*/
69227
+ true
69228
+ );
69229
+ if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
69230
+ if (canCollectSymbolAliasAccessabilityData && symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) {
69231
+ markAliasSymbolAsReferenced(rootSymbol);
69232
+ } else if (forDecoratorMetadata && getIsolatedModules(compilerOptions) && getEmitModuleKind(compilerOptions) >= 5 /* ES2015 */ && !symbolIsValue(rootSymbol) && !some(rootSymbol.declarations, isTypeOnlyImportOrExportDeclaration)) {
69233
+ const diag2 = error(typeName, Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
69234
+ const aliasDeclaration = find(rootSymbol.declarations || emptyArray, isAliasSymbolDeclaration);
69235
+ if (aliasDeclaration) {
69236
+ addRelatedInfo(diag2, createDiagnosticForNode(aliasDeclaration, Diagnostics._0_was_imported_here, idText(rootName)));
69237
+ }
69238
+ }
69239
+ }
69240
+ }
69241
+ function markTypeNodeAsReferenced(node) {
69242
+ markEntityNameOrEntityExpressionAsReference(
69243
+ node && getEntityNameFromTypeNode(node),
69244
+ /*forDecoratorMetadata*/
69245
+ false
69246
+ );
69247
+ }
69248
+ function markDecoratorMedataDataTypeNodeAsReferenced(node) {
69249
+ const entityName = getEntityNameForDecoratorMetadata(node);
69250
+ if (entityName && isEntityName(entityName)) {
69251
+ markEntityNameOrEntityExpressionAsReference(
69252
+ entityName,
69253
+ /*forDecoratorMetadata*/
69254
+ true
69255
+ );
69256
+ }
69257
+ }
68937
69258
  function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
68938
69259
  var _a;
68939
69260
  const type = getTypeOfSymbol(symbol, checkMode);
@@ -69029,7 +69350,7 @@ function createTypeChecker(host) {
69029
69350
  return getTypeOfSymbol(symbol);
69030
69351
  }
69031
69352
  if (shouldMarkIdentifierAliasReferenced(node)) {
69032
- markAliasReferenced(symbol, node);
69353
+ markLinkedReferences(node, 1 /* Identifier */);
69033
69354
  }
69034
69355
  const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
69035
69356
  const targetSymbol = resolveAliasWithDeprecationCheck(localOrExportSymbol, node);
@@ -71572,42 +71893,7 @@ function createTypeChecker(host) {
71572
71893
  checkGrammarJsxElement(node);
71573
71894
  }
71574
71895
  checkJsxPreconditions(node);
71575
- if (!getJsxNamespaceContainerForImplicitImport(node)) {
71576
- const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.Cannot_find_name_0 : void 0;
71577
- const jsxFactoryNamespace = getJsxNamespace(node);
71578
- const jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
71579
- let jsxFactorySym;
71580
- if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
71581
- jsxFactorySym = resolveName(
71582
- jsxFactoryLocation,
71583
- jsxFactoryNamespace,
71584
- 111551 /* Value */,
71585
- jsxFactoryRefErr,
71586
- /*isUse*/
71587
- true
71588
- );
71589
- }
71590
- if (jsxFactorySym) {
71591
- jsxFactorySym.isReferenced = -1 /* All */;
71592
- if (canCollectSymbolAliasAccessabilityData && jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
71593
- markAliasSymbolAsReferenced(jsxFactorySym);
71594
- }
71595
- }
71596
- if (isJsxOpeningFragment(node)) {
71597
- const file = getSourceFileOfNode(node);
71598
- const localJsxNamespace = getLocalJsxNamespace(file);
71599
- if (localJsxNamespace) {
71600
- resolveName(
71601
- jsxFactoryLocation,
71602
- localJsxNamespace,
71603
- 111551 /* Value */,
71604
- jsxFactoryRefErr,
71605
- /*isUse*/
71606
- true
71607
- );
71608
- }
71609
- }
71610
- }
71896
+ markLinkedReferences(node, 4 /* Jsx */);
71611
71897
  if (isNodeOpeningLikeElement) {
71612
71898
  const jsxOpeningLikeNode = node;
71613
71899
  const sig = getResolvedSignature(jsxOpeningLikeNode);
@@ -72038,7 +72324,13 @@ function createTypeChecker(host) {
72038
72324
  } else {
72039
72325
  if (isAnyLike) {
72040
72326
  if (isIdentifier(left) && parentSymbol) {
72041
- markAliasReferenced(parentSymbol, node);
72327
+ markLinkedReferences(
72328
+ node,
72329
+ 2 /* Property */,
72330
+ /*propSymbol*/
72331
+ void 0,
72332
+ leftType
72333
+ );
72042
72334
  }
72043
72335
  return isErrorType(apparentType) ? errorType : apparentType;
72044
72336
  }
@@ -72051,9 +72343,7 @@ function createTypeChecker(host) {
72051
72343
  node.kind === 166 /* QualifiedName */
72052
72344
  );
72053
72345
  }
72054
- if (isIdentifier(left) && parentSymbol && (getIsolatedModules(compilerOptions) || !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 306 /* EnumMember */)) || shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
72055
- markAliasReferenced(parentSymbol, node);
72056
- }
72346
+ markLinkedReferences(node, 2 /* Property */, prop, leftType);
72057
72347
  let propType;
72058
72348
  if (!prop) {
72059
72349
  const indexInfo = !isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : void 0;
@@ -78986,7 +79276,7 @@ function createTypeChecker(host) {
78986
79276
  return;
78987
79277
  }
78988
79278
  } else {
78989
- markTypeNodeAsReferenced(returnTypeNode);
79279
+ markLinkedReferences(node, 5 /* AsyncFunction */);
78990
79280
  if (isErrorType(returnType)) {
78991
79281
  return;
78992
79282
  }
@@ -79170,48 +79460,6 @@ function createTypeChecker(host) {
79170
79460
  voidType
79171
79461
  );
79172
79462
  }
79173
- function markTypeNodeAsReferenced(node) {
79174
- markEntityNameOrEntityExpressionAsReference(
79175
- node && getEntityNameFromTypeNode(node),
79176
- /*forDecoratorMetadata*/
79177
- false
79178
- );
79179
- }
79180
- function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
79181
- if (!typeName) return;
79182
- const rootName = getFirstIdentifier(typeName);
79183
- const meaning = (typeName.kind === 80 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
79184
- const rootSymbol = resolveName(
79185
- rootName,
79186
- rootName.escapedText,
79187
- meaning,
79188
- /*nameNotFoundMessage*/
79189
- void 0,
79190
- /*isUse*/
79191
- true
79192
- );
79193
- if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
79194
- if (canCollectSymbolAliasAccessabilityData && symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) {
79195
- markAliasSymbolAsReferenced(rootSymbol);
79196
- } else if (forDecoratorMetadata && getIsolatedModules(compilerOptions) && getEmitModuleKind(compilerOptions) >= 5 /* ES2015 */ && !symbolIsValue(rootSymbol) && !some(rootSymbol.declarations, isTypeOnlyImportOrExportDeclaration)) {
79197
- const diag2 = error(typeName, Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
79198
- const aliasDeclaration = find(rootSymbol.declarations || emptyArray, isAliasSymbolDeclaration);
79199
- if (aliasDeclaration) {
79200
- addRelatedInfo(diag2, createDiagnosticForNode(aliasDeclaration, Diagnostics._0_was_imported_here, idText(rootName)));
79201
- }
79202
- }
79203
- }
79204
- }
79205
- function markDecoratorMedataDataTypeNodeAsReferenced(node) {
79206
- const entityName = getEntityNameForDecoratorMetadata(node);
79207
- if (entityName && isEntityName(entityName)) {
79208
- markEntityNameOrEntityExpressionAsReference(
79209
- entityName,
79210
- /*forDecoratorMetadata*/
79211
- true
79212
- );
79213
- }
79214
- }
79215
79463
  function getEntityNameForDecoratorMetadata(node) {
79216
79464
  if (node) {
79217
79465
  switch (node.kind) {
@@ -79291,42 +79539,7 @@ function createTypeChecker(host) {
79291
79539
  }
79292
79540
  }
79293
79541
  }
79294
- if (compilerOptions.emitDecoratorMetadata) {
79295
- checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */);
79296
- switch (node.kind) {
79297
- case 263 /* ClassDeclaration */:
79298
- const constructor = getFirstConstructorWithBody(node);
79299
- if (constructor) {
79300
- for (const parameter of constructor.parameters) {
79301
- markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
79302
- }
79303
- }
79304
- break;
79305
- case 177 /* GetAccessor */:
79306
- case 178 /* SetAccessor */:
79307
- const otherKind = node.kind === 177 /* GetAccessor */ ? 178 /* SetAccessor */ : 177 /* GetAccessor */;
79308
- const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(node), otherKind);
79309
- markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
79310
- break;
79311
- case 174 /* MethodDeclaration */:
79312
- for (const parameter of node.parameters) {
79313
- markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
79314
- }
79315
- markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node));
79316
- break;
79317
- case 172 /* PropertyDeclaration */:
79318
- markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node));
79319
- break;
79320
- case 169 /* Parameter */:
79321
- markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
79322
- const containingSignature = node.parent;
79323
- for (const parameter of containingSignature.parameters) {
79324
- markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
79325
- }
79326
- markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(containingSignature));
79327
- break;
79328
- }
79329
- }
79542
+ markLinkedReferences(node, 8 /* Decorator */);
79330
79543
  for (const modifier of node.modifiers) {
79331
79544
  if (isDecorator(modifier)) {
79332
79545
  checkDecorator(modifier);
@@ -82667,9 +82880,7 @@ function createTypeChecker(host) {
82667
82880
  checkGrammarModifiers(node);
82668
82881
  if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
82669
82882
  checkImportBinding(node);
82670
- if (hasSyntacticModifier(node, 32 /* Export */)) {
82671
- markExportAsReferenced(node);
82672
- }
82883
+ markLinkedReferences(node, 6 /* ExportImportEquals */);
82673
82884
  if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) {
82674
82885
  const target = resolveAlias(getSymbolOfDeclaration(node));
82675
82886
  if (target !== unknownSymbol) {
@@ -82767,13 +82978,7 @@ function createTypeChecker(host) {
82767
82978
  if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
82768
82979
  error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, idText(exportedName));
82769
82980
  } else {
82770
- if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
82771
- markExportAsReferenced(node);
82772
- }
82773
- const target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
82774
- if (!target || getSymbolFlags(target) & 111551 /* Value */) {
82775
- checkExpressionCached(node.propertyName || node.name);
82776
- }
82981
+ markLinkedReferences(node, 7 /* ExportSpecifier */);
82777
82982
  }
82778
82983
  } else {
82779
82984
  if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
@@ -82815,8 +83020,8 @@ function createTypeChecker(host) {
82815
83020
  node
82816
83021
  ));
82817
83022
  if (sym) {
83023
+ markLinkedReferences(node, 3 /* ExportAssignment */);
82818
83024
  const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(sym, 111551 /* Value */);
82819
- markAliasReferenced(sym, id);
82820
83025
  if (getSymbolFlags(sym) & 111551 /* Value */) {
82821
83026
  checkExpressionCached(id);
82822
83027
  if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && typeOnlyDeclaration) {