@typescript-deploys/pr-build 4.7.0-pr-48168-4 → 4.7.0-pr-48168-8

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/tsserver.js CHANGED
@@ -15347,10 +15347,23 @@ var ts;
15347
15347
  && node.parent.parent.kind === 236 /* VariableStatement */;
15348
15348
  }
15349
15349
  ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
15350
+ function isCommonJsExportedExpression(node) {
15351
+ if (!isInJSFile(node))
15352
+ return false;
15353
+ return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) ||
15354
+ isCommonJsExportPropertyAssignment(node.parent);
15355
+ }
15356
+ ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
15357
+ function isCommonJsExportPropertyAssignment(node) {
15358
+ if (!isInJSFile(node))
15359
+ return false;
15360
+ return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */);
15361
+ }
15362
+ ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
15350
15363
  function isValidESSymbolDeclaration(node) {
15351
- return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15364
+ return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15352
15365
  ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
15353
- ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
15366
+ ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
15354
15367
  }
15355
15368
  ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
15356
15369
  function introducesArgumentsExoticObject(node) {
@@ -47669,6 +47682,8 @@ var ts;
47669
47682
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
47670
47683
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
47671
47684
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
47685
+ var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
47686
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
47672
47687
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47673
47688
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47674
47689
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -51573,10 +51588,16 @@ var ts;
51573
51588
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
51574
51589
  var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
51575
51590
  var appropriateConstraintTypeNode;
51591
+ var newTypeVariable;
51576
51592
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
51577
51593
  // We have a { [P in keyof T]: X }
51578
51594
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
51579
- appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51595
+ if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51596
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
51597
+ var name = typeParameterToName(newParam, context);
51598
+ newTypeVariable = ts.factory.createTypeReferenceNode(name);
51599
+ }
51600
+ appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51580
51601
  }
51581
51602
  else {
51582
51603
  appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
@@ -51586,7 +51607,14 @@ var ts;
51586
51607
  var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
51587
51608
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
51588
51609
  context.approximateLength += 10;
51589
- return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51610
+ var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51611
+ if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51612
+ // homomorphic mapped type with a non-homomorphic naive inlining
51613
+ // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
51614
+ // type stays homomorphic
51615
+ return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
51616
+ }
51617
+ return result;
51590
51618
  }
51591
51619
  function createAnonymousTypeNode(type) {
51592
51620
  var _a;
@@ -53207,7 +53235,7 @@ var ts;
53207
53235
  // If it's a class/interface/function: emit a class/interface/function with a `default` modifier
53208
53236
  // These forms can merge, eg (`export default 12; export default interface A {}`)
53209
53237
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
53210
- var _a, _b;
53238
+ var _a, _b, _c, _d;
53211
53239
  var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
53212
53240
  var isDefault = symbol.escapedName === "default" /* Default */;
53213
53241
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
@@ -53258,17 +53286,21 @@ var ts;
53258
53286
  else {
53259
53287
  // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_
53260
53288
  // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
53261
- var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined
53262
- : isConstVariable(symbol) ? 2 /* Const */
53289
+ var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
53290
+ ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
53291
+ ? 2 /* Const */
53292
+ : undefined
53293
+ : isConstVariable(symbol)
53294
+ ? 2 /* Const */
53263
53295
  : 1 /* Let */;
53264
53296
  var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
53265
53297
  var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
53266
53298
  if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
53267
53299
  textRange = textRange.parent.parent;
53268
53300
  }
53269
- var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression);
53301
+ var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
53270
53302
  if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
53271
- && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53303
+ && ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53272
53304
  var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
53273
53305
  addResult(ts.factory.createExportDeclaration(
53274
53306
  /*decorators*/ undefined,
@@ -53348,8 +53380,8 @@ var ts;
53348
53380
  // synthesize export * from "moduleReference"
53349
53381
  // Straightforward - only one thing to do - make an export declaration
53350
53382
  if (symbol.declarations) {
53351
- for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) {
53352
- var node = _c[_i];
53383
+ for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
53384
+ var node = _e[_i];
53353
53385
  var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53354
53386
  if (!resolvedModule)
53355
53387
  continue;
@@ -55155,7 +55187,10 @@ var ts;
55155
55187
  if (containsSameNamedThisProperty(expression.left, expression.right)) {
55156
55188
  return anyType;
55157
55189
  }
55158
- var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
55190
+ var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression)));
55191
+ var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
55192
+ : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
55193
+ : getWidenedLiteralType(checkExpressionCached(expression.right));
55159
55194
  if (type.flags & 524288 /* Object */ &&
55160
55195
  kind === 2 /* ModuleExports */ &&
55161
55196
  symbol.escapedName === "export=" /* ExportEquals */) {
@@ -58160,10 +58195,10 @@ var ts;
58160
58195
  else if (type !== firstType) {
58161
58196
  checkFlags |= 64 /* HasNonUniformType */;
58162
58197
  }
58163
- if (isLiteralType(type) || isPatternLiteralType(type)) {
58198
+ if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58164
58199
  checkFlags |= 128 /* HasLiteralType */;
58165
58200
  }
58166
- if (type.flags & 131072 /* Never */) {
58201
+ if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
58167
58202
  checkFlags |= 131072 /* HasNeverType */;
58168
58203
  }
58169
58204
  propTypes.push(type);
@@ -60704,10 +60739,24 @@ var ts;
60704
60739
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
60705
60740
  /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
60706
60741
  }
60742
+ /**
60743
+ * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
60744
+ * must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
60745
+ * type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
60746
+ * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
60747
+ */
60748
+ function isPossiblyReducibleByInstantiation(type) {
60749
+ return ts.some(type.types, function (t) {
60750
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
60751
+ return getReducedType(uniqueFilled) !== uniqueFilled;
60752
+ });
60753
+ }
60707
60754
  function getIndexType(type, stringsOnly, noIndexSignatures) {
60708
60755
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
60709
60756
  type = getReducedType(type);
60710
- return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60757
+ return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
60758
+ ? getIndexTypeForGenericType(type, stringsOnly)
60759
+ : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60711
60760
  type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60712
60761
  type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
60713
60762
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
@@ -61335,6 +61384,10 @@ var ts;
61335
61384
  }
61336
61385
  return type;
61337
61386
  }
61387
+ function maybeCloneTypeParameter(p) {
61388
+ var constraint = getConstraintOfTypeParameter(p);
61389
+ return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
61390
+ }
61338
61391
  function isTypicalNondistributiveConditional(root) {
61339
61392
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61340
61393
  }
@@ -61353,37 +61406,65 @@ var ts;
61353
61406
  var result;
61354
61407
  var extraTypes;
61355
61408
  var tailCount = 0;
61356
- // We loop here for an immediately nested conditional type in the false position, effectively treating
61357
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61358
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61359
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61360
- // cases we increment the tail recursion counter and stop after 1000 iterations.
61361
- while (true) {
61409
+ var _loop_18 = function () {
61362
61410
  if (tailCount === 1000) {
61363
61411
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
61364
61412
  result = errorType;
61365
- break;
61413
+ return "break";
61366
61414
  }
61367
61415
  var isUnwrapped = isTypicalNondistributiveConditional(root);
61368
61416
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
61369
61417
  var checkTypeInstantiable = isGenericType(checkType);
61370
61418
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
61371
61419
  if (checkType === wildcardType || extendsType === wildcardType) {
61372
- return wildcardType;
61420
+ return { value: wildcardType };
61373
61421
  }
61374
61422
  var combinedMapper = void 0;
61375
61423
  if (root.inferTypeParameters) {
61376
- var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */);
61377
- if (!checkTypeInstantiable) {
61424
+ // When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
61425
+ // instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
61426
+ // may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
61427
+ // [1] Eg, if we have `Foo<T, U extends T>` and `Foo<number, infer B>` - `B` is constrained to `T`, which, in turn, has been instantiated
61428
+ // as `number`
61429
+ // Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
61430
+ // [2] Eg, if we have `Foo<T, U extends T>` and `Foo<Q, infer B>` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
61431
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
61432
+ // So we need to:
61433
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
61434
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
61435
+ // * instantiate the extends type with the clones
61436
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
61437
+ // This means we have three mappers that need applying:
61438
+ // * The original `mapper` used to create this conditional
61439
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
61440
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
61441
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
61442
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
61443
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */);
61444
+ if (freshMapper) {
61445
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
61446
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
61447
+ var p = freshParams_1[_i];
61448
+ if (root.inferTypeParameters.indexOf(p) === -1) {
61449
+ p.mapper = freshCombinedMapper;
61450
+ }
61451
+ }
61452
+ }
61453
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
61454
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
61455
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
61456
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
61457
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
61378
61458
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
61379
61459
  // conditional type instead of deferring resolution. Also, we always want strict function
61380
61460
  // types rules (i.e. proper contravariance) for inferences.
61381
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61461
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61382
61462
  }
61463
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
61383
61464
  // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
61384
61465
  // those type parameters are used in type references (see getInferredTypeParameterConstraint). For
61385
61466
  // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
61386
- combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
61467
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
61387
61468
  }
61388
61469
  // Instantiate the extends type including inferences for 'infer T' type parameters
61389
61470
  var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
@@ -61405,14 +61486,14 @@ var ts;
61405
61486
  var newRoot = falseType_1.root;
61406
61487
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
61407
61488
  root = newRoot;
61408
- continue;
61489
+ return "continue";
61409
61490
  }
61410
61491
  if (canTailRecurse(falseType_1, mapper)) {
61411
- continue;
61492
+ return "continue";
61412
61493
  }
61413
61494
  }
61414
61495
  result = instantiateType(falseType_1, mapper);
61415
- break;
61496
+ return "break";
61416
61497
  }
61417
61498
  // Return trueType for a definitely true extends check. We check instantiations of the two
61418
61499
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -61423,10 +61504,10 @@ var ts;
61423
61504
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
61424
61505
  var trueMapper = combinedMapper || mapper;
61425
61506
  if (canTailRecurse(trueType_1, trueMapper)) {
61426
- continue;
61507
+ return "continue";
61427
61508
  }
61428
61509
  result = instantiateType(trueType_1, trueMapper);
61429
- break;
61510
+ return "break";
61430
61511
  }
61431
61512
  }
61432
61513
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -61438,7 +61519,19 @@ var ts;
61438
61519
  result.combinedMapper = combinedMapper;
61439
61520
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61440
61521
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61441
- break;
61522
+ return "break";
61523
+ };
61524
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
61525
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61526
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61527
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61528
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
61529
+ while (true) {
61530
+ var state_5 = _loop_18();
61531
+ if (typeof state_5 === "object")
61532
+ return state_5.value;
61533
+ if (state_5 === "break")
61534
+ break;
61442
61535
  }
61443
61536
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
61444
61537
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -61860,9 +61953,11 @@ var ts;
61860
61953
  }
61861
61954
  function getESSymbolLikeTypeForNode(node) {
61862
61955
  if (ts.isValidESSymbolDeclaration(node)) {
61863
- var symbol = getSymbolOfNode(node);
61864
- var links = getSymbolLinks(symbol);
61865
- return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
61956
+ var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
61957
+ if (symbol) {
61958
+ var links = getSymbolLinks(symbol);
61959
+ return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
61960
+ }
61866
61961
  }
61867
61962
  return esSymbolType;
61868
61963
  }
@@ -62506,6 +62601,10 @@ var ts;
62506
62601
  }
62507
62602
  return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
62508
62603
  }
62604
+ function getUniqueLiteralFilledInstantiation(type) {
62605
+ return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62606
+ type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
62607
+ }
62509
62608
  function getPermissiveInstantiation(type) {
62510
62609
  return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62511
62610
  type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
@@ -63965,7 +64064,7 @@ var ts;
63965
64064
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
63966
64065
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
63967
64066
  }
63968
- var _loop_18 = function (prop) {
64067
+ var _loop_19 = function (prop) {
63969
64068
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
63970
64069
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
63971
64070
  if (reportErrors) {
@@ -64028,9 +64127,9 @@ var ts;
64028
64127
  };
64029
64128
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
64030
64129
  var prop = _b[_i];
64031
- var state_5 = _loop_18(prop);
64032
- if (typeof state_5 === "object")
64033
- return state_5.value;
64130
+ var state_6 = _loop_19(prop);
64131
+ if (typeof state_6 === "object")
64132
+ return state_6.value;
64034
64133
  }
64035
64134
  return false;
64036
64135
  }
@@ -65020,11 +65119,11 @@ var ts;
65020
65119
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
65021
65120
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
65022
65121
  var matchingTypes = [];
65023
- var _loop_19 = function (combination) {
65122
+ var _loop_20 = function (combination) {
65024
65123
  var hasMatch = false;
65025
65124
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
65026
65125
  var type = _d[_c];
65027
- var _loop_20 = function (i) {
65126
+ var _loop_21 = function (i) {
65028
65127
  var sourceProperty = sourcePropertiesFiltered[i];
65029
65128
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
65030
65129
  if (!targetProperty)
@@ -65040,8 +65139,8 @@ var ts;
65040
65139
  }
65041
65140
  };
65042
65141
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
65043
- var state_7 = _loop_20(i);
65044
- switch (state_7) {
65142
+ var state_8 = _loop_21(i);
65143
+ switch (state_8) {
65045
65144
  case "continue-outer": continue outer;
65046
65145
  }
65047
65146
  }
@@ -65054,9 +65153,9 @@ var ts;
65054
65153
  };
65055
65154
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
65056
65155
  var combination = discriminantCombinations_1[_a];
65057
- var state_6 = _loop_19(combination);
65058
- if (typeof state_6 === "object")
65059
- return state_6.value;
65156
+ var state_7 = _loop_20(combination);
65157
+ if (typeof state_7 === "object")
65158
+ return state_7.value;
65060
65159
  }
65061
65160
  // Compare the remaining non-discriminant properties of each match.
65062
65161
  var result = -1 /* True */;
@@ -65769,7 +65868,7 @@ var ts;
65769
65868
  // The emptyArray singleton is used to signal a recursive invocation.
65770
65869
  cache.variances = ts.emptyArray;
65771
65870
  variances = [];
65772
- var _loop_21 = function (tp) {
65871
+ var _loop_22 = function (tp) {
65773
65872
  var unmeasurable = false;
65774
65873
  var unreliable = false;
65775
65874
  var oldHandler = outofbandVarianceMarkerHandler;
@@ -65801,7 +65900,7 @@ var ts;
65801
65900
  };
65802
65901
  for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
65803
65902
  var tp = typeParameters_1[_i];
65804
- _loop_21(tp);
65903
+ _loop_22(tp);
65805
65904
  }
65806
65905
  cache.variances = variances;
65807
65906
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -68172,7 +68271,7 @@ var ts;
68172
68271
  function mapTypesByKeyProperty(types, name) {
68173
68272
  var map = new ts.Map();
68174
68273
  var count = 0;
68175
- var _loop_22 = function (type) {
68274
+ var _loop_23 = function (type) {
68176
68275
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
68177
68276
  var discriminant = getTypeOfPropertyOfType(type, name);
68178
68277
  if (discriminant) {
@@ -68198,9 +68297,9 @@ var ts;
68198
68297
  };
68199
68298
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
68200
68299
  var type = types_16[_i];
68201
- var state_8 = _loop_22(type);
68202
- if (typeof state_8 === "object")
68203
- return state_8.value;
68300
+ var state_9 = _loop_23(type);
68301
+ if (typeof state_9 === "object")
68302
+ return state_9.value;
68204
68303
  }
68205
68304
  return count >= 10 && count * 2 >= types.length ? map : undefined;
68206
68305
  }
@@ -74531,7 +74630,7 @@ var ts;
74531
74630
  if (spreadIndex >= 0) {
74532
74631
  // Create synthetic arguments from spreads of tuple types.
74533
74632
  var effectiveArgs_1 = args.slice(0, spreadIndex);
74534
- var _loop_23 = function (i) {
74633
+ var _loop_24 = function (i) {
74535
74634
  var arg = args[i];
74536
74635
  // We can call checkExpressionCached because spread expressions never have a contextual type.
74537
74636
  var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -74548,7 +74647,7 @@ var ts;
74548
74647
  }
74549
74648
  };
74550
74649
  for (var i = spreadIndex; i < args.length; i++) {
74551
- _loop_23(i);
74650
+ _loop_24(i);
74552
74651
  }
74553
74652
  return effectiveArgs_1;
74554
74653
  }
@@ -74861,7 +74960,7 @@ var ts;
74861
74960
  var min_3 = Number.MAX_VALUE;
74862
74961
  var minIndex = 0;
74863
74962
  var i_1 = 0;
74864
- var _loop_24 = function (c) {
74963
+ var _loop_25 = function (c) {
74865
74964
  var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
74866
74965
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
74867
74966
  if (diags_2) {
@@ -74879,7 +74978,7 @@ var ts;
74879
74978
  };
74880
74979
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
74881
74980
  var c = candidatesForArgumentError_1[_a];
74882
- _loop_24(c);
74981
+ _loop_25(c);
74883
74982
  }
74884
74983
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74885
74984
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -75037,7 +75136,7 @@ var ts;
75037
75136
  }
75038
75137
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
75039
75138
  var parameters = [];
75040
- var _loop_25 = function (i) {
75139
+ var _loop_26 = function (i) {
75041
75140
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
75042
75141
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
75043
75142
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -75045,7 +75144,7 @@ var ts;
75045
75144
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
75046
75145
  };
75047
75146
  for (var i = 0; i < maxNonRestParam; i++) {
75048
- _loop_25(i);
75147
+ _loop_26(i);
75049
75148
  }
75050
75149
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
75051
75150
  var flags = 0 /* None */;
@@ -78272,7 +78371,7 @@ var ts;
78272
78371
  }
78273
78372
  function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
78274
78373
  var type = checkExpression(node, checkMode, forceTuple);
78275
- return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
78374
+ return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
78276
78375
  isTypeAssertion(node) ? type :
78277
78376
  getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
78278
78377
  }
@@ -79041,7 +79140,7 @@ var ts;
79041
79140
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
79042
79141
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
79043
79142
  var indexSignatureMap_1 = new ts.Map();
79044
- var _loop_26 = function (declaration) {
79143
+ var _loop_27 = function (declaration) {
79045
79144
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
79046
79145
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
79047
79146
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -79056,7 +79155,7 @@ var ts;
79056
79155
  };
79057
79156
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
79058
79157
  var declaration = _a[_i];
79059
- _loop_26(declaration);
79158
+ _loop_27(declaration);
79060
79159
  }
79061
79160
  indexSignatureMap_1.forEach(function (entry) {
79062
79161
  if (entry.declarations.length > 1) {
@@ -82435,7 +82534,7 @@ var ts;
82435
82534
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82436
82535
  var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
82437
82536
  name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
82438
- var _loop_27 = function (info) {
82537
+ var _loop_28 = function (info) {
82439
82538
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
82440
82539
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
82441
82540
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -82448,7 +82547,7 @@ var ts;
82448
82547
  };
82449
82548
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
82450
82549
  var info = indexInfos_9[_i];
82451
- _loop_27(info);
82550
+ _loop_28(info);
82452
82551
  }
82453
82552
  }
82454
82553
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -82456,7 +82555,7 @@ var ts;
82456
82555
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
82457
82556
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82458
82557
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
82459
- var _loop_28 = function (info) {
82558
+ var _loop_29 = function (info) {
82460
82559
  if (info === checkInfo)
82461
82560
  return "continue";
82462
82561
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -82471,7 +82570,7 @@ var ts;
82471
82570
  };
82472
82571
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
82473
82572
  var info = indexInfos_10[_i];
82474
- _loop_28(info);
82573
+ _loop_29(info);
82475
82574
  }
82476
82575
  }
82477
82576
  function checkTypeNameIsReserved(name, message) {
@@ -82782,7 +82881,7 @@ var ts;
82782
82881
  var baseTypes = baseTypeNode && getBaseTypes(type);
82783
82882
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
82784
82883
  var baseStaticType = getBaseConstructorTypeOfClass(type);
82785
- var _loop_29 = function (member) {
82884
+ var _loop_30 = function (member) {
82786
82885
  if (ts.hasAmbientModifier(member)) {
82787
82886
  return "continue";
82788
82887
  }
@@ -82799,7 +82898,7 @@ var ts;
82799
82898
  };
82800
82899
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82801
82900
  var member = _a[_i];
82802
- _loop_29(member);
82901
+ _loop_30(member);
82803
82902
  }
82804
82903
  }
82805
82904
  /**
@@ -82887,7 +82986,7 @@ var ts;
82887
82986
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
82888
82987
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
82889
82988
  var issuedMemberError = false;
82890
- var _loop_30 = function (member) {
82989
+ var _loop_31 = function (member) {
82891
82990
  if (ts.isStatic(member)) {
82892
82991
  return "continue";
82893
82992
  }
@@ -82906,7 +83005,7 @@ var ts;
82906
83005
  };
82907
83006
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82908
83007
  var member = _a[_i];
82909
- _loop_30(member);
83008
+ _loop_31(member);
82910
83009
  }
82911
83010
  if (!issuedMemberError) {
82912
83011
  // check again with diagnostics to generate a less-specific error
@@ -120693,7 +120792,7 @@ var ts;
120693
120792
  });
120694
120793
  // Sort by paths closest to importing file Name directory
120695
120794
  var sortedPaths = [];
120696
- var _loop_31 = function (directory) {
120795
+ var _loop_32 = function (directory) {
120697
120796
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
120698
120797
  var pathsInDirectory;
120699
120798
  allFileNames.forEach(function (_a, fileName) {
@@ -120717,9 +120816,9 @@ var ts;
120717
120816
  };
120718
120817
  var out_directory_1;
120719
120818
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
120720
- var state_9 = _loop_31(directory);
120819
+ var state_10 = _loop_32(directory);
120721
120820
  directory = out_directory_1;
120722
- if (state_9 === "break")
120821
+ if (state_10 === "break")
120723
120822
  break;
120724
120823
  }
120725
120824
  if (allFileNames.size) {
@@ -130436,9 +130535,7 @@ var ts;
130436
130535
  source = CompletionSource.ClassMemberSnippet;
130437
130536
  }
130438
130537
  }
130439
- if (preferences.includeCompletionsWithObjectLiteralMethodSnippets
130440
- && preferences.includeCompletionsWithInsertText
130441
- && origin && originIsObjectLiteralMethod(origin)) {
130538
+ if (origin && originIsObjectLiteralMethod(origin)) {
130442
130539
  var objectLiteral = ts.cast(tryGetObjectLikeCompletionContainer(contextToken), ts.isObjectLiteralExpression);
130443
130540
  var importAdder = void 0;
130444
130541
  var entry = getEntryForObjectLiteralMethodCompletion(symbol, name, objectLiteral, program, host, options, preferences, formatContext);
@@ -130447,7 +130544,7 @@ var ts;
130447
130544
  }
130448
130545
  (insertText = entry.insertText, isSnippet = entry.isSnippet, importAdder = entry.importAdder, sourceDisplay = entry.sourceDisplay);
130449
130546
  source = CompletionSource.ObjectLiteralMethodSnippet;
130450
- sortText = (parseInt(sortText, 10) + 1).toString();
130547
+ sortText = SortText.OptionalMember;
130451
130548
  if (importAdder.hasFixes()) {
130452
130549
  hasAction = true;
130453
130550
  }
@@ -132008,7 +132105,7 @@ var ts;
132008
132105
  function collectObjectLiteralMethodSymbols(members) {
132009
132106
  // TODO: support JS files.
132010
132107
  if (ts.isInJSFile(location)) {
132011
- return false;
132108
+ return;
132012
132109
  }
132013
132110
  members = members.slice(); // Needed in case `symbol` and `members` are the same array.
132014
132111
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
@@ -132242,8 +132339,7 @@ var ts;
132242
132339
  // Add filtered items to the completion list
132243
132340
  var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
132244
132341
  symbols = ts.concatenate(symbols, filteredMembers);
132245
- if (preferences.includeCompletionsWithObjectLiteralMethodSnippets
132246
- && objectLikeContainer.kind === 204 /* ObjectLiteralExpression */) {
132342
+ if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */ && preferences.includeCompletionsWithInsertText) {
132247
132343
  collectObjectLiteralMethodSymbols(filteredMembers);
132248
132344
  }
132249
132345
  }