typescript 5.5.0-dev.20240402 → 5.5.0-dev.20240404

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.5";
21
- var version = `${versionMajorMinor}.0-dev.20240402`;
21
+ var version = `${versionMajorMinor}.0-dev.20240404`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -43542,6 +43542,7 @@ function createTypeChecker(host) {
43542
43542
  isArgumentsSymbol: (symbol) => symbol === argumentsSymbol,
43543
43543
  isUnknownSymbol: (symbol) => symbol === unknownSymbol,
43544
43544
  getMergedSymbol,
43545
+ symbolIsValue,
43545
43546
  getDiagnostics,
43546
43547
  getGlobalDiagnostics,
43547
43548
  getRecursionIdentity,
@@ -49110,68 +49111,7 @@ function createTypeChecker(host) {
49110
49111
  /*skipUnionExpanding*/
49111
49112
  true
49112
49113
  )[0];
49113
- let cleanup;
49114
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
49115
- let pushFakeScope2 = function(kind2, addAll) {
49116
- Debug.assert(context.enclosingDeclaration);
49117
- let existingFakeScope;
49118
- if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
49119
- existingFakeScope = context.enclosingDeclaration;
49120
- } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
49121
- existingFakeScope = context.enclosingDeclaration.parent;
49122
- }
49123
- Debug.assertOptionalNode(existingFakeScope, isBlock);
49124
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
49125
- let newLocals;
49126
- addAll((name, symbol) => {
49127
- if (!locals.has(name)) {
49128
- newLocals = append(newLocals, name);
49129
- locals.set(name, symbol);
49130
- }
49131
- });
49132
- if (!newLocals)
49133
- return;
49134
- const oldCleanup = cleanup;
49135
- function undo() {
49136
- forEach(newLocals, (s) => locals.delete(s));
49137
- oldCleanup == null ? void 0 : oldCleanup();
49138
- }
49139
- if (existingFakeScope) {
49140
- cleanup = undo;
49141
- } else {
49142
- const fakeScope = parseNodeFactory.createBlock(emptyArray);
49143
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
49144
- fakeScope.locals = locals;
49145
- const saveEnclosingDeclaration = context.enclosingDeclaration;
49146
- setParent(fakeScope, saveEnclosingDeclaration);
49147
- context.enclosingDeclaration = fakeScope;
49148
- cleanup = () => {
49149
- context.enclosingDeclaration = saveEnclosingDeclaration;
49150
- undo();
49151
- };
49152
- }
49153
- };
49154
- var pushFakeScope = pushFakeScope2;
49155
- pushFakeScope2(
49156
- "params",
49157
- (add) => {
49158
- for (const param of expandedParams) {
49159
- add(param.escapedName, param);
49160
- }
49161
- }
49162
- );
49163
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
49164
- pushFakeScope2(
49165
- "typeParams",
49166
- (add) => {
49167
- for (const typeParam of signature.typeParameters ?? emptyArray) {
49168
- const typeParamName = typeParameterToName(typeParam, context).escapedText;
49169
- add(typeParamName, typeParam.symbol);
49170
- }
49171
- }
49172
- );
49173
- }
49174
- }
49114
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
49175
49115
  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 */));
49176
49116
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
49177
49117
  if (thisParameter) {
@@ -49262,6 +49202,111 @@ function createTypeChecker(host) {
49262
49202
  cleanup == null ? void 0 : cleanup();
49263
49203
  return node;
49264
49204
  }
49205
+ function isNewScopeNode(node) {
49206
+ return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
49207
+ }
49208
+ function getTypeParametersInScope(node) {
49209
+ return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
49210
+ }
49211
+ function getParametersInScope(node) {
49212
+ return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
49213
+ getSignatureFromDeclaration(node),
49214
+ /*skipUnionExpanding*/
49215
+ true
49216
+ )[0] : void 0;
49217
+ }
49218
+ function enterNewScope(context, declaration, expandedParams, typeParameters) {
49219
+ let cleanup;
49220
+ if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
49221
+ let pushFakeScope2 = function(kind, addAll) {
49222
+ Debug.assert(context.enclosingDeclaration);
49223
+ let existingFakeScope;
49224
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind) {
49225
+ existingFakeScope = context.enclosingDeclaration;
49226
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind) {
49227
+ existingFakeScope = context.enclosingDeclaration.parent;
49228
+ }
49229
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
49230
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
49231
+ let newLocals;
49232
+ addAll((name, symbol) => {
49233
+ if (!locals.has(name)) {
49234
+ newLocals = append(newLocals, name);
49235
+ locals.set(name, symbol);
49236
+ }
49237
+ });
49238
+ if (!newLocals)
49239
+ return;
49240
+ const oldCleanup = cleanup;
49241
+ function undo() {
49242
+ forEach(newLocals, (s) => locals.delete(s));
49243
+ oldCleanup == null ? void 0 : oldCleanup();
49244
+ }
49245
+ if (existingFakeScope) {
49246
+ cleanup = undo;
49247
+ } else {
49248
+ const fakeScope = parseNodeFactory.createBlock(emptyArray);
49249
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
49250
+ fakeScope.locals = locals;
49251
+ const saveEnclosingDeclaration = context.enclosingDeclaration;
49252
+ setParent(fakeScope, saveEnclosingDeclaration);
49253
+ context.enclosingDeclaration = fakeScope;
49254
+ cleanup = () => {
49255
+ context.enclosingDeclaration = saveEnclosingDeclaration;
49256
+ undo();
49257
+ };
49258
+ }
49259
+ };
49260
+ var pushFakeScope = pushFakeScope2;
49261
+ pushFakeScope2(
49262
+ "params",
49263
+ (add) => {
49264
+ for (const param of expandedParams ?? emptyArray) {
49265
+ if (!forEach(param.declarations, (d) => {
49266
+ if (isParameter(d) && isBindingPattern(d.name)) {
49267
+ bindPattern(d.name);
49268
+ return true;
49269
+ }
49270
+ return void 0;
49271
+ function bindPattern(p) {
49272
+ forEach(p.elements, (e) => {
49273
+ switch (e.kind) {
49274
+ case 232 /* OmittedExpression */:
49275
+ return;
49276
+ case 208 /* BindingElement */:
49277
+ return bindElement(e);
49278
+ default:
49279
+ return Debug.assertNever(e);
49280
+ }
49281
+ });
49282
+ }
49283
+ function bindElement(e) {
49284
+ if (isBindingPattern(e.name)) {
49285
+ return bindPattern(e.name);
49286
+ }
49287
+ const symbol = getSymbolOfDeclaration(e);
49288
+ add(symbol.escapedName, symbol);
49289
+ }
49290
+ })) {
49291
+ add(param.escapedName, param);
49292
+ }
49293
+ }
49294
+ }
49295
+ );
49296
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
49297
+ pushFakeScope2(
49298
+ "typeParams",
49299
+ (add) => {
49300
+ for (const typeParam of typeParameters ?? emptyArray) {
49301
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
49302
+ add(typeParamName, typeParam.symbol);
49303
+ }
49304
+ }
49305
+ );
49306
+ }
49307
+ return cleanup;
49308
+ }
49309
+ }
49265
49310
  function tryGetThisParameterDeclaration(signature, context) {
49266
49311
  if (signature.thisParameter) {
49267
49312
  return symbolToParameterDeclaration(signature.thisParameter, context);
@@ -49880,6 +49925,9 @@ function createTypeChecker(host) {
49880
49925
  if (initial.typeParameterSymbolList) {
49881
49926
  initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
49882
49927
  }
49928
+ if (initial.typeParameterNamesByTextNextNameCount) {
49929
+ initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
49930
+ }
49883
49931
  initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
49884
49932
  return initial;
49885
49933
  }
@@ -49887,7 +49935,16 @@ function createTypeChecker(host) {
49887
49935
  return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
49888
49936
  }
49889
49937
  function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
49890
- return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
49938
+ if (!(getObjectFlags(type) & 4 /* Reference */))
49939
+ return true;
49940
+ if (!isTypeReferenceNode(existing))
49941
+ return true;
49942
+ void getTypeFromTypeReference(existing);
49943
+ const symbol = getNodeLinks(existing).resolvedSymbol;
49944
+ const existingTarget = symbol && getDeclaredTypeOfSymbol(symbol);
49945
+ if (!existingTarget || existingTarget !== type.target)
49946
+ return true;
49947
+ return length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
49891
49948
  }
49892
49949
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
49893
49950
  while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
@@ -50012,6 +50069,22 @@ function createTypeChecker(host) {
50012
50069
  }
50013
50070
  return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
50014
50071
  function visitExistingNodeTreeSymbols(node) {
50072
+ const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
50073
+ const result = visitExistingNodeTreeSymbolsWorker(node);
50074
+ onExitNewScope == null ? void 0 : onExitNewScope();
50075
+ return result;
50076
+ }
50077
+ function onEnterNewScope(node) {
50078
+ const oldContex = context;
50079
+ context = cloneNodeBuilderContext(context);
50080
+ const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
50081
+ return onExitNewScope;
50082
+ function onExitNewScope() {
50083
+ cleanup == null ? void 0 : cleanup();
50084
+ context = oldContex;
50085
+ }
50086
+ }
50087
+ function visitExistingNodeTreeSymbolsWorker(node) {
50015
50088
  if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
50016
50089
  return factory.createKeywordTypeNode(133 /* AnyKeyword */);
50017
50090
  }
@@ -50162,6 +50235,21 @@ function createTypeChecker(host) {
50162
50235
  setEmitFlags(clone, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
50163
50236
  return clone;
50164
50237
  }
50238
+ if (isConditionalTypeNode(node)) {
50239
+ const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
50240
+ const disposeScope = onEnterNewScope(node);
50241
+ const extendType = visitNode(node.extendsType, visitExistingNodeTreeSymbols, isTypeNode);
50242
+ const trueType2 = visitNode(node.trueType, visitExistingNodeTreeSymbols, isTypeNode);
50243
+ disposeScope();
50244
+ const falseType2 = visitNode(node.falseType, visitExistingNodeTreeSymbols, isTypeNode);
50245
+ return factory.updateConditionalTypeNode(
50246
+ node,
50247
+ checkType,
50248
+ extendType,
50249
+ trueType2,
50250
+ falseType2
50251
+ );
50252
+ }
50165
50253
  return visitEachChild(
50166
50254
  node,
50167
50255
  visitExistingNodeTreeSymbols,
@@ -63377,6 +63465,9 @@ function createTypeChecker(host) {
63377
63465
  const resolved = resolveStructuredTypeMembers(type);
63378
63466
  return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && resolved.properties.length > 0 && every(resolved.properties, (p) => !!(p.flags & 16777216 /* Optional */));
63379
63467
  }
63468
+ if (type.flags & 33554432 /* Substitution */) {
63469
+ return isWeakType(type.baseType);
63470
+ }
63380
63471
  if (type.flags & 2097152 /* Intersection */) {
63381
63472
  return every(type.types, isWeakType);
63382
63473
  }
@@ -70345,7 +70436,11 @@ function createTypeChecker(host) {
70345
70436
  if (getPropertyOfObjectType(targetType, name) || getApplicableIndexInfoForName(targetType, name) || isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || isComparingJsxAttributes && isHyphenatedJsxName(name)) {
70346
70437
  return true;
70347
70438
  }
70348
- } else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
70439
+ }
70440
+ if (targetType.flags & 33554432 /* Substitution */) {
70441
+ return isKnownProperty(targetType.baseType, name, isComparingJsxAttributes);
70442
+ }
70443
+ if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
70349
70444
  for (const t of targetType.types) {
70350
70445
  if (isKnownProperty(t, name, isComparingJsxAttributes)) {
70351
70446
  return true;
@@ -70355,7 +70450,7 @@ function createTypeChecker(host) {
70355
70450
  return false;
70356
70451
  }
70357
70452
  function isExcessPropertyCheckTarget(type) {
70358
- return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
70453
+ return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 33554432 /* Substitution */ && isExcessPropertyCheckTarget(type.baseType) || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
70359
70454
  }
70360
70455
  function checkJsxExpression(node, checkMode) {
70361
70456
  checkGrammarJsxExpression(node);
@@ -74496,17 +74591,18 @@ function createTypeChecker(host) {
74496
74591
  const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
74497
74592
  const trueCondition = {
74498
74593
  flags: 32 /* TrueCondition */,
74499
- node: expr,
74500
- antecedent
74594
+ antecedent,
74595
+ node: expr
74501
74596
  };
74502
74597
  const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
74503
74598
  if (trueType2 === initType)
74504
74599
  return void 0;
74505
74600
  const falseCondition = {
74506
- ...trueCondition,
74507
- flags: 64 /* FalseCondition */
74601
+ flags: 64 /* FalseCondition */,
74602
+ antecedent,
74603
+ node: expr
74508
74604
  };
74509
- const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
74605
+ const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
74510
74606
  return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
74511
74607
  }
74512
74608
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
@@ -5793,61 +5793,6 @@ declare namespace ts {
5793
5793
  readonly moduleSpecifier: Expression;
5794
5794
  readonly attributes?: ImportAttributes;
5795
5795
  }
5796
- enum FlowFlags {
5797
- Unreachable = 1,
5798
- Start = 2,
5799
- BranchLabel = 4,
5800
- LoopLabel = 8,
5801
- Assignment = 16,
5802
- TrueCondition = 32,
5803
- FalseCondition = 64,
5804
- SwitchClause = 128,
5805
- ArrayMutation = 256,
5806
- Call = 512,
5807
- ReduceLabel = 1024,
5808
- Referenced = 2048,
5809
- Shared = 4096,
5810
- Label = 12,
5811
- Condition = 96,
5812
- }
5813
- type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
5814
- interface FlowNodeBase {
5815
- flags: FlowFlags;
5816
- id?: number;
5817
- }
5818
- interface FlowStart extends FlowNodeBase {
5819
- node?: FunctionExpression | ArrowFunction | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
5820
- }
5821
- interface FlowLabel extends FlowNodeBase {
5822
- antecedents: FlowNode[] | undefined;
5823
- }
5824
- interface FlowAssignment extends FlowNodeBase {
5825
- node: Expression | VariableDeclaration | BindingElement;
5826
- antecedent: FlowNode;
5827
- }
5828
- interface FlowCall extends FlowNodeBase {
5829
- node: CallExpression;
5830
- antecedent: FlowNode;
5831
- }
5832
- interface FlowCondition extends FlowNodeBase {
5833
- node: Expression;
5834
- antecedent: FlowNode;
5835
- }
5836
- interface FlowSwitchClause extends FlowNodeBase {
5837
- switchStatement: SwitchStatement;
5838
- clauseStart: number;
5839
- clauseEnd: number;
5840
- antecedent: FlowNode;
5841
- }
5842
- interface FlowArrayMutation extends FlowNodeBase {
5843
- node: CallExpression | BinaryExpression;
5844
- antecedent: FlowNode;
5845
- }
5846
- interface FlowReduceLabel extends FlowNodeBase {
5847
- target: FlowLabel;
5848
- antecedents: FlowNode[];
5849
- antecedent: FlowNode;
5850
- }
5851
5796
  type FlowType = Type | IncompleteType;
5852
5797
  interface IncompleteType {
5853
5798
  flags: TypeFlags | 0;
package/lib/typescript.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(typescript_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.5";
2331
- var version = `${versionMajorMinor}.0-dev.20240402`;
2331
+ var version = `${versionMajorMinor}.0-dev.20240404`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -48307,6 +48307,7 @@ function createTypeChecker(host) {
48307
48307
  isArgumentsSymbol: (symbol) => symbol === argumentsSymbol,
48308
48308
  isUnknownSymbol: (symbol) => symbol === unknownSymbol,
48309
48309
  getMergedSymbol,
48310
+ symbolIsValue,
48310
48311
  getDiagnostics: getDiagnostics2,
48311
48312
  getGlobalDiagnostics,
48312
48313
  getRecursionIdentity,
@@ -53875,68 +53876,7 @@ function createTypeChecker(host) {
53875
53876
  /*skipUnionExpanding*/
53876
53877
  true
53877
53878
  )[0];
53878
- let cleanup;
53879
- if (context.enclosingDeclaration && signature.declaration && signature.declaration !== context.enclosingDeclaration && !isInJSFile(signature.declaration) && (some(expandedParams) || some(signature.typeParameters))) {
53880
- let pushFakeScope2 = function(kind2, addAll) {
53881
- Debug.assert(context.enclosingDeclaration);
53882
- let existingFakeScope;
53883
- if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind2) {
53884
- existingFakeScope = context.enclosingDeclaration;
53885
- } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind2) {
53886
- existingFakeScope = context.enclosingDeclaration.parent;
53887
- }
53888
- Debug.assertOptionalNode(existingFakeScope, isBlock);
53889
- const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53890
- let newLocals;
53891
- addAll((name, symbol) => {
53892
- if (!locals.has(name)) {
53893
- newLocals = append(newLocals, name);
53894
- locals.set(name, symbol);
53895
- }
53896
- });
53897
- if (!newLocals)
53898
- return;
53899
- const oldCleanup = cleanup;
53900
- function undo() {
53901
- forEach(newLocals, (s) => locals.delete(s));
53902
- oldCleanup == null ? void 0 : oldCleanup();
53903
- }
53904
- if (existingFakeScope) {
53905
- cleanup = undo;
53906
- } else {
53907
- const fakeScope = parseNodeFactory.createBlock(emptyArray);
53908
- getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind2;
53909
- fakeScope.locals = locals;
53910
- const saveEnclosingDeclaration = context.enclosingDeclaration;
53911
- setParent(fakeScope, saveEnclosingDeclaration);
53912
- context.enclosingDeclaration = fakeScope;
53913
- cleanup = () => {
53914
- context.enclosingDeclaration = saveEnclosingDeclaration;
53915
- undo();
53916
- };
53917
- }
53918
- };
53919
- var pushFakeScope = pushFakeScope2;
53920
- pushFakeScope2(
53921
- "params",
53922
- (add) => {
53923
- for (const param of expandedParams) {
53924
- add(param.escapedName, param);
53925
- }
53926
- }
53927
- );
53928
- if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
53929
- pushFakeScope2(
53930
- "typeParams",
53931
- (add) => {
53932
- for (const typeParam of signature.typeParameters ?? emptyArray) {
53933
- const typeParamName = typeParameterToName(typeParam, context).escapedText;
53934
- add(typeParamName, typeParam.symbol);
53935
- }
53936
- }
53937
- );
53938
- }
53939
- }
53879
+ const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters);
53940
53880
  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 */));
53941
53881
  const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
53942
53882
  if (thisParameter) {
@@ -54027,6 +53967,111 @@ function createTypeChecker(host) {
54027
53967
  cleanup == null ? void 0 : cleanup();
54028
53968
  return node;
54029
53969
  }
53970
+ function isNewScopeNode(node) {
53971
+ return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
53972
+ }
53973
+ function getTypeParametersInScope(node) {
53974
+ return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).typeParameters : isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
53975
+ }
53976
+ function getParametersInScope(node) {
53977
+ return isFunctionLike(node) || isJSDocSignature(node) ? getExpandedParameters(
53978
+ getSignatureFromDeclaration(node),
53979
+ /*skipUnionExpanding*/
53980
+ true
53981
+ )[0] : void 0;
53982
+ }
53983
+ function enterNewScope(context, declaration, expandedParams, typeParameters) {
53984
+ let cleanup;
53985
+ if (context.enclosingDeclaration && declaration && declaration !== context.enclosingDeclaration && !isInJSFile(declaration) && (some(expandedParams) || some(typeParameters))) {
53986
+ let pushFakeScope2 = function(kind, addAll) {
53987
+ Debug.assert(context.enclosingDeclaration);
53988
+ let existingFakeScope;
53989
+ if (getNodeLinks(context.enclosingDeclaration).fakeScopeForSignatureDeclaration === kind) {
53990
+ existingFakeScope = context.enclosingDeclaration;
53991
+ } else if (context.enclosingDeclaration.parent && getNodeLinks(context.enclosingDeclaration.parent).fakeScopeForSignatureDeclaration === kind) {
53992
+ existingFakeScope = context.enclosingDeclaration.parent;
53993
+ }
53994
+ Debug.assertOptionalNode(existingFakeScope, isBlock);
53995
+ const locals = (existingFakeScope == null ? void 0 : existingFakeScope.locals) ?? createSymbolTable();
53996
+ let newLocals;
53997
+ addAll((name, symbol) => {
53998
+ if (!locals.has(name)) {
53999
+ newLocals = append(newLocals, name);
54000
+ locals.set(name, symbol);
54001
+ }
54002
+ });
54003
+ if (!newLocals)
54004
+ return;
54005
+ const oldCleanup = cleanup;
54006
+ function undo() {
54007
+ forEach(newLocals, (s) => locals.delete(s));
54008
+ oldCleanup == null ? void 0 : oldCleanup();
54009
+ }
54010
+ if (existingFakeScope) {
54011
+ cleanup = undo;
54012
+ } else {
54013
+ const fakeScope = parseNodeFactory.createBlock(emptyArray);
54014
+ getNodeLinks(fakeScope).fakeScopeForSignatureDeclaration = kind;
54015
+ fakeScope.locals = locals;
54016
+ const saveEnclosingDeclaration = context.enclosingDeclaration;
54017
+ setParent(fakeScope, saveEnclosingDeclaration);
54018
+ context.enclosingDeclaration = fakeScope;
54019
+ cleanup = () => {
54020
+ context.enclosingDeclaration = saveEnclosingDeclaration;
54021
+ undo();
54022
+ };
54023
+ }
54024
+ };
54025
+ var pushFakeScope = pushFakeScope2;
54026
+ pushFakeScope2(
54027
+ "params",
54028
+ (add) => {
54029
+ for (const param of expandedParams ?? emptyArray) {
54030
+ if (!forEach(param.declarations, (d) => {
54031
+ if (isParameter(d) && isBindingPattern(d.name)) {
54032
+ bindPattern(d.name);
54033
+ return true;
54034
+ }
54035
+ return void 0;
54036
+ function bindPattern(p) {
54037
+ forEach(p.elements, (e) => {
54038
+ switch (e.kind) {
54039
+ case 232 /* OmittedExpression */:
54040
+ return;
54041
+ case 208 /* BindingElement */:
54042
+ return bindElement(e);
54043
+ default:
54044
+ return Debug.assertNever(e);
54045
+ }
54046
+ });
54047
+ }
54048
+ function bindElement(e) {
54049
+ if (isBindingPattern(e.name)) {
54050
+ return bindPattern(e.name);
54051
+ }
54052
+ const symbol = getSymbolOfDeclaration(e);
54053
+ add(symbol.escapedName, symbol);
54054
+ }
54055
+ })) {
54056
+ add(param.escapedName, param);
54057
+ }
54058
+ }
54059
+ }
54060
+ );
54061
+ if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
54062
+ pushFakeScope2(
54063
+ "typeParams",
54064
+ (add) => {
54065
+ for (const typeParam of typeParameters ?? emptyArray) {
54066
+ const typeParamName = typeParameterToName(typeParam, context).escapedText;
54067
+ add(typeParamName, typeParam.symbol);
54068
+ }
54069
+ }
54070
+ );
54071
+ }
54072
+ return cleanup;
54073
+ }
54074
+ }
54030
54075
  function tryGetThisParameterDeclaration(signature, context) {
54031
54076
  if (signature.thisParameter) {
54032
54077
  return symbolToParameterDeclaration(signature.thisParameter, context);
@@ -54645,6 +54690,9 @@ function createTypeChecker(host) {
54645
54690
  if (initial.typeParameterSymbolList) {
54646
54691
  initial.typeParameterSymbolList = new Set(initial.typeParameterSymbolList);
54647
54692
  }
54693
+ if (initial.typeParameterNamesByTextNextNameCount) {
54694
+ initial.typeParameterNamesByTextNextNameCount = new Map(initial.typeParameterNamesByTextNextNameCount);
54695
+ }
54648
54696
  initial.tracker = new SymbolTrackerImpl(initial, initial.tracker.inner, initial.tracker.moduleResolverHost);
54649
54697
  return initial;
54650
54698
  }
@@ -54652,7 +54700,16 @@ function createTypeChecker(host) {
54652
54700
  return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
54653
54701
  }
54654
54702
  function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
54655
- return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54703
+ if (!(getObjectFlags(type) & 4 /* Reference */))
54704
+ return true;
54705
+ if (!isTypeReferenceNode(existing))
54706
+ return true;
54707
+ void getTypeFromTypeReference(existing);
54708
+ const symbol = getNodeLinks(existing).resolvedSymbol;
54709
+ const existingTarget = symbol && getDeclaredTypeOfSymbol(symbol);
54710
+ if (!existingTarget || existingTarget !== type.target)
54711
+ return true;
54712
+ return length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
54656
54713
  }
54657
54714
  function getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration) {
54658
54715
  while (getNodeLinks(enclosingDeclaration).fakeScopeForSignatureDeclaration) {
@@ -54777,6 +54834,22 @@ function createTypeChecker(host) {
54777
54834
  }
54778
54835
  return transformed === existing ? setTextRange(factory.cloneNode(existing), existing) : transformed;
54779
54836
  function visitExistingNodeTreeSymbols(node) {
54837
+ const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
54838
+ const result = visitExistingNodeTreeSymbolsWorker(node);
54839
+ onExitNewScope == null ? void 0 : onExitNewScope();
54840
+ return result;
54841
+ }
54842
+ function onEnterNewScope(node) {
54843
+ const oldContex = context;
54844
+ context = cloneNodeBuilderContext(context);
54845
+ const cleanup = enterNewScope(context, node, getParametersInScope(node), getTypeParametersInScope(node));
54846
+ return onExitNewScope;
54847
+ function onExitNewScope() {
54848
+ cleanup == null ? void 0 : cleanup();
54849
+ context = oldContex;
54850
+ }
54851
+ }
54852
+ function visitExistingNodeTreeSymbolsWorker(node) {
54780
54853
  if (isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) {
54781
54854
  return factory.createKeywordTypeNode(133 /* AnyKeyword */);
54782
54855
  }
@@ -54927,6 +55000,21 @@ function createTypeChecker(host) {
54927
55000
  setEmitFlags(clone2, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
54928
55001
  return clone2;
54929
55002
  }
55003
+ if (isConditionalTypeNode(node)) {
55004
+ const checkType = visitNode(node.checkType, visitExistingNodeTreeSymbols, isTypeNode);
55005
+ const disposeScope = onEnterNewScope(node);
55006
+ const extendType = visitNode(node.extendsType, visitExistingNodeTreeSymbols, isTypeNode);
55007
+ const trueType2 = visitNode(node.trueType, visitExistingNodeTreeSymbols, isTypeNode);
55008
+ disposeScope();
55009
+ const falseType2 = visitNode(node.falseType, visitExistingNodeTreeSymbols, isTypeNode);
55010
+ return factory.updateConditionalTypeNode(
55011
+ node,
55012
+ checkType,
55013
+ extendType,
55014
+ trueType2,
55015
+ falseType2
55016
+ );
55017
+ }
54930
55018
  return visitEachChild(
54931
55019
  node,
54932
55020
  visitExistingNodeTreeSymbols,
@@ -68142,6 +68230,9 @@ function createTypeChecker(host) {
68142
68230
  const resolved = resolveStructuredTypeMembers(type);
68143
68231
  return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && resolved.properties.length > 0 && every(resolved.properties, (p) => !!(p.flags & 16777216 /* Optional */));
68144
68232
  }
68233
+ if (type.flags & 33554432 /* Substitution */) {
68234
+ return isWeakType(type.baseType);
68235
+ }
68145
68236
  if (type.flags & 2097152 /* Intersection */) {
68146
68237
  return every(type.types, isWeakType);
68147
68238
  }
@@ -75110,7 +75201,11 @@ function createTypeChecker(host) {
75110
75201
  if (getPropertyOfObjectType(targetType, name) || getApplicableIndexInfoForName(targetType, name) || isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || isComparingJsxAttributes && isHyphenatedJsxName(name)) {
75111
75202
  return true;
75112
75203
  }
75113
- } else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
75204
+ }
75205
+ if (targetType.flags & 33554432 /* Substitution */) {
75206
+ return isKnownProperty(targetType.baseType, name, isComparingJsxAttributes);
75207
+ }
75208
+ if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) {
75114
75209
  for (const t of targetType.types) {
75115
75210
  if (isKnownProperty(t, name, isComparingJsxAttributes)) {
75116
75211
  return true;
@@ -75120,7 +75215,7 @@ function createTypeChecker(host) {
75120
75215
  return false;
75121
75216
  }
75122
75217
  function isExcessPropertyCheckTarget(type) {
75123
- return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
75218
+ return !!(type.flags & 524288 /* Object */ && !(getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || type.flags & 67108864 /* NonPrimitive */ || type.flags & 33554432 /* Substitution */ && isExcessPropertyCheckTarget(type.baseType) || type.flags & 1048576 /* Union */ && some(type.types, isExcessPropertyCheckTarget) || type.flags & 2097152 /* Intersection */ && every(type.types, isExcessPropertyCheckTarget));
75124
75219
  }
75125
75220
  function checkJsxExpression(node, checkMode) {
75126
75221
  checkGrammarJsxExpression(node);
@@ -79261,17 +79356,18 @@ function createTypeChecker(host) {
79261
79356
  const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
79262
79357
  const trueCondition = {
79263
79358
  flags: 32 /* TrueCondition */,
79264
- node: expr,
79265
- antecedent
79359
+ antecedent,
79360
+ node: expr
79266
79361
  };
79267
79362
  const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
79268
79363
  if (trueType2 === initType)
79269
79364
  return void 0;
79270
79365
  const falseCondition = {
79271
- ...trueCondition,
79272
- flags: 64 /* FalseCondition */
79366
+ flags: 64 /* FalseCondition */,
79367
+ antecedent,
79368
+ node: expr
79273
79369
  };
79274
- const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
79370
+ const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
79275
79371
  return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
79276
79372
  }
79277
79373
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
@@ -150175,7 +150271,8 @@ function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program)
150175
150271
  const checker = program.getTypeChecker();
150176
150272
  for (const specifier2 of nonTypeOnlySpecifiers) {
150177
150273
  const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
150178
- return !isValidTypeOnlyAliasUseSite(usage);
150274
+ const symbol = checker.getSymbolAtLocation(usage);
150275
+ return !!symbol && checker.symbolIsValue(symbol) || !isValidTypeOnlyAliasUseSite(usage);
150179
150276
  });
150180
150277
  if (isUsedAsValue) {
150181
150278
  return false;
@@ -173560,7 +173657,8 @@ var SmartIndenter;
173560
173657
  return childKind !== 290 /* JsxClosingFragment */;
173561
173658
  case 193 /* IntersectionType */:
173562
173659
  case 192 /* UnionType */:
173563
- if (childKind === 187 /* TypeLiteral */ || childKind === 189 /* TupleType */) {
173660
+ case 238 /* SatisfiesExpression */:
173661
+ if (childKind === 187 /* TypeLiteral */ || childKind === 189 /* TupleType */ || childKind === 200 /* MappedType */) {
173564
173662
  return false;
173565
173663
  }
173566
173664
  break;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.5.0-dev.20240402",
5
+ "version": "5.5.0-dev.20240404",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -64,7 +64,6 @@
64
64
  "eslint-formatter-autolinkable-stylish": "^1.3.0",
65
65
  "eslint-plugin-local": "^4.2.1",
66
66
  "eslint-plugin-no-null": "^1.0.2",
67
- "eslint-plugin-simple-import-sort": "^12.0.0",
68
67
  "fast-xml-parser": "^4.3.6",
69
68
  "glob": "^10.3.10",
70
69
  "hereby": "^1.8.9",
@@ -112,5 +111,5 @@
112
111
  "node": "20.1.0",
113
112
  "npm": "8.19.4"
114
113
  },
115
- "gitHead": "824cd6eb314bdcb8b7bde158025c82ebc014db0a"
114
+ "gitHead": "4a5f0f2b78d36afee184ec52419559a390cf17bd"
116
115
  }