typescript 5.2.0-dev.20230804 → 5.2.0-dev.20230805

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.2";
21
- var version = `${versionMajorMinor}.0-dev.20230804`;
21
+ var version = `${versionMajorMinor}.0-dev.20230805`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -25552,7 +25552,7 @@ function createAccessorPropertyBackingField(factory2, node, modifiers, initializ
25552
25552
  initializer
25553
25553
  );
25554
25554
  }
25555
- function createAccessorPropertyGetRedirector(factory2, node, modifiers, name) {
25555
+ function createAccessorPropertyGetRedirector(factory2, node, modifiers, name, receiver = factory2.createThis()) {
25556
25556
  return factory2.createGetAccessorDeclaration(
25557
25557
  modifiers,
25558
25558
  name,
@@ -25562,7 +25562,7 @@ function createAccessorPropertyGetRedirector(factory2, node, modifiers, name) {
25562
25562
  factory2.createBlock([
25563
25563
  factory2.createReturnStatement(
25564
25564
  factory2.createPropertyAccessExpression(
25565
- factory2.createThis(),
25565
+ receiver,
25566
25566
  factory2.getGeneratedPrivateNameForNode(
25567
25567
  node.name,
25568
25568
  /*prefix*/
@@ -25574,7 +25574,7 @@ function createAccessorPropertyGetRedirector(factory2, node, modifiers, name) {
25574
25574
  ])
25575
25575
  );
25576
25576
  }
25577
- function createAccessorPropertySetRedirector(factory2, node, modifiers, name) {
25577
+ function createAccessorPropertySetRedirector(factory2, node, modifiers, name, receiver = factory2.createThis()) {
25578
25578
  return factory2.createSetAccessorDeclaration(
25579
25579
  modifiers,
25580
25580
  name,
@@ -25589,7 +25589,7 @@ function createAccessorPropertySetRedirector(factory2, node, modifiers, name) {
25589
25589
  factory2.createExpressionStatement(
25590
25590
  factory2.createAssignment(
25591
25591
  factory2.createPropertyAccessExpression(
25592
- factory2.createThis(),
25592
+ receiver,
25593
25593
  factory2.getGeneratedPrivateNameForNode(
25594
25594
  node.name,
25595
25595
  /*prefix*/
@@ -66147,8 +66147,8 @@ function createTypeChecker(host) {
66147
66147
  }
66148
66148
  const parent = getRootDeclaration(symbol.valueDeclaration).parent;
66149
66149
  const links = getNodeLinks(parent);
66150
- if (!(links.flags & 524288 /* AssignmentsMarked */)) {
66151
- links.flags |= 524288 /* AssignmentsMarked */;
66150
+ if (!(links.flags & 131072 /* AssignmentsMarked */)) {
66151
+ links.flags |= 131072 /* AssignmentsMarked */;
66152
66152
  if (!hasParentWithAssignmentsMarked(parent)) {
66153
66153
  markNodeAssignments(parent);
66154
66154
  }
@@ -66156,7 +66156,7 @@ function createTypeChecker(host) {
66156
66156
  return symbol.isAssigned || false;
66157
66157
  }
66158
66158
  function hasParentWithAssignmentsMarked(node) {
66159
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 524288 /* AssignmentsMarked */));
66159
+ return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
66160
66160
  }
66161
66161
  function markNodeAssignments(node) {
66162
66162
  if (node.kind === 80 /* Identifier */) {
@@ -66262,11 +66262,11 @@ function createTypeChecker(host) {
66262
66262
  const parent = declaration.parent.parent;
66263
66263
  if (parent.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(declaration) & 6 /* Constant */ || parent.kind === 169 /* Parameter */) {
66264
66264
  const links = getNodeLinks(parent);
66265
- if (!(links.flags & 16777216 /* InCheckIdentifier */)) {
66266
- links.flags |= 16777216 /* InCheckIdentifier */;
66265
+ if (!(links.flags & 4194304 /* InCheckIdentifier */)) {
66266
+ links.flags |= 4194304 /* InCheckIdentifier */;
66267
66267
  const parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
66268
66268
  const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
66269
- links.flags &= ~16777216 /* InCheckIdentifier */;
66269
+ links.flags &= ~4194304 /* InCheckIdentifier */;
66270
66270
  if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(parent.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
66271
66271
  const pattern = declaration.parent;
66272
66272
  const narrowedType = getFlowTypeOfReference(
@@ -66343,17 +66343,7 @@ function createTypeChecker(host) {
66343
66343
  }
66344
66344
  let declaration = localOrExportSymbol.valueDeclaration;
66345
66345
  if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
66346
- if (declaration.kind === 263 /* ClassDeclaration */ && nodeIsDecorated(legacyDecorators, declaration)) {
66347
- let container = getContainingClass(node);
66348
- while (container !== void 0) {
66349
- if (container === declaration && container.name !== node) {
66350
- getNodeLinks(declaration).flags |= 1048576 /* ClassWithConstructorReference */;
66351
- getNodeLinks(node).flags |= 2097152 /* ConstructorReferenceInClass */;
66352
- break;
66353
- }
66354
- container = getContainingClass(container);
66355
- }
66356
- } else if (declaration.kind === 231 /* ClassExpression */) {
66346
+ if (isClassLike(declaration) && declaration.name !== node) {
66357
66347
  let container = getThisContainer(
66358
66348
  node,
66359
66349
  /*includeArrowFunctions*/
@@ -66361,14 +66351,7 @@ function createTypeChecker(host) {
66361
66351
  /*includeClassComputedPropertyName*/
66362
66352
  false
66363
66353
  );
66364
- while (container.kind !== 312 /* SourceFile */) {
66365
- if (container.parent === declaration) {
66366
- if (isPropertyDeclaration(container) && isStatic(container) || isClassStaticBlockDeclaration(container)) {
66367
- getNodeLinks(declaration).flags |= 1048576 /* ClassWithConstructorReference */;
66368
- getNodeLinks(node).flags |= 2097152 /* ConstructorReferenceInClass */;
66369
- }
66370
- break;
66371
- }
66354
+ while (container.kind !== 312 /* SourceFile */ && container.parent !== declaration) {
66372
66355
  container = getThisContainer(
66373
66356
  container,
66374
66357
  /*includeArrowFunctions*/
@@ -66377,6 +66360,11 @@ function createTypeChecker(host) {
66377
66360
  false
66378
66361
  );
66379
66362
  }
66363
+ if (container.kind !== 312 /* SourceFile */) {
66364
+ getNodeLinks(declaration).flags |= 262144 /* ContainsConstructorReference */;
66365
+ getNodeLinks(container).flags |= 262144 /* ContainsConstructorReference */;
66366
+ getNodeLinks(node).flags |= 536870912 /* ConstructorReference */;
66367
+ }
66380
66368
  }
66381
66369
  }
66382
66370
  checkNestedBlockScopedBinding(node, symbol);
@@ -66507,7 +66495,7 @@ function createTypeChecker(host) {
66507
66495
  if (isForStatement(container)) {
66508
66496
  const varDeclList = getAncestor(symbol.valueDeclaration, 261 /* VariableDeclarationList */);
66509
66497
  if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
66510
- getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NeedsLoopOutParameter */;
66498
+ getNodeLinks(symbol.valueDeclaration).flags |= 65536 /* NeedsLoopOutParameter */;
66511
66499
  }
66512
66500
  }
66513
66501
  getNodeLinks(symbol.valueDeclaration).flags |= 32768 /* BlockScopedBindingInLoop */;
@@ -66785,7 +66773,7 @@ function createTypeChecker(host) {
66785
66773
  if (!isCallExpression2 && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && (isPropertyDeclaration(container) || isClassStaticBlockDeclaration(container))) {
66786
66774
  forEachEnclosingBlockScopeContainer(node.parent, (current) => {
66787
66775
  if (!isSourceFile(current) || isExternalOrCommonJsModule(current)) {
66788
- getNodeLinks(current).flags |= 8388608 /* ContainsSuperPropertyInStaticInitializer */;
66776
+ getNodeLinks(current).flags |= 2097152 /* ContainsSuperPropertyInStaticInitializer */;
66789
66777
  }
66790
66778
  });
66791
66779
  }
@@ -70327,7 +70315,7 @@ function createTypeChecker(host) {
70327
70315
  }
70328
70316
  }
70329
70317
  function getThisArgumentOfCall(node) {
70330
- const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : void 0;
70318
+ const expression = node.kind === 213 /* CallExpression */ ? node.expression : node.kind === 215 /* TaggedTemplateExpression */ ? node.tag : node.kind === 170 /* Decorator */ && !legacyDecorators ? node.expression : void 0;
70331
70319
  if (expression) {
70332
70320
  const callee = skipOuterExpressions(expression);
70333
70321
  if (isAccessExpression(callee)) {
@@ -75234,7 +75222,7 @@ function createTypeChecker(host) {
75234
75222
  function setNodeLinksForPrivateIdentifierScope(node) {
75235
75223
  if (isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) {
75236
75224
  for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
75237
- getNodeLinks(lexicalScope).flags |= 4194304 /* ContainsClassWithPrivateIdentifiers */;
75225
+ getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
75238
75226
  }
75239
75227
  if (isClassExpression(node.parent)) {
75240
75228
  const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
@@ -76987,7 +76975,7 @@ function createTypeChecker(host) {
76987
76975
  }
76988
76976
  function checkWeakMapSetCollision(node) {
76989
76977
  const enclosingBlockScope = getEnclosingBlockScopeContainer(node);
76990
- if (getNodeCheckFlags(enclosingBlockScope) & 4194304 /* ContainsClassWithPrivateIdentifiers */) {
76978
+ if (getNodeCheckFlags(enclosingBlockScope) & 1048576 /* ContainsClassWithPrivateIdentifiers */) {
76991
76979
  Debug.assert(isNamedDeclaration(node) && isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier");
76992
76980
  errorSkippedOn("noEmit", node, Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText);
76993
76981
  }
@@ -77001,18 +76989,18 @@ function createTypeChecker(host) {
77001
76989
  let hasCollision = false;
77002
76990
  if (isClassExpression(node)) {
77003
76991
  for (const member of node.members) {
77004
- if (getNodeCheckFlags(member) & 8388608 /* ContainsSuperPropertyInStaticInitializer */) {
76992
+ if (getNodeCheckFlags(member) & 2097152 /* ContainsSuperPropertyInStaticInitializer */) {
77005
76993
  hasCollision = true;
77006
76994
  break;
77007
76995
  }
77008
76996
  }
77009
76997
  } else if (isFunctionExpression(node)) {
77010
- if (getNodeCheckFlags(node) & 8388608 /* ContainsSuperPropertyInStaticInitializer */) {
76998
+ if (getNodeCheckFlags(node) & 2097152 /* ContainsSuperPropertyInStaticInitializer */) {
77011
76999
  hasCollision = true;
77012
77000
  }
77013
77001
  } else {
77014
77002
  const container = getEnclosingBlockScopeContainer(node);
77015
- if (container && getNodeCheckFlags(container) & 8388608 /* ContainsSuperPropertyInStaticInitializer */) {
77003
+ if (container && getNodeCheckFlags(container) & 2097152 /* ContainsSuperPropertyInStaticInitializer */) {
77016
77004
  hasCollision = true;
77017
77005
  }
77018
77006
  }
@@ -89131,6 +89119,11 @@ function transformClassFields(context) {
89131
89119
  }
89132
89120
  }
89133
89121
  }
89122
+ function getClassThis() {
89123
+ const lex = getClassLexicalEnvironment();
89124
+ const classThis = lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
89125
+ return Debug.checkDefined(classThis);
89126
+ }
89134
89127
  function transformAutoAccessor(node) {
89135
89128
  const commentRange = getCommentRange(node);
89136
89129
  const sourceMapRange = getSourceMapRange(node);
@@ -89157,11 +89150,13 @@ function transformClassFields(context) {
89157
89150
  setOriginalNode(backingField, node);
89158
89151
  setEmitFlags(backingField, 3072 /* NoComments */);
89159
89152
  setSourceMapRange(backingField, sourceMapRange);
89160
- const getter = createAccessorPropertyGetRedirector(factory2, node, modifiers, getterName);
89153
+ const receiver = isStatic(node) ? getClassThis() : factory2.createThis();
89154
+ const getter = createAccessorPropertyGetRedirector(factory2, node, modifiers, getterName, receiver);
89161
89155
  setOriginalNode(getter, node);
89162
89156
  setCommentRange(getter, commentRange);
89163
89157
  setSourceMapRange(getter, sourceMapRange);
89164
- const setter = createAccessorPropertySetRedirector(factory2, node, modifiers, setterName);
89158
+ const setterModifiers = factory2.createModifiersFromModifierFlags(modifiersToFlags(modifiers));
89159
+ const setter = createAccessorPropertySetRedirector(factory2, node, setterModifiers, setterName, receiver);
89165
89160
  setOriginalNode(setter, node);
89166
89161
  setEmitFlags(setter, 3072 /* NoComments */);
89167
89162
  setSourceMapRange(setter, sourceMapRange);
@@ -89718,6 +89713,7 @@ function transformClassFields(context) {
89718
89713
  return filter(node.members, isNonStaticMethodOrAccessorWithPrivateName);
89719
89714
  }
89720
89715
  function getClassFacts(node) {
89716
+ var _a;
89721
89717
  let facts = 0 /* None */;
89722
89718
  const original = getOriginalNode(node);
89723
89719
  if (isClassDeclaration(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
@@ -89734,6 +89730,8 @@ function transformClassFields(context) {
89734
89730
  if (isStatic(member)) {
89735
89731
  if (member.name && (isPrivateIdentifier(member.name) || isAutoAccessorPropertyDeclaration(member)) && shouldTransformPrivateElementsOrClassStaticBlocks) {
89736
89732
  facts |= 2 /* NeedsClassConstructorReference */;
89733
+ } else if (isAutoAccessorPropertyDeclaration(member) && shouldTransformAutoAccessors === -1 /* True */ && !node.name && !((_a = node.emitNode) == null ? void 0 : _a.classThis)) {
89734
+ facts |= 2 /* NeedsClassConstructorReference */;
89737
89735
  }
89738
89736
  if (isPropertyDeclaration(member) || isClassStaticBlockDeclaration(member)) {
89739
89737
  if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
@@ -89754,6 +89752,9 @@ function transformClassFields(context) {
89754
89752
  containsInstancePrivateElements || (containsInstancePrivateElements = isPrivateIdentifierClassElementDeclaration(member));
89755
89753
  } else if (isPrivateIdentifierClassElementDeclaration(member)) {
89756
89754
  containsInstancePrivateElements = true;
89755
+ if (resolver.getNodeCheckFlags(member) & 262144 /* ContainsConstructorReference */) {
89756
+ facts |= 2 /* NeedsClassConstructorReference */;
89757
+ }
89757
89758
  } else if (isPropertyDeclaration(member)) {
89758
89759
  containsPublicInstanceFields = true;
89759
89760
  containsInitializedPublicInstanceFields || (containsInitializedPublicInstanceFields = !!member.initializer);
@@ -89854,10 +89855,11 @@ function transformClassFields(context) {
89854
89855
  getClassLexicalEnvironment().classConstructor = factory2.cloneNode(temp);
89855
89856
  pendingClassReferenceAssignment = factory2.createAssignment(temp, factory2.getInternalName(node));
89856
89857
  }
89857
- if ((_b = node.emitNode) == null ? void 0 : _b.classThis) {
89858
- getClassLexicalEnvironment().classThis = node.emitNode.classThis;
89859
- }
89860
89858
  }
89859
+ if ((_b = node.emitNode) == null ? void 0 : _b.classThis) {
89860
+ getClassLexicalEnvironment().classThis = node.emitNode.classThis;
89861
+ }
89862
+ const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 262144 /* ContainsConstructorReference */;
89861
89863
  const isExport = hasSyntacticModifier(node, 1 /* Export */);
89862
89864
  const isDefault = hasSyntacticModifier(node, 1024 /* Default */);
89863
89865
  let modifiers = visitNodes2(node.modifiers, modifierVisitor, isModifier);
@@ -89892,6 +89894,11 @@ function transformClassFields(context) {
89892
89894
  )
89893
89895
  ));
89894
89896
  }
89897
+ const alias = getClassLexicalEnvironment().classConstructor;
89898
+ if (isClassWithConstructorReference && alias) {
89899
+ enableSubstitutionForClassAliases();
89900
+ classAliases[getOriginalNodeId(node)] = alias;
89901
+ }
89895
89902
  const classDecl = factory2.updateClassDeclaration(
89896
89903
  node,
89897
89904
  modifiers,
@@ -89914,14 +89921,14 @@ function transformClassFields(context) {
89914
89921
  var _a, _b, _c;
89915
89922
  const isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */);
89916
89923
  const staticPropertiesOrClassStaticBlocks = getStaticPropertiesAndClassStaticBlock(node);
89917
- const isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 1048576 /* ClassWithConstructorReference */;
89924
+ const classCheckFlags = resolver.getNodeCheckFlags(node);
89925
+ const isClassWithConstructorReference = classCheckFlags & 262144 /* ContainsConstructorReference */;
89918
89926
  let temp;
89919
89927
  function createClassTempVar() {
89920
89928
  var _a2;
89921
89929
  if (shouldTransformPrivateElementsOrClassStaticBlocks && ((_a2 = node.emitNode) == null ? void 0 : _a2.classThis)) {
89922
89930
  return getClassLexicalEnvironment().classConstructor = node.emitNode.classThis;
89923
89931
  }
89924
- const classCheckFlags = resolver.getNodeCheckFlags(node);
89925
89932
  const requiresBlockScopedVar = classCheckFlags & 32768 /* BlockScopedBindingInLoop */;
89926
89933
  const temp2 = factory2.createTempVariable(
89927
89934
  requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration,
@@ -90888,7 +90895,7 @@ function transformClassFields(context) {
90888
90895
  }
90889
90896
  function trySubstituteClassAlias(node) {
90890
90897
  if (enabledSubstitutions & 1 /* ClassAliases */) {
90891
- if (resolver.getNodeCheckFlags(node) & 2097152 /* ConstructorReferenceInClass */) {
90898
+ if (resolver.getNodeCheckFlags(node) & 536870912 /* ConstructorReference */) {
90892
90899
  const declaration = resolver.getReferencedValueDeclaration(node);
90893
90900
  if (declaration) {
90894
90901
  const classAlias = classAliases[declaration.id];
@@ -91742,7 +91749,7 @@ function transformLegacyDecorators(context) {
91742
91749
  }
91743
91750
  }
91744
91751
  function getClassAliasIfNeeded(node) {
91745
- if (resolver.getNodeCheckFlags(node) & 1048576 /* ClassWithConstructorReference */) {
91752
+ if (resolver.getNodeCheckFlags(node) & 262144 /* ContainsConstructorReference */) {
91746
91753
  enableSubstitutionForClassAliases();
91747
91754
  const classAlias = factory2.createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? idText(node.name) : "default");
91748
91755
  classAliases[getOriginalNodeId(node)] = classAlias;
@@ -91775,7 +91782,7 @@ function transformLegacyDecorators(context) {
91775
91782
  }
91776
91783
  function trySubstituteClassAlias(node) {
91777
91784
  if (classAliases) {
91778
- if (resolver.getNodeCheckFlags(node) & 2097152 /* ConstructorReferenceInClass */) {
91785
+ if (resolver.getNodeCheckFlags(node) & 536870912 /* ConstructorReference */) {
91779
91786
  const declaration = resolver.getReferencedValueDeclaration(node);
91780
91787
  if (declaration) {
91781
91788
  const classAlias = classAliases[declaration.id];
@@ -91801,6 +91808,7 @@ function transformESDecorators(context) {
91801
91808
  endLexicalEnvironment,
91802
91809
  hoistVariableDeclaration
91803
91810
  } = context;
91811
+ const languageVersion = getEmitScriptTarget(context.getCompilerOptions());
91804
91812
  let top;
91805
91813
  let classInfo;
91806
91814
  let classThis;
@@ -93302,6 +93310,17 @@ function transformESDecorators(context) {
93302
93310
  function transformDecorator(decorator) {
93303
93311
  const expression = visitNode(decorator.expression, visitor, isExpression);
93304
93312
  setEmitFlags(expression, 3072 /* NoComments */);
93313
+ const innerExpression = skipOuterExpressions(expression);
93314
+ if (isAccessExpression(innerExpression)) {
93315
+ const { target, thisArg } = factory2.createCallBinding(
93316
+ expression,
93317
+ hoistVariableDeclaration,
93318
+ languageVersion,
93319
+ /*cacheIdentifiers*/
93320
+ true
93321
+ );
93322
+ return factory2.restoreOuterExpressions(expression, factory2.createFunctionBindCall(target, thisArg, []));
93323
+ }
93305
93324
  return expression;
93306
93325
  }
93307
93326
  function createDescriptorMethod(original, name, modifiers, asteriskToken, kind, parameters, body) {
@@ -99945,10 +99964,10 @@ function transformES2015(context) {
99945
99964
  name
99946
99965
  ));
99947
99966
  const checkFlags = resolver.getNodeCheckFlags(decl);
99948
- if (checkFlags & 262144 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
99967
+ if (checkFlags & 65536 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
99949
99968
  const outParamName = factory2.createUniqueName("out_" + idText(name));
99950
99969
  let flags = 0 /* None */;
99951
- if (checkFlags & 262144 /* NeedsLoopOutParameter */) {
99970
+ if (checkFlags & 65536 /* NeedsLoopOutParameter */) {
99952
99971
  flags |= 1 /* Body */;
99953
99972
  }
99954
99973
  if (isForStatement(container)) {