typescript 4.8.0-dev.20220613 → 4.8.0-dev.20220616

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.
@@ -0,0 +1,25 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation. All rights reserved.
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ this file except in compliance with the License. You may obtain a copy of the
5
+ License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
+ MERCHANTABLITY OR NON-INFRINGEMENT.
11
+
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+
16
+
17
+ "use strict";
18
+ var ts;
19
+ (function (ts) {
20
+ var server;
21
+ (function (server) {
22
+ server.dynamicImport = (id) => import(id);
23
+ })(server = ts.server || (ts.server = {}));
24
+ })(ts || (ts = {}));
25
+ //# sourceMappingURL=dynamicImportCompat.js.map
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.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220613";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220616";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5642,9 +5642,11 @@ var ts;
5642
5642
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true),
5643
5643
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
5644
5644
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
5645
- This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
5645
+ This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
5646
5646
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
5647
5647
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
5648
+ Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
5649
+ Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
5648
5650
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5649
5651
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
5650
5652
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -6130,6 +6132,8 @@ var ts;
6130
6132
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
6131
6133
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
6132
6134
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6135
+ _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
6136
+ We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
6133
6137
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6134
6138
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6135
6139
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -28776,9 +28780,10 @@ var ts;
28776
28780
  }
28777
28781
  nextToken();
28778
28782
  var typeArguments = parseDelimitedList(20, parseType);
28779
- if (!parseExpected(31)) {
28783
+ if (reScanGreaterToken() !== 31) {
28780
28784
  return undefined;
28781
28785
  }
28786
+ nextToken();
28782
28787
  return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
28783
28788
  }
28784
28789
  function canFollowTypeArgumentsInExpression() {
@@ -40342,6 +40347,7 @@ var ts;
40342
40347
  var potentialNewTargetCollisions = [];
40343
40348
  var potentialWeakMapSetCollisions = [];
40344
40349
  var potentialReflectCollisions = [];
40350
+ var potentialUnusedRenamedBindingElementsInTypes = [];
40345
40351
  var awaitedTypeStack = [];
40346
40352
  var diagnostics = ts.createDiagnosticCollection();
40347
40353
  var suggestionDiagnostics = ts.createDiagnosticCollection();
@@ -43217,6 +43223,9 @@ var ts;
43217
43223
  if (symbol && symbol.flags & 262144 && meaning & 788968) {
43218
43224
  return { accessibility: 0 };
43219
43225
  }
43226
+ if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, false)), firstIdentifier, meaning, false).accessibility === 0) {
43227
+ return { accessibility: 0 };
43228
+ }
43220
43229
  return (symbol && hasVisibleDeclarations(symbol, true)) || {
43221
43230
  accessibility: 1,
43222
43231
  errorSymbolName: ts.getTextOfNode(firstIdentifier),
@@ -44315,14 +44324,19 @@ var ts;
44315
44324
  context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
44316
44325
  return parameterNode;
44317
44326
  function cloneBindingName(node) {
44318
- return elideInitializerAndSetEmitFlags(node);
44319
- function elideInitializerAndSetEmitFlags(node) {
44327
+ return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
44328
+ function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
44320
44329
  if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
44321
44330
  trackComputedName(node.expression, context.enclosingDeclaration, context);
44322
44331
  }
44323
- var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
44332
+ var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
44324
44333
  if (ts.isBindingElement(visited)) {
44325
- visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined);
44334
+ if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
44335
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, undefined, visited.propertyName, undefined);
44336
+ }
44337
+ else {
44338
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined);
44339
+ }
44326
44340
  }
44327
44341
  if (!ts.nodeIsSynthesized(visited)) {
44328
44342
  visited = ts.factory.cloneNode(visited);
@@ -54118,7 +54132,7 @@ var ts;
54118
54132
  return true;
54119
54133
  if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536))
54120
54134
  return true;
54121
- if (s & 524288 && t & 67108864 && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
54135
+ if (s & 524288 && t & 67108864 && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192)))
54122
54136
  return true;
54123
54137
  if (relation === assignableRelation || relation === comparableRelation) {
54124
54138
  if (s & 1)
@@ -54602,8 +54616,13 @@ var ts;
54602
54616
  return;
54603
54617
  }
54604
54618
  reportRelationError(headMessage, source, target);
54605
- if (strictNullChecks && source.flags & 8650752 && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
54606
- associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
54619
+ if (source.flags & 262144 && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
54620
+ var syntheticParam = cloneTypeParameter(source);
54621
+ syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
54622
+ if (hasNonCircularBaseConstraint(syntheticParam)) {
54623
+ var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
54624
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
54625
+ }
54607
54626
  }
54608
54627
  }
54609
54628
  function traceUnionsOrIntersectionsTooLarge(source, target) {
@@ -54728,7 +54747,7 @@ var ts;
54728
54747
  return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
54729
54748
  }
54730
54749
  if (target.flags & 2097152) {
54731
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
54750
+ return typeRelatedToEachType(source, target, reportErrors, 2);
54732
54751
  }
54733
54752
  if (relation === comparableRelation && target.flags & 131068) {
54734
54753
  var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
@@ -56752,12 +56771,13 @@ var ts;
56752
56771
  && ((target.flags & (8 | 4 | 16)) !== 0);
56753
56772
  }
56754
56773
  function isObjectTypeWithInferableIndex(type) {
56774
+ var objectFlags = ts.getObjectFlags(type);
56755
56775
  return type.flags & 2097152
56756
56776
  ? ts.every(type.types, isObjectTypeWithInferableIndex)
56757
56777
  : !!(type.symbol
56758
56778
  && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0
56759
56779
  && !(type.symbol.flags & 32)
56760
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 && isObjectTypeWithInferableIndex(type.source));
56780
+ && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304) || !!(objectFlags & 1024 && isObjectTypeWithInferableIndex(type.source));
56761
56781
  }
56762
56782
  function createSymbolWithType(source, type) {
56763
56783
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
@@ -69337,6 +69357,21 @@ var ts;
69337
69357
  }
69338
69358
  });
69339
69359
  }
69360
+ function checkPotentialUncheckedRenamedBindingElementsInTypes() {
69361
+ var _a;
69362
+ for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
69363
+ var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
69364
+ if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
69365
+ var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
69366
+ ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
69367
+ var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
69368
+ if (!wrappingDeclaration.type) {
69369
+ ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
69370
+ }
69371
+ diagnostics.add(diagnostic);
69372
+ }
69373
+ }
69374
+ }
69340
69375
  function bindingNameText(name) {
69341
69376
  switch (name.kind) {
69342
69377
  case 79:
@@ -69579,6 +69614,13 @@ var ts;
69579
69614
  }
69580
69615
  }
69581
69616
  if (ts.isBindingElement(node)) {
69617
+ if (node.propertyName &&
69618
+ ts.isIdentifier(node.name) &&
69619
+ ts.isParameterDeclaration(node) &&
69620
+ ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
69621
+ potentialUnusedRenamedBindingElementsInTypes.push(node);
69622
+ return;
69623
+ }
69582
69624
  if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5) {
69583
69625
  checkExternalEmitHelpers(node, 4);
69584
69626
  }
@@ -72569,6 +72611,7 @@ var ts;
72569
72611
  ts.clear(potentialNewTargetCollisions);
72570
72612
  ts.clear(potentialWeakMapSetCollisions);
72571
72613
  ts.clear(potentialReflectCollisions);
72614
+ ts.clear(potentialUnusedRenamedBindingElementsInTypes);
72572
72615
  ts.forEach(node.statements, checkSourceElement);
72573
72616
  checkSourceElement(node.endOfFileToken);
72574
72617
  checkDeferredNodes(node);
@@ -72583,6 +72626,9 @@ var ts;
72583
72626
  }
72584
72627
  });
72585
72628
  }
72629
+ if (!node.isDeclarationFile) {
72630
+ checkPotentialUncheckedRenamedBindingElementsInTypes();
72631
+ }
72586
72632
  });
72587
72633
  if (compilerOptions.importsNotUsedAsValues === 2 &&
72588
72634
  !node.isDeclarationFile &&
@@ -89662,7 +89708,7 @@ var ts;
89662
89708
  });
89663
89709
  return ret;
89664
89710
  }
89665
- function filterBindingPatternInitializers(name) {
89711
+ function filterBindingPatternInitializersAndRenamings(name) {
89666
89712
  if (name.kind === 79) {
89667
89713
  return name;
89668
89714
  }
@@ -89678,7 +89724,10 @@ var ts;
89678
89724
  if (elem.kind === 227) {
89679
89725
  return elem;
89680
89726
  }
89681
- return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
89727
+ if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
89728
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
89729
+ }
89730
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
89682
89731
  }
89683
89732
  }
89684
89733
  function ensureParameter(p, modifierMask, type) {
@@ -89687,7 +89736,7 @@ var ts;
89687
89736
  oldDiag = getSymbolAccessibilityDiagnostic;
89688
89737
  getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
89689
89738
  }
89690
- var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p));
89739
+ var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p));
89691
89740
  if (!suppressNewDiagnosticContexts) {
89692
89741
  getSymbolAccessibilityDiagnostic = oldDiag;
89693
89742
  }
@@ -97010,6 +97059,7 @@ var ts;
97010
97059
  ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
97011
97060
  ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
97012
97061
  ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
97062
+ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
97013
97063
  ]);
97014
97064
  function shouldProgramCreateNewSourceFiles(program, newOptions) {
97015
97065
  if (!program)
@@ -101452,9 +101502,11 @@ var ts;
101452
101502
  }
101453
101503
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
101454
101504
  ts.Debug.assert(!!resolution.refCount);
101505
+ var affectingLocations = resolution.affectingLocations;
101506
+ if (!affectingLocations.length)
101507
+ return;
101455
101508
  if (addToResolutionsWithOnlyAffectingLocations)
101456
101509
  resolutionsWithOnlyAffectingLocations.push(resolution);
101457
- var affectingLocations = resolution.affectingLocations;
101458
101510
  for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
101459
101511
  var affectingLocation = affectingLocations_1[_i];
101460
101512
  createFileWatcherOfAffectingLocation(affectingLocation);