typescript 5.5.0-dev.20240514 → 5.5.0-dev.20240516

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 +143 -68
  2. package/lib/typescript.js +144 -68
  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.20240516`;
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."),
@@ -13652,7 +13651,8 @@ function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
13652
13651
  }
13653
13652
  function getJSDocCommentRanges(node, text) {
13654
13653
  const commentRanges = node.kind === 169 /* Parameter */ || node.kind === 168 /* TypeParameter */ || node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */ || node.kind === 217 /* ParenthesizedExpression */ || node.kind === 260 /* VariableDeclaration */ || node.kind === 281 /* ExportSpecifier */ ? concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRanges(text, node.pos);
13655
- return filter(commentRanges, (comment) => text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
13654
+ return filter(commentRanges, (comment) => comment.end <= node.end && // Due to parse errors sometime empty parameter may get comments assigned to it that end up not in parameter range
13655
+ text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
13656
13656
  }
13657
13657
  var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
13658
13658
  var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
@@ -49020,7 +49020,7 @@ function createTypeChecker(host) {
49020
49020
  return { accessibility: 0 /* Accessible */ };
49021
49021
  }
49022
49022
  return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
49023
- accessibility: 1 /* NotAccessible */,
49023
+ accessibility: 3 /* NotResolved */,
49024
49024
  errorSymbolName: getTextOfNode(firstIdentifier),
49025
49025
  errorNode: firstIdentifier
49026
49026
  };
@@ -49158,6 +49158,7 @@ function createTypeChecker(host) {
49158
49158
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
49159
49159
  range = factory.cloneNode(range);
49160
49160
  }
49161
+ if (range === location) return range;
49161
49162
  if (!location) {
49162
49163
  return range;
49163
49164
  }
@@ -51294,6 +51295,57 @@ function createTypeChecker(host) {
51294
51295
  return updated;
51295
51296
  }
51296
51297
  }
51298
+ function serializeTypeName(context, node, isTypeOf, typeArguments) {
51299
+ const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
51300
+ const symbol = resolveEntityName(
51301
+ node,
51302
+ meaning,
51303
+ /*ignoreErrors*/
51304
+ true
51305
+ );
51306
+ if (!symbol) return void 0;
51307
+ const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
51308
+ if (isSymbolAccessible(
51309
+ symbol,
51310
+ context.enclosingDeclaration,
51311
+ meaning,
51312
+ /*shouldComputeAliasesToMakeVisible*/
51313
+ false
51314
+ ).accessibility !== 0 /* Accessible */) return void 0;
51315
+ return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
51316
+ }
51317
+ function canReuseTypeNode(context, existing) {
51318
+ if (isInJSFile(existing)) {
51319
+ if (isLiteralImportTypeNode(existing)) {
51320
+ void getTypeFromImportTypeNode(existing);
51321
+ const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
51322
+ return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
51323
+ (!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
51324
+ !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
51325
+ }
51326
+ }
51327
+ if (isTypeReferenceNode(existing)) {
51328
+ if (isConstTypeReference(existing)) return false;
51329
+ const type = getTypeFromTypeReference(existing);
51330
+ const symbol = getNodeLinks(existing).resolvedSymbol;
51331
+ if (!symbol) return false;
51332
+ if (symbol.flags & 262144 /* TypeParameter */) {
51333
+ return true;
51334
+ }
51335
+ if (isInJSDoc(existing)) {
51336
+ return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
51337
+ }
51338
+ }
51339
+ if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
51340
+ const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
51341
+ return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
51342
+ }
51343
+ return true;
51344
+ }
51345
+ function serializeExistingTypeNode(context, typeNode) {
51346
+ const type = getTypeFromTypeNode(typeNode);
51347
+ return typeToTypeNodeHelper(type, context);
51348
+ }
51297
51349
  function tryReuseExistingTypeNodeHelper(context, existing) {
51298
51350
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
51299
51351
  cancellationToken.throwIfCancellationRequested();
@@ -51303,6 +51355,7 @@ function createTypeChecker(host) {
51303
51355
  if (hadError) {
51304
51356
  return void 0;
51305
51357
  }
51358
+ context.approximateLength += existing.end - existing.pos;
51306
51359
  return transformed;
51307
51360
  function visitExistingNodeTreeSymbols(node) {
51308
51361
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
@@ -51402,20 +51455,38 @@ function createTypeChecker(host) {
51402
51455
  );
51403
51456
  }
51404
51457
  }
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);
51458
+ if (isTypeReferenceNode(node)) {
51459
+ if (canReuseTypeNode(context, node)) {
51460
+ const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
51461
+ const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
51462
+ if (!introducesError) {
51463
+ const updated = factory.updateTypeReferenceNode(
51464
+ node,
51465
+ newName,
51466
+ typeArguments
51467
+ );
51468
+ return setTextRange2(context, updated, node);
51469
+ } else {
51470
+ const serializedName = serializeTypeName(
51471
+ context,
51472
+ node.typeName,
51473
+ /*isTypeOf*/
51474
+ false,
51475
+ typeArguments
51476
+ );
51477
+ if (serializedName) {
51478
+ return setTextRange2(context, serializedName, node.typeName);
51479
+ }
51480
+ }
51481
+ }
51482
+ return serializeExistingTypeNode(context, node);
51412
51483
  }
51413
51484
  if (isLiteralImportTypeNode(node)) {
51414
51485
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
51415
51486
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
51416
51487
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
51417
51488
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
51418
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51489
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
51419
51490
  }
51420
51491
  return factory.updateImportTypeNode(
51421
51492
  node,
@@ -51447,13 +51518,48 @@ function createTypeChecker(host) {
51447
51518
  }
51448
51519
  return visited;
51449
51520
  }
51450
- if (isEntityName(node) || isEntityNameExpression(node)) {
51451
- if (isDeclarationName(node)) {
51452
- return node;
51521
+ if (isTypeQueryNode(node)) {
51522
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
51523
+ if (introducesError) {
51524
+ const serializedName = serializeTypeName(
51525
+ context,
51526
+ node.exprName,
51527
+ /*isTypeOf*/
51528
+ true
51529
+ );
51530
+ if (serializedName) {
51531
+ return setTextRange2(context, serializedName, node.exprName);
51532
+ }
51533
+ return serializeExistingTypeNode(context, node);
51534
+ }
51535
+ return factory.updateTypeQueryNode(
51536
+ node,
51537
+ exprName,
51538
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
51539
+ );
51540
+ }
51541
+ if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
51542
+ const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
51543
+ if (!introducesError) {
51544
+ return factory.updateComputedPropertyName(node, result);
51545
+ } else {
51546
+ const type = getWidenedType(getRegularTypeOfExpression(node.expression));
51547
+ const computedPropertyNameType = typeToTypeNodeHelper(type, context);
51548
+ Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
51549
+ const literal = computedPropertyNameType.literal;
51550
+ if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
51551
+ return factory.createIdentifier(literal.text);
51552
+ }
51553
+ if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
51554
+ return literal;
51555
+ }
51556
+ return factory.updateComputedPropertyName(node, literal);
51453
51557
  }
51454
- const { introducesError, node: result } = trackExistingEntityName(node, context);
51558
+ }
51559
+ if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
51560
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
51455
51561
  hadError = hadError || introducesError;
51456
- return result;
51562
+ return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
51457
51563
  }
51458
51564
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
51459
51565
  const visited = visitEachChild(
@@ -51487,6 +51593,11 @@ function createTypeChecker(host) {
51487
51593
  falseType2
51488
51594
  );
51489
51595
  }
51596
+ if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
51597
+ if (!canReuseTypeNode(context, node)) {
51598
+ return serializeExistingTypeNode(context, node);
51599
+ }
51600
+ }
51490
51601
  return visitEachChild(
51491
51602
  node,
51492
51603
  visitExistingNodeTreeSymbols,
@@ -77452,6 +77563,10 @@ function createTypeChecker(host) {
77452
77563
  texts.push(span.literal.text);
77453
77564
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
77454
77565
  }
77566
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
77567
+ if (evaluated) {
77568
+ return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
77569
+ }
77455
77570
  if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(
77456
77571
  node,
77457
77572
  /*contextFlags*/
@@ -77459,8 +77574,7 @@ function createTypeChecker(host) {
77459
77574
  ) || unknownType, isTemplateLiteralContextualType)) {
77460
77575
  return getTemplateLiteralType(texts, types);
77461
77576
  }
77462
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
77463
- return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
77577
+ return stringType;
77464
77578
  }
77465
77579
  function isTemplateLiteralContextualType(type) {
77466
77580
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
@@ -110150,7 +110264,7 @@ function transformDeclarations(context) {
110150
110264
  }
110151
110265
  }
110152
110266
  }
110153
- } else {
110267
+ } else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
110154
110268
  const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
110155
110269
  if (errorInfo) {
110156
110270
  if (errorInfo.typeName) {
@@ -118364,7 +118478,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118364
118478
  let reasonToRelatedInfo;
118365
118479
  const cachedBindAndCheckDiagnosticsForFile = {};
118366
118480
  const cachedDeclarationDiagnosticsForFile = {};
118367
- let resolvedTypeReferenceDirectives = createModeAwareCache();
118368
118481
  let fileProcessingDiagnostics;
118369
118482
  let automaticTypeDirectiveNames;
118370
118483
  let automaticTypeDirectiveResolutions;
@@ -118640,7 +118753,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118640
118753
  resolvedLibProcessing = void 0;
118641
118754
  resolvedModulesProcessing = void 0;
118642
118755
  resolvedTypeReferenceDirectiveNamesProcessing = void 0;
118643
- resolvedTypeReferenceDirectives = void 0;
118644
118756
  const program = {
118645
118757
  getRootFileNames: () => rootNames,
118646
118758
  getSourceFile,
@@ -120354,53 +120466,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120354
120466
  (_b2 = tracing) == null ? void 0 : _b2.pop();
120355
120467
  }
120356
120468
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
120357
- var _a2;
120358
120469
  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
120470
  const { resolvedTypeReferenceDirective } = resolution;
120365
120471
  if (resolvedTypeReferenceDirective) {
120366
120472
  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
- }
120473
+ processSourceFile(
120474
+ resolvedTypeReferenceDirective.resolvedFileName,
120475
+ /*isDefaultLib*/
120476
+ false,
120477
+ /*ignoreNoDefaultLib*/
120478
+ false,
120479
+ resolvedTypeReferenceDirective.packageId,
120480
+ reason
120481
+ );
120404
120482
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
120405
120483
  } else {
120406
120484
  addFilePreprocessingFileExplainingDiagnostic(
@@ -120411,9 +120489,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120411
120489
  [typeReferenceDirective]
120412
120490
  );
120413
120491
  }
120414
- if (saveResolution) {
120415
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
120416
- }
120417
120492
  }
120418
120493
  function pathForLibFile(libFileName) {
120419
120494
  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.20240516`;
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."),
@@ -17551,7 +17551,8 @@ function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
17551
17551
  }
17552
17552
  function getJSDocCommentRanges(node, text) {
17553
17553
  const commentRanges = node.kind === 169 /* Parameter */ || node.kind === 168 /* TypeParameter */ || node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */ || node.kind === 217 /* ParenthesizedExpression */ || node.kind === 260 /* VariableDeclaration */ || node.kind === 281 /* ExportSpecifier */ ? concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRanges(text, node.pos);
17554
- return filter(commentRanges, (comment) => text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
17554
+ return filter(commentRanges, (comment) => comment.end <= node.end && // Due to parse errors sometime empty parameter may get comments assigned to it that end up not in parameter range
17555
+ text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
17555
17556
  }
17556
17557
  var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
17557
17558
  var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
@@ -53814,7 +53815,7 @@ function createTypeChecker(host) {
53814
53815
  return { accessibility: 0 /* Accessible */ };
53815
53816
  }
53816
53817
  return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
53817
- accessibility: 1 /* NotAccessible */,
53818
+ accessibility: 3 /* NotResolved */,
53818
53819
  errorSymbolName: getTextOfNode(firstIdentifier),
53819
53820
  errorNode: firstIdentifier
53820
53821
  };
@@ -53952,6 +53953,7 @@ function createTypeChecker(host) {
53952
53953
  if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
53953
53954
  range = factory.cloneNode(range);
53954
53955
  }
53956
+ if (range === location) return range;
53955
53957
  if (!location) {
53956
53958
  return range;
53957
53959
  }
@@ -56088,6 +56090,57 @@ function createTypeChecker(host) {
56088
56090
  return updated;
56089
56091
  }
56090
56092
  }
56093
+ function serializeTypeName(context, node, isTypeOf, typeArguments) {
56094
+ const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
56095
+ const symbol = resolveEntityName(
56096
+ node,
56097
+ meaning,
56098
+ /*ignoreErrors*/
56099
+ true
56100
+ );
56101
+ if (!symbol) return void 0;
56102
+ const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
56103
+ if (isSymbolAccessible(
56104
+ symbol,
56105
+ context.enclosingDeclaration,
56106
+ meaning,
56107
+ /*shouldComputeAliasesToMakeVisible*/
56108
+ false
56109
+ ).accessibility !== 0 /* Accessible */) return void 0;
56110
+ return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
56111
+ }
56112
+ function canReuseTypeNode(context, existing) {
56113
+ if (isInJSFile(existing)) {
56114
+ if (isLiteralImportTypeNode(existing)) {
56115
+ void getTypeFromImportTypeNode(existing);
56116
+ const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
56117
+ return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
56118
+ (!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
56119
+ !(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
56120
+ }
56121
+ }
56122
+ if (isTypeReferenceNode(existing)) {
56123
+ if (isConstTypeReference(existing)) return false;
56124
+ const type = getTypeFromTypeReference(existing);
56125
+ const symbol = getNodeLinks(existing).resolvedSymbol;
56126
+ if (!symbol) return false;
56127
+ if (symbol.flags & 262144 /* TypeParameter */) {
56128
+ return true;
56129
+ }
56130
+ if (isInJSDoc(existing)) {
56131
+ return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
56132
+ }
56133
+ }
56134
+ if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
56135
+ const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
56136
+ return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
56137
+ }
56138
+ return true;
56139
+ }
56140
+ function serializeExistingTypeNode(context, typeNode) {
56141
+ const type = getTypeFromTypeNode(typeNode);
56142
+ return typeToTypeNodeHelper(type, context);
56143
+ }
56091
56144
  function tryReuseExistingTypeNodeHelper(context, existing) {
56092
56145
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
56093
56146
  cancellationToken.throwIfCancellationRequested();
@@ -56097,6 +56150,7 @@ function createTypeChecker(host) {
56097
56150
  if (hadError) {
56098
56151
  return void 0;
56099
56152
  }
56153
+ context.approximateLength += existing.end - existing.pos;
56100
56154
  return transformed;
56101
56155
  function visitExistingNodeTreeSymbols(node) {
56102
56156
  const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
@@ -56196,20 +56250,38 @@ function createTypeChecker(host) {
56196
56250
  );
56197
56251
  }
56198
56252
  }
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);
56253
+ if (isTypeReferenceNode(node)) {
56254
+ if (canReuseTypeNode(context, node)) {
56255
+ const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
56256
+ const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
56257
+ if (!introducesError) {
56258
+ const updated = factory.updateTypeReferenceNode(
56259
+ node,
56260
+ newName,
56261
+ typeArguments
56262
+ );
56263
+ return setTextRange2(context, updated, node);
56264
+ } else {
56265
+ const serializedName = serializeTypeName(
56266
+ context,
56267
+ node.typeName,
56268
+ /*isTypeOf*/
56269
+ false,
56270
+ typeArguments
56271
+ );
56272
+ if (serializedName) {
56273
+ return setTextRange2(context, serializedName, node.typeName);
56274
+ }
56275
+ }
56276
+ }
56277
+ return serializeExistingTypeNode(context, node);
56206
56278
  }
56207
56279
  if (isLiteralImportTypeNode(node)) {
56208
56280
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
56209
56281
  if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
56210
56282
  (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
56211
56283
  !(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
56212
- return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56284
+ return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
56213
56285
  }
56214
56286
  return factory.updateImportTypeNode(
56215
56287
  node,
@@ -56241,13 +56313,48 @@ function createTypeChecker(host) {
56241
56313
  }
56242
56314
  return visited;
56243
56315
  }
56244
- if (isEntityName(node) || isEntityNameExpression(node)) {
56245
- if (isDeclarationName(node)) {
56246
- return node;
56316
+ if (isTypeQueryNode(node)) {
56317
+ const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
56318
+ if (introducesError) {
56319
+ const serializedName = serializeTypeName(
56320
+ context,
56321
+ node.exprName,
56322
+ /*isTypeOf*/
56323
+ true
56324
+ );
56325
+ if (serializedName) {
56326
+ return setTextRange2(context, serializedName, node.exprName);
56327
+ }
56328
+ return serializeExistingTypeNode(context, node);
56247
56329
  }
56248
- const { introducesError, node: result } = trackExistingEntityName(node, context);
56330
+ return factory.updateTypeQueryNode(
56331
+ node,
56332
+ exprName,
56333
+ visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
56334
+ );
56335
+ }
56336
+ if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
56337
+ const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
56338
+ if (!introducesError) {
56339
+ return factory.updateComputedPropertyName(node, result);
56340
+ } else {
56341
+ const type = getWidenedType(getRegularTypeOfExpression(node.expression));
56342
+ const computedPropertyNameType = typeToTypeNodeHelper(type, context);
56343
+ Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
56344
+ const literal = computedPropertyNameType.literal;
56345
+ if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
56346
+ return factory.createIdentifier(literal.text);
56347
+ }
56348
+ if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
56349
+ return literal;
56350
+ }
56351
+ return factory.updateComputedPropertyName(node, literal);
56352
+ }
56353
+ }
56354
+ if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
56355
+ const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
56249
56356
  hadError = hadError || introducesError;
56250
- return result;
56357
+ return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
56251
56358
  }
56252
56359
  if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
56253
56360
  const visited = visitEachChild(
@@ -56281,6 +56388,11 @@ function createTypeChecker(host) {
56281
56388
  falseType2
56282
56389
  );
56283
56390
  }
56391
+ if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
56392
+ if (!canReuseTypeNode(context, node)) {
56393
+ return serializeExistingTypeNode(context, node);
56394
+ }
56395
+ }
56284
56396
  return visitEachChild(
56285
56397
  node,
56286
56398
  visitExistingNodeTreeSymbols,
@@ -82246,6 +82358,10 @@ function createTypeChecker(host) {
82246
82358
  texts.push(span.literal.text);
82247
82359
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
82248
82360
  }
82361
+ const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
82362
+ if (evaluated) {
82363
+ return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
82364
+ }
82249
82365
  if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType2(
82250
82366
  node,
82251
82367
  /*contextFlags*/
@@ -82253,8 +82369,7 @@ function createTypeChecker(host) {
82253
82369
  ) || unknownType, isTemplateLiteralContextualType)) {
82254
82370
  return getTemplateLiteralType(texts, types);
82255
82371
  }
82256
- const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
82257
- return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
82372
+ return stringType;
82258
82373
  }
82259
82374
  function isTemplateLiteralContextualType(type) {
82260
82375
  return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
@@ -115126,7 +115241,7 @@ function transformDeclarations(context) {
115126
115241
  }
115127
115242
  }
115128
115243
  }
115129
- } else {
115244
+ } else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
115130
115245
  const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
115131
115246
  if (errorInfo) {
115132
115247
  if (errorInfo.typeName) {
@@ -123397,7 +123512,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123397
123512
  let reasonToRelatedInfo;
123398
123513
  const cachedBindAndCheckDiagnosticsForFile = {};
123399
123514
  const cachedDeclarationDiagnosticsForFile = {};
123400
- let resolvedTypeReferenceDirectives = createModeAwareCache();
123401
123515
  let fileProcessingDiagnostics;
123402
123516
  let automaticTypeDirectiveNames;
123403
123517
  let automaticTypeDirectiveResolutions;
@@ -123673,7 +123787,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123673
123787
  resolvedLibProcessing = void 0;
123674
123788
  resolvedModulesProcessing = void 0;
123675
123789
  resolvedTypeReferenceDirectiveNamesProcessing = void 0;
123676
- resolvedTypeReferenceDirectives = void 0;
123677
123790
  const program = {
123678
123791
  getRootFileNames: () => rootNames,
123679
123792
  getSourceFile,
@@ -125387,53 +125500,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125387
125500
  (_b2 = tracing) == null ? void 0 : _b2.pop();
125388
125501
  }
125389
125502
  function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
125390
- var _a2;
125391
125503
  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
125504
  const { resolvedTypeReferenceDirective } = resolution;
125398
125505
  if (resolvedTypeReferenceDirective) {
125399
125506
  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
- }
125507
+ processSourceFile(
125508
+ resolvedTypeReferenceDirective.resolvedFileName,
125509
+ /*isDefaultLib*/
125510
+ false,
125511
+ /*ignoreNoDefaultLib*/
125512
+ false,
125513
+ resolvedTypeReferenceDirective.packageId,
125514
+ reason
125515
+ );
125437
125516
  if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
125438
125517
  } else {
125439
125518
  addFilePreprocessingFileExplainingDiagnostic(
@@ -125444,9 +125523,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125444
125523
  [typeReferenceDirective]
125445
125524
  );
125446
125525
  }
125447
- if (saveResolution) {
125448
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
125449
- }
125450
125526
  }
125451
125527
  function pathForLibFile(libFileName) {
125452
125528
  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.20240516",
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": "5c21b7fd93cc60b05d560f931fb8bb26d7972f76"
114
114
  }