@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.
@@ -15541,10 +15541,23 @@ var ts;
15541
15541
  && node.parent.parent.kind === 236 /* VariableStatement */;
15542
15542
  }
15543
15543
  ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
15544
+ function isCommonJsExportedExpression(node) {
15545
+ if (!isInJSFile(node))
15546
+ return false;
15547
+ return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) ||
15548
+ isCommonJsExportPropertyAssignment(node.parent);
15549
+ }
15550
+ ts.isCommonJsExportedExpression = isCommonJsExportedExpression;
15551
+ function isCommonJsExportPropertyAssignment(node) {
15552
+ if (!isInJSFile(node))
15553
+ return false;
15554
+ return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */);
15555
+ }
15556
+ ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment;
15544
15557
  function isValidESSymbolDeclaration(node) {
15545
- return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15558
+ return (ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
15546
15559
  ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
15547
- ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
15560
+ ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node)) || isCommonJsExportPropertyAssignment(node);
15548
15561
  }
15549
15562
  ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
15550
15563
  function introducesArgumentsExoticObject(node) {
@@ -47863,6 +47876,8 @@ var ts;
47863
47876
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
47864
47877
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
47865
47878
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
47879
+ var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
47880
+ var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints)
47866
47881
  var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47867
47882
  var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
47868
47883
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
@@ -51767,10 +51782,16 @@ var ts;
51767
51782
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
51768
51783
  var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
51769
51784
  var appropriateConstraintTypeNode;
51785
+ var newTypeVariable;
51770
51786
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
51771
51787
  // We have a { [P in keyof T]: X }
51772
51788
  // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
51773
- appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51789
+ if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51790
+ var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
51791
+ var name = typeParameterToName(newParam, context);
51792
+ newTypeVariable = ts.factory.createTypeReferenceNode(name);
51793
+ }
51794
+ appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
51774
51795
  }
51775
51796
  else {
51776
51797
  appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
@@ -51780,7 +51801,14 @@ var ts;
51780
51801
  var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
51781
51802
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
51782
51803
  context.approximateLength += 10;
51783
- return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51804
+ var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51805
+ if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
51806
+ // homomorphic mapped type with a non-homomorphic naive inlining
51807
+ // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
51808
+ // type stays homomorphic
51809
+ 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 */));
51810
+ }
51811
+ return result;
51784
51812
  }
51785
51813
  function createAnonymousTypeNode(type) {
51786
51814
  var _a;
@@ -53401,7 +53429,7 @@ var ts;
53401
53429
  // If it's a class/interface/function: emit a class/interface/function with a `default` modifier
53402
53430
  // These forms can merge, eg (`export default 12; export default interface A {}`)
53403
53431
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
53404
- var _a, _b;
53432
+ var _a, _b, _c, _d;
53405
53433
  var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
53406
53434
  var isDefault = symbol.escapedName === "default" /* Default */;
53407
53435
  if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
@@ -53452,17 +53480,21 @@ var ts;
53452
53480
  else {
53453
53481
  // 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!_
53454
53482
  // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property`
53455
- var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined
53456
- : isConstVariable(symbol) ? 2 /* Const */
53483
+ var flags = !(symbol.flags & 2 /* BlockScopedVariable */)
53484
+ ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration)
53485
+ ? 2 /* Const */
53486
+ : undefined
53487
+ : isConstVariable(symbol)
53488
+ ? 2 /* Const */
53457
53489
  : 1 /* Let */;
53458
53490
  var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol);
53459
53491
  var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
53460
53492
  if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
53461
53493
  textRange = textRange.parent.parent;
53462
53494
  }
53463
- var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression);
53495
+ var propertyAccessRequire = (_c = symbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isPropertyAccessExpression);
53464
53496
  if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
53465
- && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53497
+ && ((_d = type.symbol) === null || _d === void 0 ? void 0 : _d.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) {
53466
53498
  var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
53467
53499
  addResult(ts.factory.createExportDeclaration(
53468
53500
  /*decorators*/ undefined,
@@ -53542,8 +53574,8 @@ var ts;
53542
53574
  // synthesize export * from "moduleReference"
53543
53575
  // Straightforward - only one thing to do - make an export declaration
53544
53576
  if (symbol.declarations) {
53545
- for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) {
53546
- var node = _c[_i];
53577
+ for (var _i = 0, _e = symbol.declarations; _i < _e.length; _i++) {
53578
+ var node = _e[_i];
53547
53579
  var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
53548
53580
  if (!resolvedModule)
53549
53581
  continue;
@@ -55349,7 +55381,10 @@ var ts;
55349
55381
  if (containsSameNamedThisProperty(expression.left, expression.right)) {
55350
55382
  return anyType;
55351
55383
  }
55352
- var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
55384
+ 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)));
55385
+ var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol)
55386
+ : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right))
55387
+ : getWidenedLiteralType(checkExpressionCached(expression.right));
55353
55388
  if (type.flags & 524288 /* Object */ &&
55354
55389
  kind === 2 /* ModuleExports */ &&
55355
55390
  symbol.escapedName === "export=" /* ExportEquals */) {
@@ -58354,10 +58389,10 @@ var ts;
58354
58389
  else if (type !== firstType) {
58355
58390
  checkFlags |= 64 /* HasNonUniformType */;
58356
58391
  }
58357
- if (isLiteralType(type) || isPatternLiteralType(type)) {
58392
+ if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58358
58393
  checkFlags |= 128 /* HasLiteralType */;
58359
58394
  }
58360
- if (type.flags & 131072 /* Never */) {
58395
+ if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
58361
58396
  checkFlags |= 131072 /* HasNeverType */;
58362
58397
  }
58363
58398
  propTypes.push(type);
@@ -60898,10 +60933,24 @@ var ts;
60898
60933
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
60899
60934
  /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
60900
60935
  }
60936
+ /**
60937
+ * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
60938
+ * must be kept generic, as that instantiation information needs to flow through the type system. By replacing all
60939
+ * type parameters in the union with a special never type that is treated as a literal in `getReducedType`, we can cause the `getReducedType` logic
60940
+ * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
60941
+ */
60942
+ function isPossiblyReducibleByInstantiation(type) {
60943
+ return ts.some(type.types, function (t) {
60944
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
60945
+ return getReducedType(uniqueFilled) !== uniqueFilled;
60946
+ });
60947
+ }
60901
60948
  function getIndexType(type, stringsOnly, noIndexSignatures) {
60902
60949
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
60903
60950
  type = getReducedType(type);
60904
- return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60951
+ return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
60952
+ ? getIndexTypeForGenericType(type, stringsOnly)
60953
+ : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60905
60954
  type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
60906
60955
  type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
60907
60956
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
@@ -61529,6 +61578,10 @@ var ts;
61529
61578
  }
61530
61579
  return type;
61531
61580
  }
61581
+ function maybeCloneTypeParameter(p) {
61582
+ var constraint = getConstraintOfTypeParameter(p);
61583
+ return constraint && (isGenericObjectType(constraint) || isGenericIndexType(constraint)) ? cloneTypeParameter(p) : p;
61584
+ }
61532
61585
  function isTypicalNondistributiveConditional(root) {
61533
61586
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61534
61587
  }
@@ -61547,37 +61600,65 @@ var ts;
61547
61600
  var result;
61548
61601
  var extraTypes;
61549
61602
  var tailCount = 0;
61550
- // We loop here for an immediately nested conditional type in the false position, effectively treating
61551
- // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61552
- // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61553
- // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61554
- // cases we increment the tail recursion counter and stop after 1000 iterations.
61555
- while (true) {
61603
+ var _loop_18 = function () {
61556
61604
  if (tailCount === 1000) {
61557
61605
  error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
61558
61606
  result = errorType;
61559
- break;
61607
+ return "break";
61560
61608
  }
61561
61609
  var isUnwrapped = isTypicalNondistributiveConditional(root);
61562
61610
  var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
61563
61611
  var checkTypeInstantiable = isGenericType(checkType);
61564
61612
  var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
61565
61613
  if (checkType === wildcardType || extendsType === wildcardType) {
61566
- return wildcardType;
61614
+ return { value: wildcardType };
61567
61615
  }
61568
61616
  var combinedMapper = void 0;
61569
61617
  if (root.inferTypeParameters) {
61570
- var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */);
61571
- if (!checkTypeInstantiable) {
61618
+ // When we're looking at making an inference for an infer type, when we get its constraint, it'll automagically be
61619
+ // instantiated with the context, so it doesn't need the mapper for the inference contex - however the constraint
61620
+ // may refer to another _root_, _uncloned_ `infer` type parameter [1], or to something mapped by `mapper` [2].
61621
+ // [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
61622
+ // as `number`
61623
+ // Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
61624
+ // [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`
61625
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
61626
+ // So we need to:
61627
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
61628
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
61629
+ // * instantiate the extends type with the clones
61630
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
61631
+ // This means we have three mappers that need applying:
61632
+ // * The original `mapper` used to create this conditional
61633
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
61634
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
61635
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
61636
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
61637
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */);
61638
+ if (freshMapper) {
61639
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
61640
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
61641
+ var p = freshParams_1[_i];
61642
+ if (root.inferTypeParameters.indexOf(p) === -1) {
61643
+ p.mapper = freshCombinedMapper;
61644
+ }
61645
+ }
61646
+ }
61647
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
61648
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
61649
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
61650
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
61651
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
61572
61652
  // We don't want inferences from constraints as they may cause us to eagerly resolve the
61573
61653
  // conditional type instead of deferring resolution. Also, we always want strict function
61574
61654
  // types rules (i.e. proper contravariance) for inferences.
61575
- inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61655
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
61576
61656
  }
61657
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
61577
61658
  // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
61578
61659
  // those type parameters are used in type references (see getInferredTypeParameterConstraint). For
61579
61660
  // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
61580
- combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper;
61661
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
61581
61662
  }
61582
61663
  // Instantiate the extends type including inferences for 'infer T' type parameters
61583
61664
  var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
@@ -61599,14 +61680,14 @@ var ts;
61599
61680
  var newRoot = falseType_1.root;
61600
61681
  if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
61601
61682
  root = newRoot;
61602
- continue;
61683
+ return "continue";
61603
61684
  }
61604
61685
  if (canTailRecurse(falseType_1, mapper)) {
61605
- continue;
61686
+ return "continue";
61606
61687
  }
61607
61688
  }
61608
61689
  result = instantiateType(falseType_1, mapper);
61609
- break;
61690
+ return "break";
61610
61691
  }
61611
61692
  // Return trueType for a definitely true extends check. We check instantiations of the two
61612
61693
  // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
@@ -61617,10 +61698,10 @@ var ts;
61617
61698
  var trueType_1 = getTypeFromTypeNode(root.node.trueType);
61618
61699
  var trueMapper = combinedMapper || mapper;
61619
61700
  if (canTailRecurse(trueType_1, trueMapper)) {
61620
- continue;
61701
+ return "continue";
61621
61702
  }
61622
61703
  result = instantiateType(trueType_1, trueMapper);
61623
- break;
61704
+ return "break";
61624
61705
  }
61625
61706
  }
61626
61707
  // Return a deferred type for a check that is neither definitely true nor definitely false
@@ -61632,7 +61713,19 @@ var ts;
61632
61713
  result.combinedMapper = combinedMapper;
61633
61714
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61634
61715
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61635
- break;
61716
+ return "break";
61717
+ };
61718
+ // We loop here for an immediately nested conditional type in the false position, effectively treating
61719
+ // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
61720
+ // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
61721
+ // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
61722
+ // cases we increment the tail recursion counter and stop after 1000 iterations.
61723
+ while (true) {
61724
+ var state_5 = _loop_18();
61725
+ if (typeof state_5 === "object")
61726
+ return state_5.value;
61727
+ if (state_5 === "break")
61728
+ break;
61636
61729
  }
61637
61730
  return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
61638
61731
  // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
@@ -62054,9 +62147,11 @@ var ts;
62054
62147
  }
62055
62148
  function getESSymbolLikeTypeForNode(node) {
62056
62149
  if (ts.isValidESSymbolDeclaration(node)) {
62057
- var symbol = getSymbolOfNode(node);
62058
- var links = getSymbolLinks(symbol);
62059
- return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62150
+ var symbol = ts.isCommonJsExportPropertyAssignment(node) ? getSymbolOfNode(node.left) : getSymbolOfNode(node);
62151
+ if (symbol) {
62152
+ var links = getSymbolLinks(symbol);
62153
+ return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
62154
+ }
62060
62155
  }
62061
62156
  return esSymbolType;
62062
62157
  }
@@ -62700,6 +62795,10 @@ var ts;
62700
62795
  }
62701
62796
  return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable
62702
62797
  }
62798
+ function getUniqueLiteralFilledInstantiation(type) {
62799
+ return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62800
+ type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper));
62801
+ }
62703
62802
  function getPermissiveInstantiation(type) {
62704
62803
  return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type :
62705
62804
  type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
@@ -64159,7 +64258,7 @@ var ts;
64159
64258
  reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
64160
64259
  checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget];
64161
64260
  }
64162
- var _loop_18 = function (prop) {
64261
+ var _loop_19 = function (prop) {
64163
64262
  if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
64164
64263
  if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
64165
64264
  if (reportErrors) {
@@ -64222,9 +64321,9 @@ var ts;
64222
64321
  };
64223
64322
  for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
64224
64323
  var prop = _b[_i];
64225
- var state_5 = _loop_18(prop);
64226
- if (typeof state_5 === "object")
64227
- return state_5.value;
64324
+ var state_6 = _loop_19(prop);
64325
+ if (typeof state_6 === "object")
64326
+ return state_6.value;
64228
64327
  }
64229
64328
  return false;
64230
64329
  }
@@ -65214,11 +65313,11 @@ var ts;
65214
65313
  // constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
65215
65314
  var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
65216
65315
  var matchingTypes = [];
65217
- var _loop_19 = function (combination) {
65316
+ var _loop_20 = function (combination) {
65218
65317
  var hasMatch = false;
65219
65318
  outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
65220
65319
  var type = _d[_c];
65221
- var _loop_20 = function (i) {
65320
+ var _loop_21 = function (i) {
65222
65321
  var sourceProperty = sourcePropertiesFiltered[i];
65223
65322
  var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
65224
65323
  if (!targetProperty)
@@ -65234,8 +65333,8 @@ var ts;
65234
65333
  }
65235
65334
  };
65236
65335
  for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
65237
- var state_7 = _loop_20(i);
65238
- switch (state_7) {
65336
+ var state_8 = _loop_21(i);
65337
+ switch (state_8) {
65239
65338
  case "continue-outer": continue outer;
65240
65339
  }
65241
65340
  }
@@ -65248,9 +65347,9 @@ var ts;
65248
65347
  };
65249
65348
  for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
65250
65349
  var combination = discriminantCombinations_1[_a];
65251
- var state_6 = _loop_19(combination);
65252
- if (typeof state_6 === "object")
65253
- return state_6.value;
65350
+ var state_7 = _loop_20(combination);
65351
+ if (typeof state_7 === "object")
65352
+ return state_7.value;
65254
65353
  }
65255
65354
  // Compare the remaining non-discriminant properties of each match.
65256
65355
  var result = -1 /* True */;
@@ -65963,7 +66062,7 @@ var ts;
65963
66062
  // The emptyArray singleton is used to signal a recursive invocation.
65964
66063
  cache.variances = ts.emptyArray;
65965
66064
  variances = [];
65966
- var _loop_21 = function (tp) {
66065
+ var _loop_22 = function (tp) {
65967
66066
  var unmeasurable = false;
65968
66067
  var unreliable = false;
65969
66068
  var oldHandler = outofbandVarianceMarkerHandler;
@@ -65995,7 +66094,7 @@ var ts;
65995
66094
  };
65996
66095
  for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
65997
66096
  var tp = typeParameters_1[_i];
65998
- _loop_21(tp);
66097
+ _loop_22(tp);
65999
66098
  }
66000
66099
  cache.variances = variances;
66001
66100
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -68366,7 +68465,7 @@ var ts;
68366
68465
  function mapTypesByKeyProperty(types, name) {
68367
68466
  var map = new ts.Map();
68368
68467
  var count = 0;
68369
- var _loop_22 = function (type) {
68468
+ var _loop_23 = function (type) {
68370
68469
  if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) {
68371
68470
  var discriminant = getTypeOfPropertyOfType(type, name);
68372
68471
  if (discriminant) {
@@ -68392,9 +68491,9 @@ var ts;
68392
68491
  };
68393
68492
  for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
68394
68493
  var type = types_16[_i];
68395
- var state_8 = _loop_22(type);
68396
- if (typeof state_8 === "object")
68397
- return state_8.value;
68494
+ var state_9 = _loop_23(type);
68495
+ if (typeof state_9 === "object")
68496
+ return state_9.value;
68398
68497
  }
68399
68498
  return count >= 10 && count * 2 >= types.length ? map : undefined;
68400
68499
  }
@@ -74725,7 +74824,7 @@ var ts;
74725
74824
  if (spreadIndex >= 0) {
74726
74825
  // Create synthetic arguments from spreads of tuple types.
74727
74826
  var effectiveArgs_1 = args.slice(0, spreadIndex);
74728
- var _loop_23 = function (i) {
74827
+ var _loop_24 = function (i) {
74729
74828
  var arg = args[i];
74730
74829
  // We can call checkExpressionCached because spread expressions never have a contextual type.
74731
74830
  var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
@@ -74742,7 +74841,7 @@ var ts;
74742
74841
  }
74743
74842
  };
74744
74843
  for (var i = spreadIndex; i < args.length; i++) {
74745
- _loop_23(i);
74844
+ _loop_24(i);
74746
74845
  }
74747
74846
  return effectiveArgs_1;
74748
74847
  }
@@ -75055,7 +75154,7 @@ var ts;
75055
75154
  var min_3 = Number.MAX_VALUE;
75056
75155
  var minIndex = 0;
75057
75156
  var i_1 = 0;
75058
- var _loop_24 = function (c) {
75157
+ var _loop_25 = function (c) {
75059
75158
  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)); };
75060
75159
  var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2);
75061
75160
  if (diags_2) {
@@ -75073,7 +75172,7 @@ var ts;
75073
75172
  };
75074
75173
  for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
75075
75174
  var c = candidatesForArgumentError_1[_a];
75076
- _loop_24(c);
75175
+ _loop_25(c);
75077
75176
  }
75078
75177
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
75079
75178
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
@@ -75231,7 +75330,7 @@ var ts;
75231
75330
  }
75232
75331
  var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
75233
75332
  var parameters = [];
75234
- var _loop_25 = function (i) {
75333
+ var _loop_26 = function (i) {
75235
75334
  var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
75236
75335
  i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
75237
75336
  i < s.parameters.length ? s.parameters[i] : undefined; });
@@ -75239,7 +75338,7 @@ var ts;
75239
75338
  parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
75240
75339
  };
75241
75340
  for (var i = 0; i < maxNonRestParam; i++) {
75242
- _loop_25(i);
75341
+ _loop_26(i);
75243
75342
  }
75244
75343
  var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
75245
75344
  var flags = 0 /* None */;
@@ -78466,7 +78565,7 @@ var ts;
78466
78565
  }
78467
78566
  function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
78468
78567
  var type = checkExpression(node, checkMode, forceTuple);
78469
- return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
78568
+ return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
78470
78569
  isTypeAssertion(node) ? type :
78471
78570
  getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
78472
78571
  }
@@ -79235,7 +79334,7 @@ var ts;
79235
79334
  var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
79236
79335
  if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
79237
79336
  var indexSignatureMap_1 = new ts.Map();
79238
- var _loop_26 = function (declaration) {
79337
+ var _loop_27 = function (declaration) {
79239
79338
  if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
79240
79339
  forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
79241
79340
  var entry = indexSignatureMap_1.get(getTypeId(type));
@@ -79250,7 +79349,7 @@ var ts;
79250
79349
  };
79251
79350
  for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
79252
79351
  var declaration = _a[_i];
79253
- _loop_26(declaration);
79352
+ _loop_27(declaration);
79254
79353
  }
79255
79354
  indexSignatureMap_1.forEach(function (entry) {
79256
79355
  if (entry.declarations.length > 1) {
@@ -82629,7 +82728,7 @@ var ts;
82629
82728
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82630
82729
  var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ ||
82631
82730
  name && name.kind === 161 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
82632
- var _loop_27 = function (info) {
82731
+ var _loop_28 = function (info) {
82633
82732
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
82634
82733
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
82635
82734
  // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
@@ -82642,7 +82741,7 @@ var ts;
82642
82741
  };
82643
82742
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
82644
82743
  var info = indexInfos_9[_i];
82645
- _loop_27(info);
82744
+ _loop_28(info);
82646
82745
  }
82647
82746
  }
82648
82747
  function checkIndexConstraintForIndexSignature(type, checkInfo) {
@@ -82650,7 +82749,7 @@ var ts;
82650
82749
  var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
82651
82750
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined;
82652
82751
  var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
82653
- var _loop_28 = function (info) {
82752
+ var _loop_29 = function (info) {
82654
82753
  if (info === checkInfo)
82655
82754
  return "continue";
82656
82755
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
@@ -82665,7 +82764,7 @@ var ts;
82665
82764
  };
82666
82765
  for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
82667
82766
  var info = indexInfos_10[_i];
82668
- _loop_28(info);
82767
+ _loop_29(info);
82669
82768
  }
82670
82769
  }
82671
82770
  function checkTypeNameIsReserved(name, message) {
@@ -82976,7 +83075,7 @@ var ts;
82976
83075
  var baseTypes = baseTypeNode && getBaseTypes(type);
82977
83076
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
82978
83077
  var baseStaticType = getBaseConstructorTypeOfClass(type);
82979
- var _loop_29 = function (member) {
83078
+ var _loop_30 = function (member) {
82980
83079
  if (ts.hasAmbientModifier(member)) {
82981
83080
  return "continue";
82982
83081
  }
@@ -82993,7 +83092,7 @@ var ts;
82993
83092
  };
82994
83093
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
82995
83094
  var member = _a[_i];
82996
- _loop_29(member);
83095
+ _loop_30(member);
82997
83096
  }
82998
83097
  }
82999
83098
  /**
@@ -83081,7 +83180,7 @@ var ts;
83081
83180
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
83082
83181
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
83083
83182
  var issuedMemberError = false;
83084
- var _loop_30 = function (member) {
83183
+ var _loop_31 = function (member) {
83085
83184
  if (ts.isStatic(member)) {
83086
83185
  return "continue";
83087
83186
  }
@@ -83100,7 +83199,7 @@ var ts;
83100
83199
  };
83101
83200
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
83102
83201
  var member = _a[_i];
83103
- _loop_30(member);
83202
+ _loop_31(member);
83104
83203
  }
83105
83204
  if (!issuedMemberError) {
83106
83205
  // check again with diagnostics to generate a less-specific error
@@ -120887,7 +120986,7 @@ var ts;
120887
120986
  });
120888
120987
  // Sort by paths closest to importing file Name directory
120889
120988
  var sortedPaths = [];
120890
- var _loop_31 = function (directory) {
120989
+ var _loop_32 = function (directory) {
120891
120990
  var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
120892
120991
  var pathsInDirectory;
120893
120992
  allFileNames.forEach(function (_a, fileName) {
@@ -120911,9 +121010,9 @@ var ts;
120911
121010
  };
120912
121011
  var out_directory_1;
120913
121012
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
120914
- var state_9 = _loop_31(directory);
121013
+ var state_10 = _loop_32(directory);
120915
121014
  directory = out_directory_1;
120916
- if (state_9 === "break")
121015
+ if (state_10 === "break")
120917
121016
  break;
120918
121017
  }
120919
121018
  if (allFileNames.size) {
@@ -131047,9 +131146,7 @@ var ts;
131047
131146
  source = CompletionSource.ClassMemberSnippet;
131048
131147
  }
131049
131148
  }
131050
- if (preferences.includeCompletionsWithObjectLiteralMethodSnippets
131051
- && preferences.includeCompletionsWithInsertText
131052
- && origin && originIsObjectLiteralMethod(origin)) {
131149
+ if (origin && originIsObjectLiteralMethod(origin)) {
131053
131150
  var objectLiteral = ts.cast(tryGetObjectLikeCompletionContainer(contextToken), ts.isObjectLiteralExpression);
131054
131151
  var importAdder = void 0;
131055
131152
  var entry = getEntryForObjectLiteralMethodCompletion(symbol, name, objectLiteral, program, host, options, preferences, formatContext);
@@ -131058,7 +131155,7 @@ var ts;
131058
131155
  }
131059
131156
  (insertText = entry.insertText, isSnippet = entry.isSnippet, importAdder = entry.importAdder, sourceDisplay = entry.sourceDisplay);
131060
131157
  source = CompletionSource.ObjectLiteralMethodSnippet;
131061
- sortText = (parseInt(sortText, 10) + 1).toString();
131158
+ sortText = SortText.OptionalMember;
131062
131159
  if (importAdder.hasFixes()) {
131063
131160
  hasAction = true;
131064
131161
  }
@@ -132619,7 +132716,7 @@ var ts;
132619
132716
  function collectObjectLiteralMethodSymbols(members) {
132620
132717
  // TODO: support JS files.
132621
132718
  if (ts.isInJSFile(location)) {
132622
- return false;
132719
+ return;
132623
132720
  }
132624
132721
  members = members.slice(); // Needed in case `symbol` and `members` are the same array.
132625
132722
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
@@ -132853,8 +132950,7 @@ var ts;
132853
132950
  // Add filtered items to the completion list
132854
132951
  var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
132855
132952
  symbols = ts.concatenate(symbols, filteredMembers);
132856
- if (preferences.includeCompletionsWithObjectLiteralMethodSnippets
132857
- && objectLikeContainer.kind === 204 /* ObjectLiteralExpression */) {
132953
+ if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */ && preferences.includeCompletionsWithInsertText) {
132858
132954
  collectObjectLiteralMethodSymbols(filteredMembers);
132859
132955
  }
132860
132956
  }