typescript 5.5.0-dev.20240514 → 5.5.0-dev.20240515

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.
Files changed (3) hide show
  1. package/lib/tsc.js +141 -67
  2. package/lib/typescript.js +142 -67
  3. package/package.json +2 -2
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.20240514`;
21
+ var version = `${versionMajorMinor}.0-dev.20240515`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6732,7 +6732,6 @@ var Diagnostics = {
6732
6732
  Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
6733
6733
  Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
6734
6734
  Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
6735
- Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
6736
6735
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
6737
6736
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
6738
6737
  Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
@@ -49020,7 +49019,7 @@ function createTypeChecker(host) {
49020
49019
  return { accessibility: 0 /* Accessible */ };
49021
49020
  }
49022
49021
  return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
49023
- accessibility: 1 /* NotAccessible */,
49022
+ accessibility: 3 /* NotResolved */,
49024
49023
  errorSymbolName: getTextOfNode(firstIdentifier),
49025
49024
  errorNode: firstIdentifier
49026
49025
  };
@@ -49158,6 +49157,7 @@ function createTypeChecker(host) {
49158
49157
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
49159
49158
  range = factory.cloneNode(range);
49160
49159
  }
49160
+ if (range === location) return range;
49161
49161
  if (!location) {
49162
49162
  return range;
49163
49163
  }
@@ -51294,6 +51294,57 @@ function createTypeChecker(host) {
51294
51294
  return updated;
51295
51295
  }
51296
51296
  }
51297
+ function serializeTypeName(context, node, isTypeOf, typeArguments) {
51298
+ const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
51299
+ const symbol = resolveEntityName(
51300
+ node,
51301
+ meaning,
51302
+ /*ignoreErrors*/
51303
+ true
51304
+ );
51305
+ if (!symbol) return void 0;
51306
+ const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
51307
+ if (isSymbolAccessible(
51308
+ symbol,
51309
+ context.enclosingDeclaration,
51310
+ meaning,
51311
+ /*shouldComputeAliasesToMakeVisible*/
51312
+ false
51313
+ ).accessibility !== 0 /* Accessible */) return void 0;
51314
+ return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
51315
+ }
51316
+ function canReuseTypeNode(context, existing) {
51317
+ if (isInJSFile(existing)) {
51318
+ if (isLiteralImportTypeNode(existing)) {
51319
+ void getTypeFromImportTypeNode(existing);
51320
+ const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
51321
+ return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
51322
+ (!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
51323
+ !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
51324
+ }
51325
+ }
51326
+ if (isTypeReferenceNode(existing)) {
51327
+ if (isConstTypeReference(existing)) return false;
51328
+ const type = getTypeFromTypeReference(existing);
51329
+ const symbol = getNodeLinks(existing).resolvedSymbol;
51330
+ if (!symbol) return false;
51331
+ if (symbol.flags & 262144 /* TypeParameter */) {
51332
+ return true;
51333
+ }
51334
+ if (isInJSDoc(existing)) {
51335
+ return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
51336
+ }
51337
+ }
51338
+ if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
51339
+ const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
51340
+ return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
51341
+ }
51342
+ return true;
51343
+ }
51344
+ function serializeExistingTypeNode(context, typeNode) {
51345
+ const type = getTypeFromTypeNode(typeNode);
51346
+ return typeToTypeNodeHelper(type, context);
51347
+ }
51297
51348
  function tryReuseExistingTypeNodeHelper(context, existing) {
51298
51349
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
51299
51350
  cancellationToken.throwIfCancellationRequested();
@@ -51303,6 +51354,7 @@ function createTypeChecker(host) {
51303
51354
  if (hadError) {
51304
51355
  return void 0;
51305
51356
  }
51357
+ context.approximateLength += existing.end - existing.pos;
51306
51358
  return transformed;
51307
51359
  function visitExistingNodeTreeSymbols(node) {
51308
51360
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
@@ -51402,20 +51454,38 @@ function createTypeChecker(host) {
51402
51454
  );
51403
51455
  }
51404
51456
  }
51405
- if (isTypeReferenceNode(node) && isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
51406
- node,
51407
- 788968 /* Type */,
51408
- /*ignoreErrors*/
51409
- true
51410
- ))) {
51411
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51457
+ if (isTypeReferenceNode(node)) {
51458
+ if (canReuseTypeNode(context, node)) {
51459
+ const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
51460
+ const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
51461
+ if (!introducesError) {
51462
+ const updated = factory.updateTypeReferenceNode(
51463
+ node,
51464
+ newName,
51465
+ typeArguments
51466
+ );
51467
+ return setTextRange2(context, updated, node);
51468
+ } else {
51469
+ const serializedName = serializeTypeName(
51470
+ context,
51471
+ node.typeName,
51472
+ /*isTypeOf*/
51473
+ false,
51474
+ typeArguments
51475
+ );
51476
+ if (serializedName) {
51477
+ return setTextRange2(context, serializedName, node.typeName);
51478
+ }
51479
+ }
51480
+ }
51481
+ return serializeExistingTypeNode(context, node);
51412
51482
  }
51413
51483
  if (isLiteralImportTypeNode(node)) {
51414
51484
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
51415
51485
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
51416
51486
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
51417
51487
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
51418
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51488
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51419
51489
  }
51420
51490
  return factory.updateImportTypeNode(
51421
51491
  node,
@@ -51447,13 +51517,48 @@ function createTypeChecker(host) {
51447
51517
  }
51448
51518
  return visited;
51449
51519
  }
51450
- if (isEntityName(node) || isEntityNameExpression(node)) {
51451
- if (isDeclarationName(node)) {
51452
- return node;
51520
+ if (isTypeQueryNode(node)) {
51521
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51522
+ if (introducesError) {
51523
+ const serializedName = serializeTypeName(
51524
+ context,
51525
+ node.exprName,
51526
+ /*isTypeOf*/
51527
+ true
51528
+ );
51529
+ if (serializedName) {
51530
+ return setTextRange2(context, serializedName, node.exprName);
51531
+ }
51532
+ return serializeExistingTypeNode(context, node);
51533
+ }
51534
+ return factory.updateTypeQueryNode(
51535
+ node,
51536
+ exprName,
51537
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51538
+ );
51539
+ }
51540
+ if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
51541
+ const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
51542
+ if (!introducesError) {
51543
+ return factory.updateComputedPropertyName(node, result);
51544
+ } else {
51545
+ const type = getWidenedType(getRegularTypeOfExpression(node.expression));
51546
+ const computedPropertyNameType = typeToTypeNodeHelper(type, context);
51547
+ Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
51548
+ const literal = computedPropertyNameType.literal;
51549
+ if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
51550
+ return factory.createIdentifier(literal.text);
51551
+ }
51552
+ if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
51553
+ return literal;
51554
+ }
51555
+ return factory.updateComputedPropertyName(node, literal);
51453
51556
  }
51454
- const { introducesError, node: result } = trackExistingEntityName(node, context);
51557
+ }
51558
+ if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
51559
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
51455
51560
  hadError = hadError || introducesError;
51456
- return result;
51561
+ return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
51457
51562
  }
51458
51563
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
51459
51564
  const visited = visitEachChild(
@@ -51487,6 +51592,11 @@ function createTypeChecker(host) {
51487
51592
  falseType2
51488
51593
  );
51489
51594
  }
51595
+ if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
51596
+ if (!canReuseTypeNode(context, node)) {
51597
+ return serializeExistingTypeNode(context, node);
51598
+ }
51599
+ }
51490
51600
  return visitEachChild(
51491
51601
  node,
51492
51602
  visitExistingNodeTreeSymbols,
@@ -77452,6 +77562,10 @@ function createTypeChecker(host) {
77452
77562
  texts.push(span.literal.text);
77453
77563
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
77454
77564
  }
77565
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
77566
+ if (evaluated) {
77567
+ return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
77568
+ }
77455
77569
  if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(
77456
77570
  node,
77457
77571
  /*contextFlags*/
@@ -77459,8 +77573,7 @@ function createTypeChecker(host) {
77459
77573
  ) || unknownType, isTemplateLiteralContextualType)) {
77460
77574
  return getTemplateLiteralType(texts, types);
77461
77575
  }
77462
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
77463
- return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
77576
+ return stringType;
77464
77577
  }
77465
77578
  function isTemplateLiteralContextualType(type) {
77466
77579
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
@@ -110150,7 +110263,7 @@ function transformDeclarations(context) {
110150
110263
  }
110151
110264
  }
110152
110265
  }
110153
- } else {
110266
+ } else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
110154
110267
  const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
110155
110268
  if (errorInfo) {
110156
110269
  if (errorInfo.typeName) {
@@ -118364,7 +118477,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118364
118477
  let reasonToRelatedInfo;
118365
118478
  const cachedBindAndCheckDiagnosticsForFile = {};
118366
118479
  const cachedDeclarationDiagnosticsForFile = {};
118367
- let resolvedTypeReferenceDirectives = createModeAwareCache();
118368
118480
  let fileProcessingDiagnostics;
118369
118481
  let automaticTypeDirectiveNames;
118370
118482
  let automaticTypeDirectiveResolutions;
@@ -118640,7 +118752,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118640
118752
  resolvedLibProcessing = void 0;
118641
118753
  resolvedModulesProcessing = void 0;
118642
118754
  resolvedTypeReferenceDirectiveNamesProcessing = void 0;
118643
- resolvedTypeReferenceDirectives = void 0;
118644
118755
  const program = {
118645
118756
  getRootFileNames: () => rootNames,
118646
118757
  getSourceFile,
@@ -120354,53 +120465,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120354
120465
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120355
120466
  }
120356
120467
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
120357
- var _a2;
120358
120468
  addResolutionDiagnostics(resolution);
120359
- const previousResolution = (_a2 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
120360
- if (previousResolution && previousResolution.primary) {
120361
- return;
120362
- }
120363
- let saveResolution = true;
120364
120469
  const { resolvedTypeReferenceDirective } = resolution;
120365
120470
  if (resolvedTypeReferenceDirective) {
120366
120471
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++;
120367
- if (resolvedTypeReferenceDirective.primary) {
120368
- processSourceFile(
120369
- resolvedTypeReferenceDirective.resolvedFileName,
120370
- /*isDefaultLib*/
120371
- false,
120372
- /*ignoreNoDefaultLib*/
120373
- false,
120374
- resolvedTypeReferenceDirective.packageId,
120375
- reason
120376
- );
120377
- } else {
120378
- if (previousResolution) {
120379
- if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
120380
- const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
120381
- const existingFile = getSourceFile(previousResolution.resolvedFileName);
120382
- if (otherFileText !== existingFile.text) {
120383
- addFilePreprocessingFileExplainingDiagnostic(
120384
- existingFile,
120385
- reason,
120386
- Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
120387
- [typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName]
120388
- );
120389
- }
120390
- }
120391
- saveResolution = false;
120392
- } else {
120393
- processSourceFile(
120394
- resolvedTypeReferenceDirective.resolvedFileName,
120395
- /*isDefaultLib*/
120396
- false,
120397
- /*ignoreNoDefaultLib*/
120398
- false,
120399
- resolvedTypeReferenceDirective.packageId,
120400
- reason
120401
- );
120402
- }
120403
- }
120472
+ processSourceFile(
120473
+ resolvedTypeReferenceDirective.resolvedFileName,
120474
+ /*isDefaultLib*/
120475
+ false,
120476
+ /*ignoreNoDefaultLib*/
120477
+ false,
120478
+ resolvedTypeReferenceDirective.packageId,
120479
+ reason
120480
+ );
120404
120481
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
120405
120482
  } else {
120406
120483
  addFilePreprocessingFileExplainingDiagnostic(
@@ -120411,9 +120488,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120411
120488
  [typeReferenceDirective]
120412
120489
  );
120413
120490
  }
120414
- if (saveResolution) {
120415
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
120416
- }
120417
120491
  }
120418
120492
  function pathForLibFile(libFileName) {
120419
120493
  const existing = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName);
package/lib/typescript.js CHANGED
@@ -2368,7 +2368,7 @@ module.exports = __toCommonJS(typescript_exports);
2368
2368
 
2369
2369
  // src/compiler/corePublic.ts
2370
2370
  var versionMajorMinor = "5.5";
2371
- var version = `${versionMajorMinor}.0-dev.20240514`;
2371
+ var version = `${versionMajorMinor}.0-dev.20240515`;
2372
2372
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2373
2373
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2374
2374
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6394,6 +6394,7 @@ var SymbolAccessibility = /* @__PURE__ */ ((SymbolAccessibility2) => {
6394
6394
  SymbolAccessibility2[SymbolAccessibility2["Accessible"] = 0] = "Accessible";
6395
6395
  SymbolAccessibility2[SymbolAccessibility2["NotAccessible"] = 1] = "NotAccessible";
6396
6396
  SymbolAccessibility2[SymbolAccessibility2["CannotBeNamed"] = 2] = "CannotBeNamed";
6397
+ SymbolAccessibility2[SymbolAccessibility2["NotResolved"] = 3] = "NotResolved";
6397
6398
  return SymbolAccessibility2;
6398
6399
  })(SymbolAccessibility || {});
6399
6400
  var SyntheticSymbolKind = /* @__PURE__ */ ((SyntheticSymbolKind2) => {
@@ -10338,7 +10339,6 @@ var Diagnostics = {
10338
10339
  Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
10339
10340
  Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
10340
10341
  Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
10341
- Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
10342
10342
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
10343
10343
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
10344
10344
  Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
@@ -53814,7 +53814,7 @@ function createTypeChecker(host) {
53814
53814
  return { accessibility: 0 /* Accessible */ };
53815
53815
  }
53816
53816
  return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
53817
- accessibility: 1 /* NotAccessible */,
53817
+ accessibility: 3 /* NotResolved */,
53818
53818
  errorSymbolName: getTextOfNode(firstIdentifier),
53819
53819
  errorNode: firstIdentifier
53820
53820
  };
@@ -53952,6 +53952,7 @@ function createTypeChecker(host) {
53952
53952
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
53953
53953
  range = factory.cloneNode(range);
53954
53954
  }
53955
+ if (range === location) return range;
53955
53956
  if (!location) {
53956
53957
  return range;
53957
53958
  }
@@ -56088,6 +56089,57 @@ function createTypeChecker(host) {
56088
56089
  return updated;
56089
56090
  }
56090
56091
  }
56092
+ function serializeTypeName(context, node, isTypeOf, typeArguments) {
56093
+ const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
56094
+ const symbol = resolveEntityName(
56095
+ node,
56096
+ meaning,
56097
+ /*ignoreErrors*/
56098
+ true
56099
+ );
56100
+ if (!symbol) return void 0;
56101
+ const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
56102
+ if (isSymbolAccessible(
56103
+ symbol,
56104
+ context.enclosingDeclaration,
56105
+ meaning,
56106
+ /*shouldComputeAliasesToMakeVisible*/
56107
+ false
56108
+ ).accessibility !== 0 /* Accessible */) return void 0;
56109
+ return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
56110
+ }
56111
+ function canReuseTypeNode(context, existing) {
56112
+ if (isInJSFile(existing)) {
56113
+ if (isLiteralImportTypeNode(existing)) {
56114
+ void getTypeFromImportTypeNode(existing);
56115
+ const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
56116
+ return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
56117
+ (!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
56118
+ !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
56119
+ }
56120
+ }
56121
+ if (isTypeReferenceNode(existing)) {
56122
+ if (isConstTypeReference(existing)) return false;
56123
+ const type = getTypeFromTypeReference(existing);
56124
+ const symbol = getNodeLinks(existing).resolvedSymbol;
56125
+ if (!symbol) return false;
56126
+ if (symbol.flags & 262144 /* TypeParameter */) {
56127
+ return true;
56128
+ }
56129
+ if (isInJSDoc(existing)) {
56130
+ return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
56131
+ }
56132
+ }
56133
+ if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
56134
+ const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
56135
+ return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
56136
+ }
56137
+ return true;
56138
+ }
56139
+ function serializeExistingTypeNode(context, typeNode) {
56140
+ const type = getTypeFromTypeNode(typeNode);
56141
+ return typeToTypeNodeHelper(type, context);
56142
+ }
56091
56143
  function tryReuseExistingTypeNodeHelper(context, existing) {
56092
56144
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
56093
56145
  cancellationToken.throwIfCancellationRequested();
@@ -56097,6 +56149,7 @@ function createTypeChecker(host) {
56097
56149
  if (hadError) {
56098
56150
  return void 0;
56099
56151
  }
56152
+ context.approximateLength += existing.end - existing.pos;
56100
56153
  return transformed;
56101
56154
  function visitExistingNodeTreeSymbols(node) {
56102
56155
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
@@ -56196,20 +56249,38 @@ function createTypeChecker(host) {
56196
56249
  );
56197
56250
  }
56198
56251
  }
56199
- if (isTypeReferenceNode(node) && isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
56200
- node,
56201
- 788968 /* Type */,
56202
- /*ignoreErrors*/
56203
- true
56204
- ))) {
56205
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56252
+ if (isTypeReferenceNode(node)) {
56253
+ if (canReuseTypeNode(context, node)) {
56254
+ const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
56255
+ const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
56256
+ if (!introducesError) {
56257
+ const updated = factory.updateTypeReferenceNode(
56258
+ node,
56259
+ newName,
56260
+ typeArguments
56261
+ );
56262
+ return setTextRange2(context, updated, node);
56263
+ } else {
56264
+ const serializedName = serializeTypeName(
56265
+ context,
56266
+ node.typeName,
56267
+ /*isTypeOf*/
56268
+ false,
56269
+ typeArguments
56270
+ );
56271
+ if (serializedName) {
56272
+ return setTextRange2(context, serializedName, node.typeName);
56273
+ }
56274
+ }
56275
+ }
56276
+ return serializeExistingTypeNode(context, node);
56206
56277
  }
56207
56278
  if (isLiteralImportTypeNode(node)) {
56208
56279
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
56209
56280
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
56210
56281
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
56211
56282
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
56212
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56283
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56213
56284
  }
56214
56285
  return factory.updateImportTypeNode(
56215
56286
  node,
@@ -56241,13 +56312,48 @@ function createTypeChecker(host) {
56241
56312
  }
56242
56313
  return visited;
56243
56314
  }
56244
- if (isEntityName(node) || isEntityNameExpression(node)) {
56245
- if (isDeclarationName(node)) {
56246
- return node;
56315
+ if (isTypeQueryNode(node)) {
56316
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
56317
+ if (introducesError) {
56318
+ const serializedName = serializeTypeName(
56319
+ context,
56320
+ node.exprName,
56321
+ /*isTypeOf*/
56322
+ true
56323
+ );
56324
+ if (serializedName) {
56325
+ return setTextRange2(context, serializedName, node.exprName);
56326
+ }
56327
+ return serializeExistingTypeNode(context, node);
56247
56328
  }
56248
- const { introducesError, node: result } = trackExistingEntityName(node, context);
56329
+ return factory.updateTypeQueryNode(
56330
+ node,
56331
+ exprName,
56332
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
56333
+ );
56334
+ }
56335
+ if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
56336
+ const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
56337
+ if (!introducesError) {
56338
+ return factory.updateComputedPropertyName(node, result);
56339
+ } else {
56340
+ const type = getWidenedType(getRegularTypeOfExpression(node.expression));
56341
+ const computedPropertyNameType = typeToTypeNodeHelper(type, context);
56342
+ Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
56343
+ const literal = computedPropertyNameType.literal;
56344
+ if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
56345
+ return factory.createIdentifier(literal.text);
56346
+ }
56347
+ if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
56348
+ return literal;
56349
+ }
56350
+ return factory.updateComputedPropertyName(node, literal);
56351
+ }
56352
+ }
56353
+ if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
56354
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
56249
56355
  hadError = hadError || introducesError;
56250
- return result;
56356
+ return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
56251
56357
  }
56252
56358
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
56253
56359
  const visited = visitEachChild(
@@ -56281,6 +56387,11 @@ function createTypeChecker(host) {
56281
56387
  falseType2
56282
56388
  );
56283
56389
  }
56390
+ if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
56391
+ if (!canReuseTypeNode(context, node)) {
56392
+ return serializeExistingTypeNode(context, node);
56393
+ }
56394
+ }
56284
56395
  return visitEachChild(
56285
56396
  node,
56286
56397
  visitExistingNodeTreeSymbols,
@@ -82246,6 +82357,10 @@ function createTypeChecker(host) {
82246
82357
  texts.push(span.literal.text);
82247
82358
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
82248
82359
  }
82360
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
82361
+ if (evaluated) {
82362
+ return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
82363
+ }
82249
82364
  if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType2(
82250
82365
  node,
82251
82366
  /*contextFlags*/
@@ -82253,8 +82368,7 @@ function createTypeChecker(host) {
82253
82368
  ) || unknownType, isTemplateLiteralContextualType)) {
82254
82369
  return getTemplateLiteralType(texts, types);
82255
82370
  }
82256
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
82257
- return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
82371
+ return stringType;
82258
82372
  }
82259
82373
  function isTemplateLiteralContextualType(type) {
82260
82374
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
@@ -115126,7 +115240,7 @@ function transformDeclarations(context) {
115126
115240
  }
115127
115241
  }
115128
115242
  }
115129
- } else {
115243
+ } else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
115130
115244
  const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
115131
115245
  if (errorInfo) {
115132
115246
  if (errorInfo.typeName) {
@@ -123397,7 +123511,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123397
123511
  let reasonToRelatedInfo;
123398
123512
  const cachedBindAndCheckDiagnosticsForFile = {};
123399
123513
  const cachedDeclarationDiagnosticsForFile = {};
123400
- let resolvedTypeReferenceDirectives = createModeAwareCache();
123401
123514
  let fileProcessingDiagnostics;
123402
123515
  let automaticTypeDirectiveNames;
123403
123516
  let automaticTypeDirectiveResolutions;
@@ -123673,7 +123786,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123673
123786
  resolvedLibProcessing = void 0;
123674
123787
  resolvedModulesProcessing = void 0;
123675
123788
  resolvedTypeReferenceDirectiveNamesProcessing = void 0;
123676
- resolvedTypeReferenceDirectives = void 0;
123677
123789
  const program = {
123678
123790
  getRootFileNames: () => rootNames,
123679
123791
  getSourceFile,
@@ -125387,53 +125499,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125387
125499
  (_b2 = tracing) == null ? void 0 : _b2.pop();
125388
125500
  }
125389
125501
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
125390
- var _a2;
125391
125502
  addResolutionDiagnostics(resolution);
125392
- const previousResolution = (_a2 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
125393
- if (previousResolution && previousResolution.primary) {
125394
- return;
125395
- }
125396
- let saveResolution = true;
125397
125503
  const { resolvedTypeReferenceDirective } = resolution;
125398
125504
  if (resolvedTypeReferenceDirective) {
125399
125505
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++;
125400
- if (resolvedTypeReferenceDirective.primary) {
125401
- processSourceFile(
125402
- resolvedTypeReferenceDirective.resolvedFileName,
125403
- /*isDefaultLib*/
125404
- false,
125405
- /*ignoreNoDefaultLib*/
125406
- false,
125407
- resolvedTypeReferenceDirective.packageId,
125408
- reason
125409
- );
125410
- } else {
125411
- if (previousResolution) {
125412
- if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
125413
- const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
125414
- const existingFile = getSourceFile(previousResolution.resolvedFileName);
125415
- if (otherFileText !== existingFile.text) {
125416
- addFilePreprocessingFileExplainingDiagnostic(
125417
- existingFile,
125418
- reason,
125419
- Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
125420
- [typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName]
125421
- );
125422
- }
125423
- }
125424
- saveResolution = false;
125425
- } else {
125426
- processSourceFile(
125427
- resolvedTypeReferenceDirective.resolvedFileName,
125428
- /*isDefaultLib*/
125429
- false,
125430
- /*ignoreNoDefaultLib*/
125431
- false,
125432
- resolvedTypeReferenceDirective.packageId,
125433
- reason
125434
- );
125435
- }
125436
- }
125506
+ processSourceFile(
125507
+ resolvedTypeReferenceDirective.resolvedFileName,
125508
+ /*isDefaultLib*/
125509
+ false,
125510
+ /*ignoreNoDefaultLib*/
125511
+ false,
125512
+ resolvedTypeReferenceDirective.packageId,
125513
+ reason
125514
+ );
125437
125515
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
125438
125516
  } else {
125439
125517
  addFilePreprocessingFileExplainingDiagnostic(
@@ -125444,9 +125522,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125444
125522
  [typeReferenceDirective]
125445
125523
  );
125446
125524
  }
125447
- if (saveResolution) {
125448
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
125449
- }
125450
125525
  }
125451
125526
  function pathForLibFile(libFileName) {
125452
125527
  const existing = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.5.0-dev.20240514",
5
+ "version": "5.5.0-dev.20240515",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -110,5 +110,5 @@
110
110
  "node": "20.1.0",
111
111
  "npm": "8.19.4"
112
112
  },
113
- "gitHead": "e51cbc8764da1f7df05c3504e15f9fda98dc91b6"
113
+ "gitHead": "4ece0a381be3d925b12b9a1626583578b8735805"
114
114
  }