@typescript-deploys/pr-build 5.4.0-pr-56034-9 → 5.4.0-pr-55774-44

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-insiders.20240108`;
21
+ var version = `${versionMajorMinor}.0-insiders.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
  }
@@ -17672,9 +17671,6 @@ var stringReplace = String.prototype.replace;
17672
17671
  function replaceFirstStar(s, replacement) {
17673
17672
  return stringReplace.call(s, "*", replacement);
17674
17673
  }
17675
- function getNameFromImportAttribute(node) {
17676
- return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
17677
- }
17678
17674
 
17679
17675
  // src/compiler/factory/baseNodeFactory.ts
17680
17676
  function createBaseNodeFactory() {
@@ -44288,6 +44284,14 @@ function createTypeChecker(host) {
44288
44284
  emptyArray,
44289
44285
  emptyArray
44290
44286
  );
44287
+ var resolvingApparentMappedType = createAnonymousType(
44288
+ /*symbol*/
44289
+ void 0,
44290
+ emptySymbols,
44291
+ emptyArray,
44292
+ emptyArray,
44293
+ emptyArray
44294
+ );
44291
44295
  var markerSuperType = createTypeParameter();
44292
44296
  var markerSubType = createTypeParameter();
44293
44297
  markerSubType.constraint = markerSuperType;
@@ -44442,7 +44446,6 @@ function createTypeChecker(host) {
44442
44446
  var deferredGlobalImportMetaType;
44443
44447
  var deferredGlobalImportMetaExpressionType;
44444
44448
  var deferredGlobalImportCallOptionsType;
44445
- var deferredGlobalImportAttributesType;
44446
44449
  var deferredGlobalDisposableType;
44447
44450
  var deferredGlobalAsyncDisposableType;
44448
44451
  var deferredGlobalExtractSymbol;
@@ -47338,29 +47341,7 @@ function createTypeChecker(host) {
47338
47341
  function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
47339
47342
  const container = getParentOfSymbol(symbol);
47340
47343
  if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
47341
- const additionalContainers = mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
47342
- const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
47343
- const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
47344
- if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
47345
- container,
47346
- enclosingDeclaration,
47347
- 1920 /* Namespace */,
47348
- /*useOnlyExternalAliasing*/
47349
- false
47350
- )) {
47351
- return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
47352
- }
47353
- const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
47354
- return forEachEntry(t, (s) => {
47355
- if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
47356
- return s;
47357
- }
47358
- });
47359
- }) : void 0;
47360
- let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
47361
- res = append(res, objectLiteralContainer);
47362
- res = addRange(res, reexportContainers);
47363
- return res;
47344
+ return getWithAlternativeContainers(container);
47364
47345
  }
47365
47346
  const candidates = mapDefined(symbol.declarations, (d) => {
47366
47347
  if (!isAmbientModule(d) && d.parent) {
@@ -47382,7 +47363,40 @@ function createTypeChecker(host) {
47382
47363
  if (!length(candidates)) {
47383
47364
  return void 0;
47384
47365
  }
47385
- 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
+ }
47386
47400
  function fileSymbolIfFileSymbolExportEqualsContainer(d) {
47387
47401
  return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
47388
47402
  }
@@ -47420,6 +47434,13 @@ function createTypeChecker(host) {
47420
47434
  });
47421
47435
  }
47422
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
+ }
47423
47444
  if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
47424
47445
  return s1;
47425
47446
  }
@@ -52743,24 +52764,6 @@ function createTypeChecker(host) {
52743
52764
  0 /* Normal */
52744
52765
  ), declaration, reportErrors2);
52745
52766
  }
52746
- function getTypeFromImportAttributes(node) {
52747
- const links = getNodeLinks(node);
52748
- if (!links.resolvedType) {
52749
- const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
52750
- const members = createSymbolTable();
52751
- forEach(node.elements, (attr) => {
52752
- const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
52753
- member.parent = symbol;
52754
- member.links.type = checkImportAttribute(attr);
52755
- member.links.target = member;
52756
- members.set(member.escapedName, member);
52757
- });
52758
- const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
52759
- type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
52760
- links.resolvedType = type;
52761
- }
52762
- return links.resolvedType;
52763
- }
52764
52767
  function isGlobalSymbolConstructor(node) {
52765
52768
  const symbol = getSymbolOfNode(node);
52766
52769
  const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
@@ -54627,6 +54630,14 @@ function createTypeChecker(host) {
54627
54630
  return getCheckFlags(s) & 4096 /* Late */;
54628
54631
  }
54629
54632
  function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
54633
+ if (isTupleType(type)) {
54634
+ forEachType(getUnionType(getElementTypes(type).map((_, i) => getStringLiteralType("" + i))), cb);
54635
+ return;
54636
+ }
54637
+ if (isArrayType(type)) {
54638
+ cb(numberType);
54639
+ return;
54640
+ }
54630
54641
  for (const prop of getPropertiesOfType(type)) {
54631
54642
  cb(getLiteralTypeFromProperty(prop, include));
54632
54643
  }
@@ -55176,14 +55187,30 @@ function createTypeChecker(host) {
55176
55187
  return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
55177
55188
  }
55178
55189
  function getApparentTypeOfMappedType(type) {
55179
- return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
55190
+ if (type.resolvedApparentType) {
55191
+ if (type.resolvedApparentType === resolvingApparentMappedType) {
55192
+ return type.resolvedApparentType = type;
55193
+ }
55194
+ return type.resolvedApparentType;
55195
+ }
55196
+ type.resolvedApparentType = resolvingApparentMappedType;
55197
+ return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
55180
55198
  }
55181
55199
  function getResolvedApparentTypeOfMappedType(type) {
55182
- const typeVariable = getHomomorphicTypeVariable(type);
55183
- if (typeVariable && !type.declaration.nameType) {
55184
- const constraint = getConstraintOfTypeParameter(typeVariable);
55200
+ const mappedType = type.target || type;
55201
+ const typeVariable = getHomomorphicTypeVariable(mappedType);
55202
+ if (typeVariable && !mappedType.declaration.nameType) {
55203
+ let constraint;
55204
+ if (!type.target) {
55205
+ constraint = getConstraintOfTypeParameter(typeVariable);
55206
+ } else {
55207
+ const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
55208
+ if (modifiersConstraint) {
55209
+ constraint = getApparentType(modifiersConstraint);
55210
+ }
55211
+ }
55185
55212
  if (constraint && everyType(constraint, isArrayOrTupleType)) {
55186
- return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
55213
+ return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
55187
55214
  }
55188
55215
  }
55189
55216
  return type;
@@ -55274,6 +55301,7 @@ function createTypeChecker(host) {
55274
55301
  clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
55275
55302
  clone2.links.containingType = containingType;
55276
55303
  clone2.links.mapper = links == null ? void 0 : links.mapper;
55304
+ clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
55277
55305
  return clone2;
55278
55306
  } else {
55279
55307
  return singleProp;
@@ -56494,7 +56522,7 @@ function createTypeChecker(host) {
56494
56522
  if (constraint) {
56495
56523
  constraints = append(constraints, constraint);
56496
56524
  }
56497
- } else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && node === parent.type) {
56525
+ } else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 200 /* MappedType */ && (node === parent.type || node === parent.nameType)) {
56498
56526
  const mappedType = getTypeFromTypeNode(parent);
56499
56527
  if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
56500
56528
  const typeParameter = getHomomorphicTypeVariable(mappedType);
@@ -56742,14 +56770,6 @@ function createTypeChecker(host) {
56742
56770
  reportErrors2
56743
56771
  )) || emptyObjectType;
56744
56772
  }
56745
- function getGlobalImportAttributesType(reportErrors2) {
56746
- return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
56747
- "ImportAttributes",
56748
- /*arity*/
56749
- 0,
56750
- reportErrors2
56751
- )) || emptyObjectType;
56752
- }
56753
56773
  function getGlobalESSymbolConstructorSymbol(reportErrors2) {
56754
56774
  return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
56755
56775
  }
@@ -61907,6 +61927,18 @@ function createTypeChecker(host) {
61907
61927
  }
61908
61928
  return result2;
61909
61929
  }
61930
+ function getApparentMappedTypeKeys(nameType, targetType) {
61931
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
61932
+ const mappedKeys = [];
61933
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
61934
+ modifiersType,
61935
+ 8576 /* StringOrNumberLiteralOrUnique */,
61936
+ /*stringsOnly*/
61937
+ false,
61938
+ (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
61939
+ );
61940
+ return getUnionType(mappedKeys);
61941
+ }
61910
61942
  function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
61911
61943
  let result2;
61912
61944
  let originalErrorInfo;
@@ -62089,16 +62121,8 @@ function createTypeChecker(host) {
62089
62121
  const constraintType = getConstraintTypeFromMappedType(targetType);
62090
62122
  let targetKeys;
62091
62123
  if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
62092
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
62093
- const mappedKeys = [];
62094
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
62095
- modifiersType,
62096
- 8576 /* StringOrNumberLiteralOrUnique */,
62097
- /*stringsOnly*/
62098
- false,
62099
- (t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
62100
- );
62101
- targetKeys = getUnionType([...mappedKeys, nameType]);
62124
+ const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
62125
+ targetKeys = getUnionType([mappedKeys, nameType]);
62102
62126
  } else {
62103
62127
  targetKeys = nameType || constraintType;
62104
62128
  }
@@ -62269,9 +62293,18 @@ function createTypeChecker(host) {
62269
62293
  }
62270
62294
  }
62271
62295
  } else if (sourceFlags & 4194304 /* Index */) {
62272
- if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2)) {
62296
+ const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
62297
+ if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
62273
62298
  return result2;
62274
62299
  }
62300
+ if (isDeferredMappedIndex) {
62301
+ const mappedType = source2.type;
62302
+ const nameType = getNameTypeFromMappedType(mappedType);
62303
+ const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
62304
+ if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
62305
+ return result2;
62306
+ }
62307
+ }
62275
62308
  } else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
62276
62309
  if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
62277
62310
  const constraint = getBaseConstraintOfType(source2);
@@ -66208,7 +66241,7 @@ function createTypeChecker(host) {
66208
66241
  case 80 /* Identifier */:
66209
66242
  if (!isThisInTypeQuery(node)) {
66210
66243
  const symbol = getResolvedSymbol(node);
66211
- return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
66244
+ return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
66212
66245
  }
66213
66246
  break;
66214
66247
  case 211 /* PropertyAccessExpression */:
@@ -66217,7 +66250,7 @@ function createTypeChecker(host) {
66217
66250
  case 206 /* ObjectBindingPattern */:
66218
66251
  case 207 /* ArrayBindingPattern */:
66219
66252
  const rootDeclaration = getRootDeclaration(node.parent);
66220
- return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
66253
+ return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
66221
66254
  }
66222
66255
  return false;
66223
66256
  }
@@ -67298,10 +67331,17 @@ function createTypeChecker(host) {
67298
67331
  return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
67299
67332
  }
67300
67333
  function isSymbolAssigned(symbol) {
67301
- if (!symbol.valueDeclaration) {
67334
+ return !isPastLastAssignment(
67335
+ symbol,
67336
+ /*location*/
67337
+ void 0
67338
+ );
67339
+ }
67340
+ function isPastLastAssignment(symbol, location) {
67341
+ const parent = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
67342
+ if (!parent) {
67302
67343
  return false;
67303
67344
  }
67304
- const parent = getRootDeclaration(symbol.valueDeclaration).parent;
67305
67345
  const links = getNodeLinks(parent);
67306
67346
  if (!(links.flags & 131072 /* AssignmentsMarked */)) {
67307
67347
  links.flags |= 131072 /* AssignmentsMarked */;
@@ -67309,7 +67349,7 @@ function createTypeChecker(host) {
67309
67349
  markNodeAssignments(parent);
67310
67350
  }
67311
67351
  }
67312
- return symbol.isAssigned || false;
67352
+ return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
67313
67353
  }
67314
67354
  function isSomeSymbolAssigned(rootDeclaration) {
67315
67355
  Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
@@ -67322,23 +67362,81 @@ function createTypeChecker(host) {
67322
67362
  return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
67323
67363
  }
67324
67364
  function hasParentWithAssignmentsMarked(node) {
67325
- return !!findAncestor(node.parent, (node2) => (isFunctionLike(node2) || isCatchClause(node2)) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
67365
+ return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
67366
+ }
67367
+ function isFunctionOrSourceFile(node) {
67368
+ return isFunctionLikeDeclaration(node) || isSourceFile(node);
67326
67369
  }
67327
67370
  function markNodeAssignments(node) {
67328
- if (node.kind === 80 /* Identifier */) {
67329
- if (isAssignmentTarget(node)) {
67330
- const symbol = getResolvedSymbol(node);
67331
- if (isParameterOrCatchClauseVariable(symbol)) {
67332
- symbol.isAssigned = true;
67371
+ switch (node.kind) {
67372
+ case 80 /* Identifier */:
67373
+ if (isAssignmentTarget(node)) {
67374
+ const symbol = getResolvedSymbol(node);
67375
+ if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
67376
+ const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
67377
+ const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
67378
+ symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
67379
+ }
67380
+ }
67381
+ return;
67382
+ case 281 /* ExportSpecifier */:
67383
+ const exportDeclaration = node.parent.parent;
67384
+ if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
67385
+ const symbol = resolveEntityName(
67386
+ node.propertyName || node.name,
67387
+ 111551 /* Value */,
67388
+ /*ignoreErrors*/
67389
+ true,
67390
+ /*dontResolveAlias*/
67391
+ true
67392
+ );
67393
+ if (symbol && isParameterOrMutableLocalVariable(symbol)) {
67394
+ symbol.lastAssignmentPos = Number.MAX_VALUE;
67395
+ }
67333
67396
  }
67397
+ return;
67398
+ case 264 /* InterfaceDeclaration */:
67399
+ case 265 /* TypeAliasDeclaration */:
67400
+ case 266 /* EnumDeclaration */:
67401
+ return;
67402
+ }
67403
+ if (isTypeNode(node)) {
67404
+ return;
67405
+ }
67406
+ forEachChild(node, markNodeAssignments);
67407
+ }
67408
+ function extendAssignmentPosition(node, declaration) {
67409
+ let pos = node.pos;
67410
+ while (node && node.pos > declaration.pos) {
67411
+ switch (node.kind) {
67412
+ case 243 /* VariableStatement */:
67413
+ case 244 /* ExpressionStatement */:
67414
+ case 245 /* IfStatement */:
67415
+ case 246 /* DoStatement */:
67416
+ case 247 /* WhileStatement */:
67417
+ case 248 /* ForStatement */:
67418
+ case 249 /* ForInStatement */:
67419
+ case 250 /* ForOfStatement */:
67420
+ case 254 /* WithStatement */:
67421
+ case 255 /* SwitchStatement */:
67422
+ case 258 /* TryStatement */:
67423
+ case 263 /* ClassDeclaration */:
67424
+ pos = node.end;
67334
67425
  }
67335
- } else {
67336
- forEachChild(node, markNodeAssignments);
67426
+ node = node.parent;
67337
67427
  }
67428
+ return pos;
67338
67429
  }
67339
67430
  function isConstantVariable(symbol) {
67340
67431
  return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
67341
67432
  }
67433
+ function isParameterOrMutableLocalVariable(symbol) {
67434
+ const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
67435
+ return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
67436
+ }
67437
+ function isMutableLocalVariableDeclaration(declaration) {
67438
+ return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
67439
+ }
67342
67440
  function parameterInitializerContainsUndefined(declaration) {
67343
67441
  const links = getNodeLinks(declaration);
67344
67442
  if (links.parameterInitializerContainsUndefined === void 0) {
@@ -67587,7 +67685,7 @@ function createTypeChecker(host) {
67587
67685
  const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
67588
67686
  const typeIsAutomatic = type === autoType || type === autoArrayType;
67589
67687
  const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 235 /* NonNullExpression */;
67590
- while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameter2 && !isSymbolAssigned(localOrExportSymbol))) {
67688
+ while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
67591
67689
  flowContainer = getControlFlowContainer(flowContainer);
67592
67690
  }
67593
67691
  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 */;
@@ -68858,8 +68956,6 @@ function createTypeChecker(host) {
68858
68956
  case 286 /* JsxOpeningElement */:
68859
68957
  case 285 /* JsxSelfClosingElement */:
68860
68958
  return getContextualJsxElementAttributesType(parent, contextFlags);
68861
- case 301 /* ImportAttribute */:
68862
- return getContextualImportAttributeType(parent);
68863
68959
  }
68864
68960
  return void 0;
68865
68961
  }
@@ -68907,12 +69003,6 @@ function createTypeChecker(host) {
68907
69003
  }
68908
69004
  }
68909
69005
  }
68910
- function getContextualImportAttributeType(node) {
68911
- return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
68912
- /*reportErrors*/
68913
- false
68914
- ), getNameFromImportAttribute(node));
68915
- }
68916
69006
  function getContextualJsxElementAttributesType(node, contextFlags) {
68917
69007
  if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
68918
69008
  const index = findContextualNode(
@@ -80998,13 +81088,6 @@ function createTypeChecker(host) {
80998
81088
  var _a;
80999
81089
  const node = declaration.attributes;
81000
81090
  if (node) {
81001
- const importAttributesType = getGlobalImportAttributesType(
81002
- /*reportErrors*/
81003
- true
81004
- );
81005
- if (importAttributesType !== emptyObjectType) {
81006
- checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
81007
- }
81008
81091
  const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
81009
81092
  const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
81010
81093
  const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
@@ -81024,9 +81107,6 @@ function createTypeChecker(host) {
81024
81107
  }
81025
81108
  }
81026
81109
  }
81027
- function checkImportAttribute(node) {
81028
- return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
81029
- }
81030
81110
  function checkImportDeclaration(node) {
81031
81111
  if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
81032
81112
  return;
@@ -82442,12 +82522,6 @@ function createTypeChecker(host) {
82442
82522
  if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
82443
82523
  return checkMetaPropertyKeyword(node.parent);
82444
82524
  }
82445
- if (isImportAttributes(node)) {
82446
- return getGlobalImportAttributesType(
82447
- /*reportErrors*/
82448
- false
82449
- );
82450
- }
82451
82525
  return errorType;
82452
82526
  }
82453
82527
  function getTypeOfAssignmentPattern(expr) {
@@ -113470,7 +113544,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
113470
113544
  function willEmitLeadingNewLine(node) {
113471
113545
  if (!currentSourceFile)
113472
113546
  return false;
113473
- if (some(getLeadingCommentRanges(currentSourceFile.text, node.pos), commentWillEmitNewLine))
113547
+ const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
113548
+ if (leadingCommentRanges) {
113549
+ const parseNode = getParseTreeNode(node);
113550
+ if (parseNode && isParenthesizedExpression(parseNode.parent)) {
113551
+ return true;
113552
+ }
113553
+ }
113554
+ if (some(leadingCommentRanges, commentWillEmitNewLine))
113474
113555
  return true;
113475
113556
  if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
113476
113557
  return true;
@@ -119528,7 +119609,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119528
119609
  }
119529
119610
  const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
119530
119611
  const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
119531
- const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
119612
+ const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
119532
119613
  const resolvedFileName = resolution.resolvedFileName;
119533
119614
  if (isFromNodeModulesSearch) {
119534
119615
  currentNodeModulesDepth++;