typescript 5.4.0-dev.20231106 → 5.4.0-dev.20231108

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.20231108`;
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(
@@ -48157,6 +48157,21 @@ function createTypeChecker(host) {
48157
48157
  const typeId = type2.id;
48158
48158
  const symbol = type2.symbol;
48159
48159
  if (symbol) {
48160
+ const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
48161
+ if (isInstantiationExpressionType) {
48162
+ const instantiationExpressionType = type2;
48163
+ const existing = instantiationExpressionType.node;
48164
+ if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type2) {
48165
+ const typeNode = serializeExistingTypeNode(context, existing);
48166
+ if (typeNode) {
48167
+ return typeNode;
48168
+ }
48169
+ }
48170
+ if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
48171
+ return createElidedInformationPlaceholder(context);
48172
+ }
48173
+ return visitAndTransformType(type2, createTypeNodeFromObjectType);
48174
+ }
48160
48175
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
48161
48176
  if (isJSConstructor(symbol.valueDeclaration)) {
48162
48177
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -48168,7 +48183,7 @@ function createTypeChecker(host) {
48168
48183
  false
48169
48184
  ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
48170
48185
  return symbolToTypeNode(symbol, context, isInstanceType);
48171
- } else if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
48186
+ } else if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
48172
48187
  const typeAlias = getTypeAliasForTypeLiteral(type2);
48173
48188
  if (typeAlias) {
48174
48189
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -48179,20 +48194,6 @@ function createTypeChecker(host) {
48179
48194
  return visitAndTransformType(type2, createTypeNodeFromObjectType);
48180
48195
  }
48181
48196
  } else {
48182
- const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
48183
- if (isInstantiationExpressionType) {
48184
- const instantiationExpressionType = type2;
48185
- if (isTypeQueryNode(instantiationExpressionType.node)) {
48186
- const typeNode = serializeExistingTypeNode(context, instantiationExpressionType.node);
48187
- if (typeNode) {
48188
- return typeNode;
48189
- }
48190
- }
48191
- if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
48192
- return createElidedInformationPlaceholder(context);
48193
- }
48194
- return visitAndTransformType(type2, createTypeNodeFromObjectType);
48195
- }
48196
48197
  return createTypeNodeFromObjectType(type2);
48197
48198
  }
48198
48199
  function shouldWriteTypeOfFunctionSymbol() {
@@ -48746,36 +48747,65 @@ function createTypeChecker(host) {
48746
48747
  true
48747
48748
  )[0];
48748
48749
  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() {
48750
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
48751
+ let pushFakeScope2 = function(kind2, addAll) {
48752
+ Debug.assert(context.enclosingDeclaration);
48753
+ let existingFakeScope;
48754
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
48755
+ existingFakeScope = context.enclosingDeclaration;
48756
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
48757
+ existingFakeScope = context.enclosingDeclaration.parent;
48758
+ }
48759
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
48760
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
48761
+ let newLocals;
48762
+ addAll((name, symbol) => {
48763
+ if (!locals.has(name)) {
48764
+ newLocals = append(newLocals, name);
48765
+ locals.set(name, symbol);
48766
+ }
48767
+ });
48768
+ if (!newLocals)
48769
+ return;
48770
+ const oldCleanup = cleanup;
48771
+ function undo() {
48762
48772
  forEach(newLocals, (s) => locals.delete(s));
48763
- };
48764
- var removeNewLocals = removeNewLocals2;
48773
+ oldCleanup == null ? void 0 : oldCleanup();
48774
+ }
48765
48775
  if (existingFakeScope) {
48766
- cleanup = removeNewLocals2;
48776
+ cleanup = undo;
48767
48777
  } else {
48768
48778
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
48769
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
48779
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
48770
48780
  fakeScope.locals = locals;
48771
48781
  const saveEnclosingDeclaration = context.enclosingDeclaration;
48772
48782
  setParent(fakeScope, saveEnclosingDeclaration);
48773
48783
  context.enclosingDeclaration = fakeScope;
48774
48784
  cleanup = () => {
48775
48785
  context.enclosingDeclaration = saveEnclosingDeclaration;
48776
- removeNewLocals2();
48786
+ undo();
48777
48787
  };
48778
48788
  }
48789
+ };
48790
+ var pushFakeScope = pushFakeScope2;
48791
+ pushFakeScope2(
48792
+ "params",
48793
+ (add) => {
48794
+ for (const param of expandedParams) {
48795
+ add(param.escapedName, param);
48796
+ }
48797
+ }
48798
+ );
48799
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
48800
+ pushFakeScope2(
48801
+ "typeParams",
48802
+ (add) => {
48803
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
48804
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
48805
+ add(typeParamName, typeParam.symbol);
48806
+ }
48807
+ }
48808
+ );
48779
48809
  }
48780
48810
  }
48781
48811
  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 +49350,7 @@ function createTypeChecker(host) {
49320
49350
  return identifier;
49321
49351
  }
49322
49352
  }
49323
- function typeParameterShadowsNameInScope(escapedName, context, type) {
49353
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
49324
49354
  const result = resolveName(
49325
49355
  context.enclosingDeclaration,
49326
49356
  escapedName,
@@ -49331,11 +49361,8 @@ function createTypeChecker(host) {
49331
49361
  /*isUse*/
49332
49362
  false
49333
49363
  );
49334
- if (result) {
49335
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
49336
- return false;
49337
- }
49338
- return true;
49364
+ if (result && result.flags & 262144 /* TypeParameter */) {
49365
+ return result !== type.symbol;
49339
49366
  }
49340
49367
  return false;
49341
49368
  }
@@ -49361,7 +49388,7 @@ function createTypeChecker(host) {
49361
49388
  const rawtext = result.escapedText;
49362
49389
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
49363
49390
  let text = rawtext;
49364
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
49391
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
49365
49392
  i++;
49366
49393
  text = `${rawtext}_${i}`;
49367
49394
  }
@@ -49372,7 +49399,7 @@ function createTypeChecker(host) {
49372
49399
  }
49373
49400
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
49374
49401
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
49375
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
49402
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
49376
49403
  }
49377
49404
  return result;
49378
49405
  }
@@ -49517,7 +49544,10 @@ function createTypeChecker(host) {
49517
49544
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
49518
49545
  }
49519
49546
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
49520
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
49547
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
49548
+ enclosingDeclaration = enclosingDeclaration.parent;
49549
+ }
49550
+ return enclosingDeclaration;
49521
49551
  }
49522
49552
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
49523
49553
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -49597,7 +49627,7 @@ function createTypeChecker(host) {
49597
49627
  }
49598
49628
  if (isIdentifier(node)) {
49599
49629
  const type = getDeclaredTypeOfSymbol(sym);
49600
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
49630
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
49601
49631
  name.symbol = sym;
49602
49632
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
49603
49633
  }
@@ -59071,6 +59101,7 @@ function createTypeChecker(host) {
59071
59101
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
59072
59102
  }
59073
59103
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
59104
+ Debug.assert(type.symbol, "anonymous type must have symbol to be instantiated");
59074
59105
  const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
59075
59106
  if (type.objectFlags & 32 /* Mapped */) {
59076
59107
  result.declaration = type.declaration;
@@ -62318,6 +62349,7 @@ function createTypeChecker(host) {
62318
62349
  const sourceObjectFlags = getObjectFlags(source2);
62319
62350
  const targetObjectFlags = getObjectFlags(target2);
62320
62351
  if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source2.symbol === target2.symbol || sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source2.target === target2.target) {
62352
+ Debug.assertEqual(sourceSignatures.length, targetSignatures.length);
62321
62353
  for (let i = 0; i < targetSignatures.length; i++) {
62322
62354
  const related = signatureRelatedTo(
62323
62355
  sourceSignatures[i],
@@ -66528,6 +66560,9 @@ function createTypeChecker(host) {
66528
66560
  }
66529
66561
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
66530
66562
  if (!assumeTrue) {
66563
+ if (type === candidate) {
66564
+ return neverType;
66565
+ }
66531
66566
  if (checkDerived) {
66532
66567
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
66533
66568
  }
@@ -66544,6 +66579,9 @@ function createTypeChecker(host) {
66544
66579
  if (type.flags & 3 /* AnyOrUnknown */) {
66545
66580
  return candidate;
66546
66581
  }
66582
+ if (type === candidate) {
66583
+ return candidate;
66584
+ }
66547
66585
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
66548
66586
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
66549
66587
  const narrowedType = mapType(candidate, (c) => {
@@ -72569,14 +72607,7 @@ function createTypeChecker(host) {
72569
72607
  hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
72570
72608
  hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
72571
72609
  if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
72572
- const result3 = createAnonymousType(
72573
- /*symbol*/
72574
- void 0,
72575
- resolved.members,
72576
- callSignatures,
72577
- constructSignatures,
72578
- resolved.indexInfos
72579
- );
72610
+ const result3 = createAnonymousType(createSymbol(0 /* None */, "__instantiationExpression" /* InstantiationExpression */), resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
72580
72611
  result3.objectFlags |= 8388608 /* InstantiationExpressionType */;
72581
72612
  result3.node = node;
72582
72613
  return result3;
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.20231108`;
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) => {
@@ -6586,6 +6587,7 @@ var InternalSymbolName = /* @__PURE__ */ ((InternalSymbolName2) => {
6586
6587
  InternalSymbolName2["ExportEquals"] = "export=";
6587
6588
  InternalSymbolName2["Default"] = "default";
6588
6589
  InternalSymbolName2["This"] = "this";
6590
+ InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
6589
6591
  return InternalSymbolName2;
6590
6592
  })(InternalSymbolName || {});
6591
6593
  var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
@@ -52403,7 +52405,7 @@ function createTypeChecker(host) {
52403
52405
  return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
52404
52406
  }
52405
52407
  function toNodeBuilderFlags(flags = 0 /* None */) {
52406
- return flags & 848330091 /* NodeBuilderFlagsMask */;
52408
+ return flags & 848330095 /* NodeBuilderFlagsMask */;
52407
52409
  }
52408
52410
  function isClassInstanceSide(type) {
52409
52411
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
@@ -52652,7 +52654,7 @@ function createTypeChecker(host) {
52652
52654
  }
52653
52655
  return factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
52654
52656
  }
52655
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
52657
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */) {
52656
52658
  const name2 = typeParameterToName(type, context);
52657
52659
  context.approximateLength += idText(name2).length;
52658
52660
  return factory.createTypeReferenceNode(
@@ -52863,6 +52865,21 @@ function createTypeChecker(host) {
52863
52865
  const typeId = type2.id;
52864
52866
  const symbol = type2.symbol;
52865
52867
  if (symbol) {
52868
+ const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
52869
+ if (isInstantiationExpressionType) {
52870
+ const instantiationExpressionType = type2;
52871
+ const existing = instantiationExpressionType.node;
52872
+ if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type2) {
52873
+ const typeNode = serializeExistingTypeNode(context, existing);
52874
+ if (typeNode) {
52875
+ return typeNode;
52876
+ }
52877
+ }
52878
+ if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
52879
+ return createElidedInformationPlaceholder(context);
52880
+ }
52881
+ return visitAndTransformType(type2, createTypeNodeFromObjectType);
52882
+ }
52866
52883
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
52867
52884
  if (isJSConstructor(symbol.valueDeclaration)) {
52868
52885
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -52874,7 +52891,7 @@ function createTypeChecker(host) {
52874
52891
  false
52875
52892
  ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
52876
52893
  return symbolToTypeNode(symbol, context, isInstanceType);
52877
- } else if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
52894
+ } else if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
52878
52895
  const typeAlias = getTypeAliasForTypeLiteral(type2);
52879
52896
  if (typeAlias) {
52880
52897
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -52885,20 +52902,6 @@ function createTypeChecker(host) {
52885
52902
  return visitAndTransformType(type2, createTypeNodeFromObjectType);
52886
52903
  }
52887
52904
  } else {
52888
- const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
52889
- if (isInstantiationExpressionType) {
52890
- const instantiationExpressionType = type2;
52891
- if (isTypeQueryNode(instantiationExpressionType.node)) {
52892
- const typeNode = serializeExistingTypeNode(context, instantiationExpressionType.node);
52893
- if (typeNode) {
52894
- return typeNode;
52895
- }
52896
- }
52897
- if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
52898
- return createElidedInformationPlaceholder(context);
52899
- }
52900
- return visitAndTransformType(type2, createTypeNodeFromObjectType);
52901
- }
52902
52905
  return createTypeNodeFromObjectType(type2);
52903
52906
  }
52904
52907
  function shouldWriteTypeOfFunctionSymbol() {
@@ -53452,36 +53455,65 @@ function createTypeChecker(host) {
53452
53455
  true
53453
53456
  )[0];
53454
53457
  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() {
53458
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
53459
+ let pushFakeScope2 = function(kind2, addAll) {
53460
+ Debug.assert(context.enclosingDeclaration);
53461
+ let existingFakeScope;
53462
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
53463
+ existingFakeScope = context.enclosingDeclaration;
53464
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
53465
+ existingFakeScope = context.enclosingDeclaration.parent;
53466
+ }
53467
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
53468
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53469
+ let newLocals;
53470
+ addAll((name, symbol) => {
53471
+ if (!locals.has(name)) {
53472
+ newLocals = append(newLocals, name);
53473
+ locals.set(name, symbol);
53474
+ }
53475
+ });
53476
+ if (!newLocals)
53477
+ return;
53478
+ const oldCleanup = cleanup;
53479
+ function undo() {
53468
53480
  forEach(newLocals, (s) => locals.delete(s));
53469
- };
53470
- var removeNewLocals = removeNewLocals2;
53481
+ oldCleanup == null ? void 0 : oldCleanup();
53482
+ }
53471
53483
  if (existingFakeScope) {
53472
- cleanup = removeNewLocals2;
53484
+ cleanup = undo;
53473
53485
  } else {
53474
53486
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
53475
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
53487
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
53476
53488
  fakeScope.locals = locals;
53477
53489
  const saveEnclosingDeclaration = context.enclosingDeclaration;
53478
53490
  setParent(fakeScope, saveEnclosingDeclaration);
53479
53491
  context.enclosingDeclaration = fakeScope;
53480
53492
  cleanup = () => {
53481
53493
  context.enclosingDeclaration = saveEnclosingDeclaration;
53482
- removeNewLocals2();
53494
+ undo();
53483
53495
  };
53484
53496
  }
53497
+ };
53498
+ var pushFakeScope = pushFakeScope2;
53499
+ pushFakeScope2(
53500
+ "params",
53501
+ (add) => {
53502
+ for (const param of expandedParams) {
53503
+ add(param.escapedName, param);
53504
+ }
53505
+ }
53506
+ );
53507
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53508
+ pushFakeScope2(
53509
+ "typeParams",
53510
+ (add) => {
53511
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
53512
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
53513
+ add(typeParamName, typeParam.symbol);
53514
+ }
53515
+ }
53516
+ );
53485
53517
  }
53486
53518
  }
53487
53519
  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 +54058,7 @@ function createTypeChecker(host) {
54026
54058
  return identifier;
54027
54059
  }
54028
54060
  }
54029
- function typeParameterShadowsNameInScope(escapedName, context, type) {
54061
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
54030
54062
  const result = resolveName(
54031
54063
  context.enclosingDeclaration,
54032
54064
  escapedName,
@@ -54037,11 +54069,8 @@ function createTypeChecker(host) {
54037
54069
  /*isUse*/
54038
54070
  false
54039
54071
  );
54040
- if (result) {
54041
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
54042
- return false;
54043
- }
54044
- return true;
54072
+ if (result && result.flags & 262144 /* TypeParameter */) {
54073
+ return result !== type.symbol;
54045
54074
  }
54046
54075
  return false;
54047
54076
  }
@@ -54067,7 +54096,7 @@ function createTypeChecker(host) {
54067
54096
  const rawtext = result.escapedText;
54068
54097
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
54069
54098
  let text = rawtext;
54070
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
54099
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
54071
54100
  i++;
54072
54101
  text = `${rawtext}_${i}`;
54073
54102
  }
@@ -54078,7 +54107,7 @@ function createTypeChecker(host) {
54078
54107
  }
54079
54108
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
54080
54109
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
54081
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
54110
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
54082
54111
  }
54083
54112
  return result;
54084
54113
  }
@@ -54223,7 +54252,10 @@ function createTypeChecker(host) {
54223
54252
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54224
54253
  }
54225
54254
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
54226
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
54255
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
54256
+ enclosingDeclaration = enclosingDeclaration.parent;
54257
+ }
54258
+ return enclosingDeclaration;
54227
54259
  }
54228
54260
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
54229
54261
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -54303,7 +54335,7 @@ function createTypeChecker(host) {
54303
54335
  }
54304
54336
  if (isIdentifier(node)) {
54305
54337
  const type = getDeclaredTypeOfSymbol(sym);
54306
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
54338
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
54307
54339
  name.symbol = sym;
54308
54340
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
54309
54341
  }
@@ -63777,6 +63809,7 @@ function createTypeChecker(host) {
63777
63809
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
63778
63810
  }
63779
63811
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
63812
+ Debug.assert(type.symbol, "anonymous type must have symbol to be instantiated");
63780
63813
  const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
63781
63814
  if (type.objectFlags & 32 /* Mapped */) {
63782
63815
  result.declaration = type.declaration;
@@ -67024,6 +67057,7 @@ function createTypeChecker(host) {
67024
67057
  const sourceObjectFlags = getObjectFlags(source2);
67025
67058
  const targetObjectFlags = getObjectFlags(target2);
67026
67059
  if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source2.symbol === target2.symbol || sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source2.target === target2.target) {
67060
+ Debug.assertEqual(sourceSignatures.length, targetSignatures.length);
67027
67061
  for (let i = 0; i < targetSignatures.length; i++) {
67028
67062
  const related = signatureRelatedTo(
67029
67063
  sourceSignatures[i],
@@ -71234,6 +71268,9 @@ function createTypeChecker(host) {
71234
71268
  }
71235
71269
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
71236
71270
  if (!assumeTrue) {
71271
+ if (type === candidate) {
71272
+ return neverType;
71273
+ }
71237
71274
  if (checkDerived) {
71238
71275
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
71239
71276
  }
@@ -71250,6 +71287,9 @@ function createTypeChecker(host) {
71250
71287
  if (type.flags & 3 /* AnyOrUnknown */) {
71251
71288
  return candidate;
71252
71289
  }
71290
+ if (type === candidate) {
71291
+ return candidate;
71292
+ }
71253
71293
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
71254
71294
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
71255
71295
  const narrowedType = mapType(candidate, (c) => {
@@ -77275,14 +77315,7 @@ function createTypeChecker(host) {
77275
77315
  hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
77276
77316
  hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
77277
77317
  if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
77278
- const result3 = createAnonymousType(
77279
- /*symbol*/
77280
- void 0,
77281
- resolved.members,
77282
- callSignatures,
77283
- constructSignatures,
77284
- resolved.indexInfos
77285
- );
77318
+ const result3 = createAnonymousType(createSymbol(0 /* None */, "__instantiationExpression" /* InstantiationExpression */), resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
77286
77319
  result3.objectFlags |= 8388608 /* InstantiationExpressionType */;
77287
77320
  result3.node = node;
77288
77321
  return result3;
@@ -150272,7 +150305,17 @@ var errorCodes18 = [
150272
150305
  Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
150273
150306
  Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
150274
150307
  Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
150275
- Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
150308
+ Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
150309
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery.code,
150310
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later.code,
150311
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom.code,
150312
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig.code,
150313
+ Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code,
150314
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig.code,
150315
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha.code,
150316
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode.code,
150317
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig.code,
150318
+ Diagnostics.Cannot_find_namespace_0_Did_you_mean_1.code
150276
150319
  ];
150277
150320
  registerCodeFix({
150278
150321
  errorCodes: errorCodes18,
@@ -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,
@@ -7048,6 +7049,7 @@ declare namespace ts {
7048
7049
  ExportEquals = "export=",
7049
7050
  Default = "default",
7050
7051
  This = "this",
7052
+ InstantiationExpression = "__instantiationExpression",
7051
7053
  }
7052
7054
  /**
7053
7055
  * This represents a string whose leading underscore have been escaped by adding extra leading underscores.
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.20231108`;
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) => {
@@ -4349,6 +4350,7 @@ ${lanes.join("\n")}
4349
4350
  InternalSymbolName2["ExportEquals"] = "export=";
4350
4351
  InternalSymbolName2["Default"] = "default";
4351
4352
  InternalSymbolName2["This"] = "this";
4353
+ InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
4352
4354
  return InternalSymbolName2;
4353
4355
  })(InternalSymbolName || {});
4354
4356
  NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
@@ -50168,7 +50170,7 @@ ${lanes.join("\n")}
50168
50170
  return symbol && !!symbol.valueDeclaration && isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
50169
50171
  }
50170
50172
  function toNodeBuilderFlags(flags = 0 /* None */) {
50171
- return flags & 848330091 /* NodeBuilderFlagsMask */;
50173
+ return flags & 848330095 /* NodeBuilderFlagsMask */;
50172
50174
  }
50173
50175
  function isClassInstanceSide(type) {
50174
50176
  return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
@@ -50417,7 +50419,7 @@ ${lanes.join("\n")}
50417
50419
  }
50418
50420
  return factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
50419
50421
  }
50420
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
50422
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.flags & 262144 /* TypeParameter */) {
50421
50423
  const name2 = typeParameterToName(type, context);
50422
50424
  context.approximateLength += idText(name2).length;
50423
50425
  return factory.createTypeReferenceNode(
@@ -50628,6 +50630,21 @@ ${lanes.join("\n")}
50628
50630
  const typeId = type2.id;
50629
50631
  const symbol = type2.symbol;
50630
50632
  if (symbol) {
50633
+ const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
50634
+ if (isInstantiationExpressionType) {
50635
+ const instantiationExpressionType = type2;
50636
+ const existing = instantiationExpressionType.node;
50637
+ if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type2) {
50638
+ const typeNode = serializeExistingTypeNode(context, existing);
50639
+ if (typeNode) {
50640
+ return typeNode;
50641
+ }
50642
+ }
50643
+ if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
50644
+ return createElidedInformationPlaceholder(context);
50645
+ }
50646
+ return visitAndTransformType(type2, createTypeNodeFromObjectType);
50647
+ }
50631
50648
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
50632
50649
  if (isJSConstructor(symbol.valueDeclaration)) {
50633
50650
  return symbolToTypeNode(symbol, context, isInstanceType);
@@ -50639,7 +50656,7 @@ ${lanes.join("\n")}
50639
50656
  false
50640
50657
  ).accessibility !== 0 /* Accessible */)) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) {
50641
50658
  return symbolToTypeNode(symbol, context, isInstanceType);
50642
- } else if ((_a2 = context.visitedTypes) == null ? void 0 : _a2.has(typeId)) {
50659
+ } else if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
50643
50660
  const typeAlias = getTypeAliasForTypeLiteral(type2);
50644
50661
  if (typeAlias) {
50645
50662
  return symbolToTypeNode(typeAlias, context, 788968 /* Type */);
@@ -50650,20 +50667,6 @@ ${lanes.join("\n")}
50650
50667
  return visitAndTransformType(type2, createTypeNodeFromObjectType);
50651
50668
  }
50652
50669
  } else {
50653
- const isInstantiationExpressionType = !!(getObjectFlags(type2) & 8388608 /* InstantiationExpressionType */);
50654
- if (isInstantiationExpressionType) {
50655
- const instantiationExpressionType = type2;
50656
- if (isTypeQueryNode(instantiationExpressionType.node)) {
50657
- const typeNode = serializeExistingTypeNode(context, instantiationExpressionType.node);
50658
- if (typeNode) {
50659
- return typeNode;
50660
- }
50661
- }
50662
- if ((_b2 = context.visitedTypes) == null ? void 0 : _b2.has(typeId)) {
50663
- return createElidedInformationPlaceholder(context);
50664
- }
50665
- return visitAndTransformType(type2, createTypeNodeFromObjectType);
50666
- }
50667
50670
  return createTypeNodeFromObjectType(type2);
50668
50671
  }
50669
50672
  function shouldWriteTypeOfFunctionSymbol() {
@@ -51217,36 +51220,65 @@ ${lanes.join("\n")}
51217
51220
  true
51218
51221
  )[0];
51219
51222
  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() {
51223
+ if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
51224
+ let pushFakeScope2 = function(kind2, addAll) {
51225
+ Debug.assert(context.enclosingDeclaration);
51226
+ let existingFakeScope;
51227
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
51228
+ existingFakeScope = context.enclosingDeclaration;
51229
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
51230
+ existingFakeScope = context.enclosingDeclaration.parent;
51231
+ }
51232
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
51233
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
51234
+ let newLocals;
51235
+ addAll((name, symbol) => {
51236
+ if (!locals.has(name)) {
51237
+ newLocals = append(newLocals, name);
51238
+ locals.set(name, symbol);
51239
+ }
51240
+ });
51241
+ if (!newLocals)
51242
+ return;
51243
+ const oldCleanup = cleanup;
51244
+ function undo() {
51233
51245
  forEach(newLocals, (s) => locals.delete(s));
51234
- };
51235
- var removeNewLocals = removeNewLocals2;
51246
+ oldCleanup == null ? void 0 : oldCleanup();
51247
+ }
51236
51248
  if (existingFakeScope) {
51237
- cleanup = removeNewLocals2;
51249
+ cleanup = undo;
51238
51250
  } else {
51239
51251
  const fakeScope = parseNodeFactory.createBlock(emptyArray);
51240
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = true;
51252
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
51241
51253
  fakeScope.locals = locals;
51242
51254
  const saveEnclosingDeclaration = context.enclosingDeclaration;
51243
51255
  setParent(fakeScope, saveEnclosingDeclaration);
51244
51256
  context.enclosingDeclaration = fakeScope;
51245
51257
  cleanup = () => {
51246
51258
  context.enclosingDeclaration = saveEnclosingDeclaration;
51247
- removeNewLocals2();
51259
+ undo();
51248
51260
  };
51249
51261
  }
51262
+ };
51263
+ var pushFakeScope = pushFakeScope2;
51264
+ pushFakeScope2(
51265
+ "params",
51266
+ (add) => {
51267
+ for (const param of expandedParams) {
51268
+ add(param.escapedName, param);
51269
+ }
51270
+ }
51271
+ );
51272
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51273
+ pushFakeScope2(
51274
+ "typeParams",
51275
+ (add) => {
51276
+ for (const typeParam of signature.typeParameters ?? emptyArray) {
51277
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
51278
+ add(typeParamName, typeParam.symbol);
51279
+ }
51280
+ }
51281
+ );
51250
51282
  }
51251
51283
  }
51252
51284
  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 +51823,7 @@ ${lanes.join("\n")}
51791
51823
  return identifier;
51792
51824
  }
51793
51825
  }
51794
- function typeParameterShadowsNameInScope(escapedName, context, type) {
51826
+ function typeParameterShadowsOtherTypeParameterInScope(escapedName, context, type) {
51795
51827
  const result = resolveName(
51796
51828
  context.enclosingDeclaration,
51797
51829
  escapedName,
@@ -51802,11 +51834,8 @@ ${lanes.join("\n")}
51802
51834
  /*isUse*/
51803
51835
  false
51804
51836
  );
51805
- if (result) {
51806
- if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) {
51807
- return false;
51808
- }
51809
- return true;
51837
+ if (result && result.flags & 262144 /* TypeParameter */) {
51838
+ return result !== type.symbol;
51810
51839
  }
51811
51840
  return false;
51812
51841
  }
@@ -51832,7 +51861,7 @@ ${lanes.join("\n")}
51832
51861
  const rawtext = result.escapedText;
51833
51862
  let i = ((_a = context.typeParameterNamesByTextNextNameCount) == null ? void 0 : _a.get(rawtext)) || 0;
51834
51863
  let text = rawtext;
51835
- while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
51864
+ while (((_b = context.typeParameterNamesByText) == null ? void 0 : _b.has(text)) || typeParameterShadowsOtherTypeParameterInScope(text, context, type)) {
51836
51865
  i++;
51837
51866
  text = `${rawtext}_${i}`;
51838
51867
  }
@@ -51843,7 +51872,7 @@ ${lanes.join("\n")}
51843
51872
  }
51844
51873
  (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = /* @__PURE__ */ new Map())).set(rawtext, i);
51845
51874
  (context.typeParameterNames || (context.typeParameterNames = /* @__PURE__ */ new Map())).set(getTypeId(type), result);
51846
- (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(rawtext);
51875
+ (context.typeParameterNamesByText || (context.typeParameterNamesByText = /* @__PURE__ */ new Set())).add(text);
51847
51876
  }
51848
51877
  return result;
51849
51878
  }
@@ -51988,7 +52017,10 @@ ${lanes.join("\n")}
51988
52017
  return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
51989
52018
  }
51990
52019
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
51991
- return getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration ? enclosingDeclaration.parent : enclosingDeclaration;
52020
+ while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
52021
+ enclosingDeclaration = enclosingDeclaration.parent;
52022
+ }
52023
+ return enclosingDeclaration;
51992
52024
  }
51993
52025
  function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
51994
52026
  if (!isErrorType(type) && enclosingDeclaration) {
@@ -52068,7 +52100,7 @@ ${lanes.join("\n")}
52068
52100
  }
52069
52101
  if (isIdentifier(node)) {
52070
52102
  const type = getDeclaredTypeOfSymbol(sym);
52071
- const name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : factory.cloneNode(node);
52103
+ const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
52072
52104
  name.symbol = sym;
52073
52105
  return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52074
52106
  }
@@ -61542,6 +61574,7 @@ ${lanes.join("\n")}
61542
61574
  ) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType;
61543
61575
  }
61544
61576
  function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
61577
+ Debug.assert(type.symbol, "anonymous type must have symbol to be instantiated");
61545
61578
  const result = createObjectType(type.objectFlags & ~(524288 /* CouldContainTypeVariablesComputed */ | 1048576 /* CouldContainTypeVariables */) | 64 /* Instantiated */, type.symbol);
61546
61579
  if (type.objectFlags & 32 /* Mapped */) {
61547
61580
  result.declaration = type.declaration;
@@ -64789,6 +64822,7 @@ ${lanes.join("\n")}
64789
64822
  const sourceObjectFlags = getObjectFlags(source2);
64790
64823
  const targetObjectFlags = getObjectFlags(target2);
64791
64824
  if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source2.symbol === target2.symbol || sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source2.target === target2.target) {
64825
+ Debug.assertEqual(sourceSignatures.length, targetSignatures.length);
64792
64826
  for (let i = 0; i < targetSignatures.length; i++) {
64793
64827
  const related = signatureRelatedTo(
64794
64828
  sourceSignatures[i],
@@ -68999,6 +69033,9 @@ ${lanes.join("\n")}
68999
69033
  }
69000
69034
  function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
69001
69035
  if (!assumeTrue) {
69036
+ if (type === candidate) {
69037
+ return neverType;
69038
+ }
69002
69039
  if (checkDerived) {
69003
69040
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
69004
69041
  }
@@ -69015,6 +69052,9 @@ ${lanes.join("\n")}
69015
69052
  if (type.flags & 3 /* AnyOrUnknown */) {
69016
69053
  return candidate;
69017
69054
  }
69055
+ if (type === candidate) {
69056
+ return candidate;
69057
+ }
69018
69058
  const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
69019
69059
  const keyPropertyName = type.flags & 1048576 /* Union */ ? getKeyPropertyName(type) : void 0;
69020
69060
  const narrowedType = mapType(candidate, (c) => {
@@ -75040,14 +75080,7 @@ ${lanes.join("\n")}
75040
75080
  hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
75041
75081
  hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
75042
75082
  if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
75043
- const result3 = createAnonymousType(
75044
- /*symbol*/
75045
- void 0,
75046
- resolved.members,
75047
- callSignatures,
75048
- constructSignatures,
75049
- resolved.indexInfos
75050
- );
75083
+ const result3 = createAnonymousType(createSymbol(0 /* None */, "__instantiationExpression" /* InstantiationExpression */), resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
75051
75084
  result3.objectFlags |= 8388608 /* InstantiationExpressionType */;
75052
75085
  result3.node = node;
75053
75086
  return result3;
@@ -150273,7 +150306,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
150273
150306
  Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
150274
150307
  Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
150275
150308
  Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
150276
- Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
150309
+ Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
150310
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery.code,
150311
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later.code,
150312
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom.code,
150313
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig.code,
150314
+ Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code,
150315
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig.code,
150316
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha.code,
150317
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode.code,
150318
+ Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig.code,
150319
+ Diagnostics.Cannot_find_namespace_0_Did_you_mean_1.code
150277
150320
  ];
150278
150321
  registerCodeFix({
150279
150322
  errorCodes: errorCodes18,
@@ -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.20231108`;
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.20231108",
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": "50f48840a32e3b8e2498967a09e7119203f5131b"
118
118
  }