typescript 5.5.0-dev.20240311 → 5.5.0-dev.20240312

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.20240311`;
21
+ var version = `${versionMajorMinor}.0-dev.20240312`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -44179,8 +44179,6 @@ function createTypeChecker(host) {
44179
44179
  var comparableRelation = /* @__PURE__ */ new Map();
44180
44180
  var identityRelation = /* @__PURE__ */ new Map();
44181
44181
  var enumRelation = /* @__PURE__ */ new Map();
44182
- var builtinGlobals = createSymbolTable();
44183
- builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
44184
44182
  var suggestedExtensions = [
44185
44183
  [".mts", ".mjs"],
44186
44184
  [".ts", ".js"],
@@ -44598,17 +44596,17 @@ function createTypeChecker(host) {
44598
44596
  }
44599
44597
  }
44600
44598
  }
44601
- function addToSymbolTable(target, source, message) {
44602
- source.forEach((sourceSymbol, id) => {
44603
- const targetSymbol = target.get(id);
44604
- if (targetSymbol) {
44605
- forEach(targetSymbol.declarations, addDeclarationDiagnostic(unescapeLeadingUnderscores(id), message));
44606
- } else {
44607
- target.set(id, sourceSymbol);
44608
- }
44609
- });
44610
- function addDeclarationDiagnostic(id, message2) {
44611
- return (declaration) => diagnostics.add(createDiagnosticForNode(declaration, message2, id));
44599
+ function addUndefinedToGlobalsOrErrorOnRedeclaration() {
44600
+ const name = undefinedSymbol.escapedName;
44601
+ const targetSymbol = globals.get(name);
44602
+ if (targetSymbol) {
44603
+ forEach(targetSymbol.declarations, (declaration) => {
44604
+ if (!isTypeDeclaration(declaration)) {
44605
+ diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, unescapeLeadingUnderscores(name)));
44606
+ }
44607
+ });
44608
+ } else {
44609
+ globals.set(name, undefinedSymbol);
44612
44610
  }
44613
44611
  }
44614
44612
  function getSymbolLinks(symbol) {
@@ -44678,7 +44676,14 @@ function createTypeChecker(host) {
44678
44676
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
44679
44677
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
44680
44678
  } else if (isClassLike(declaration)) {
44681
- return !findAncestor(usage, (n) => isComputedPropertyName(n) && n.parent.parent === declaration);
44679
+ const container = findAncestor(usage, (n) => n === declaration ? "quit" : isComputedPropertyName(n) ? n.parent.parent === declaration : isDecorator(n) && (n.parent === declaration || isMethodDeclaration(n.parent) && n.parent.parent === declaration || isGetOrSetAccessorDeclaration(n.parent) && n.parent.parent === declaration || isPropertyDeclaration(n.parent) && n.parent.parent === declaration || isParameter(n.parent) && n.parent.parent.parent === declaration));
44680
+ if (!container) {
44681
+ return true;
44682
+ }
44683
+ if (isDecorator(container)) {
44684
+ return !!findAncestor(usage, (n) => n === container ? "quit" : isFunctionLike(n) && !getImmediatelyInvokedFunctionExpression(n));
44685
+ }
44686
+ return false;
44682
44687
  } else if (isPropertyDeclaration(declaration)) {
44683
44688
  return !isPropertyImmediatelyReferencedWithinDeclaration(
44684
44689
  declaration,
@@ -60572,7 +60577,7 @@ function createTypeChecker(host) {
60572
60577
  if (reduced !== type) {
60573
60578
  return reduced;
60574
60579
  }
60575
- if (type.flags & 2097152 /* Intersection */ && some(type.types, isEmptyAnonymousObjectType)) {
60580
+ if (type.flags & 2097152 /* Intersection */ && shouldNormalizeIntersection(type)) {
60576
60581
  const normalizedTypes = sameMap(type.types, (t) => getNormalizedType(t, writing));
60577
60582
  if (normalizedTypes !== type.types) {
60578
60583
  return getIntersectionType(normalizedTypes);
@@ -60580,6 +60585,17 @@ function createTypeChecker(host) {
60580
60585
  }
60581
60586
  return type;
60582
60587
  }
60588
+ function shouldNormalizeIntersection(type) {
60589
+ let hasInstantiable = false;
60590
+ let hasNullableOrEmpty = false;
60591
+ for (const t of type.types) {
60592
+ hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
60593
+ hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
60594
+ if (hasInstantiable && hasNullableOrEmpty)
60595
+ return true;
60596
+ }
60597
+ return false;
60598
+ }
60583
60599
  function getNormalizedTupleType(type, writing) {
60584
60600
  const elements = getElementTypes(type);
60585
60601
  const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
@@ -65430,9 +65446,9 @@ function createTypeChecker(host) {
65430
65446
  if (strictNullChecks) {
65431
65447
  switch (facts) {
65432
65448
  case 524288 /* NEUndefined */:
65433
- return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
65449
+ return removeNullableByIntersection(reduced, 65536 /* EQUndefined */, 131072 /* EQNull */, 33554432 /* IsNull */, nullType);
65434
65450
  case 1048576 /* NENull */:
65435
- return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
65451
+ return removeNullableByIntersection(reduced, 131072 /* EQNull */, 65536 /* EQUndefined */, 16777216 /* IsUndefined */, undefinedType);
65436
65452
  case 2097152 /* NEUndefinedOrNull */:
65437
65453
  case 4194304 /* Truthy */:
65438
65454
  return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
@@ -65440,6 +65456,14 @@ function createTypeChecker(host) {
65440
65456
  }
65441
65457
  return reduced;
65442
65458
  }
65459
+ function removeNullableByIntersection(type, targetFacts, otherFacts, otherIncludesFacts, otherType) {
65460
+ const facts = getTypeFacts(type, 65536 /* EQUndefined */ | 131072 /* EQNull */ | 16777216 /* IsUndefined */ | 33554432 /* IsNull */);
65461
+ if (!(facts & targetFacts)) {
65462
+ return type;
65463
+ }
65464
+ const emptyAndOtherUnion = getUnionType([emptyObjectType, otherType]);
65465
+ return mapType(type, (t) => hasTypeFacts(t, targetFacts) ? getIntersectionType([t, !(facts & otherIncludesFacts) && hasTypeFacts(t, otherFacts) ? emptyAndOtherUnion : emptyObjectType]) : t);
65466
+ }
65443
65467
  function recombineUnknownType(type) {
65444
65468
  return type === unknownUnionType ? unknownType : type;
65445
65469
  }
@@ -69007,7 +69031,7 @@ function createTypeChecker(host) {
69007
69031
  }
69008
69032
  }
69009
69033
  function checkSpreadExpression(node, checkMode) {
69010
- if (languageVersion < 2 /* ES2015 */) {
69034
+ if (languageVersion < 2 /* SpreadElements */) {
69011
69035
  checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
69012
69036
  }
69013
69037
  const arrayOrIterableType = checkExpression(node.expression, checkMode);
@@ -69041,7 +69065,7 @@ function createTypeChecker(host) {
69041
69065
  for (let i = 0; i < elementCount; i++) {
69042
69066
  const e = elements[i];
69043
69067
  if (e.kind === 230 /* SpreadElement */) {
69044
- if (languageVersion < 2 /* ES2015 */) {
69068
+ if (languageVersion < 2 /* SpreadElements */) {
69045
69069
  checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
69046
69070
  }
69047
69071
  const spreadType = checkExpression(e.expression, checkMode, forceTuple);
@@ -69271,7 +69295,7 @@ function createTypeChecker(host) {
69271
69295
  addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
69272
69296
  }
69273
69297
  } else if (memberDecl.kind === 305 /* SpreadAssignment */) {
69274
- if (languageVersion < 2 /* ES2015 */) {
69298
+ if (languageVersion < 2 /* ObjectAssign */) {
69275
69299
  checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
69276
69300
  }
69277
69301
  if (propertiesArray.length > 0) {
@@ -70296,7 +70320,7 @@ function createTypeChecker(host) {
70296
70320
  const isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
70297
70321
  let prop;
70298
70322
  if (isPrivateIdentifier(right)) {
70299
- if (languageVersion < 99 /* ESNext */) {
70323
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
70300
70324
  if (assignmentKind !== 0 /* None */) {
70301
70325
  checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
70302
70326
  }
@@ -72909,7 +72933,7 @@ function createTypeChecker(host) {
72909
72933
  function checkTaggedTemplateExpression(node) {
72910
72934
  if (!checkGrammarTaggedTemplateChain(node))
72911
72935
  checkGrammarTypeArguments(node, node.typeArguments);
72912
- if (languageVersion < 2 /* ES2015 */) {
72936
+ if (languageVersion < 2 /* TaggedTemplates */) {
72913
72937
  checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
72914
72938
  }
72915
72939
  const signature = getResolvedSignature(node);
@@ -74556,7 +74580,7 @@ function createTypeChecker(host) {
74556
74580
  return silentNeverType;
74557
74581
  }
74558
74582
  if (isPrivateIdentifier(left)) {
74559
- if (languageVersion < 99 /* ESNext */) {
74583
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
74560
74584
  checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
74561
74585
  }
74562
74586
  if (!getNodeLinks(left).resolvedSymbol && getContainingClass(left)) {
@@ -74617,7 +74641,7 @@ function createTypeChecker(host) {
74617
74641
  if (propertyIndex < properties.length - 1) {
74618
74642
  error(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
74619
74643
  } else {
74620
- if (languageVersion < 99 /* ESNext */) {
74644
+ if (languageVersion < 5 /* ObjectSpreadRest */) {
74621
74645
  checkExternalEmitHelpers(property, 4 /* Rest */);
74622
74646
  }
74623
74647
  const nonRestNames = [];
@@ -74638,7 +74662,7 @@ function createTypeChecker(host) {
74638
74662
  }
74639
74663
  function checkArrayLiteralAssignment(node, sourceType, checkMode) {
74640
74664
  const elements = node.elements;
74641
- if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
74665
+ if (languageVersion < 2 /* DestructuringAssignment */ && compilerOptions.downlevelIteration) {
74642
74666
  checkExternalEmitHelpers(node, 512 /* Read */);
74643
74667
  }
74644
74668
  const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
@@ -75340,10 +75364,10 @@ function createTypeChecker(host) {
75340
75364
  }
75341
75365
  const isAsync = (functionFlags & 2 /* Async */) !== 0;
75342
75366
  if (node.asteriskToken) {
75343
- if (isAsync && languageVersion < 99 /* ESNext */) {
75367
+ if (isAsync && languageVersion < 5 /* AsyncGenerators */) {
75344
75368
  checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
75345
75369
  }
75346
- if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
75370
+ if (!isAsync && languageVersion < 2 /* Generators */ && compilerOptions.downlevelIteration) {
75347
75371
  checkExternalEmitHelpers(node, 256 /* Values */);
75348
75372
  }
75349
75373
  }
@@ -76115,13 +76139,13 @@ function createTypeChecker(host) {
76115
76139
  }
76116
76140
  const functionFlags = getFunctionFlags(node);
76117
76141
  if (!(functionFlags & 4 /* Invalid */)) {
76118
- if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) {
76142
+ if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 5 /* AsyncGenerators */) {
76119
76143
  checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
76120
76144
  }
76121
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) {
76145
+ if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* AsyncFunctions */) {
76122
76146
  checkExternalEmitHelpers(node, 64 /* Awaiter */);
76123
76147
  }
76124
- if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) {
76148
+ if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* Generators */) {
76125
76149
  checkExternalEmitHelpers(node, 128 /* Generator */);
76126
76150
  }
76127
76151
  }
@@ -76354,15 +76378,17 @@ function createTypeChecker(host) {
76354
76378
  setNodeLinksForPrivateIdentifierScope(node);
76355
76379
  }
76356
76380
  function setNodeLinksForPrivateIdentifierScope(node) {
76357
- if (isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) {
76358
- for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
76359
- getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
76360
- }
76361
- if (isClassExpression(node.parent)) {
76362
- const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
76363
- if (enclosingIterationStatement) {
76364
- getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
76365
- getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
76381
+ if (isPrivateIdentifier(node.name)) {
76382
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
76383
+ for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
76384
+ getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
76385
+ }
76386
+ if (isClassExpression(node.parent)) {
76387
+ const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
76388
+ if (enclosingIterationStatement) {
76389
+ getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
76390
+ getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
76391
+ }
76366
76392
  }
76367
76393
  }
76368
76394
  }
@@ -77487,7 +77513,7 @@ function createTypeChecker(host) {
77487
77513
  if (node.kind === 169 /* Parameter */) {
77488
77514
  checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
77489
77515
  }
77490
- } else if (languageVersion < 99 /* ESNext */) {
77516
+ } else if (languageVersion < 99 /* ClassAndClassElementDecorators */) {
77491
77517
  checkExternalEmitHelpers(firstDecorator, 8 /* ESDecorateAndRunInitializers */);
77492
77518
  if (isClassDeclaration(node)) {
77493
77519
  if (!node.name) {
@@ -78192,7 +78218,7 @@ function createTypeChecker(host) {
78192
78218
  potentialUnusedRenamedBindingElementsInTypes.push(node);
78193
78219
  return;
78194
78220
  }
78195
- if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
78221
+ if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ObjectSpreadRest */) {
78196
78222
  checkExternalEmitHelpers(node, 4 /* Rest */);
78197
78223
  }
78198
78224
  if (node.propertyName && node.propertyName.kind === 167 /* ComputedPropertyName */) {
@@ -78228,7 +78254,7 @@ function createTypeChecker(host) {
78228
78254
  }
78229
78255
  }
78230
78256
  if (isBindingPattern(node.name)) {
78231
- if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
78257
+ if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* BindingPatterns */ && compilerOptions.downlevelIteration) {
78232
78258
  checkExternalEmitHelpers(node, 512 /* Read */);
78233
78259
  }
78234
78260
  forEach(node.name.elements, checkSourceElement);
@@ -78379,7 +78405,7 @@ function createTypeChecker(host) {
78379
78405
  }
78380
78406
  function checkVariableDeclarationList(node) {
78381
78407
  const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
78382
- if (blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) {
78408
+ if ((blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) && languageVersion < 99 /* UsingAndAwaitUsing */) {
78383
78409
  checkExternalEmitHelpers(node, 16777216 /* AddDisposableResourceAndDisposeResources */);
78384
78410
  }
78385
78411
  forEach(node.declarations, checkSourceElement);
@@ -78552,11 +78578,11 @@ function createTypeChecker(host) {
78552
78578
  grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block);
78553
78579
  } else {
78554
78580
  const functionFlags = getFunctionFlags(container);
78555
- if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) {
78581
+ if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 5 /* ForAwaitOf */) {
78556
78582
  checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
78557
78583
  }
78558
78584
  }
78559
- } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) {
78585
+ } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ForOf */) {
78560
78586
  checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
78561
78587
  }
78562
78588
  if (node.initializer.kind === 261 /* VariableDeclarationList */) {
@@ -79480,6 +79506,7 @@ function createTypeChecker(host) {
79480
79506
  case "symbol":
79481
79507
  case "void":
79482
79508
  case "object":
79509
+ case "undefined":
79483
79510
  error(name, message, name.escapedText);
79484
79511
  }
79485
79512
  }
@@ -79619,12 +79646,12 @@ function createTypeChecker(host) {
79619
79646
  return true;
79620
79647
  }
79621
79648
  function getFirstTransformableStaticClassElement(node) {
79622
- const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ESNext */ && classOrConstructorParameterIsDecorated(
79649
+ const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */ && classOrConstructorParameterIsDecorated(
79623
79650
  /*useLegacyDecorators*/
79624
79651
  false,
79625
79652
  node
79626
79653
  );
79627
- const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
79654
+ const willTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */;
79628
79655
  const willTransformInitializers = !emitStandardClassFields;
79629
79656
  if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
79630
79657
  for (const member of node.members) {
@@ -79653,7 +79680,7 @@ function createTypeChecker(host) {
79653
79680
  const parent = walkUpOuterExpressions(node);
79654
79681
  if (!isNamedEvaluationSource(parent))
79655
79682
  return;
79656
- const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ESNext */;
79683
+ const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */;
79657
79684
  let location;
79658
79685
  if (willTransformESDecorators && classOrConstructorParameterIsDecorated(
79659
79686
  /*useLegacyDecorators*/
@@ -79713,7 +79740,7 @@ function createTypeChecker(host) {
79713
79740
  const baseTypeNode = getEffectiveBaseTypeNode(node);
79714
79741
  if (baseTypeNode) {
79715
79742
  forEach(baseTypeNode.typeArguments, checkSourceElement);
79716
- if (languageVersion < 2 /* ES2015 */) {
79743
+ if (languageVersion < 2 /* Classes */) {
79717
79744
  checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
79718
79745
  }
79719
79746
  const extendsNode = getClassExtendsHeritageElement(node);
@@ -83182,7 +83209,7 @@ function createTypeChecker(host) {
83182
83209
  }
83183
83210
  }
83184
83211
  }
83185
- addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
83212
+ addUndefinedToGlobalsOrErrorOnRedeclaration();
83186
83213
  getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
83187
83214
  getSymbolLinks(argumentsSymbol).type = getGlobalType(
83188
83215
  "IArguments",
@@ -86770,12 +86797,12 @@ function getOriginalNodeId(node) {
86770
86797
  function containsDefaultReference(node) {
86771
86798
  if (!node)
86772
86799
  return false;
86773
- if (!isNamedImports(node))
86800
+ if (!isNamedImports(node) && !isNamedExports(node))
86774
86801
  return false;
86775
86802
  return some(node.elements, isNamedDefaultReference);
86776
86803
  }
86777
86804
  function isNamedDefaultReference(e) {
86778
- return e.propertyName !== void 0 && e.propertyName.escapedText === "default" /* Default */;
86805
+ return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
86779
86806
  }
86780
86807
  function chainBundle(context, transformSourceFile) {
86781
86808
  return transformSourceFileOrBundle;
@@ -86849,6 +86876,7 @@ function collectExternalModuleInfo(context, sourceFile) {
86849
86876
  externalImports.push(node);
86850
86877
  if (isNamedExports(node.exportClause)) {
86851
86878
  addExportedNamesForExportDeclaration(node);
86879
+ hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
86852
86880
  } else {
86853
86881
  const name = node.exportClause.name;
86854
86882
  if (!uniqueExports.get(idText(name))) {
package/lib/tsserver.js CHANGED
@@ -106,6 +106,7 @@ __export(server_exports, {
106
106
  JsxEmit: () => JsxEmit,
107
107
  JsxFlags: () => JsxFlags,
108
108
  JsxReferenceKind: () => JsxReferenceKind,
109
+ LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
109
110
  LanguageServiceMode: () => LanguageServiceMode,
110
111
  LanguageVariant: () => LanguageVariant,
111
112
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
@@ -2325,7 +2326,7 @@ module.exports = __toCommonJS(server_exports);
2325
2326
 
2326
2327
  // src/compiler/corePublic.ts
2327
2328
  var versionMajorMinor = "5.5";
2328
- var version = `${versionMajorMinor}.0-dev.20240311`;
2329
+ var version = `${versionMajorMinor}.0-dev.20240312`;
2329
2330
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2330
2331
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2331
2332
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7233,6 +7234,38 @@ var InternalEmitFlags = /* @__PURE__ */ ((InternalEmitFlags3) => {
7233
7234
  InternalEmitFlags3[InternalEmitFlags3["TransformPrivateStaticElements"] = 32] = "TransformPrivateStaticElements";
7234
7235
  return InternalEmitFlags3;
7235
7236
  })(InternalEmitFlags || {});
7237
+ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarget2) => {
7238
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Classes"] = 2 /* ES2015 */] = "Classes";
7239
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForOf"] = 2 /* ES2015 */] = "ForOf";
7240
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Generators"] = 2 /* ES2015 */] = "Generators";
7241
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Iteration"] = 2 /* ES2015 */] = "Iteration";
7242
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["SpreadElements"] = 2 /* ES2015 */] = "SpreadElements";
7243
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RestElements"] = 2 /* ES2015 */] = "RestElements";
7244
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TaggedTemplates"] = 2 /* ES2015 */] = "TaggedTemplates";
7245
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["DestructuringAssignment"] = 2 /* ES2015 */] = "DestructuringAssignment";
7246
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindingPatterns"] = 2 /* ES2015 */] = "BindingPatterns";
7247
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ArrowFunctions"] = 2 /* ES2015 */] = "ArrowFunctions";
7248
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BlockScopedVariables"] = 2 /* ES2015 */] = "BlockScopedVariables";
7249
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectAssign"] = 2 /* ES2015 */] = "ObjectAssign";
7250
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Exponentiation"] = 3 /* ES2016 */] = "Exponentiation";
7251
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncFunctions"] = 4 /* ES2017 */] = "AsyncFunctions";
7252
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForAwaitOf"] = 5 /* ES2018 */] = "ForAwaitOf";
7253
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncGenerators"] = 5 /* ES2018 */] = "AsyncGenerators";
7254
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncIteration"] = 5 /* ES2018 */] = "AsyncIteration";
7255
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectSpreadRest"] = 5 /* ES2018 */] = "ObjectSpreadRest";
7256
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindinglessCatch"] = 6 /* ES2019 */] = "BindinglessCatch";
7257
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BigInt"] = 7 /* ES2020 */] = "BigInt";
7258
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["NullishCoalesce"] = 7 /* ES2020 */] = "NullishCoalesce";
7259
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["OptionalChaining"] = 7 /* ES2020 */] = "OptionalChaining";
7260
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["LogicalAssignment"] = 8 /* ES2021 */] = "LogicalAssignment";
7261
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TopLevelAwait"] = 9 /* ES2022 */] = "TopLevelAwait";
7262
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassFields"] = 9 /* ES2022 */] = "ClassFields";
7263
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["PrivateNamesAndClassStaticBlocks"] = 9 /* ES2022 */] = "PrivateNamesAndClassStaticBlocks";
7264
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ShebangComments"] = 99 /* ESNext */] = "ShebangComments";
7265
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["UsingAndAwaitUsing"] = 99 /* ESNext */] = "UsingAndAwaitUsing";
7266
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassAndClassElementDecorators"] = 99 /* ESNext */] = "ClassAndClassElementDecorators";
7267
+ return LanguageFeatureMinimumTarget2;
7268
+ })(LanguageFeatureMinimumTarget || {});
7236
7269
  var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
7237
7270
  ExternalEmitHelpers2[ExternalEmitHelpers2["Extends"] = 1] = "Extends";
7238
7271
  ExternalEmitHelpers2[ExternalEmitHelpers2["Assign"] = 2] = "Assign";
@@ -48898,8 +48931,6 @@ function createTypeChecker(host) {
48898
48931
  var comparableRelation = /* @__PURE__ */ new Map();
48899
48932
  var identityRelation = /* @__PURE__ */ new Map();
48900
48933
  var enumRelation = /* @__PURE__ */ new Map();
48901
- var builtinGlobals = createSymbolTable();
48902
- builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
48903
48934
  var suggestedExtensions = [
48904
48935
  [".mts", ".mjs"],
48905
48936
  [".ts", ".js"],
@@ -49317,17 +49348,17 @@ function createTypeChecker(host) {
49317
49348
  }
49318
49349
  }
49319
49350
  }
49320
- function addToSymbolTable(target, source, message) {
49321
- source.forEach((sourceSymbol, id) => {
49322
- const targetSymbol = target.get(id);
49323
- if (targetSymbol) {
49324
- forEach(targetSymbol.declarations, addDeclarationDiagnostic(unescapeLeadingUnderscores(id), message));
49325
- } else {
49326
- target.set(id, sourceSymbol);
49327
- }
49328
- });
49329
- function addDeclarationDiagnostic(id, message2) {
49330
- return (declaration) => diagnostics.add(createDiagnosticForNode(declaration, message2, id));
49351
+ function addUndefinedToGlobalsOrErrorOnRedeclaration() {
49352
+ const name = undefinedSymbol.escapedName;
49353
+ const targetSymbol = globals.get(name);
49354
+ if (targetSymbol) {
49355
+ forEach(targetSymbol.declarations, (declaration) => {
49356
+ if (!isTypeDeclaration(declaration)) {
49357
+ diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, unescapeLeadingUnderscores(name)));
49358
+ }
49359
+ });
49360
+ } else {
49361
+ globals.set(name, undefinedSymbol);
49331
49362
  }
49332
49363
  }
49333
49364
  function getSymbolLinks(symbol) {
@@ -49397,7 +49428,14 @@ function createTypeChecker(host) {
49397
49428
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
49398
49429
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
49399
49430
  } else if (isClassLike(declaration)) {
49400
- return !findAncestor(usage, (n) => isComputedPropertyName(n) && n.parent.parent === declaration);
49431
+ const container = findAncestor(usage, (n) => n === declaration ? "quit" : isComputedPropertyName(n) ? n.parent.parent === declaration : isDecorator(n) && (n.parent === declaration || isMethodDeclaration(n.parent) && n.parent.parent === declaration || isGetOrSetAccessorDeclaration(n.parent) && n.parent.parent === declaration || isPropertyDeclaration(n.parent) && n.parent.parent === declaration || isParameter(n.parent) && n.parent.parent.parent === declaration));
49432
+ if (!container) {
49433
+ return true;
49434
+ }
49435
+ if (isDecorator(container)) {
49436
+ return !!findAncestor(usage, (n) => n === container ? "quit" : isFunctionLike(n) && !getImmediatelyInvokedFunctionExpression(n));
49437
+ }
49438
+ return false;
49401
49439
  } else if (isPropertyDeclaration(declaration)) {
49402
49440
  return !isPropertyImmediatelyReferencedWithinDeclaration(
49403
49441
  declaration,
@@ -65291,7 +65329,7 @@ function createTypeChecker(host) {
65291
65329
  if (reduced !== type) {
65292
65330
  return reduced;
65293
65331
  }
65294
- if (type.flags & 2097152 /* Intersection */ && some(type.types, isEmptyAnonymousObjectType)) {
65332
+ if (type.flags & 2097152 /* Intersection */ && shouldNormalizeIntersection(type)) {
65295
65333
  const normalizedTypes = sameMap(type.types, (t) => getNormalizedType(t, writing));
65296
65334
  if (normalizedTypes !== type.types) {
65297
65335
  return getIntersectionType(normalizedTypes);
@@ -65299,6 +65337,17 @@ function createTypeChecker(host) {
65299
65337
  }
65300
65338
  return type;
65301
65339
  }
65340
+ function shouldNormalizeIntersection(type) {
65341
+ let hasInstantiable = false;
65342
+ let hasNullableOrEmpty = false;
65343
+ for (const t of type.types) {
65344
+ hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
65345
+ hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
65346
+ if (hasInstantiable && hasNullableOrEmpty)
65347
+ return true;
65348
+ }
65349
+ return false;
65350
+ }
65302
65351
  function getNormalizedTupleType(type, writing) {
65303
65352
  const elements = getElementTypes(type);
65304
65353
  const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
@@ -70149,9 +70198,9 @@ function createTypeChecker(host) {
70149
70198
  if (strictNullChecks) {
70150
70199
  switch (facts) {
70151
70200
  case 524288 /* NEUndefined */:
70152
- return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
70201
+ return removeNullableByIntersection(reduced, 65536 /* EQUndefined */, 131072 /* EQNull */, 33554432 /* IsNull */, nullType);
70153
70202
  case 1048576 /* NENull */:
70154
- return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
70203
+ return removeNullableByIntersection(reduced, 131072 /* EQNull */, 65536 /* EQUndefined */, 16777216 /* IsUndefined */, undefinedType);
70155
70204
  case 2097152 /* NEUndefinedOrNull */:
70156
70205
  case 4194304 /* Truthy */:
70157
70206
  return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
@@ -70159,6 +70208,14 @@ function createTypeChecker(host) {
70159
70208
  }
70160
70209
  return reduced;
70161
70210
  }
70211
+ function removeNullableByIntersection(type, targetFacts, otherFacts, otherIncludesFacts, otherType) {
70212
+ const facts = getTypeFacts(type, 65536 /* EQUndefined */ | 131072 /* EQNull */ | 16777216 /* IsUndefined */ | 33554432 /* IsNull */);
70213
+ if (!(facts & targetFacts)) {
70214
+ return type;
70215
+ }
70216
+ const emptyAndOtherUnion = getUnionType([emptyObjectType, otherType]);
70217
+ return mapType(type, (t) => hasTypeFacts(t, targetFacts) ? getIntersectionType([t, !(facts & otherIncludesFacts) && hasTypeFacts(t, otherFacts) ? emptyAndOtherUnion : emptyObjectType]) : t);
70218
+ }
70162
70219
  function recombineUnknownType(type) {
70163
70220
  return type === unknownUnionType ? unknownType : type;
70164
70221
  }
@@ -73726,7 +73783,7 @@ function createTypeChecker(host) {
73726
73783
  }
73727
73784
  }
73728
73785
  function checkSpreadExpression(node, checkMode) {
73729
- if (languageVersion < 2 /* ES2015 */) {
73786
+ if (languageVersion < 2 /* SpreadElements */) {
73730
73787
  checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
73731
73788
  }
73732
73789
  const arrayOrIterableType = checkExpression(node.expression, checkMode);
@@ -73760,7 +73817,7 @@ function createTypeChecker(host) {
73760
73817
  for (let i = 0; i < elementCount; i++) {
73761
73818
  const e = elements[i];
73762
73819
  if (e.kind === 230 /* SpreadElement */) {
73763
- if (languageVersion < 2 /* ES2015 */) {
73820
+ if (languageVersion < 2 /* SpreadElements */) {
73764
73821
  checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
73765
73822
  }
73766
73823
  const spreadType = checkExpression(e.expression, checkMode, forceTuple);
@@ -73990,7 +74047,7 @@ function createTypeChecker(host) {
73990
74047
  addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
73991
74048
  }
73992
74049
  } else if (memberDecl.kind === 305 /* SpreadAssignment */) {
73993
- if (languageVersion < 2 /* ES2015 */) {
74050
+ if (languageVersion < 2 /* ObjectAssign */) {
73994
74051
  checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
73995
74052
  }
73996
74053
  if (propertiesArray.length > 0) {
@@ -75015,7 +75072,7 @@ function createTypeChecker(host) {
75015
75072
  const isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
75016
75073
  let prop;
75017
75074
  if (isPrivateIdentifier(right)) {
75018
- if (languageVersion < 99 /* ESNext */) {
75075
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
75019
75076
  if (assignmentKind !== 0 /* None */) {
75020
75077
  checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
75021
75078
  }
@@ -77628,7 +77685,7 @@ function createTypeChecker(host) {
77628
77685
  function checkTaggedTemplateExpression(node) {
77629
77686
  if (!checkGrammarTaggedTemplateChain(node))
77630
77687
  checkGrammarTypeArguments(node, node.typeArguments);
77631
- if (languageVersion < 2 /* ES2015 */) {
77688
+ if (languageVersion < 2 /* TaggedTemplates */) {
77632
77689
  checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
77633
77690
  }
77634
77691
  const signature = getResolvedSignature(node);
@@ -79275,7 +79332,7 @@ function createTypeChecker(host) {
79275
79332
  return silentNeverType;
79276
79333
  }
79277
79334
  if (isPrivateIdentifier(left)) {
79278
- if (languageVersion < 99 /* ESNext */) {
79335
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
79279
79336
  checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
79280
79337
  }
79281
79338
  if (!getNodeLinks(left).resolvedSymbol && getContainingClass(left)) {
@@ -79336,7 +79393,7 @@ function createTypeChecker(host) {
79336
79393
  if (propertyIndex < properties.length - 1) {
79337
79394
  error2(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
79338
79395
  } else {
79339
- if (languageVersion < 99 /* ESNext */) {
79396
+ if (languageVersion < 5 /* ObjectSpreadRest */) {
79340
79397
  checkExternalEmitHelpers(property, 4 /* Rest */);
79341
79398
  }
79342
79399
  const nonRestNames = [];
@@ -79357,7 +79414,7 @@ function createTypeChecker(host) {
79357
79414
  }
79358
79415
  function checkArrayLiteralAssignment(node, sourceType, checkMode) {
79359
79416
  const elements = node.elements;
79360
- if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
79417
+ if (languageVersion < 2 /* DestructuringAssignment */ && compilerOptions.downlevelIteration) {
79361
79418
  checkExternalEmitHelpers(node, 512 /* Read */);
79362
79419
  }
79363
79420
  const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
@@ -80059,10 +80116,10 @@ function createTypeChecker(host) {
80059
80116
  }
80060
80117
  const isAsync = (functionFlags & 2 /* Async */) !== 0;
80061
80118
  if (node.asteriskToken) {
80062
- if (isAsync && languageVersion < 99 /* ESNext */) {
80119
+ if (isAsync && languageVersion < 5 /* AsyncGenerators */) {
80063
80120
  checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
80064
80121
  }
80065
- if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
80122
+ if (!isAsync && languageVersion < 2 /* Generators */ && compilerOptions.downlevelIteration) {
80066
80123
  checkExternalEmitHelpers(node, 256 /* Values */);
80067
80124
  }
80068
80125
  }
@@ -80834,13 +80891,13 @@ function createTypeChecker(host) {
80834
80891
  }
80835
80892
  const functionFlags = getFunctionFlags(node);
80836
80893
  if (!(functionFlags & 4 /* Invalid */)) {
80837
- if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) {
80894
+ if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 5 /* AsyncGenerators */) {
80838
80895
  checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
80839
80896
  }
80840
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) {
80897
+ if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* AsyncFunctions */) {
80841
80898
  checkExternalEmitHelpers(node, 64 /* Awaiter */);
80842
80899
  }
80843
- if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) {
80900
+ if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* Generators */) {
80844
80901
  checkExternalEmitHelpers(node, 128 /* Generator */);
80845
80902
  }
80846
80903
  }
@@ -81073,15 +81130,17 @@ function createTypeChecker(host) {
81073
81130
  setNodeLinksForPrivateIdentifierScope(node);
81074
81131
  }
81075
81132
  function setNodeLinksForPrivateIdentifierScope(node) {
81076
- if (isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) {
81077
- for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
81078
- getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
81079
- }
81080
- if (isClassExpression(node.parent)) {
81081
- const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
81082
- if (enclosingIterationStatement) {
81083
- getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
81084
- getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
81133
+ if (isPrivateIdentifier(node.name)) {
81134
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
81135
+ for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
81136
+ getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
81137
+ }
81138
+ if (isClassExpression(node.parent)) {
81139
+ const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
81140
+ if (enclosingIterationStatement) {
81141
+ getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
81142
+ getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
81143
+ }
81085
81144
  }
81086
81145
  }
81087
81146
  }
@@ -82206,7 +82265,7 @@ function createTypeChecker(host) {
82206
82265
  if (node.kind === 169 /* Parameter */) {
82207
82266
  checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
82208
82267
  }
82209
- } else if (languageVersion < 99 /* ESNext */) {
82268
+ } else if (languageVersion < 99 /* ClassAndClassElementDecorators */) {
82210
82269
  checkExternalEmitHelpers(firstDecorator, 8 /* ESDecorateAndRunInitializers */);
82211
82270
  if (isClassDeclaration(node)) {
82212
82271
  if (!node.name) {
@@ -82911,7 +82970,7 @@ function createTypeChecker(host) {
82911
82970
  potentialUnusedRenamedBindingElementsInTypes.push(node);
82912
82971
  return;
82913
82972
  }
82914
- if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
82973
+ if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ObjectSpreadRest */) {
82915
82974
  checkExternalEmitHelpers(node, 4 /* Rest */);
82916
82975
  }
82917
82976
  if (node.propertyName && node.propertyName.kind === 167 /* ComputedPropertyName */) {
@@ -82947,7 +83006,7 @@ function createTypeChecker(host) {
82947
83006
  }
82948
83007
  }
82949
83008
  if (isBindingPattern(node.name)) {
82950
- if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
83009
+ if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* BindingPatterns */ && compilerOptions.downlevelIteration) {
82951
83010
  checkExternalEmitHelpers(node, 512 /* Read */);
82952
83011
  }
82953
83012
  forEach(node.name.elements, checkSourceElement);
@@ -83098,7 +83157,7 @@ function createTypeChecker(host) {
83098
83157
  }
83099
83158
  function checkVariableDeclarationList(node) {
83100
83159
  const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
83101
- if (blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) {
83160
+ if ((blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) && languageVersion < 99 /* UsingAndAwaitUsing */) {
83102
83161
  checkExternalEmitHelpers(node, 16777216 /* AddDisposableResourceAndDisposeResources */);
83103
83162
  }
83104
83163
  forEach(node.declarations, checkSourceElement);
@@ -83271,11 +83330,11 @@ function createTypeChecker(host) {
83271
83330
  grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block);
83272
83331
  } else {
83273
83332
  const functionFlags = getFunctionFlags(container);
83274
- if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) {
83333
+ if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 5 /* ForAwaitOf */) {
83275
83334
  checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
83276
83335
  }
83277
83336
  }
83278
- } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) {
83337
+ } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ForOf */) {
83279
83338
  checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
83280
83339
  }
83281
83340
  if (node.initializer.kind === 261 /* VariableDeclarationList */) {
@@ -84199,6 +84258,7 @@ function createTypeChecker(host) {
84199
84258
  case "symbol":
84200
84259
  case "void":
84201
84260
  case "object":
84261
+ case "undefined":
84202
84262
  error2(name, message, name.escapedText);
84203
84263
  }
84204
84264
  }
@@ -84338,12 +84398,12 @@ function createTypeChecker(host) {
84338
84398
  return true;
84339
84399
  }
84340
84400
  function getFirstTransformableStaticClassElement(node) {
84341
- const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ESNext */ && classOrConstructorParameterIsDecorated(
84401
+ const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */ && classOrConstructorParameterIsDecorated(
84342
84402
  /*useLegacyDecorators*/
84343
84403
  false,
84344
84404
  node
84345
84405
  );
84346
- const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
84406
+ const willTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */;
84347
84407
  const willTransformInitializers = !emitStandardClassFields;
84348
84408
  if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
84349
84409
  for (const member of node.members) {
@@ -84372,7 +84432,7 @@ function createTypeChecker(host) {
84372
84432
  const parent2 = walkUpOuterExpressions(node);
84373
84433
  if (!isNamedEvaluationSource(parent2))
84374
84434
  return;
84375
- const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ESNext */;
84435
+ const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */;
84376
84436
  let location;
84377
84437
  if (willTransformESDecorators && classOrConstructorParameterIsDecorated(
84378
84438
  /*useLegacyDecorators*/
@@ -84432,7 +84492,7 @@ function createTypeChecker(host) {
84432
84492
  const baseTypeNode = getEffectiveBaseTypeNode(node);
84433
84493
  if (baseTypeNode) {
84434
84494
  forEach(baseTypeNode.typeArguments, checkSourceElement);
84435
- if (languageVersion < 2 /* ES2015 */) {
84495
+ if (languageVersion < 2 /* Classes */) {
84436
84496
  checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
84437
84497
  }
84438
84498
  const extendsNode = getClassExtendsHeritageElement(node);
@@ -87901,7 +87961,7 @@ function createTypeChecker(host) {
87901
87961
  }
87902
87962
  }
87903
87963
  }
87904
- addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
87964
+ addUndefinedToGlobalsOrErrorOnRedeclaration();
87905
87965
  getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
87906
87966
  getSymbolLinks(argumentsSymbol).type = getGlobalType(
87907
87967
  "IArguments",
@@ -91666,12 +91726,12 @@ function getOriginalNodeId(node) {
91666
91726
  function containsDefaultReference(node) {
91667
91727
  if (!node)
91668
91728
  return false;
91669
- if (!isNamedImports(node))
91729
+ if (!isNamedImports(node) && !isNamedExports(node))
91670
91730
  return false;
91671
91731
  return some(node.elements, isNamedDefaultReference);
91672
91732
  }
91673
91733
  function isNamedDefaultReference(e) {
91674
- return e.propertyName !== void 0 && e.propertyName.escapedText === "default" /* Default */;
91734
+ return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
91675
91735
  }
91676
91736
  function chainBundle(context, transformSourceFile) {
91677
91737
  return transformSourceFileOrBundle;
@@ -91745,6 +91805,7 @@ function collectExternalModuleInfo(context, sourceFile) {
91745
91805
  externalImports.push(node);
91746
91806
  if (isNamedExports(node.exportClause)) {
91747
91807
  addExportedNamesForExportDeclaration(node);
91808
+ hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
91748
91809
  } else {
91749
91810
  const name = node.exportClause.name;
91750
91811
  if (!uniqueExports.get(idText(name))) {
@@ -173293,6 +173354,7 @@ __export(ts_exports2, {
173293
173354
  JsxEmit: () => JsxEmit,
173294
173355
  JsxFlags: () => JsxFlags,
173295
173356
  JsxReferenceKind: () => JsxReferenceKind,
173357
+ LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
173296
173358
  LanguageServiceMode: () => LanguageServiceMode,
173297
173359
  LanguageVariant: () => LanguageVariant,
173298
173360
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
@@ -188068,6 +188130,7 @@ start(initializeNodeSystem(), require("os").platform());
188068
188130
  JsxEmit,
188069
188131
  JsxFlags,
188070
188132
  JsxReferenceKind,
188133
+ LanguageFeatureMinimumTarget,
188071
188134
  LanguageServiceMode,
188072
188135
  LanguageVariant,
188073
188136
  LexicalEnvironmentFlags,
package/lib/typescript.js CHANGED
@@ -106,6 +106,7 @@ __export(typescript_exports, {
106
106
  JsxEmit: () => JsxEmit,
107
107
  JsxFlags: () => JsxFlags,
108
108
  JsxReferenceKind: () => JsxReferenceKind,
109
+ LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
109
110
  LanguageServiceMode: () => LanguageServiceMode,
110
111
  LanguageVariant: () => LanguageVariant,
111
112
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
@@ -2325,7 +2326,7 @@ module.exports = __toCommonJS(typescript_exports);
2325
2326
 
2326
2327
  // src/compiler/corePublic.ts
2327
2328
  var versionMajorMinor = "5.5";
2328
- var version = `${versionMajorMinor}.0-dev.20240311`;
2329
+ var version = `${versionMajorMinor}.0-dev.20240312`;
2329
2330
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2330
2331
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2331
2332
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -7233,6 +7234,38 @@ var InternalEmitFlags = /* @__PURE__ */ ((InternalEmitFlags3) => {
7233
7234
  InternalEmitFlags3[InternalEmitFlags3["TransformPrivateStaticElements"] = 32] = "TransformPrivateStaticElements";
7234
7235
  return InternalEmitFlags3;
7235
7236
  })(InternalEmitFlags || {});
7237
+ var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarget2) => {
7238
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Classes"] = 2 /* ES2015 */] = "Classes";
7239
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForOf"] = 2 /* ES2015 */] = "ForOf";
7240
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Generators"] = 2 /* ES2015 */] = "Generators";
7241
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Iteration"] = 2 /* ES2015 */] = "Iteration";
7242
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["SpreadElements"] = 2 /* ES2015 */] = "SpreadElements";
7243
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RestElements"] = 2 /* ES2015 */] = "RestElements";
7244
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TaggedTemplates"] = 2 /* ES2015 */] = "TaggedTemplates";
7245
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["DestructuringAssignment"] = 2 /* ES2015 */] = "DestructuringAssignment";
7246
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindingPatterns"] = 2 /* ES2015 */] = "BindingPatterns";
7247
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ArrowFunctions"] = 2 /* ES2015 */] = "ArrowFunctions";
7248
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BlockScopedVariables"] = 2 /* ES2015 */] = "BlockScopedVariables";
7249
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectAssign"] = 2 /* ES2015 */] = "ObjectAssign";
7250
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Exponentiation"] = 3 /* ES2016 */] = "Exponentiation";
7251
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncFunctions"] = 4 /* ES2017 */] = "AsyncFunctions";
7252
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForAwaitOf"] = 5 /* ES2018 */] = "ForAwaitOf";
7253
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncGenerators"] = 5 /* ES2018 */] = "AsyncGenerators";
7254
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncIteration"] = 5 /* ES2018 */] = "AsyncIteration";
7255
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectSpreadRest"] = 5 /* ES2018 */] = "ObjectSpreadRest";
7256
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindinglessCatch"] = 6 /* ES2019 */] = "BindinglessCatch";
7257
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BigInt"] = 7 /* ES2020 */] = "BigInt";
7258
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["NullishCoalesce"] = 7 /* ES2020 */] = "NullishCoalesce";
7259
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["OptionalChaining"] = 7 /* ES2020 */] = "OptionalChaining";
7260
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["LogicalAssignment"] = 8 /* ES2021 */] = "LogicalAssignment";
7261
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TopLevelAwait"] = 9 /* ES2022 */] = "TopLevelAwait";
7262
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassFields"] = 9 /* ES2022 */] = "ClassFields";
7263
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["PrivateNamesAndClassStaticBlocks"] = 9 /* ES2022 */] = "PrivateNamesAndClassStaticBlocks";
7264
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ShebangComments"] = 99 /* ESNext */] = "ShebangComments";
7265
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["UsingAndAwaitUsing"] = 99 /* ESNext */] = "UsingAndAwaitUsing";
7266
+ LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassAndClassElementDecorators"] = 99 /* ESNext */] = "ClassAndClassElementDecorators";
7267
+ return LanguageFeatureMinimumTarget2;
7268
+ })(LanguageFeatureMinimumTarget || {});
7236
7269
  var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
7237
7270
  ExternalEmitHelpers2[ExternalEmitHelpers2["Extends"] = 1] = "Extends";
7238
7271
  ExternalEmitHelpers2[ExternalEmitHelpers2["Assign"] = 2] = "Assign";
@@ -48898,8 +48931,6 @@ function createTypeChecker(host) {
48898
48931
  var comparableRelation = /* @__PURE__ */ new Map();
48899
48932
  var identityRelation = /* @__PURE__ */ new Map();
48900
48933
  var enumRelation = /* @__PURE__ */ new Map();
48901
- var builtinGlobals = createSymbolTable();
48902
- builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
48903
48934
  var suggestedExtensions = [
48904
48935
  [".mts", ".mjs"],
48905
48936
  [".ts", ".js"],
@@ -49317,17 +49348,17 @@ function createTypeChecker(host) {
49317
49348
  }
49318
49349
  }
49319
49350
  }
49320
- function addToSymbolTable(target, source, message) {
49321
- source.forEach((sourceSymbol, id) => {
49322
- const targetSymbol = target.get(id);
49323
- if (targetSymbol) {
49324
- forEach(targetSymbol.declarations, addDeclarationDiagnostic(unescapeLeadingUnderscores(id), message));
49325
- } else {
49326
- target.set(id, sourceSymbol);
49327
- }
49328
- });
49329
- function addDeclarationDiagnostic(id, message2) {
49330
- return (declaration) => diagnostics.add(createDiagnosticForNode(declaration, message2, id));
49351
+ function addUndefinedToGlobalsOrErrorOnRedeclaration() {
49352
+ const name = undefinedSymbol.escapedName;
49353
+ const targetSymbol = globals.get(name);
49354
+ if (targetSymbol) {
49355
+ forEach(targetSymbol.declarations, (declaration) => {
49356
+ if (!isTypeDeclaration(declaration)) {
49357
+ diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, unescapeLeadingUnderscores(name)));
49358
+ }
49359
+ });
49360
+ } else {
49361
+ globals.set(name, undefinedSymbol);
49331
49362
  }
49332
49363
  }
49333
49364
  function getSymbolLinks(symbol) {
@@ -49397,7 +49428,14 @@ function createTypeChecker(host) {
49397
49428
  } else if (declaration.kind === 260 /* VariableDeclaration */) {
49398
49429
  return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
49399
49430
  } else if (isClassLike(declaration)) {
49400
- return !findAncestor(usage, (n) => isComputedPropertyName(n) && n.parent.parent === declaration);
49431
+ const container = findAncestor(usage, (n) => n === declaration ? "quit" : isComputedPropertyName(n) ? n.parent.parent === declaration : isDecorator(n) && (n.parent === declaration || isMethodDeclaration(n.parent) && n.parent.parent === declaration || isGetOrSetAccessorDeclaration(n.parent) && n.parent.parent === declaration || isPropertyDeclaration(n.parent) && n.parent.parent === declaration || isParameter(n.parent) && n.parent.parent.parent === declaration));
49432
+ if (!container) {
49433
+ return true;
49434
+ }
49435
+ if (isDecorator(container)) {
49436
+ return !!findAncestor(usage, (n) => n === container ? "quit" : isFunctionLike(n) && !getImmediatelyInvokedFunctionExpression(n));
49437
+ }
49438
+ return false;
49401
49439
  } else if (isPropertyDeclaration(declaration)) {
49402
49440
  return !isPropertyImmediatelyReferencedWithinDeclaration(
49403
49441
  declaration,
@@ -65291,7 +65329,7 @@ function createTypeChecker(host) {
65291
65329
  if (reduced !== type) {
65292
65330
  return reduced;
65293
65331
  }
65294
- if (type.flags & 2097152 /* Intersection */ && some(type.types, isEmptyAnonymousObjectType)) {
65332
+ if (type.flags & 2097152 /* Intersection */ && shouldNormalizeIntersection(type)) {
65295
65333
  const normalizedTypes = sameMap(type.types, (t) => getNormalizedType(t, writing));
65296
65334
  if (normalizedTypes !== type.types) {
65297
65335
  return getIntersectionType(normalizedTypes);
@@ -65299,6 +65337,17 @@ function createTypeChecker(host) {
65299
65337
  }
65300
65338
  return type;
65301
65339
  }
65340
+ function shouldNormalizeIntersection(type) {
65341
+ let hasInstantiable = false;
65342
+ let hasNullableOrEmpty = false;
65343
+ for (const t of type.types) {
65344
+ hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
65345
+ hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
65346
+ if (hasInstantiable && hasNullableOrEmpty)
65347
+ return true;
65348
+ }
65349
+ return false;
65350
+ }
65302
65351
  function getNormalizedTupleType(type, writing) {
65303
65352
  const elements = getElementTypes(type);
65304
65353
  const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
@@ -70149,9 +70198,9 @@ function createTypeChecker(host) {
70149
70198
  if (strictNullChecks) {
70150
70199
  switch (facts) {
70151
70200
  case 524288 /* NEUndefined */:
70152
- return mapType(reduced, (t) => hasTypeFacts(t, 65536 /* EQUndefined */) ? getIntersectionType([t, hasTypeFacts(t, 131072 /* EQNull */) && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t);
70201
+ return removeNullableByIntersection(reduced, 65536 /* EQUndefined */, 131072 /* EQNull */, 33554432 /* IsNull */, nullType);
70153
70202
  case 1048576 /* NENull */:
70154
- return mapType(reduced, (t) => hasTypeFacts(t, 131072 /* EQNull */) ? getIntersectionType([t, hasTypeFacts(t, 65536 /* EQUndefined */) && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t);
70203
+ return removeNullableByIntersection(reduced, 131072 /* EQNull */, 65536 /* EQUndefined */, 16777216 /* IsUndefined */, undefinedType);
70155
70204
  case 2097152 /* NEUndefinedOrNull */:
70156
70205
  case 4194304 /* Truthy */:
70157
70206
  return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
@@ -70159,6 +70208,14 @@ function createTypeChecker(host) {
70159
70208
  }
70160
70209
  return reduced;
70161
70210
  }
70211
+ function removeNullableByIntersection(type, targetFacts, otherFacts, otherIncludesFacts, otherType) {
70212
+ const facts = getTypeFacts(type, 65536 /* EQUndefined */ | 131072 /* EQNull */ | 16777216 /* IsUndefined */ | 33554432 /* IsNull */);
70213
+ if (!(facts & targetFacts)) {
70214
+ return type;
70215
+ }
70216
+ const emptyAndOtherUnion = getUnionType([emptyObjectType, otherType]);
70217
+ return mapType(type, (t) => hasTypeFacts(t, targetFacts) ? getIntersectionType([t, !(facts & otherIncludesFacts) && hasTypeFacts(t, otherFacts) ? emptyAndOtherUnion : emptyObjectType]) : t);
70218
+ }
70162
70219
  function recombineUnknownType(type) {
70163
70220
  return type === unknownUnionType ? unknownType : type;
70164
70221
  }
@@ -73726,7 +73783,7 @@ function createTypeChecker(host) {
73726
73783
  }
73727
73784
  }
73728
73785
  function checkSpreadExpression(node, checkMode) {
73729
- if (languageVersion < 2 /* ES2015 */) {
73786
+ if (languageVersion < 2 /* SpreadElements */) {
73730
73787
  checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
73731
73788
  }
73732
73789
  const arrayOrIterableType = checkExpression(node.expression, checkMode);
@@ -73760,7 +73817,7 @@ function createTypeChecker(host) {
73760
73817
  for (let i = 0; i < elementCount; i++) {
73761
73818
  const e = elements[i];
73762
73819
  if (e.kind === 230 /* SpreadElement */) {
73763
- if (languageVersion < 2 /* ES2015 */) {
73820
+ if (languageVersion < 2 /* SpreadElements */) {
73764
73821
  checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
73765
73822
  }
73766
73823
  const spreadType = checkExpression(e.expression, checkMode, forceTuple);
@@ -73990,7 +74047,7 @@ function createTypeChecker(host) {
73990
74047
  addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
73991
74048
  }
73992
74049
  } else if (memberDecl.kind === 305 /* SpreadAssignment */) {
73993
- if (languageVersion < 2 /* ES2015 */) {
74050
+ if (languageVersion < 2 /* ObjectAssign */) {
73994
74051
  checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
73995
74052
  }
73996
74053
  if (propertiesArray.length > 0) {
@@ -75015,7 +75072,7 @@ function createTypeChecker(host) {
75015
75072
  const isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
75016
75073
  let prop;
75017
75074
  if (isPrivateIdentifier(right)) {
75018
- if (languageVersion < 99 /* ESNext */) {
75075
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
75019
75076
  if (assignmentKind !== 0 /* None */) {
75020
75077
  checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
75021
75078
  }
@@ -77628,7 +77685,7 @@ function createTypeChecker(host) {
77628
77685
  function checkTaggedTemplateExpression(node) {
77629
77686
  if (!checkGrammarTaggedTemplateChain(node))
77630
77687
  checkGrammarTypeArguments(node, node.typeArguments);
77631
- if (languageVersion < 2 /* ES2015 */) {
77688
+ if (languageVersion < 2 /* TaggedTemplates */) {
77632
77689
  checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
77633
77690
  }
77634
77691
  const signature = getResolvedSignature(node);
@@ -79275,7 +79332,7 @@ function createTypeChecker(host) {
79275
79332
  return silentNeverType;
79276
79333
  }
79277
79334
  if (isPrivateIdentifier(left)) {
79278
- if (languageVersion < 99 /* ESNext */) {
79335
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
79279
79336
  checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
79280
79337
  }
79281
79338
  if (!getNodeLinks(left).resolvedSymbol && getContainingClass(left)) {
@@ -79336,7 +79393,7 @@ function createTypeChecker(host) {
79336
79393
  if (propertyIndex < properties.length - 1) {
79337
79394
  error2(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
79338
79395
  } else {
79339
- if (languageVersion < 99 /* ESNext */) {
79396
+ if (languageVersion < 5 /* ObjectSpreadRest */) {
79340
79397
  checkExternalEmitHelpers(property, 4 /* Rest */);
79341
79398
  }
79342
79399
  const nonRestNames = [];
@@ -79357,7 +79414,7 @@ function createTypeChecker(host) {
79357
79414
  }
79358
79415
  function checkArrayLiteralAssignment(node, sourceType, checkMode) {
79359
79416
  const elements = node.elements;
79360
- if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
79417
+ if (languageVersion < 2 /* DestructuringAssignment */ && compilerOptions.downlevelIteration) {
79361
79418
  checkExternalEmitHelpers(node, 512 /* Read */);
79362
79419
  }
79363
79420
  const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
@@ -80059,10 +80116,10 @@ function createTypeChecker(host) {
80059
80116
  }
80060
80117
  const isAsync = (functionFlags & 2 /* Async */) !== 0;
80061
80118
  if (node.asteriskToken) {
80062
- if (isAsync && languageVersion < 99 /* ESNext */) {
80119
+ if (isAsync && languageVersion < 5 /* AsyncGenerators */) {
80063
80120
  checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
80064
80121
  }
80065
- if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
80122
+ if (!isAsync && languageVersion < 2 /* Generators */ && compilerOptions.downlevelIteration) {
80066
80123
  checkExternalEmitHelpers(node, 256 /* Values */);
80067
80124
  }
80068
80125
  }
@@ -80834,13 +80891,13 @@ function createTypeChecker(host) {
80834
80891
  }
80835
80892
  const functionFlags = getFunctionFlags(node);
80836
80893
  if (!(functionFlags & 4 /* Invalid */)) {
80837
- if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) {
80894
+ if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 5 /* AsyncGenerators */) {
80838
80895
  checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
80839
80896
  }
80840
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) {
80897
+ if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* AsyncFunctions */) {
80841
80898
  checkExternalEmitHelpers(node, 64 /* Awaiter */);
80842
80899
  }
80843
- if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) {
80900
+ if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* Generators */) {
80844
80901
  checkExternalEmitHelpers(node, 128 /* Generator */);
80845
80902
  }
80846
80903
  }
@@ -81073,15 +81130,17 @@ function createTypeChecker(host) {
81073
81130
  setNodeLinksForPrivateIdentifierScope(node);
81074
81131
  }
81075
81132
  function setNodeLinksForPrivateIdentifierScope(node) {
81076
- if (isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) {
81077
- for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
81078
- getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
81079
- }
81080
- if (isClassExpression(node.parent)) {
81081
- const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
81082
- if (enclosingIterationStatement) {
81083
- getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
81084
- getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
81133
+ if (isPrivateIdentifier(node.name)) {
81134
+ if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
81135
+ for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
81136
+ getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
81137
+ }
81138
+ if (isClassExpression(node.parent)) {
81139
+ const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
81140
+ if (enclosingIterationStatement) {
81141
+ getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
81142
+ getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
81143
+ }
81085
81144
  }
81086
81145
  }
81087
81146
  }
@@ -82206,7 +82265,7 @@ function createTypeChecker(host) {
82206
82265
  if (node.kind === 169 /* Parameter */) {
82207
82266
  checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
82208
82267
  }
82209
- } else if (languageVersion < 99 /* ESNext */) {
82268
+ } else if (languageVersion < 99 /* ClassAndClassElementDecorators */) {
82210
82269
  checkExternalEmitHelpers(firstDecorator, 8 /* ESDecorateAndRunInitializers */);
82211
82270
  if (isClassDeclaration(node)) {
82212
82271
  if (!node.name) {
@@ -82911,7 +82970,7 @@ function createTypeChecker(host) {
82911
82970
  potentialUnusedRenamedBindingElementsInTypes.push(node);
82912
82971
  return;
82913
82972
  }
82914
- if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
82973
+ if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ObjectSpreadRest */) {
82915
82974
  checkExternalEmitHelpers(node, 4 /* Rest */);
82916
82975
  }
82917
82976
  if (node.propertyName && node.propertyName.kind === 167 /* ComputedPropertyName */) {
@@ -82947,7 +83006,7 @@ function createTypeChecker(host) {
82947
83006
  }
82948
83007
  }
82949
83008
  if (isBindingPattern(node.name)) {
82950
- if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) {
83009
+ if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* BindingPatterns */ && compilerOptions.downlevelIteration) {
82951
83010
  checkExternalEmitHelpers(node, 512 /* Read */);
82952
83011
  }
82953
83012
  forEach(node.name.elements, checkSourceElement);
@@ -83098,7 +83157,7 @@ function createTypeChecker(host) {
83098
83157
  }
83099
83158
  function checkVariableDeclarationList(node) {
83100
83159
  const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
83101
- if (blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) {
83160
+ if ((blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) && languageVersion < 99 /* UsingAndAwaitUsing */) {
83102
83161
  checkExternalEmitHelpers(node, 16777216 /* AddDisposableResourceAndDisposeResources */);
83103
83162
  }
83104
83163
  forEach(node.declarations, checkSourceElement);
@@ -83271,11 +83330,11 @@ function createTypeChecker(host) {
83271
83330
  grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block);
83272
83331
  } else {
83273
83332
  const functionFlags = getFunctionFlags(container);
83274
- if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) {
83333
+ if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 5 /* ForAwaitOf */) {
83275
83334
  checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
83276
83335
  }
83277
83336
  }
83278
- } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) {
83337
+ } else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ForOf */) {
83279
83338
  checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
83280
83339
  }
83281
83340
  if (node.initializer.kind === 261 /* VariableDeclarationList */) {
@@ -84199,6 +84258,7 @@ function createTypeChecker(host) {
84199
84258
  case "symbol":
84200
84259
  case "void":
84201
84260
  case "object":
84261
+ case "undefined":
84202
84262
  error2(name, message, name.escapedText);
84203
84263
  }
84204
84264
  }
@@ -84338,12 +84398,12 @@ function createTypeChecker(host) {
84338
84398
  return true;
84339
84399
  }
84340
84400
  function getFirstTransformableStaticClassElement(node) {
84341
- const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ESNext */ && classOrConstructorParameterIsDecorated(
84401
+ const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */ && classOrConstructorParameterIsDecorated(
84342
84402
  /*useLegacyDecorators*/
84343
84403
  false,
84344
84404
  node
84345
84405
  );
84346
- const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
84406
+ const willTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */;
84347
84407
  const willTransformInitializers = !emitStandardClassFields;
84348
84408
  if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
84349
84409
  for (const member of node.members) {
@@ -84372,7 +84432,7 @@ function createTypeChecker(host) {
84372
84432
  const parent2 = walkUpOuterExpressions(node);
84373
84433
  if (!isNamedEvaluationSource(parent2))
84374
84434
  return;
84375
- const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ESNext */;
84435
+ const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */;
84376
84436
  let location;
84377
84437
  if (willTransformESDecorators && classOrConstructorParameterIsDecorated(
84378
84438
  /*useLegacyDecorators*/
@@ -84432,7 +84492,7 @@ function createTypeChecker(host) {
84432
84492
  const baseTypeNode = getEffectiveBaseTypeNode(node);
84433
84493
  if (baseTypeNode) {
84434
84494
  forEach(baseTypeNode.typeArguments, checkSourceElement);
84435
- if (languageVersion < 2 /* ES2015 */) {
84495
+ if (languageVersion < 2 /* Classes */) {
84436
84496
  checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
84437
84497
  }
84438
84498
  const extendsNode = getClassExtendsHeritageElement(node);
@@ -87901,7 +87961,7 @@ function createTypeChecker(host) {
87901
87961
  }
87902
87962
  }
87903
87963
  }
87904
- addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
87964
+ addUndefinedToGlobalsOrErrorOnRedeclaration();
87905
87965
  getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
87906
87966
  getSymbolLinks(argumentsSymbol).type = getGlobalType(
87907
87967
  "IArguments",
@@ -91666,12 +91726,12 @@ function getOriginalNodeId(node) {
91666
91726
  function containsDefaultReference(node) {
91667
91727
  if (!node)
91668
91728
  return false;
91669
- if (!isNamedImports(node))
91729
+ if (!isNamedImports(node) && !isNamedExports(node))
91670
91730
  return false;
91671
91731
  return some(node.elements, isNamedDefaultReference);
91672
91732
  }
91673
91733
  function isNamedDefaultReference(e) {
91674
- return e.propertyName !== void 0 && e.propertyName.escapedText === "default" /* Default */;
91734
+ return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
91675
91735
  }
91676
91736
  function chainBundle(context, transformSourceFile) {
91677
91737
  return transformSourceFileOrBundle;
@@ -91745,6 +91805,7 @@ function collectExternalModuleInfo(context, sourceFile) {
91745
91805
  externalImports.push(node);
91746
91806
  if (isNamedExports(node.exportClause)) {
91747
91807
  addExportedNamesForExportDeclaration(node);
91808
+ hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
91748
91809
  } else {
91749
91810
  const name = node.exportClause.name;
91750
91811
  if (!uniqueExports.get(idText(name))) {
@@ -173293,6 +173354,7 @@ __export(ts_exports2, {
173293
173354
  JsxEmit: () => JsxEmit,
173294
173355
  JsxFlags: () => JsxFlags,
173295
173356
  JsxReferenceKind: () => JsxReferenceKind,
173357
+ LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
173296
173358
  LanguageServiceMode: () => LanguageServiceMode,
173297
173359
  LanguageVariant: () => LanguageVariant,
173298
173360
  LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
@@ -187493,6 +187555,7 @@ if (typeof console !== "undefined") {
187493
187555
  JsxEmit,
187494
187556
  JsxFlags,
187495
187557
  JsxReferenceKind,
187558
+ LanguageFeatureMinimumTarget,
187496
187559
  LanguageServiceMode,
187497
187560
  LanguageVariant,
187498
187561
  LexicalEnvironmentFlags,
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.5";
57
- var version = `${versionMajorMinor}.0-dev.20240311`;
57
+ var version = `${versionMajorMinor}.0-dev.20240312`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
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.20240311",
5
+ "version": "5.5.0-dev.20240312",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -112,5 +112,5 @@
112
112
  "node": "20.1.0",
113
113
  "npm": "8.19.4"
114
114
  },
115
- "gitHead": "3fca8c842a42bb43ba5a86dcce1b7fb0eae6c7a4"
115
+ "gitHead": "9bdfa441c687316b51c8f4329fc6c0535a8f1bca"
116
116
  }