typescript 4.6.0-dev.20211202 → 4.6.0-dev.20211206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20211202";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20211206";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
@@ -738,7 +738,11 @@ var ts;
738
738
  }
739
739
  return deduplicated;
740
740
  }
741
- function insertSorted(array, insert, compare) {
741
+ function createSortedArray() {
742
+ return [];
743
+ }
744
+ ts.createSortedArray = createSortedArray;
745
+ function insertSorted(array, insert, compare, allowDuplicates) {
742
746
  if (array.length === 0) {
743
747
  array.push(insert);
744
748
  return;
@@ -747,6 +751,9 @@ var ts;
747
751
  if (insertIndex < 0) {
748
752
  array.splice(~insertIndex, 0, insert);
749
753
  }
754
+ else if (allowDuplicates) {
755
+ array.splice(insertIndex, 0, insert);
756
+ }
750
757
  }
751
758
  ts.insertSorted = insertSorted;
752
759
  function sortAndDeduplicate(array, comparer, equalityComparer) {
@@ -5431,6 +5438,7 @@ var ts;
5431
5438
  Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."),
5432
5439
  An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."),
5433
5440
  Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."),
5441
+ Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function: diag(2311, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function_2311", "Cannot find name '{0}'. Did you mean to write this in an async function?"),
5434
5442
  An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."),
5435
5443
  Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."),
5436
5444
  Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."),
@@ -16516,6 +16524,10 @@ var ts;
16516
16524
  return text.replace(/\$/gm, "\\$");
16517
16525
  }
16518
16526
  ts.escapeSnippetText = escapeSnippetText;
16527
+ function isThisTypeParameter(type) {
16528
+ return !!(type.flags & 262144 && type.isThisType);
16529
+ }
16530
+ ts.isThisTypeParameter = isThisTypeParameter;
16519
16531
  })(ts || (ts = {}));
16520
16532
  var ts;
16521
16533
  (function (ts) {
@@ -33811,7 +33823,10 @@ var ts;
33811
33823
  }
33812
33824
  }
33813
33825
  var failedLookupLocations = [];
33814
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
33826
+ var features = ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
33827
+ ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
33828
+ NodeResolutionFeatures.None;
33829
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
33815
33830
  var resolved = primaryLookup();
33816
33831
  var primary = true;
33817
33832
  if (!resolved) {
@@ -34364,13 +34379,15 @@ var ts;
34364
34379
  NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
34365
34380
  NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
34366
34381
  NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
34382
+ NodeResolutionFeatures[NodeResolutionFeatures["Node12Default"] = 14] = "Node12Default";
34383
+ NodeResolutionFeatures[NodeResolutionFeatures["NodeNextDefault"] = 30] = "NodeNextDefault";
34367
34384
  NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
34368
34385
  })(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
34369
34386
  function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
34370
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
34387
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Node12Default, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
34371
34388
  }
34372
34389
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
34373
- return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
34390
+ return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
34374
34391
  }
34375
34392
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
34376
34393
  var containingDirectory = ts.getDirectoryPath(containingFile);
@@ -38297,6 +38314,7 @@ var ts;
38297
38314
  getIndexInfosOfType: getIndexInfosOfType,
38298
38315
  getSignaturesOfType: getSignaturesOfType,
38299
38316
  getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 ? stringType : numberType); },
38317
+ getIndexType: function (type) { return getIndexType(type); },
38300
38318
  getBaseTypes: getBaseTypes,
38301
38319
  getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
38302
38320
  getWidenedType: getWidenedType,
@@ -39447,11 +39465,12 @@ var ts;
39447
39465
  }
39448
39466
  }
39449
39467
  }
39450
- function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) {
39468
+ function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
39451
39469
  if (excludeGlobals === void 0) { excludeGlobals = false; }
39452
- return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol);
39470
+ if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
39471
+ return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions, getSymbol);
39453
39472
  }
39454
- function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) {
39473
+ function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
39455
39474
  var _a, _b, _c;
39456
39475
  var originalLocation = location;
39457
39476
  var result;
@@ -39686,7 +39705,7 @@ var ts;
39686
39705
  }
39687
39706
  }
39688
39707
  if (!result) {
39689
- if (nameNotFoundMessage) {
39708
+ if (nameNotFoundMessage && produceDiagnostics) {
39690
39709
  if (!errorLocation ||
39691
39710
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
39692
39711
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
@@ -39696,7 +39715,7 @@ var ts;
39696
39715
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
39697
39716
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
39698
39717
  var suggestion = void 0;
39699
- if (suggestionCount < maximumSuggestionCount) {
39718
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
39700
39719
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
39701
39720
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
39702
39721
  if (isGlobalScopeAugmentationDeclaration) {
@@ -39731,7 +39750,7 @@ var ts;
39731
39750
  }
39732
39751
  return undefined;
39733
39752
  }
39734
- if (nameNotFoundMessage) {
39753
+ if (nameNotFoundMessage && produceDiagnostics) {
39735
39754
  if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
39736
39755
  var propertyName = propertyWithInvalidInitializer.name;
39737
39756
  error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
@@ -41923,7 +41942,7 @@ var ts;
41923
41942
  context.approximateLength += 6;
41924
41943
  return ts.factory.createKeywordTypeNode(147);
41925
41944
  }
41926
- if (isThisTypeParameter(type)) {
41945
+ if (ts.isThisTypeParameter(type)) {
41927
41946
  if (context.flags & 4194304) {
41928
41947
  if (!context.encounteredError && !(context.flags & 32768)) {
41929
41948
  context.encounteredError = true;
@@ -48811,7 +48830,7 @@ var ts;
48811
48830
  return symbol;
48812
48831
  }
48813
48832
  function getGlobalSymbol(name, meaning, diagnostic) {
48814
- return resolveName(undefined, name, meaning, diagnostic, name, false);
48833
+ return resolveName(undefined, name, meaning, diagnostic, name, false, false, false);
48815
48834
  }
48816
48835
  function getGlobalType(name, arity, reportErrors) {
48817
48836
  var symbol = getGlobalTypeSymbol(name, reportErrors);
@@ -50240,9 +50259,6 @@ var ts;
50240
50259
  return (type.flags & 58982400 || isGenericMappedType(type) || isGenericTupleType(type) ? 8388608 : 0) |
50241
50260
  (type.flags & (58982400 | 4194304 | 134217728 | 268435456) && !isPatternLiteralType(type) ? 16777216 : 0);
50242
50261
  }
50243
- function isThisTypeParameter(type) {
50244
- return !!(type.flags & 262144 && type.isThisType);
50245
- }
50246
50262
  function getSimplifiedType(type, writing) {
50247
50263
  return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
50248
50264
  type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
@@ -54742,7 +54758,7 @@ var ts;
54742
54758
  return result;
54743
54759
  }
54744
54760
  function getFalsyFlags(type) {
54745
- return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
54761
+ return type.flags & 3145728 ? getFalsyFlagsOfTypes(type.types) :
54746
54762
  type.flags & 128 ? type.value === "" ? 128 : 0 :
54747
54763
  type.flags & 256 ? type.value === 0 ? 256 : 0 :
54748
54764
  type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
@@ -56130,6 +56146,10 @@ var ts;
56130
56146
  case "BigInt64Array":
56131
56147
  case "BigUint64Array":
56132
56148
  return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later;
56149
+ case "await":
56150
+ if (ts.isCallExpression(node.parent)) {
56151
+ return ts.Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function;
56152
+ }
56133
56153
  default:
56134
56154
  if (node.parent.kind === 295) {
56135
56155
  return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
@@ -57534,7 +57554,7 @@ var ts;
57534
57554
  function narrowByInKeyword(type, name, assumeTrue) {
57535
57555
  if (type.flags & 1048576
57536
57556
  || type.flags & 524288 && declaredType !== type
57537
- || isThisTypeParameter(type)
57557
+ || ts.isThisTypeParameter(type)
57538
57558
  || type.flags & 2097152 && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
57539
57559
  return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
57540
57560
  }
@@ -59872,15 +59892,9 @@ var ts;
59872
59892
  }
59873
59893
  }
59874
59894
  function isValidSpreadType(type) {
59875
- if (type.flags & 465829888) {
59876
- var constraint = getBaseConstraintOfType(type);
59877
- if (constraint !== undefined) {
59878
- return isValidSpreadType(constraint);
59879
- }
59880
- }
59881
- return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
59882
- getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
59883
- type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
59895
+ var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType));
59896
+ return !!(t.flags & (1 | 67108864 | 524288 | 58982400) ||
59897
+ t.flags & 3145728 && ts.every(t.types, isValidSpreadType));
59884
59898
  }
59885
59899
  function checkJsxSelfClosingElementDeferred(node) {
59886
59900
  checkJsxOpeningLikeElementOrOpeningFragment(node);
@@ -60666,7 +60680,7 @@ var ts;
60666
60680
  }
60667
60681
  var propType;
60668
60682
  if (!prop) {
60669
- var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ?
60683
+ var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ?
60670
60684
  getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined;
60671
60685
  if (!(indexInfo && indexInfo.type)) {
60672
60686
  var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, true);
@@ -60683,7 +60697,7 @@ var ts;
60683
60697
  return anyType;
60684
60698
  }
60685
60699
  if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
60686
- reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
60700
+ reportNonexistentProperty(right, ts.isThisTypeParameter(leftType) ? apparentType : leftType, isUncheckedJS);
60687
60701
  }
60688
60702
  return errorType;
60689
60703
  }
@@ -60957,7 +60971,7 @@ var ts;
60957
60971
  }
60958
60972
  function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
60959
60973
  ts.Debug.assert(outerName !== undefined, "outername should always be defined");
60960
- var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
60974
+ var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, true, function (symbols, name, meaning) {
60961
60975
  ts.Debug.assertEqual(outerName, name, "name should equal outerName");
60962
60976
  var symbol = getSymbol(symbols, name, meaning);
60963
60977
  if (symbol)
@@ -61147,7 +61161,7 @@ var ts;
61147
61161
  }
61148
61162
  var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
61149
61163
  var accessFlags = ts.isAssignmentTarget(node) ?
61150
- 4 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 : 0) :
61164
+ 4 | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 : 0) :
61151
61165
  32;
61152
61166
  var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
61153
61167
  return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
@@ -72858,11 +72872,13 @@ var ts;
72858
72872
  return false;
72859
72873
  }
72860
72874
  function checkNumericLiteralValueSize(node) {
72861
- if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
72875
+ var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1;
72876
+ var isScientific = node.numericLiteralFlags & 16;
72877
+ if (isFractional || isScientific) {
72862
72878
  return;
72863
72879
  }
72864
- var apparentValue = +ts.getTextOfNode(node);
72865
- if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
72880
+ var value = +node.text;
72881
+ if (value <= Math.pow(2, 53) - 1) {
72866
72882
  return;
72867
72883
  }
72868
72884
  addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers));
@@ -75556,7 +75572,7 @@ var ts;
75556
75572
  return undefined;
75557
75573
  }
75558
75574
  var prefix = getClassMemberPrefix(node, member);
75559
- var memberName = getExpressionForPropertyName(member, true);
75575
+ var memberName = getExpressionForPropertyName(member, !ts.hasSyntacticModifier(member, 2));
75560
75576
  var descriptor = languageVersion > 0
75561
75577
  ? member.kind === 166
75562
75578
  ? factory.createVoidZero()