typescript 4.9.0-dev.20220918 → 4.9.0-dev.20220920

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.
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220918");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -2692,7 +2692,7 @@ var ts;
2692
2692
  if (typeof func !== "function") {
2693
2693
  return "";
2694
2694
  }
2695
- else if (func.hasOwnProperty("name")) {
2695
+ else if (ts.hasProperty(func, "name")) {
2696
2696
  return func.name;
2697
2697
  }
2698
2698
  else {
@@ -3017,7 +3017,7 @@ var ts;
3017
3017
  ];
3018
3018
  for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
3019
3019
  var ctor = nodeConstructors_1[_i];
3020
- if (!ctor.prototype.hasOwnProperty("__debugKind")) {
3020
+ if (!ts.hasProperty(ctor, "__debugKind")) {
3021
3021
  Object.defineProperties(ctor.prototype, {
3022
3022
  // for use with vscode-js-debug's new customDescriptionGenerator in launch.json
3023
3023
  __tsDebuggerDisplay: {
@@ -3872,7 +3872,6 @@ var ts;
3872
3872
  var typeCatalog = []; // NB: id is index + 1
3873
3873
  var legendPath;
3874
3874
  var legend = [];
3875
- ;
3876
3875
  /** Starts tracing for the given project. */
3877
3876
  function startTracing(tracingMode, traceDir, configFilePath) {
3878
3877
  ts.Debug.assert(!ts.tracing, "Tracing already started");
@@ -8704,8 +8703,6 @@ var ts;
8704
8703
  The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
8705
8704
  The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
8706
8705
  The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
8707
- The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."),
8708
- The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
8709
8706
  The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
8710
8707
  The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
8711
8708
  The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
@@ -8954,6 +8951,7 @@ var ts;
8954
8951
  Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
8955
8952
  Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
8956
8953
  Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
8954
+ Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator: diag(2638, ts.DiagnosticCategory.Error, "Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operato_2638", "Type '{0}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator."),
8957
8955
  Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
8958
8956
  A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
8959
8957
  Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -10337,7 +10335,7 @@ var ts;
10337
10335
  ts.stringToToken = stringToToken;
10338
10336
  /* @internal */
10339
10337
  function computeLineStarts(text) {
10340
- var result = new Array();
10338
+ var result = [];
10341
10339
  var pos = 0;
10342
10340
  var lineStart = 0;
10343
10341
  while (pos < text.length) {
@@ -13470,7 +13468,7 @@ var ts;
13470
13468
  // Node Arrays
13471
13469
  /* @internal */
13472
13470
  function isNodeArray(array) {
13473
- return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
13471
+ return ts.hasProperty(array, "pos") && ts.hasProperty(array, "end");
13474
13472
  }
13475
13473
  ts.isNodeArray = isNodeArray;
13476
13474
  // Literals
@@ -14942,7 +14940,6 @@ var ts;
14942
14940
  return emitNode && emitNode.flags || 0;
14943
14941
  }
14944
14942
  ts.getEmitFlags = getEmitFlags;
14945
- ;
14946
14943
  function getScriptTargetFeatures() {
14947
14944
  return {
14948
14945
  es2015: {
@@ -19668,7 +19665,7 @@ var ts;
19668
19665
  }
19669
19666
  function isWatchSet(options) {
19670
19667
  // Firefox has Object.prototype.watch
19671
- return options.watch && options.hasOwnProperty("watch");
19668
+ return options.watch && ts.hasProperty(options, "watch");
19672
19669
  }
19673
19670
  ts.isWatchSet = isWatchSet;
19674
19671
  function closeFileWatcher(watcher) {
@@ -26953,7 +26950,7 @@ var ts;
26953
26950
  clone.transformFlags = node.transformFlags;
26954
26951
  setOriginalNode(clone, node);
26955
26952
  for (var key in node) {
26956
- if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
26953
+ if (ts.hasProperty(clone, key) || !ts.hasProperty(node, key)) {
26957
26954
  continue;
26958
26955
  }
26959
26956
  clone[key] = node[key];
@@ -31841,7 +31838,6 @@ var ts;
31841
31838
  visitNodes(cbNode, cbNodes, node.parameters) ||
31842
31839
  visitNode(cbNode, node.type);
31843
31840
  }
31844
- ;
31845
31841
  function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
31846
31842
  return visitNodes(cbNode, cbNodes, node.types);
31847
31843
  }
@@ -43157,7 +43153,7 @@ var ts;
43157
43153
  function convertCompilerOptionsForTelemetry(opts) {
43158
43154
  var out = {};
43159
43155
  for (var key in opts) {
43160
- if (opts.hasOwnProperty(key)) {
43156
+ if (ts.hasProperty(opts, key)) {
43161
43157
  var type = getOptionFromName(key);
43162
43158
  if (type !== undefined) { // Ignore unknown options
43163
43159
  out[key] = getOptionValueWithEmptyStrings(opts[key], type);
@@ -49541,6 +49537,7 @@ var ts;
49541
49537
  isPropertyAccessible: isPropertyAccessible,
49542
49538
  getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
49543
49539
  getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
49540
+ isTypeParameterPossiblyReferenced: isTypeParameterPossiblyReferenced,
49544
49541
  };
49545
49542
  function runWithInferenceBlockedFromSourceNode(node, fn) {
49546
49543
  var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
@@ -49660,7 +49657,8 @@ var ts;
49660
49657
  var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
49661
49658
  emptyTypeLiteralSymbol.members = ts.createSymbolTable();
49662
49659
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49663
- var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType;
49660
+ var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49661
+ var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
49664
49662
  var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
49665
49663
  emptyGenericType.instantiations = new ts.Map();
49666
49664
  var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
@@ -49774,6 +49772,7 @@ var ts;
49774
49772
  var deferredGlobalOmitSymbol;
49775
49773
  var deferredGlobalAwaitedSymbol;
49776
49774
  var deferredGlobalBigIntType;
49775
+ var deferredGlobalRecordSymbol;
49777
49776
  var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
49778
49777
  var flowLoopStart = 0;
49779
49778
  var flowLoopCount = 0;
@@ -50569,12 +50568,13 @@ var ts;
50569
50568
  * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
50570
50569
  * the given name can be found.
50571
50570
  *
50571
+ * @param nameNotFoundMessage If defined, we will report errors found during resolve.
50572
50572
  * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
50573
50573
  */
50574
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
50574
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions) {
50575
50575
  if (excludeGlobals === void 0) { excludeGlobals = false; }
50576
- if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
50577
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
50576
+ if (getSpellingSuggestions === void 0) { getSpellingSuggestions = true; }
50577
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
50578
50578
  }
50579
50579
  function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
50580
50580
  var _a, _b, _c;
@@ -50732,7 +50732,9 @@ var ts;
50732
50732
  // TypeScript 1.0 spec (April 2014): 3.4.1
50733
50733
  // The scope of a type parameter extends over the entire declaration with which the type
50734
50734
  // parameter list is associated, with the exception of static member declarations in classes.
50735
- error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
50735
+ if (nameNotFoundMessage) {
50736
+ error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
50737
+ }
50736
50738
  return undefined;
50737
50739
  }
50738
50740
  break loop;
@@ -50770,7 +50772,9 @@ var ts;
50770
50772
  if (ts.isClassLike(grandparent) || grandparent.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
50771
50773
  // A reference to this grandparent's type parameters would be an error
50772
50774
  if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
50773
- error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
50775
+ if (nameNotFoundMessage) {
50776
+ error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
50777
+ }
50774
50778
  return undefined;
50775
50779
  }
50776
50780
  }
@@ -50966,7 +50970,7 @@ var ts;
50966
50970
  }
50967
50971
  return undefined;
50968
50972
  }
50969
- else if (checkAndReportErrorForInvalidInitializer()) {
50973
+ else if (nameNotFoundMessage && checkAndReportErrorForInvalidInitializer()) {
50970
50974
  return undefined;
50971
50975
  }
50972
50976
  // Perform extra checks only if error reporting was requested
@@ -57127,7 +57131,6 @@ var ts;
57127
57131
  return container;
57128
57132
  }
57129
57133
  }
57130
- ;
57131
57134
  }
57132
57135
  /** Create a synthetic property access flow node after the last statement of the file */
57133
57136
  function getFlowTypeFromCommonJSExport(symbol) {
@@ -61873,6 +61876,10 @@ var ts;
61873
61876
  function getGlobalBigIntType() {
61874
61877
  return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
61875
61878
  }
61879
+ function getGlobalRecordSymbol() {
61880
+ deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
61881
+ return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
61882
+ }
61876
61883
  /**
61877
61884
  * Instantiates a global type that is generic with some element type, and returns that instantiation.
61878
61885
  */
@@ -64598,9 +64605,10 @@ var ts;
64598
64605
  node.parent.kind === 202 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
64599
64606
  }
64600
64607
  function isTypeParameterPossiblyReferenced(tp, node) {
64601
- // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks
64608
+ // If the type parameter doesn't have exactly one declaration, if there are intervening statement blocks
64602
64609
  // between the node and the type parameter declaration, if the node contains actual references to the
64603
- // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced.
64610
+ // type parameter, or if the node contains type queries that we can't prove couldn't contain references to the type parameter,
64611
+ // we consider the type parameter possibly referenced.
64604
64612
  if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
64605
64613
  var container = tp.symbol.declarations[0].parent;
64606
64614
  for (var n = node; n !== container; n = n.parent) {
@@ -64619,6 +64627,27 @@ var ts;
64619
64627
  return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
64620
64628
  getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
64621
64629
  case 183 /* SyntaxKind.TypeQuery */:
64630
+ var entityName = node.exprName;
64631
+ var firstIdentifier = ts.getFirstIdentifier(entityName);
64632
+ var firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
64633
+ var tpDeclaration = tp.symbol.declarations[0]; // There is exactly one declaration, otherwise `containsReference` is not called
64634
+ var tpScope_1;
64635
+ if (tpDeclaration.kind === 165 /* SyntaxKind.TypeParameter */) { // Type parameter is a regular type parameter, e.g. foo<T>
64636
+ tpScope_1 = tpDeclaration.parent;
64637
+ }
64638
+ else if (tp.isThisType) {
64639
+ // Type parameter is the this type, and its declaration is the class declaration.
64640
+ tpScope_1 = tpDeclaration;
64641
+ }
64642
+ else {
64643
+ // Type parameter's declaration was unrecognized.
64644
+ // This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
64645
+ return true;
64646
+ }
64647
+ if (firstIdentifierSymbol.declarations) {
64648
+ return ts.some(firstIdentifierSymbol.declarations, function (idDecl) { return ts.isNodeDescendantOf(idDecl, tpScope_1); }) ||
64649
+ ts.some(node.typeArguments, containsReference);
64650
+ }
64622
64651
  return true;
64623
64652
  case 171 /* SyntaxKind.MethodDeclaration */:
64624
64653
  case 170 /* SyntaxKind.MethodSignature */:
@@ -72167,18 +72196,26 @@ var ts;
72167
72196
  }
72168
72197
  function isTypePresencePossible(type, propName, assumeTrue) {
72169
72198
  var prop = getPropertyOfType(type, propName);
72170
- if (prop) {
72171
- return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue;
72172
- }
72173
- return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue;
72174
- }
72175
- function narrowByInKeyword(type, name, assumeTrue) {
72176
- if (type.flags & 1048576 /* TypeFlags.Union */
72177
- || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type && !(declaredType === unknownType && isEmptyAnonymousObjectType(type))
72178
- || ts.isThisTypeParameter(type)
72179
- || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
72199
+ return prop ?
72200
+ !!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
72201
+ !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
72202
+ }
72203
+ function narrowByInKeyword(type, nameType, assumeTrue) {
72204
+ var name = getPropertyNameFromType(nameType);
72205
+ var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
72206
+ if (isKnownProperty) {
72207
+ // If the check is for a known property (i.e. a property declared in some constituent of
72208
+ // the target type), we filter the target type by presence of absence of the property.
72180
72209
  return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
72181
72210
  }
72211
+ if (assumeTrue) {
72212
+ // If the check is for an unknown property, we intersect the target type with `Record<X, unknown>`,
72213
+ // where X is the name of the property.
72214
+ var recordSymbol = getGlobalRecordSymbol();
72215
+ if (recordSymbol) {
72216
+ return getIntersectionType([type, getTypeAliasInstantiation(recordSymbol, [nameType, unknownType])]);
72217
+ }
72218
+ }
72182
72219
  return type;
72183
72220
  }
72184
72221
  function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
@@ -72237,15 +72274,14 @@ var ts;
72237
72274
  return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
72238
72275
  }
72239
72276
  var target = getReferenceCandidate(expr.right);
72240
- var leftType = getTypeOfNode(expr.left);
72241
- if (leftType.flags & 128 /* TypeFlags.StringLiteral */) {
72242
- var name = ts.escapeLeadingUnderscores(leftType.value);
72277
+ var leftType = getTypeOfExpression(expr.left);
72278
+ if (leftType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */) {
72243
72279
  if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
72244
- getAccessedPropertyName(reference) === name) {
72280
+ getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
72245
72281
  return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
72246
72282
  }
72247
72283
  if (isMatchingReference(reference, target)) {
72248
- return narrowByInKeyword(type, name, assumeTrue);
72284
+ return narrowByInKeyword(type, leftType, assumeTrue);
72249
72285
  }
72250
72286
  }
72251
72287
  break;
@@ -76415,7 +76451,6 @@ var ts;
76415
76451
  }
76416
76452
  return false;
76417
76453
  }
76418
- ;
76419
76454
  var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
76420
76455
  if (!hasProp(suggestedMethod)) {
76421
76456
  return undefined;
@@ -79986,6 +80021,9 @@ var ts;
79986
80021
  }
79987
80022
  return booleanType;
79988
80023
  }
80024
+ function hasEmptyObjectIntersection(type) {
80025
+ return someType(type, function (t) { return t === unknownEmptyObjectType || !!(t.flags & 2097152 /* TypeFlags.Intersection */) && ts.some(t.types, isEmptyAnonymousObjectType); });
80026
+ }
79989
80027
  function checkInExpression(left, right, leftType, rightType) {
79990
80028
  if (leftType === silentNeverType || rightType === silentNeverType) {
79991
80029
  return silentNeverType;
@@ -80002,40 +80040,20 @@ var ts;
80002
80040
  }
80003
80041
  }
80004
80042
  else {
80005
- leftType = checkNonNullType(leftType, left);
80006
- // TypeScript 1.0 spec (April 2014): 4.15.5
80007
- // Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
80008
- if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) ||
80009
- isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) {
80010
- error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol);
80043
+ // The type of the lef operand must be assignable to string, number, or symbol.
80044
+ checkTypeAssignableTo(checkNonNullType(leftType, left), stringNumberSymbolType, left);
80045
+ }
80046
+ // The type of the right operand must be assignable to 'object'.
80047
+ if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
80048
+ // The {} type is assignable to the object type, yet {} might represent a primitive type. Here we
80049
+ // detect and error on {} that results from narrowing the unknown type, as well as intersections
80050
+ // that include {} (we know that the other types in such intersections are assignable to object
80051
+ // since we already checked for that).
80052
+ if (hasEmptyObjectIntersection(rightType)) {
80053
+ error(right, ts.Diagnostics.Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator, typeToString(rightType));
80011
80054
  }
80012
80055
  }
80013
- rightType = checkNonNullType(rightType, right);
80014
- // TypeScript 1.0 spec (April 2014): 4.15.5
80015
- // The in operator requires the right operand to be
80016
- //
80017
- // 1. assignable to the non-primitive type,
80018
- // 2. an unconstrained type parameter,
80019
- // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the
80020
- // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the
80021
- // non-primitive type, or
80022
- // 4. a type parameter whose constraint is
80023
- // i. an object type,
80024
- // ii. the non-primitive type, or
80025
- // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type.
80026
- //
80027
- // The divergent behavior for type parameters and unions containing type parameters is a workaround for type
80028
- // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance
80029
- // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error
80030
- // unless *all* instantiations would result in an error.
80031
- //
80032
80056
  // The result is always of the Boolean primitive type.
80033
- var rightTypeConstraint = getConstraintOfType(rightType);
80034
- if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
80035
- rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
80036
- !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
80037
- error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
80038
- }
80039
80057
  return booleanType;
80040
80058
  }
80041
80059
  function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
@@ -88477,7 +88495,7 @@ var ts;
88477
88495
  }
88478
88496
  var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
88479
88497
  if (node) {
88480
- var symbol = getReferencedValueSymbol(node);
88498
+ var symbol = getReferencedValueOrAliasSymbol(node);
88481
88499
  // We should only get the declaration of an alias if there isn't a local value
88482
88500
  // declaration for the symbol
88483
88501
  if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
@@ -88844,6 +88862,25 @@ var ts;
88844
88862
  }
88845
88863
  return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
88846
88864
  }
88865
+ /**
88866
+ * Get either a value-meaning symbol or an alias symbol.
88867
+ * Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
88868
+ * we call `resolveName` to find a symbol.
88869
+ * This is because when caching the resolved symbol, we only consider value symbols, but here
88870
+ * we want to also get an alias symbol if one exists.
88871
+ */
88872
+ function getReferencedValueOrAliasSymbol(reference) {
88873
+ var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
88874
+ if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
88875
+ return resolvedSymbol;
88876
+ }
88877
+ return resolveName(reference, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */,
88878
+ /*nodeNotFoundMessage*/ undefined,
88879
+ /*nameArg*/ undefined,
88880
+ /*isUse*/ true,
88881
+ /*excludeGlobals*/ undefined,
88882
+ /*getSpellingSuggestions*/ undefined);
88883
+ }
88847
88884
  function getReferencedValueDeclaration(referenceIn) {
88848
88885
  if (!ts.isGeneratedIdentifier(referenceIn)) {
88849
88886
  var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
@@ -95293,9 +95330,10 @@ var ts;
95293
95330
  return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
95294
95331
  }
95295
95332
  function shouldEmitAliasDeclaration(node) {
95296
- return compilerOptions.preserveValueImports
95297
- ? resolver.isValueAliasDeclaration(node)
95298
- : resolver.isReferencedAliasDeclaration(node);
95333
+ return ts.isInJSFile(node) ||
95334
+ (compilerOptions.preserveValueImports
95335
+ ? resolver.isValueAliasDeclaration(node)
95336
+ : resolver.isReferencedAliasDeclaration(node));
95299
95337
  }
95300
95338
  }
95301
95339
  ts.transformTypeScript = transformTypeScript;
@@ -110467,7 +110505,7 @@ var ts;
110467
110505
  var _a;
110468
110506
  var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
110469
110507
  var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
110470
- if (augmentingDeclarations) {
110508
+ if (primaryDeclaration && augmentingDeclarations) {
110471
110509
  for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
110472
110510
  var augmentations = augmentingDeclarations_1[_i];
110473
110511
  context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)));
@@ -118516,7 +118554,6 @@ var ts;
118516
118554
  return resolutions;
118517
118555
  }
118518
118556
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
118519
- ;
118520
118557
  /**
118521
118558
  * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
118522
118559
  * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
@@ -135012,7 +135049,7 @@ var ts;
135012
135049
  if (!dependencies)
135013
135050
  continue;
135014
135051
  for (var dep in dependencies) {
135015
- if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) {
135052
+ if (ts.hasProperty(dependencies, dep) && !ts.startsWith(dep, "@types/")) {
135016
135053
  result.push(dep);
135017
135054
  }
135018
135055
  }
@@ -135865,7 +135902,6 @@ var ts;
135865
135902
  var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
135866
135903
  return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
135867
135904
  }
135868
- ;
135869
135905
  function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
135870
135906
  var declarations = symbol.getDeclarations();
135871
135907
  if (!(declarations && declarations.length)) {
@@ -138569,7 +138605,6 @@ var ts;
138569
138605
  function isArrowFunctionBody(node) {
138570
138606
  return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node;
138571
138607
  }
138572
- ;
138573
138608
  /** True if symbol is a type or a module containing at least one type. */
138574
138609
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
138575
138610
  if (seenModules === void 0) { seenModules = new ts.Map(); }
@@ -149650,19 +149685,19 @@ var ts;
149650
149685
  return function (context) { return context.options && context.options[optionName] === optionValue; };
149651
149686
  }
149652
149687
  function isOptionEnabled(optionName) {
149653
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; };
149688
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !!context.options[optionName]; };
149654
149689
  }
149655
149690
  function isOptionDisabled(optionName) {
149656
- return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !context.options[optionName]; };
149691
+ return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !context.options[optionName]; };
149657
149692
  }
149658
149693
  function isOptionDisabledOrUndefined(optionName) {
149659
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName]; };
149694
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName]; };
149660
149695
  }
149661
149696
  function isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName) {
149662
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
149697
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
149663
149698
  }
149664
149699
  function isOptionEnabledOrUndefined(optionName) {
149665
- return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; };
149700
+ return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !!context.options[optionName]; };
149666
149701
  }
149667
149702
  function isForContext(context) {
149668
149703
  return context.contextNode.kind === 245 /* SyntaxKind.ForStatement */;
@@ -162646,7 +162681,6 @@ var ts;
162646
162681
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
162647
162682
  },
162648
162683
  });
162649
- ;
162650
162684
  function getInfo(context, considerPartialSpans) {
162651
162685
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
162652
162686
  var file = context.file, program = context.program;
@@ -163123,7 +163157,6 @@ var ts;
163123
163157
  });
163124
163158
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
163125
163159
  }
163126
- ;
163127
163160
  function isValidExpression(node) {
163128
163161
  return ts.isBinaryExpression(node) || ts.isConditionalExpression(node);
163129
163162
  }
@@ -163171,7 +163204,6 @@ var ts;
163171
163204
  if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
163172
163205
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
163173
163206
  }
163174
- ;
163175
163207
  var finalExpression = getFinalExpressionInChain(expression.right);
163176
163208
  if (!finalExpression)
163177
163209
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) };
@@ -165515,7 +165547,6 @@ var ts;
165515
165547
  (function (ts) {
165516
165548
  var refactor;
165517
165549
  (function (refactor) {
165518
- ;
165519
165550
  /**
165520
165551
  * Checks if some refactor info has refactor error info.
165521
165552
  */
@@ -165620,7 +165651,6 @@ var ts;
165620
165651
  // Imports will be copied to the new file anyway, and may still be needed in the old file.
165621
165652
  // Prologue directives will be copied to the new file and should be left in the old file.
165622
165653
  return !isPureImport(statement) && !ts.isPrologueDirective(statement);
165623
- ;
165624
165654
  }
165625
165655
  function isPureImport(node) {
165626
165656
  switch (node.kind) {
@@ -175256,7 +175286,7 @@ var ts;
175256
175286
  // raw is now fixed and ready
175257
175287
  this.safelist = raw.typesMap;
175258
175288
  for (var key in raw.simpleMap) {
175259
- if (raw.simpleMap.hasOwnProperty(key)) {
175289
+ if (ts.hasProperty(raw.simpleMap, key)) {
175260
175290
  this.legacySafelist.set(key, raw.simpleMap[key].toLowerCase());
175261
175291
  }
175262
175292
  }
@@ -178670,7 +178700,6 @@ var ts;
178670
178700
  }
178671
178701
  return ts.deduplicate(outputs, ts.equateValues);
178672
178702
  }
178673
- ;
178674
178703
  function createDocumentSpanSet() {
178675
178704
  return ts.createSet(function (_a) {
178676
178705
  var textSpan = _a.textSpan;