typescript 5.4.0-dev.20240108 → 5.4.0-dev.20240110

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.20240108`;
21
+ var version = `${versionMajorMinor}.0-dev.20240110`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12673,7 +12673,7 @@ function isPartOfTypeNode(node) {
12673
12673
  case 116 /* VoidKeyword */:
12674
12674
  return node.parent.kind !== 222 /* VoidExpression */;
12675
12675
  case 233 /* ExpressionWithTypeArguments */:
12676
- return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
12676
+ return isPartOfTypeExpressionWithTypeArguments(node);
12677
12677
  case 168 /* TypeParameter */:
12678
12678
  return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
12679
12679
  case 80 /* Identifier */:
@@ -12698,7 +12698,7 @@ function isPartOfTypeNode(node) {
12698
12698
  }
12699
12699
  switch (parent.kind) {
12700
12700
  case 233 /* ExpressionWithTypeArguments */:
12701
- return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
12701
+ return isPartOfTypeExpressionWithTypeArguments(parent);
12702
12702
  case 168 /* TypeParameter */:
12703
12703
  return node === parent.constraint;
12704
12704
  case 352 /* JSDocTemplateTag */:
@@ -12732,6 +12732,9 @@ function isPartOfTypeNode(node) {
12732
12732
  }
12733
12733
  return false;
12734
12734
  }
12735
+ function isPartOfTypeExpressionWithTypeArguments(node) {
12736
+ return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
12737
+ }
12735
12738
  function forEachReturnStatement(body, visitor) {
12736
12739
  return traverse(body);
12737
12740
  function traverse(node) {
@@ -16070,7 +16073,7 @@ function Symbol4(flags, name) {
16070
16073
  this.exportSymbol = void 0;
16071
16074
  this.constEnumOnlyModule = void 0;
16072
16075
  this.isReferenced = void 0;
16073
- this.isAssigned = void 0;
16076
+ this.lastAssignmentPos = void 0;
16074
16077
  this.links = void 0;
16075
16078
  }
16076
16079
  function Type3(checker, flags) {
@@ -17495,10 +17498,6 @@ function isInfinityOrNaNString(name) {
17495
17498
  function isCatchClauseVariableDeclaration(node) {
17496
17499
  return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
17497
17500
  }
17498
- function isParameterOrCatchClauseVariable(symbol) {
17499
- const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
17500
- return !!declaration && (isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
17501
- }
17502
17501
  function isFunctionExpressionOrArrowFunction(node) {
17503
17502
  return node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */;
17504
17503
  }
@@ -44285,6 +44284,14 @@ function createTypeChecker(host) {
44285
44284
  emptyArray,
44286
44285
  emptyArray
44287
44286
  );
44287
+ var resolvingApparentMappedType = createAnonymousType(
44288
+ /*symbol*/
44289
+ void 0,
44290
+ emptySymbols,
44291
+ emptyArray,
44292
+ emptyArray,
44293
+ emptyArray
44294
+ );
44288
44295
  var markerSuperType = createTypeParameter();
44289
44296
  var markerSubType = createTypeParameter();
44290
44297
  markerSubType.constraint = markerSuperType;
@@ -47334,29 +47341,7 @@ function createTypeChecker(host) {
47334
47341
  function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
47335
47342
  const container = getParentOfSymbol(symbol);
47336
47343
  if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
47337
- const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
47338
- const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
47339
- const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
47340
- if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
47341
- container,
47342
- enclosingDeclaration,
47343
- 1920 /* Namespace */,
47344
- /*useOnlyExternalAliasing*/
47345
- false
47346
- )) {
47347
- return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
47348
- }
47349
- const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
47350
- return forEachEntry(t, (s) => {
47351
- if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
47352
- return s;
47353
- }
47354
- });
47355
- }) : void 0;
47356
- let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
47357
- res = append(res, objectLiteralContainer);
47358
- res = addRange(res, reexportContainers);
47359
- return res;
47344
+ return getWithAlternativeContainers(container);
47360
47345
  }
47361
47346
  const candidates = mapDefined(symbol.declarations, (d) => {
47362
47347
  if (!isAmbientModule(d) && d.parent) {
@@ -47378,7 +47363,40 @@ function createTypeChecker(host) {
47378
47363
  if (!length(candidates)) {
47379
47364
  return void 0;
47380
47365
  }
47381
- return mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
47366
+ const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
47367
+ let bestContainers = [];
47368
+ let alternativeContainers = [];
47369
+ for (const container2 of containers) {
47370
+ const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
47371
+ bestContainers = append(bestContainers, bestMatch);
47372
+ alternativeContainers = addRange(alternativeContainers, rest);
47373
+ }
47374
+ return concatenate(bestContainers, alternativeContainers);
47375
+ function getWithAlternativeContainers(container2) {
47376
+ const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
47377
+ const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
47378
+ const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
47379
+ if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
47380
+ container2,
47381
+ enclosingDeclaration,
47382
+ 1920 /* Namespace */,
47383
+ /*useOnlyExternalAliasing*/
47384
+ false
47385
+ )) {
47386
+ return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
47387
+ }
47388
+ const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
47389
+ return forEachEntry(t, (s) => {
47390
+ if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
47391
+ return s;
47392
+ }
47393
+ });
47394
+ }) : void 0;
47395
+ let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
47396
+ res = append(res, objectLiteralContainer);
47397
+ res = addRange(res, reexportContainers);
47398
+ return res;
47399
+ }
47382
47400
  function fileSymbolIfFileSymbolExportEqualsContainer(d) {
47383
47401
  return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
47384
47402
  }
@@ -47416,6 +47434,13 @@ function createTypeChecker(host) {
47416
47434
  });
47417
47435
  }
47418
47436
  function getSymbolIfSameReference(s1, s2) {
47437
+ var _a, _b;
47438
+ if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
47439
+ s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
47440
+ }
47441
+ if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
47442
+ s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
47443
+ }
47419
47444
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
47420
47445
  return s1;
47421
47446
  }
@@ -55154,14 +55179,30 @@ function createTypeChecker(host) {
55154
55179
  return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
55155
55180
  }
55156
55181
  function getApparentTypeOfMappedType(type) {
55157
- return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
55182
+ if (type.resolvedApparentType) {
55183
+ if (type.resolvedApparentType === resolvingApparentMappedType) {
55184
+ return type.resolvedApparentType = type;
55185
+ }
55186
+ return type.resolvedApparentType;
55187
+ }
55188
+ type.resolvedApparentType = resolvingApparentMappedType;
55189
+ return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
55158
55190
  }
55159
55191
  function getResolvedApparentTypeOfMappedType(type) {
55160
- const typeVariable = getHomomorphicTypeVariable(type);
55161
- if (typeVariable && !type.declaration.nameType) {
55162
- const constraint = getConstraintOfTypeParameter(typeVariable);
55192
+ const mappedType = type.target || type;
55193
+ const typeVariable = getHomomorphicTypeVariable(mappedType);
55194
+ if (typeVariable && !mappedType.declaration.nameType) {
55195
+ let constraint;
55196
+ if (!type.target) {
55197
+ constraint = getConstraintOfTypeParameter(typeVariable);
55198
+ } else {
55199
+ const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
55200
+ if (modifiersConstraint) {
55201
+ constraint = getApparentType(modifiersConstraint);
55202
+ }
55203
+ }
55163
55204
  if (constraint && everyType(constraint, isArrayOrTupleType)) {
55164
- return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
55205
+ return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
55165
55206
  }
55166
55207
  }
55167
55208
  return type;
@@ -55252,6 +55293,7 @@ function createTypeChecker(host) {
55252
55293
  clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
55253
55294
  clone2.links.containingType = containingType;
55254
55295
  clone2.links.mapper = links == null ? void 0 : links.mapper;
55296
+ clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
55255
55297
  return clone2;
55256
55298
  } else {
55257
55299
  return singleProp;
@@ -61877,6 +61919,18 @@ function createTypeChecker(host) {
61877
61919
  }
61878
61920
  return result2;
61879
61921
  }
61922
+ function getApparentMappedTypeKeys(nameType, targetType) {
61923
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
61924
+ const mappedKeys = [];
61925
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
61926
+ modifiersType,
61927
+ 8576 /* StringOrNumberLiteralOrUnique */,
61928
+ /*stringsOnly*/
61929
+ false,
61930
+ (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
61931
+ );
61932
+ return getUnionType(mappedKeys);
61933
+ }
61880
61934
  function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
61881
61935
  let result2;
61882
61936
  let originalErrorInfo;
@@ -62059,16 +62113,8 @@ function createTypeChecker(host) {
62059
62113
  const constraintType = getConstraintTypeFromMappedType(targetType);
62060
62114
  let targetKeys;
62061
62115
  if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
62062
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
62063
- const mappedKeys = [];
62064
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
62065
- modifiersType,
62066
- 8576 /* StringOrNumberLiteralOrUnique */,
62067
- /*stringsOnly*/
62068
- false,
62069
- (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
62070
- );
62071
- targetKeys = getUnionType([...mappedKeys, nameType]);
62116
+ const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
62117
+ targetKeys = getUnionType([mappedKeys, nameType]);
62072
62118
  } else {
62073
62119
  targetKeys = nameType || constraintType;
62074
62120
  }
@@ -62239,9 +62285,18 @@ function createTypeChecker(host) {
62239
62285
  }
62240
62286
  }
62241
62287
  } else if (sourceFlags & 4194304 /* Index */) {
62242
- if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2)) {
62288
+ const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
62289
+ if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
62243
62290
  return result2;
62244
62291
  }
62292
+ if (isDeferredMappedIndex) {
62293
+ const mappedType = source2.type;
62294
+ const nameType = getNameTypeFromMappedType(mappedType);
62295
+ const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
62296
+ if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
62297
+ return result2;
62298
+ }
62299
+ }
62245
62300
  } else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
62246
62301
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
62247
62302
  const constraint = getBaseConstraintOfType(source2);
@@ -66178,7 +66233,7 @@ function createTypeChecker(host) {
66178
66233
  case 80 /* Identifier */:
66179
66234
  if (!isThisInTypeQuery(node)) {
66180
66235
  const symbol = getResolvedSymbol(node);
66181
- return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
66236
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
66182
66237
  }
66183
66238
  break;
66184
66239
  case 211 /* PropertyAccessExpression */:
@@ -66187,7 +66242,7 @@ function createTypeChecker(host) {
66187
66242
  case 206 /* ObjectBindingPattern */:
66188
66243
  case 207 /* ArrayBindingPattern */:
66189
66244
  const rootDeclaration = getRootDeclaration(node.parent);
66190
- return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
66245
+ return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
66191
66246
  }
66192
66247
  return false;
66193
66248
  }
@@ -67268,10 +67323,17 @@ function createTypeChecker(host) {
67268
67323
  return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
67269
67324
  }
67270
67325
  function isSymbolAssigned(symbol) {
67271
- if (!symbol.valueDeclaration) {
67326
+ return !isPastLastAssignment(
67327
+ symbol,
67328
+ /*location*/
67329
+ void 0
67330
+ );
67331
+ }
67332
+ function isPastLastAssignment(symbol, location) {
67333
+ const parent = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
67334
+ if (!parent) {
67272
67335
  return false;
67273
67336
  }
67274
- const parent = getRootDeclaration(symbol.valueDeclaration).parent;
67275
67337
  const links = getNodeLinks(parent);
67276
67338
  if (!(links.flags & 131072 /* AssignmentsMarked */)) {
67277
67339
  links.flags |= 131072 /* AssignmentsMarked */;
@@ -67279,7 +67341,7 @@ function createTypeChecker(host) {
67279
67341
  markNodeAssignments(parent);
67280
67342
  }
67281
67343
  }
67282
- return symbol.isAssigned || false;
67344
+ return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
67283
67345
  }
67284
67346
  function isSomeSymbolAssigned(rootDeclaration) {
67285
67347
  Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
@@ -67292,23 +67354,81 @@ function createTypeChecker(host) {
67292
67354
  return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
67293
67355
  }
67294
67356
  function hasParentWithAssignmentsMarked(node) {
67295
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
67357
+ return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
67358
+ }
67359
+ function isFunctionOrSourceFile(node) {
67360
+ return isFunctionLikeDeclaration(node) || isSourceFile(node);
67296
67361
  }
67297
67362
  function markNodeAssignments(node) {
67298
- if (node.kind === 80 /* Identifier */) {
67299
- if (isAssignmentTarget(node)) {
67300
- const symbol = getResolvedSymbol(node);
67301
- if (isParameterOrCatchClauseVariable(symbol)) {
67302
- symbol.isAssigned = true;
67363
+ switch (node.kind) {
67364
+ case 80 /* Identifier */:
67365
+ if (isAssignmentTarget(node)) {
67366
+ const symbol = getResolvedSymbol(node);
67367
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
67368
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
67369
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
67370
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
67371
+ }
67303
67372
  }
67373
+ return;
67374
+ case 281 /* ExportSpecifier */:
67375
+ const exportDeclaration = node.parent.parent;
67376
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
67377
+ const symbol = resolveEntityName(
67378
+ node.propertyName || node.name,
67379
+ 111551 /* Value */,
67380
+ /*ignoreErrors*/
67381
+ true,
67382
+ /*dontResolveAlias*/
67383
+ true
67384
+ );
67385
+ if (symbol && isParameterOrMutableLocalVariable(symbol)) {
67386
+ symbol.lastAssignmentPos = Number.MAX_VALUE;
67387
+ }
67388
+ }
67389
+ return;
67390
+ case 264 /* InterfaceDeclaration */:
67391
+ case 265 /* TypeAliasDeclaration */:
67392
+ case 266 /* EnumDeclaration */:
67393
+ return;
67394
+ }
67395
+ if (isTypeNode(node)) {
67396
+ return;
67397
+ }
67398
+ forEachChild(node, markNodeAssignments);
67399
+ }
67400
+ function extendAssignmentPosition(node, declaration) {
67401
+ let pos = node.pos;
67402
+ while (node && node.pos > declaration.pos) {
67403
+ switch (node.kind) {
67404
+ case 243 /* VariableStatement */:
67405
+ case 244 /* ExpressionStatement */:
67406
+ case 245 /* IfStatement */:
67407
+ case 246 /* DoStatement */:
67408
+ case 247 /* WhileStatement */:
67409
+ case 248 /* ForStatement */:
67410
+ case 249 /* ForInStatement */:
67411
+ case 250 /* ForOfStatement */:
67412
+ case 254 /* WithStatement */:
67413
+ case 255 /* SwitchStatement */:
67414
+ case 258 /* TryStatement */:
67415
+ case 263 /* ClassDeclaration */:
67416
+ pos = node.end;
67304
67417
  }
67305
- } else {
67306
- forEachChild(node, markNodeAssignments);
67418
+ node = node.parent;
67307
67419
  }
67420
+ return pos;
67308
67421
  }
67309
67422
  function isConstantVariable(symbol) {
67310
67423
  return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
67311
67424
  }
67425
+ function isParameterOrMutableLocalVariable(symbol) {
67426
+ const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
67427
+ return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
67428
+ }
67429
+ function isMutableLocalVariableDeclaration(declaration) {
67430
+ return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
67431
+ }
67312
67432
  function parameterInitializerContainsUndefined(declaration) {
67313
67433
  const links = getNodeLinks(declaration);
67314
67434
  if (links.parameterInitializerContainsUndefined === void 0) {
@@ -67557,7 +67677,7 @@ function createTypeChecker(host) {
67557
67677
  const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
67558
67678
  const typeIsAutomatic = type === autoType || type === autoArrayType;
67559
67679
  const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 235 /* NonNullExpression */;
67560
- while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameter2 && !isSymbolAssigned(localOrExportSymbol))) {
67680
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
67561
67681
  flowContainer = getControlFlowContainer(flowContainer);
67562
67682
  }
67563
67683
  const assumeInitialized = isParameter2 || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
@@ -113416,7 +113536,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113416
113536
  function willEmitLeadingNewLine(node) {
113417
113537
  if (!currentSourceFile)
113418
113538
  return false;
113419
- if (some(getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
113539
+ const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
113540
+ if (leadingCommentRanges) {
113541
+ const parseNode = getParseTreeNode(node);
113542
+ if (parseNode && isParenthesizedExpression(parseNode.parent)) {
113543
+ return true;
113544
+ }
113545
+ }
113546
+ if (some(leadingCommentRanges, commentWillEmitNewLine))
113420
113547
  return true;
113421
113548
  if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
113422
113549
  return true;