typescript 4.5.0-dev.20211023 → 4.5.0-dev.20211027

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20211023";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20211027";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -49397,21 +49397,28 @@ var ts;
49397
49397
  var namespaceName = getFullyQualifiedName(namespace);
49398
49398
  var declarationName = ts.declarationNameToString(right);
49399
49399
  var suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace);
49400
- var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
49401
- var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
49402
- var canSuggestTypeof = containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName);
49403
49400
  if (suggestionForNonexistentModule) {
49404
49401
  error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule));
49402
+ return undefined;
49405
49403
  }
49406
- else if (canSuggestTypeof) {
49404
+ var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
49405
+ var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet
49406
+ && (meaning & 788968 /* Type */)
49407
+ && containingQualifiedName
49408
+ && !ts.isTypeOfExpression(containingQualifiedName.parent)
49409
+ && tryGetQualifiedNameAsValue(containingQualifiedName);
49410
+ if (canSuggestTypeof) {
49407
49411
  error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName));
49412
+ return undefined;
49408
49413
  }
49409
- else if (meaning & 1920 /* Namespace */ && exportedTypeSymbol && ts.isQualifiedName(name.parent)) {
49410
- error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText));
49411
- }
49412
- else {
49413
- error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
49414
+ if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) {
49415
+ var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
49416
+ if (exportedTypeSymbol) {
49417
+ error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText));
49418
+ return undefined;
49419
+ }
49414
49420
  }
49421
+ error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
49415
49422
  }
49416
49423
  return undefined;
49417
49424
  }
@@ -59324,7 +59331,7 @@ var ts;
59324
59331
  var _loop_16 = function () {
59325
59332
  i--;
59326
59333
  var t = types[i];
59327
- if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) {
59334
+ if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
59328
59335
  ts.orderedRemoveItemAt(types, i);
59329
59336
  }
59330
59337
  };
@@ -63057,13 +63064,12 @@ var ts;
63057
63064
  traceUnionsOrIntersectionsTooLarge(source, target);
63058
63065
  var result = 0 /* False */;
63059
63066
  var saveErrorInfo = captureErrorCalculationState();
63060
- // Note that these checks are specifically ordered to produce correct results. In particular,
63061
- // we need to deconstruct unions before intersections (because unions are always at the top),
63062
- // and we need to handle "each" relations before "some" relations for the same kind of type.
63063
- if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63064
- result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
63065
- recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
63066
- structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63067
+ if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
63068
+ // We skip caching when source or target is a union with no more than three constituents.
63069
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63070
+ }
63071
+ else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63072
+ result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
63067
63073
  }
63068
63074
  if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63069
63075
  if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
@@ -63520,19 +63526,19 @@ var ts;
63520
63526
  var maybeStart = maybeCount;
63521
63527
  maybeKeys[maybeCount] = id;
63522
63528
  maybeCount++;
63529
+ var saveExpandingFlags = expandingFlags;
63523
63530
  if (recursionFlags & 1 /* Source */) {
63524
63531
  sourceStack[sourceDepth] = source;
63525
63532
  sourceDepth++;
63533
+ if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63534
+ expandingFlags |= 1 /* Source */;
63526
63535
  }
63527
63536
  if (recursionFlags & 2 /* Target */) {
63528
63537
  targetStack[targetDepth] = target;
63529
63538
  targetDepth++;
63539
+ if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63540
+ expandingFlags |= 2 /* Target */;
63530
63541
  }
63531
- var saveExpandingFlags = expandingFlags;
63532
- if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63533
- expandingFlags |= 1 /* Source */;
63534
- if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63535
- expandingFlags |= 2 /* Target */;
63536
63542
  var originalHandler;
63537
63543
  var propagatingVarianceFlags = 0;
63538
63544
  if (outofbandVarianceMarkerHandler) {
@@ -63556,13 +63562,13 @@ var ts;
63556
63562
  if (outofbandVarianceMarkerHandler) {
63557
63563
  outofbandVarianceMarkerHandler = originalHandler;
63558
63564
  }
63559
- expandingFlags = saveExpandingFlags;
63560
63565
  if (recursionFlags & 1 /* Source */) {
63561
63566
  sourceDepth--;
63562
63567
  }
63563
63568
  if (recursionFlags & 2 /* Target */) {
63564
63569
  targetDepth--;
63565
63570
  }
63571
+ expandingFlags = saveExpandingFlags;
63566
63572
  if (result) {
63567
63573
  if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
63568
63574
  if (result === -1 /* True */ || result === 3 /* Maybe */) {
@@ -63900,8 +63906,7 @@ var ts;
63900
63906
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
63901
63907
  instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
63902
63908
  }
63903
- var result_9 = inferTypesFromTemplateLiteralType(source, target);
63904
- if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) {
63909
+ if (isTypeMatchedByTemplateLiteralType(source, target)) {
63905
63910
  return -1 /* True */;
63906
63911
  }
63907
63912
  }
@@ -64096,9 +64101,9 @@ var ts;
64096
64101
  if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
64097
64102
  var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
64098
64103
  if (objectOnlyTarget.flags & 1048576 /* Union */) {
64099
- var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
64100
- if (result_10) {
64101
- return result_10;
64104
+ var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
64105
+ if (result_9) {
64106
+ return result_9;
64102
64107
  }
64103
64108
  }
64104
64109
  }
@@ -64170,13 +64175,13 @@ var ts;
64170
64175
  var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
64171
64176
  getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
64172
64177
  if (modifiersRelated) {
64173
- var result_11;
64178
+ var result_10;
64174
64179
  var targetConstraint = getConstraintTypeFromMappedType(target);
64175
64180
  var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
64176
- if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64181
+ if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64177
64182
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
64178
64183
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
64179
- return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64184
+ return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64180
64185
  }
64181
64186
  }
64182
64187
  }
@@ -66259,6 +66264,10 @@ var ts;
66259
66264
  inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) :
66260
66265
  undefined;
66261
66266
  }
66267
+ function isTypeMatchedByTemplateLiteralType(source, target) {
66268
+ var inferences = inferTypesFromTemplateLiteralType(source, target);
66269
+ return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); });
66270
+ }
66262
66271
  function getStringLikeTypeForType(type) {
66263
66272
  return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
66264
66273
  }
@@ -67794,7 +67803,7 @@ var ts;
67794
67803
  mapType(type, mapper);
67795
67804
  }
67796
67805
  function getConstituentCount(type) {
67797
- return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1;
67806
+ return type.flags & 1048576 /* Union */ ? type.types.length : 1;
67798
67807
  }
67799
67808
  function extractTypesOfKind(type, kind) {
67800
67809
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
@@ -69292,7 +69301,7 @@ var ts;
69292
69301
  return parent.kind === 205 /* PropertyAccessExpression */ ||
69293
69302
  parent.kind === 207 /* CallExpression */ && parent.expression === node ||
69294
69303
  parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node &&
69295
- !(isGenericTypeWithoutNullableConstraint(type) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
69304
+ !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
69296
69305
  }
69297
69306
  function isGenericTypeWithUnionConstraint(type) {
69298
69307
  return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
@@ -78721,12 +78730,12 @@ var ts;
78721
78730
  case 264 /* ImportEqualsDeclaration */:
78722
78731
  case 267 /* NamespaceImport */:
78723
78732
  case 266 /* ImportClause */:
78724
- var result_12 = 0 /* None */;
78733
+ var result_11 = 0 /* None */;
78725
78734
  var target = resolveAlias(getSymbolOfNode(d));
78726
78735
  ts.forEach(target.declarations, function (d) {
78727
- result_12 |= getDeclarationSpaces(d);
78736
+ result_11 |= getDeclarationSpaces(d);
78728
78737
  });
78729
- return result_12;
78738
+ return result_11;
78730
78739
  case 253 /* VariableDeclaration */:
78731
78740
  case 202 /* BindingElement */:
78732
78741
  case 255 /* FunctionDeclaration */:
@@ -94899,8 +94908,8 @@ var ts;
94899
94908
  function convertJsxChildrenToChildrenPropAssignment(children) {
94900
94909
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
94901
94910
  if (ts.length(nonWhitespaceChildren) === 1) {
94902
- var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
94903
- return result_13 && factory.createPropertyAssignment("children", result_13);
94911
+ var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
94912
+ return result_12 && factory.createPropertyAssignment("children", result_12);
94904
94913
  }
94905
94914
  var result = ts.mapDefined(children, transformJsxChildToExpression);
94906
94915
  return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
@@ -113700,15 +113709,15 @@ var ts;
113700
113709
  // which per above occurred during the current program creation.
113701
113710
  // Since we assume the filesystem does not change during program creation,
113702
113711
  // it is safe to reuse resolutions from the earlier call.
113703
- var result_14 = [];
113712
+ var result_13 = [];
113704
113713
  var i = 0;
113705
113714
  for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
113706
113715
  var moduleName = moduleNames_1[_i];
113707
113716
  var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
113708
113717
  i++;
113709
- result_14.push(resolvedModule);
113718
+ result_13.push(resolvedModule);
113710
113719
  }
113711
- return result_14;
113720
+ return result_13;
113712
113721
  }
113713
113722
  // At this point, we know at least one of the following hold:
113714
113723
  // - file has local declarations for ambient modules
@@ -118770,9 +118779,9 @@ var ts;
118770
118779
  if (!preferSymlinks) {
118771
118780
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
118772
118781
  // so we only need to remove them from the realpath filenames.
118773
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
118774
- if (result_15)
118775
- return result_15;
118782
+ var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
118783
+ if (result_14)
118784
+ return result_14;
118776
118785
  }
118777
118786
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
118778
118787
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -118792,10 +118801,10 @@ var ts;
118792
118801
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
118793
118802
  var symlinkDirectory = symlinkDirectories_1[_i];
118794
118803
  var option = ts.resolvePath(symlinkDirectory, relative);
118795
- var result_16 = cb(option, target === referenceRedirect);
118804
+ var result_15 = cb(option, target === referenceRedirect);
118796
118805
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
118797
- if (result_16)
118798
- return result_16;
118806
+ if (result_15)
118807
+ return result_15;
118799
118808
  }
118800
118809
  });
118801
118810
  });
@@ -1661,6 +1661,7 @@
1661
1661
  "_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property_2610": "\"{0}\" 在类 \"{1}\" 中定义为访问器,但这里在 \"{2}\" 中重写为实例属性。",
1662
1662
  "_0_is_deprecated_6385": "“{0}”已弃用。",
1663
1663
  "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012": "“{0}”不是关键字“{1}”的有效元属性。是否是指“{2}”?",
1664
+ "_0_is_not_allowed_as_a_parameter_name_1390": "不允许将 '{0}' 作为参数名。",
1664
1665
  "_0_is_not_allowed_as_a_variable_declaration_name_1389": "“{0}”不得用作变量声明名称。",
1665
1666
  "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": "“{0}”在其自身的基表达式中得到直接或间接引用。",
1666
1667
  "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": "“{0}”在其自身的类型批注中得到直接或间接引用。",
@@ -1661,6 +1661,7 @@
1661
1661
  "_0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property_2610": "'{0}' 在類別 '{1}' 中定義為存取子,但在此處的 '{2}' 中卻覆寫為執行個體屬性。",
1662
1662
  "_0_is_deprecated_6385": "'{0}' 已淘汰。",
1663
1663
  "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012": "'{0}' 對關鍵字 '{1}' 而言不是有效的中繼屬性。您是指 '{2}' 嗎?",
1664
+ "_0_is_not_allowed_as_a_parameter_name_1390": "不允許 '{0}' 做為參數名稱。",
1664
1665
  "_0_is_not_allowed_as_a_variable_declaration_name_1389": "'{0}' 不能是變數宣告名稱。",
1665
1666
  "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": "'{0}' 在其本身的基底運算式中直接或間接受到參考。",
1666
1667
  "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": "'{0}' 在其本身的類型註釋中直接或間接受到參考。",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.5.0-dev.20211023",
5
+ "version": "4.5.0-dev.20211027",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [