typescript 5.4.0-dev.20231106 → 5.4.0-dev.20231107

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.4";
21
- var version = `${versionMajorMinor}.0-dev.20231106`;
21
+ var version = `${versionMajorMinor}.0-dev.20231107`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -47697,7 +47697,7 @@ function createTypeChecker(host) {
47697
47697
  return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
47698
47698
  }
47699
47699
  function toNodeBuilderFlags(flags = 0 /* None */) {
47700
- return flags & 848330091 /* NodeBuilderFlagsMask */;
47700
+ return flags & 848330095 /* NodeBuilderFlagsMask */;
47701
47701
  }
47702
47702
  function isClassInstanceSide(type) {
47703
47703
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
@@ -47946,7 +47946,7 @@ function createTypeChecker(host) {
47946
47946
  }
47947
47947
  return factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
47948
47948
  }
47949
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
47949
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */) {
47950
47950
  const name2 = typeParameterToName(type, context);
47951
47951
  context.approximateLength += idText(name2).length;
47952
47952
  return factory.createTypeReferenceNode(
@@ -48746,36 +48746,65 @@ function createTypeChecker(host) {
48746
48746
  true
48747
48747
  )[0];
48748
48748
  let cleanup;
48749
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && some(expandedParams)) {
48750
- const existingFakeScope = getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration ? context.enclosingDeclaration : void 0;
48751
- Debug.assertOptionalNode(existingFakeScope, isBlock);
48752
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
48753
- let newLocals;
48754
- for (const param of expandedParams) {
48755
- if (!locals.has(param.escapedName)) {
48756
- newLocals = append(newLocals, param.escapedName);
48757
- locals.set(param.escapedName, param);
48758
- }
48759
- }
48760
- if (newLocals) {
48761
- let removeNewLocals2 = function() {
48749
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
48750
+ let pushFakeScope2 = function(kind2, addAll) {
48751
+ Debug.assert(context.enclosingDeclaration);
48752
+ let existingFakeScope;
48753
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
48754
+ existingFakeScope = context.enclosingDeclaration;
48755
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
48756
+ existingFakeScope = context.enclosingDeclaration.parent;
48757
+ }
48758
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
48759
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
48760
+ let newLocals;
48761
+ addAll((name, symbol) => {
48762
+ if (!locals.has(name)) {
48763
+ newLocals = append(newLocals, name);
48764
+ locals.set(name, symbol);
48765
+ }
48766
+ });
48767
+ if (!newLocals)
48768
+ return;
48769
+ const oldCleanup = cleanup;
48770
+ function undo() {
48762
48771
  forEach(newLocals, (s) => locals.delete(s));
48763
- };
48764
- var removeNewLocals = removeNewLocals2;
48772
+ oldCleanup == null ? void 0 : oldCleanup();
48773
+ }
48765
48774
  if (existingFakeScope) {
48766
- cleanup = removeNewLocals2;
48775
+ cleanup = undo;
48767
48776
  } else {
48768
48777
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
48769
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
48778
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
48770
48779
  fakeScope.locals = locals;
48771
48780
  const saveEnclosingDeclaration = context.enclosingDeclaration;
48772
48781
  setParent(fakeScope, saveEnclosingDeclaration);
48773
48782
  context.enclosingDeclaration = fakeScope;
48774
48783
  cleanup = () => {
48775
48784
  context.enclosingDeclaration = saveEnclosingDeclaration;
48776
- removeNewLocals2();
48785
+ undo();
48777
48786
  };
48778
48787
  }
48788
+ };
48789
+ var pushFakeScope = pushFakeScope2;
48790
+ pushFakeScope2(
48791
+ "params",
48792
+ (add) => {
48793
+ for (const param of expandedParams) {
48794
+ add(param.escapedName, param);
48795
+ }
48796
+ }
48797
+ );
48798
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
48799
+ pushFakeScope2(
48800
+ "typeParams",
48801
+ (add) => {
48802
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
48803
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
48804
+ add(typeParamName, typeParam.symbol);
48805
+ }
48806
+ }
48807
+ );
48779
48808
  }
48780
48809
  }
48781
48810
  const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports));
@@ -49320,7 +49349,7 @@ function createTypeChecker(host) {
49320
49349
  return identifier;
49321
49350
  }
49322
49351
  }
49323
- function typeParameterShadowsNameInScope(escapedName, context, type) {
49352
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
49324
49353
  const result = resolveName(
49325
49354
  context.enclosingDeclaration,
49326
49355
  escapedName,
@@ -49331,11 +49360,8 @@ function createTypeChecker(host) {
49331
49360
  /*isUse*/
49332
49361
  false
49333
49362
  );
49334
- if (result) {
49335
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
49336
- return false;
49337
- }
49338
- return true;
49363
+ if (result && result.flags & 262144 /* TypeParameter */) {
49364
+ return result !== type.symbol;
49339
49365
  }
49340
49366
  return false;
49341
49367
  }
@@ -49361,7 +49387,7 @@ function createTypeChecker(host) {
49361
49387
  const rawtext = result.escapedText;
49362
49388
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
49363
49389
  let text = rawtext;
49364
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
49390
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
49365
49391
  i++;
49366
49392
  text = `${rawtext}_${i}`;
49367
49393
  }
@@ -49372,7 +49398,7 @@ function createTypeChecker(host) {
49372
49398
  }
49373
49399
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
49374
49400
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
49375
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
49401
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
49376
49402
  }
49377
49403
  return result;
49378
49404
  }
@@ -49517,7 +49543,10 @@ function createTypeChecker(host) {
49517
49543
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
49518
49544
  }
49519
49545
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
49520
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
49546
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
49547
+ enclosingDeclaration = enclosingDeclaration.parent;
49548
+ }
49549
+ return enclosingDeclaration;
49521
49550
  }
49522
49551
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
49523
49552
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -49597,7 +49626,7 @@ function createTypeChecker(host) {
49597
49626
  }
49598
49627
  if (isIdentifier(node)) {
49599
49628
  const type = getDeclaredTypeOfSymbol(sym);
49600
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
49629
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
49601
49630
  name.symbol = sym;
49602
49631
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
49603
49632
  }
@@ -66528,6 +66557,9 @@ function createTypeChecker(host) {
66528
66557
  }
66529
66558
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
66530
66559
  if (!assumeTrue) {
66560
+ if (type === candidate) {
66561
+ return neverType;
66562
+ }
66531
66563
  if (checkDerived) {
66532
66564
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
66533
66565
  }
@@ -66544,6 +66576,9 @@ function createTypeChecker(host) {
66544
66576
  if (type.flags & 3 /* AnyOrUnknown */) {
66545
66577
  return candidate;
66546
66578
  }
66579
+ if (type === candidate) {
66580
+ return candidate;
66581
+ }
66547
66582
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
66548
66583
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
66549
66584
  const narrowedType = mapType(candidate, (c) => {
package/lib/tsserver.js CHANGED
@@ -2330,7 +2330,7 @@ module.exports = __toCommonJS(server_exports);
2330
2330
 
2331
2331
  // src/compiler/corePublic.ts
2332
2332
  var versionMajorMinor = "5.4";
2333
- var version = `${versionMajorMinor}.0-dev.20231106`;
2333
+ var version = `${versionMajorMinor}.0-dev.20231107`;
2334
2334
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2335
2335
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2336
2336
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6402,6 +6402,7 @@ var TypeFormatFlags = /* @__PURE__ */ ((TypeFormatFlags2) => {
6402
6402
  TypeFormatFlags2[TypeFormatFlags2["None"] = 0] = "None";
6403
6403
  TypeFormatFlags2[TypeFormatFlags2["NoTruncation"] = 1] = "NoTruncation";
6404
6404
  TypeFormatFlags2[TypeFormatFlags2["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
6405
+ TypeFormatFlags2[TypeFormatFlags2["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
6405
6406
  TypeFormatFlags2[TypeFormatFlags2["UseStructuralFallback"] = 8] = "UseStructuralFallback";
6406
6407
  TypeFormatFlags2[TypeFormatFlags2["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
6407
6408
  TypeFormatFlags2[TypeFormatFlags2["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
@@ -6421,7 +6422,7 @@ var TypeFormatFlags = /* @__PURE__ */ ((TypeFormatFlags2) => {
6421
6422
  TypeFormatFlags2[TypeFormatFlags2["InElementType"] = 2097152] = "InElementType";
6422
6423
  TypeFormatFlags2[TypeFormatFlags2["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
6423
6424
  TypeFormatFlags2[TypeFormatFlags2["InTypeAlias"] = 8388608] = "InTypeAlias";
6424
- TypeFormatFlags2[TypeFormatFlags2["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
6425
+ TypeFormatFlags2[TypeFormatFlags2["NodeBuilderFlagsMask"] = 848330095] = "NodeBuilderFlagsMask";
6425
6426
  return TypeFormatFlags2;
6426
6427
  })(TypeFormatFlags || {});
6427
6428
  var SymbolFormatFlags = /* @__PURE__ */ ((SymbolFormatFlags2) => {
@@ -52403,7 +52404,7 @@ function createTypeChecker(host) {
52403
52404
  return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
52404
52405
  }
52405
52406
  function toNodeBuilderFlags(flags = 0 /* None */) {
52406
- return flags & 848330091 /* NodeBuilderFlagsMask */;
52407
+ return flags & 848330095 /* NodeBuilderFlagsMask */;
52407
52408
  }
52408
52409
  function isClassInstanceSide(type) {
52409
52410
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
@@ -52652,7 +52653,7 @@ function createTypeChecker(host) {
52652
52653
  }
52653
52654
  return factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
52654
52655
  }
52655
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
52656
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */) {
52656
52657
  const name2 = typeParameterToName(type, context);
52657
52658
  context.approximateLength += idText(name2).length;
52658
52659
  return factory.createTypeReferenceNode(
@@ -53452,36 +53453,65 @@ function createTypeChecker(host) {
53452
53453
  true
53453
53454
  )[0];
53454
53455
  let cleanup;
53455
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && some(expandedParams)) {
53456
- const existingFakeScope = getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration ? context.enclosingDeclaration : void 0;
53457
- Debug.assertOptionalNode(existingFakeScope, isBlock);
53458
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53459
- let newLocals;
53460
- for (const param of expandedParams) {
53461
- if (!locals.has(param.escapedName)) {
53462
- newLocals = append(newLocals, param.escapedName);
53463
- locals.set(param.escapedName, param);
53464
- }
53465
- }
53466
- if (newLocals) {
53467
- let removeNewLocals2 = function() {
53456
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
53457
+ let pushFakeScope2 = function(kind2, addAll) {
53458
+ Debug.assert(context.enclosingDeclaration);
53459
+ let existingFakeScope;
53460
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
53461
+ existingFakeScope = context.enclosingDeclaration;
53462
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
53463
+ existingFakeScope = context.enclosingDeclaration.parent;
53464
+ }
53465
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
53466
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53467
+ let newLocals;
53468
+ addAll((name, symbol) => {
53469
+ if (!locals.has(name)) {
53470
+ newLocals = append(newLocals, name);
53471
+ locals.set(name, symbol);
53472
+ }
53473
+ });
53474
+ if (!newLocals)
53475
+ return;
53476
+ const oldCleanup = cleanup;
53477
+ function undo() {
53468
53478
  forEach(newLocals, (s) => locals.delete(s));
53469
- };
53470
- var removeNewLocals = removeNewLocals2;
53479
+ oldCleanup == null ? void 0 : oldCleanup();
53480
+ }
53471
53481
  if (existingFakeScope) {
53472
- cleanup = removeNewLocals2;
53482
+ cleanup = undo;
53473
53483
  } else {
53474
53484
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
53475
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
53485
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
53476
53486
  fakeScope.locals = locals;
53477
53487
  const saveEnclosingDeclaration = context.enclosingDeclaration;
53478
53488
  setParent(fakeScope, saveEnclosingDeclaration);
53479
53489
  context.enclosingDeclaration = fakeScope;
53480
53490
  cleanup = () => {
53481
53491
  context.enclosingDeclaration = saveEnclosingDeclaration;
53482
- removeNewLocals2();
53492
+ undo();
53483
53493
  };
53484
53494
  }
53495
+ };
53496
+ var pushFakeScope = pushFakeScope2;
53497
+ pushFakeScope2(
53498
+ "params",
53499
+ (add) => {
53500
+ for (const param of expandedParams) {
53501
+ add(param.escapedName, param);
53502
+ }
53503
+ }
53504
+ );
53505
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53506
+ pushFakeScope2(
53507
+ "typeParams",
53508
+ (add) => {
53509
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
53510
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
53511
+ add(typeParamName, typeParam.symbol);
53512
+ }
53513
+ }
53514
+ );
53485
53515
  }
53486
53516
  }
53487
53517
  const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports));
@@ -54026,7 +54056,7 @@ function createTypeChecker(host) {
54026
54056
  return identifier;
54027
54057
  }
54028
54058
  }
54029
- function typeParameterShadowsNameInScope(escapedName, context, type) {
54059
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
54030
54060
  const result = resolveName(
54031
54061
  context.enclosingDeclaration,
54032
54062
  escapedName,
@@ -54037,11 +54067,8 @@ function createTypeChecker(host) {
54037
54067
  /*isUse*/
54038
54068
  false
54039
54069
  );
54040
- if (result) {
54041
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
54042
- return false;
54043
- }
54044
- return true;
54070
+ if (result && result.flags & 262144 /* TypeParameter */) {
54071
+ return result !== type.symbol;
54045
54072
  }
54046
54073
  return false;
54047
54074
  }
@@ -54067,7 +54094,7 @@ function createTypeChecker(host) {
54067
54094
  const rawtext = result.escapedText;
54068
54095
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
54069
54096
  let text = rawtext;
54070
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
54097
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
54071
54098
  i++;
54072
54099
  text = `${rawtext}_${i}`;
54073
54100
  }
@@ -54078,7 +54105,7 @@ function createTypeChecker(host) {
54078
54105
  }
54079
54106
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
54080
54107
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
54081
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
54108
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
54082
54109
  }
54083
54110
  return result;
54084
54111
  }
@@ -54223,7 +54250,10 @@ function createTypeChecker(host) {
54223
54250
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54224
54251
  }
54225
54252
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
54226
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
54253
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
54254
+ enclosingDeclaration = enclosingDeclaration.parent;
54255
+ }
54256
+ return enclosingDeclaration;
54227
54257
  }
54228
54258
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
54229
54259
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -54303,7 +54333,7 @@ function createTypeChecker(host) {
54303
54333
  }
54304
54334
  if (isIdentifier(node)) {
54305
54335
  const type = getDeclaredTypeOfSymbol(sym);
54306
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
54336
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
54307
54337
  name.symbol = sym;
54308
54338
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
54309
54339
  }
@@ -71234,6 +71264,9 @@ function createTypeChecker(host) {
71234
71264
  }
71235
71265
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
71236
71266
  if (!assumeTrue) {
71267
+ if (type === candidate) {
71268
+ return neverType;
71269
+ }
71237
71270
  if (checkDerived) {
71238
71271
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
71239
71272
  }
@@ -71250,6 +71283,9 @@ function createTypeChecker(host) {
71250
71283
  if (type.flags & 3 /* AnyOrUnknown */) {
71251
71284
  return candidate;
71252
71285
  }
71286
+ if (type === candidate) {
71287
+ return candidate;
71288
+ }
71253
71289
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
71254
71290
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
71255
71291
  const narrowedType = mapType(candidate, (c) => {
@@ -6887,6 +6887,7 @@ declare namespace ts {
6887
6887
  None = 0,
6888
6888
  NoTruncation = 1,
6889
6889
  WriteArrayAsGenericType = 2,
6890
+ GenerateNamesForShadowedTypeParams = 4,
6890
6891
  UseStructuralFallback = 8,
6891
6892
  WriteTypeArgumentsOfSignature = 32,
6892
6893
  UseFullyQualifiedType = 64,
@@ -6906,7 +6907,7 @@ declare namespace ts {
6906
6907
  InElementType = 2097152,
6907
6908
  InFirstTypeArgument = 4194304,
6908
6909
  InTypeAlias = 8388608,
6909
- NodeBuilderFlagsMask = 848330091,
6910
+ NodeBuilderFlagsMask = 848330095,
6910
6911
  }
6911
6912
  enum SymbolFormatFlags {
6912
6913
  None = 0,
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.4";
38
- version = `${versionMajorMinor}.0-dev.20231106`;
38
+ version = `${versionMajorMinor}.0-dev.20231107`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4165,6 +4165,7 @@ ${lanes.join("\n")}
4165
4165
  TypeFormatFlags2[TypeFormatFlags2["None"] = 0] = "None";
4166
4166
  TypeFormatFlags2[TypeFormatFlags2["NoTruncation"] = 1] = "NoTruncation";
4167
4167
  TypeFormatFlags2[TypeFormatFlags2["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType";
4168
+ TypeFormatFlags2[TypeFormatFlags2["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams";
4168
4169
  TypeFormatFlags2[TypeFormatFlags2["UseStructuralFallback"] = 8] = "UseStructuralFallback";
4169
4170
  TypeFormatFlags2[TypeFormatFlags2["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature";
4170
4171
  TypeFormatFlags2[TypeFormatFlags2["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType";
@@ -4184,7 +4185,7 @@ ${lanes.join("\n")}
4184
4185
  TypeFormatFlags2[TypeFormatFlags2["InElementType"] = 2097152] = "InElementType";
4185
4186
  TypeFormatFlags2[TypeFormatFlags2["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
4186
4187
  TypeFormatFlags2[TypeFormatFlags2["InTypeAlias"] = 8388608] = "InTypeAlias";
4187
- TypeFormatFlags2[TypeFormatFlags2["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
4188
+ TypeFormatFlags2[TypeFormatFlags2["NodeBuilderFlagsMask"] = 848330095] = "NodeBuilderFlagsMask";
4188
4189
  return TypeFormatFlags2;
4189
4190
  })(TypeFormatFlags || {});
4190
4191
  SymbolFormatFlags = /* @__PURE__ */ ((SymbolFormatFlags2) => {
@@ -50168,7 +50169,7 @@ ${lanes.join("\n")}
50168
50169
  return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
50169
50170
  }
50170
50171
  function toNodeBuilderFlags(flags = 0 /* None */) {
50171
- return flags & 848330091 /* NodeBuilderFlagsMask */;
50172
+ return flags & 848330095 /* NodeBuilderFlagsMask */;
50172
50173
  }
50173
50174
  function isClassInstanceSide(type) {
50174
50175
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
@@ -50417,7 +50418,7 @@ ${lanes.join("\n")}
50417
50418
  }
50418
50419
  return factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
50419
50420
  }
50420
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
50421
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */) {
50421
50422
  const name2 = typeParameterToName(type, context);
50422
50423
  context.approximateLength += idText(name2).length;
50423
50424
  return factory.createTypeReferenceNode(
@@ -51217,36 +51218,65 @@ ${lanes.join("\n")}
51217
51218
  true
51218
51219
  )[0];
51219
51220
  let cleanup;
51220
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && some(expandedParams)) {
51221
- const existingFakeScope = getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration ? context.enclosingDeclaration : void 0;
51222
- Debug.assertOptionalNode(existingFakeScope, isBlock);
51223
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
51224
- let newLocals;
51225
- for (const param of expandedParams) {
51226
- if (!locals.has(param.escapedName)) {
51227
- newLocals = append(newLocals, param.escapedName);
51228
- locals.set(param.escapedName, param);
51229
- }
51230
- }
51231
- if (newLocals) {
51232
- let removeNewLocals2 = function() {
51221
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
51222
+ let pushFakeScope2 = function(kind2, addAll) {
51223
+ Debug.assert(context.enclosingDeclaration);
51224
+ let existingFakeScope;
51225
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
51226
+ existingFakeScope = context.enclosingDeclaration;
51227
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
51228
+ existingFakeScope = context.enclosingDeclaration.parent;
51229
+ }
51230
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
51231
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
51232
+ let newLocals;
51233
+ addAll((name, symbol) => {
51234
+ if (!locals.has(name)) {
51235
+ newLocals = append(newLocals, name);
51236
+ locals.set(name, symbol);
51237
+ }
51238
+ });
51239
+ if (!newLocals)
51240
+ return;
51241
+ const oldCleanup = cleanup;
51242
+ function undo() {
51233
51243
  forEach(newLocals, (s) => locals.delete(s));
51234
- };
51235
- var removeNewLocals = removeNewLocals2;
51244
+ oldCleanup == null ? void 0 : oldCleanup();
51245
+ }
51236
51246
  if (existingFakeScope) {
51237
- cleanup = removeNewLocals2;
51247
+ cleanup = undo;
51238
51248
  } else {
51239
51249
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
51240
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
51250
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
51241
51251
  fakeScope.locals = locals;
51242
51252
  const saveEnclosingDeclaration = context.enclosingDeclaration;
51243
51253
  setParent(fakeScope, saveEnclosingDeclaration);
51244
51254
  context.enclosingDeclaration = fakeScope;
51245
51255
  cleanup = () => {
51246
51256
  context.enclosingDeclaration = saveEnclosingDeclaration;
51247
- removeNewLocals2();
51257
+ undo();
51248
51258
  };
51249
51259
  }
51260
+ };
51261
+ var pushFakeScope = pushFakeScope2;
51262
+ pushFakeScope2(
51263
+ "params",
51264
+ (add) => {
51265
+ for (const param of expandedParams) {
51266
+ add(param.escapedName, param);
51267
+ }
51268
+ }
51269
+ );
51270
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51271
+ pushFakeScope2(
51272
+ "typeParams",
51273
+ (add) => {
51274
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
51275
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
51276
+ add(typeParamName, typeParam.symbol);
51277
+ }
51278
+ }
51279
+ );
51250
51280
  }
51251
51281
  }
51252
51282
  const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports));
@@ -51791,7 +51821,7 @@ ${lanes.join("\n")}
51791
51821
  return identifier;
51792
51822
  }
51793
51823
  }
51794
- function typeParameterShadowsNameInScope(escapedName, context, type) {
51824
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
51795
51825
  const result = resolveName(
51796
51826
  context.enclosingDeclaration,
51797
51827
  escapedName,
@@ -51802,11 +51832,8 @@ ${lanes.join("\n")}
51802
51832
  /*isUse*/
51803
51833
  false
51804
51834
  );
51805
- if (result) {
51806
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
51807
- return false;
51808
- }
51809
- return true;
51835
+ if (result && result.flags & 262144 /* TypeParameter */) {
51836
+ return result !== type.symbol;
51810
51837
  }
51811
51838
  return false;
51812
51839
  }
@@ -51832,7 +51859,7 @@ ${lanes.join("\n")}
51832
51859
  const rawtext = result.escapedText;
51833
51860
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
51834
51861
  let text = rawtext;
51835
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
51862
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
51836
51863
  i++;
51837
51864
  text = `${rawtext}_${i}`;
51838
51865
  }
@@ -51843,7 +51870,7 @@ ${lanes.join("\n")}
51843
51870
  }
51844
51871
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
51845
51872
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
51846
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
51873
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
51847
51874
  }
51848
51875
  return result;
51849
51876
  }
@@ -51988,7 +52015,10 @@ ${lanes.join("\n")}
51988
52015
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
51989
52016
  }
51990
52017
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
51991
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
52018
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
52019
+ enclosingDeclaration = enclosingDeclaration.parent;
52020
+ }
52021
+ return enclosingDeclaration;
51992
52022
  }
51993
52023
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
51994
52024
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -52068,7 +52098,7 @@ ${lanes.join("\n")}
52068
52098
  }
52069
52099
  if (isIdentifier(node)) {
52070
52100
  const type = getDeclaredTypeOfSymbol(sym);
52071
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
52101
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
52072
52102
  name.symbol = sym;
52073
52103
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52074
52104
  }
@@ -68999,6 +69029,9 @@ ${lanes.join("\n")}
68999
69029
  }
69000
69030
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
69001
69031
  if (!assumeTrue) {
69032
+ if (type === candidate) {
69033
+ return neverType;
69034
+ }
69002
69035
  if (checkDerived) {
69003
69036
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
69004
69037
  }
@@ -69015,6 +69048,9 @@ ${lanes.join("\n")}
69015
69048
  if (type.flags & 3 /* AnyOrUnknown */) {
69016
69049
  return candidate;
69017
69050
  }
69051
+ if (type === candidate) {
69052
+ return candidate;
69053
+ }
69018
69054
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
69019
69055
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
69020
69056
  const narrowedType = mapType(candidate, (c) => {
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-dev.20231106`;
57
+ var version = `${versionMajorMinor}.0-dev.20231107`;
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.4.0-dev.20231106",
5
+ "version": "5.4.0-dev.20231107",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "b1ab082c80e4fddc3cfd6d28e66eceb52066f2be"
117
+ "gitHead": "27556f5d3bc4cd3797efe31d32f45775e2a1ca75"
118
118
  }