typescript 4.7.0-dev.20220425 → 4.7.0-dev.20220428

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.20220425";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220428";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -8861,6 +8861,7 @@ var ts;
8861
8861
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
8862
8862
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
8863
8863
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
8864
+ Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments: diag(2810, ts.DiagnosticCategory.Error, "Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_2810", "Expected 1 argument, but got 0. 'new Promise()' needs a JSDoc hint to produce a 'resolve' that can be called without arguments."),
8864
8865
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8865
8866
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
8866
8867
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -37951,7 +37952,8 @@ var ts;
37951
37952
  if (!comment) {
37952
37953
  comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
37953
37954
  }
37954
- return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
37955
+ var end = comment !== undefined ? getNodePos() : typeExpression.end;
37956
+ return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
37955
37957
  }
37956
37958
  function escapedTextsEqual(a, b) {
37957
37959
  while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
@@ -48325,6 +48327,7 @@ var ts;
48325
48327
  var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
48326
48328
  var numberOrBigIntType = getUnionType([numberType, bigintType]);
48327
48329
  var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
48330
+ var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type
48328
48331
  var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; });
48329
48332
  var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; });
48330
48333
  var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal
@@ -51306,7 +51309,7 @@ var ts;
51306
51309
  }
51307
51310
  }
51308
51311
  function getExportSymbolOfValueSymbolIfExported(symbol) {
51309
- return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol);
51312
+ return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol);
51310
51313
  }
51311
51314
  function symbolIsValue(symbol) {
51312
51315
  return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && !getTypeOnlyAliasDeclaration(symbol));
@@ -58709,7 +58712,7 @@ var ts;
58709
58712
  var typeVariable = getHomomorphicTypeVariable(type);
58710
58713
  if (typeVariable && !type.declaration.nameType) {
58711
58714
  var constraint = getConstraintOfTypeParameter(typeVariable);
58712
- if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
58715
+ if (constraint && isArrayOrTupleType(constraint)) {
58713
58716
  return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
58714
58717
  }
58715
58718
  }
@@ -59071,10 +59074,10 @@ var ts;
59071
59074
  }
59072
59075
  function isApplicableIndexType(source, target) {
59073
59076
  // A 'string' index signature applies to types assignable to 'string' or 'number', and a 'number' index
59074
- // signature applies to types assignable to 'number' and numeric string literal types.
59077
+ // signature applies to types assignable to 'number', `${number}` and numeric string literal types.
59075
59078
  return isTypeAssignableTo(source, target) ||
59076
59079
  target === stringType && isTypeAssignableTo(source, numberType) ||
59077
- target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
59080
+ target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value));
59078
59081
  }
59079
59082
  function getIndexInfosOfStructuredType(type) {
59080
59083
  if (type.flags & 3670016 /* StructuredType */) {
@@ -60090,6 +60093,20 @@ var ts;
60090
60093
  constraints = ts.append(constraints, constraint);
60091
60094
  }
60092
60095
  }
60096
+ // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the
60097
+ // template type XXX, K has an added constraint of number | `${number}`.
60098
+ else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) {
60099
+ var mappedType = getTypeFromTypeNode(parent);
60100
+ if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
60101
+ var typeParameter = getHomomorphicTypeVariable(mappedType);
60102
+ if (typeParameter) {
60103
+ var constraint = getConstraintOfTypeParameter(typeParameter);
60104
+ if (constraint && everyType(constraint, isArrayOrTupleType)) {
60105
+ constraints = ts.append(constraints, getUnionType([numberType, numericStringType]));
60106
+ }
60107
+ }
60108
+ }
60109
+ }
60093
60110
  node = parent;
60094
60111
  }
60095
60112
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
@@ -61057,7 +61074,7 @@ var ts;
61057
61074
  while (i > 0) {
61058
61075
  i--;
61059
61076
  var t = types[i];
61060
- var remove = t.flags & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61077
+ var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61061
61078
  t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61062
61079
  t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61063
61080
  t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */;
@@ -61216,7 +61233,7 @@ var ts;
61216
61233
  if (!strictNullChecks && includes & 98304 /* Nullable */) {
61217
61234
  return includes & 32768 /* Undefined */ ? undefinedType : nullType;
61218
61235
  }
61219
- if (includes & 4 /* String */ && includes & 128 /* StringLiteral */ ||
61236
+ if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ||
61220
61237
  includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ ||
61221
61238
  includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ ||
61222
61239
  includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) {
@@ -63100,7 +63117,7 @@ var ts;
63100
63117
  if (!type.declaration.nameType) {
63101
63118
  var constraint = void 0;
63102
63119
  if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
63103
- (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
63120
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
63104
63121
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
63105
63122
  }
63106
63123
  if (isGenericTupleType(t)) {
@@ -64538,7 +64555,7 @@ var ts;
64538
64555
  }
64539
64556
  return false;
64540
64557
  }
64541
- return isTupleType(target) || isArrayType(target);
64558
+ return isArrayOrTupleType(target);
64542
64559
  }
64543
64560
  if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
64544
64561
  if (reportErrors) {
@@ -64668,7 +64685,7 @@ var ts;
64668
64685
  // We suppress recursive intersection property checks because they can generate lots of work when relating
64669
64686
  // recursive intersections that are structurally similar but not exactly identical. See #37854.
64670
64687
  if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
64671
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64688
+ isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) {
64672
64689
  inPropertyCheck = true;
64673
64690
  result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
64674
64691
  inPropertyCheck = false;
@@ -65656,7 +65673,7 @@ var ts;
65656
65673
  return varianceResult;
65657
65674
  }
65658
65675
  }
65659
- else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65676
+ else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
65660
65677
  if (relation !== identityRelation) {
65661
65678
  return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
65662
65679
  }
@@ -66032,7 +66049,7 @@ var ts;
66032
66049
  }
66033
66050
  var result = -1 /* True */;
66034
66051
  if (isTupleType(target)) {
66035
- if (isArrayType(source) || isTupleType(source)) {
66052
+ if (isArrayOrTupleType(source)) {
66036
66053
  if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
66037
66054
  return 0 /* False */;
66038
66055
  }
@@ -66993,6 +67010,9 @@ var ts;
66993
67010
  function isReadonlyArrayType(type) {
66994
67011
  return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType;
66995
67012
  }
67013
+ function isArrayOrTupleType(type) {
67014
+ return isArrayType(type) || isTupleType(type);
67015
+ }
66996
67016
  function isMutableArrayOrTuple(type) {
66997
67017
  return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
66998
67018
  }
@@ -67444,7 +67464,7 @@ var ts;
67444
67464
  else if (type.flags & 2097152 /* Intersection */) {
67445
67465
  result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
67446
67466
  }
67447
- else if (isArrayType(type) || isTupleType(type)) {
67467
+ else if (isArrayOrTupleType(type)) {
67448
67468
  result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
67449
67469
  }
67450
67470
  if (result && context === undefined) {
@@ -67481,7 +67501,7 @@ var ts;
67481
67501
  }
67482
67502
  }
67483
67503
  }
67484
- if (isArrayType(type) || isTupleType(type)) {
67504
+ if (isArrayOrTupleType(type)) {
67485
67505
  for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
67486
67506
  var t = _c[_b];
67487
67507
  if (reportWideningErrorsInType(t)) {
@@ -68542,7 +68562,7 @@ var ts;
68542
68562
  }
68543
68563
  // Infer from the members of source and target only if the two types are possibly related
68544
68564
  if (!typesDefinitelyUnrelated(source, target)) {
68545
- if (isArrayType(source) || isTupleType(source)) {
68565
+ if (isArrayOrTupleType(source)) {
68546
68566
  if (isTupleType(target)) {
68547
68567
  var sourceArity = getTypeReferenceArity(source);
68548
68568
  var targetArity = getTypeReferenceArity(target);
@@ -75563,8 +75583,14 @@ var ts;
75563
75583
  var parameterRange = hasRestParameter ? min
75564
75584
  : min < max ? min + "-" + max
75565
75585
  : min;
75566
- var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75567
- : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75586
+ var isVoidPromiseError = !hasRestParameter && parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node);
75587
+ if (isVoidPromiseError && ts.isInJSFile(node)) {
75588
+ return getDiagnosticForCallNode(node, ts.Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments);
75589
+ }
75590
+ var error = hasRestParameter
75591
+ ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1
75592
+ : isVoidPromiseError
75593
+ ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise
75568
75594
  : ts.Diagnostics.Expected_0_arguments_but_got_1;
75569
75595
  if (min < args.length && args.length < max) {
75570
75596
  // between min and max, but with no matching overload
@@ -108487,6 +108513,8 @@ var ts;
108487
108513
  var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
108488
108514
  errorFallbackNode = undefined;
108489
108515
  var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */));
108516
+ preserveJsDoc(statement, input);
108517
+ ts.removeAllComments(input);
108490
108518
  return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
108491
108519
  }
108492
108520
  }
@@ -124871,7 +124899,7 @@ var ts;
124871
124899
  if (!state.watch || !state.lastCachedPackageJsonLookups)
124872
124900
  return;
124873
124901
  ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath), new ts.Map(state.lastCachedPackageJsonLookups.get(resolvedPath)), {
124874
- createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
124902
+ createNewValue: function (path, _input) { return state.watchFile(path, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.PackageJson, resolved); },
124875
124903
  onDeleteValue: ts.closeFileWatcher,
124876
124904
  });
124877
124905
  }
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.7.0-dev.20220425",
5
+ "version": "4.7.0-dev.20220428",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [