typescript 4.5.0-dev.20211101 → 4.6.0-dev.20211104

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.
@@ -290,11 +290,11 @@ var ts;
290
290
  (function (ts) {
291
291
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
292
292
  // If changing the text in this section, be sure to test `configurePrerelease` too.
293
- ts.versionMajorMinor = "4.5";
293
+ ts.versionMajorMinor = "4.6";
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20211101";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211104";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -4994,6 +4994,7 @@ var ts;
4994
4994
  NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 33554432] = "ConstructorReferenceInClass";
4995
4995
  NodeCheckFlags[NodeCheckFlags["ContainsClassWithPrivateIdentifiers"] = 67108864] = "ContainsClassWithPrivateIdentifiers";
4996
4996
  NodeCheckFlags[NodeCheckFlags["ContainsSuperPropertyInStaticInitializer"] = 134217728] = "ContainsSuperPropertyInStaticInitializer";
4997
+ NodeCheckFlags[NodeCheckFlags["InCheckIdentifier"] = 268435456] = "InCheckIdentifier";
4997
4998
  })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {}));
4998
4999
  var TypeFlags;
4999
5000
  (function (TypeFlags) {
@@ -5067,8 +5068,6 @@ var ts;
5067
5068
  // 'Narrowable' types are types where narrowing actually narrows.
5068
5069
  // This *should* be every type other than null, undefined, void, and never
5069
5070
  TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable";
5070
- /* @internal */
5071
- TypeFlags[TypeFlags["NotPrimitiveUnion"] = 468598819] = "NotPrimitiveUnion";
5072
5071
  // The following flags are aggregated during union and intersection type construction
5073
5072
  /* @internal */
5074
5073
  TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
@@ -5081,6 +5080,10 @@ var ts;
5081
5080
  TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard";
5082
5081
  /* @internal */
5083
5082
  TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject";
5083
+ /* @internal */
5084
+ TypeFlags[TypeFlags["IncludesInstantiable"] = 33554432] = "IncludesInstantiable";
5085
+ /* @internal */
5086
+ TypeFlags[TypeFlags["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
5084
5087
  })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {}));
5085
5088
  // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
5086
5089
  // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
@@ -8295,7 +8298,7 @@ var ts;
8295
8298
  Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
8296
8299
  Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
8297
8300
  Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
8298
- Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."),
8301
+ Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."),
8299
8302
  Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
8300
8303
  Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
8301
8304
  String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
@@ -8895,11 +8898,12 @@ var ts;
8895
8898
  Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."),
8896
8899
  Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
8897
8900
  Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"),
8898
- Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext'."),
8901
+ Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."),
8899
8902
  Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
8900
8903
  Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
8901
8904
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
8902
8905
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8906
+ Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8903
8907
  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}'."),
8904
8908
  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}'."),
8905
8909
  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}'."),
@@ -11926,6 +11930,7 @@ var ts;
11926
11930
  tokenValue = tokenValue.slice(0, -1);
11927
11931
  pos--;
11928
11932
  }
11933
+ return getIdentifierToken();
11929
11934
  }
11930
11935
  return token;
11931
11936
  }
@@ -54312,12 +54317,15 @@ var ts;
54312
54317
  }
54313
54318
  /** Return the inferred type for a binding element */
54314
54319
  function getTypeForBindingElement(declaration) {
54315
- var pattern = declaration.parent;
54316
- var parentType = getTypeForBindingElementParent(pattern.parent);
54317
- // If no type or an any type was inferred for parent, infer that for the binding element
54318
- if (!parentType || isTypeAny(parentType)) {
54320
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent);
54321
+ return parentType && getBindingElementTypeFromParentType(declaration, parentType);
54322
+ }
54323
+ function getBindingElementTypeFromParentType(declaration, parentType) {
54324
+ // If an any type was inferred for parent, infer that for the binding element
54325
+ if (isTypeAny(parentType)) {
54319
54326
  return parentType;
54320
54327
  }
54328
+ var pattern = declaration.parent;
54321
54329
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
54322
54330
  if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
54323
54331
  parentType = getNonNullableType(parentType);
@@ -59529,6 +59537,8 @@ var ts;
59529
59537
  // We ignore 'never' types in unions
59530
59538
  if (!(flags & 131072 /* Never */)) {
59531
59539
  includes |= flags & 205258751 /* IncludesMask */;
59540
+ if (flags & 465829888 /* Instantiable */)
59541
+ includes |= 33554432 /* IncludesInstantiable */;
59532
59542
  if (type === wildcardType)
59533
59543
  includes |= 8388608 /* IncludesWildcard */;
59534
59544
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
@@ -59742,7 +59752,7 @@ var ts;
59742
59752
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
59743
59753
  }
59744
59754
  }
59745
- var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
59755
+ var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
59746
59756
  (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
59747
59757
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
59748
59758
  }
@@ -62937,7 +62947,7 @@ var ts;
62937
62947
  return true;
62938
62948
  }
62939
62949
  if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
62940
- var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
62950
+ var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
62941
62951
  if (related !== undefined) {
62942
62952
  return !!(related & 1 /* Succeeded */);
62943
62953
  }
@@ -63786,7 +63796,8 @@ var ts;
63786
63796
  if (overflow) {
63787
63797
  return 0 /* False */;
63788
63798
  }
63789
- var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0), relation);
63799
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
63800
+ var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
63790
63801
  var entry = relation.get(id);
63791
63802
  if (entry !== undefined) {
63792
63803
  if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
@@ -63813,16 +63824,13 @@ var ts;
63813
63824
  targetStack = [];
63814
63825
  }
63815
63826
  else {
63816
- // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids
63817
- // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus
63818
- // prevent finding matches- but it should hit up the common cases
63819
- var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) {
63820
- var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
63821
- return "=" + index;
63822
- }); }).join(",");
63827
+ // A key that starts with "*" is an indication that we have type references that reference constrained
63828
+ // type parameters. For such keys we also check against the key we would have gotten if all type parameters
63829
+ // were unconstrained.
63830
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
63823
63831
  for (var i = 0; i < maybeCount; i++) {
63824
63832
  // If source and target are already being compared, consider them related with assumptions
63825
- if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
63833
+ if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
63826
63834
  return 3 /* Maybe */;
63827
63835
  }
63828
63836
  }
@@ -64117,7 +64125,7 @@ var ts;
64117
64125
  originalErrorInfo = undefined;
64118
64126
  }
64119
64127
  }
64120
- else if (isGenericMappedType(target)) {
64128
+ else if (isGenericMappedType(target) && relation !== identityRelation) {
64121
64129
  // Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`.
64122
64130
  var keysRemapped = !!target.declaration.nameType;
64123
64131
  var templateType = getTemplateTypeFromMappedType(target);
@@ -65329,48 +65337,56 @@ var ts;
65329
65337
  function isTypeReferenceWithGenericArguments(type) {
65330
65338
  return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
65331
65339
  }
65332
- /**
65333
- * getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65334
- * where A.id=111 and number.id=12
65335
- */
65336
- function getTypeReferenceId(type, typeParameters, depth) {
65337
- if (depth === void 0) { depth = 0; }
65338
- var result = "" + type.target.id;
65339
- for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65340
- var t = _a[_i];
65341
- if (isUnconstrainedTypeParameter(t)) {
65342
- var index = typeParameters.indexOf(t);
65343
- if (index < 0) {
65344
- index = typeParameters.length;
65345
- typeParameters.push(t);
65340
+ function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
65341
+ var typeParameters = [];
65342
+ var constraintMarker = "";
65343
+ var sourceId = getTypeReferenceId(source, 0);
65344
+ var targetId = getTypeReferenceId(target, 0);
65345
+ return "" + constraintMarker + sourceId + "," + targetId + postFix;
65346
+ // getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65347
+ // where A.id=111 and number.id=12
65348
+ function getTypeReferenceId(type, depth) {
65349
+ if (depth === void 0) { depth = 0; }
65350
+ var result = "" + type.target.id;
65351
+ for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65352
+ var t = _a[_i];
65353
+ if (t.flags & 262144 /* TypeParameter */) {
65354
+ if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
65355
+ var index = typeParameters.indexOf(t);
65356
+ if (index < 0) {
65357
+ index = typeParameters.length;
65358
+ typeParameters.push(t);
65359
+ }
65360
+ result += "=" + index;
65361
+ continue;
65362
+ }
65363
+ // We mark type references that reference constrained type parameters such that we know to obtain
65364
+ // and look for a "broadest equivalent key" in the cache.
65365
+ constraintMarker = "*";
65366
+ }
65367
+ else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65368
+ result += "<" + getTypeReferenceId(t, depth + 1) + ">";
65369
+ continue;
65346
65370
  }
65347
- result += "=" + index;
65348
- }
65349
- else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65350
- result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
65351
- }
65352
- else {
65353
65371
  result += "-" + t.id;
65354
65372
  }
65373
+ return result;
65355
65374
  }
65356
- return result;
65357
65375
  }
65358
65376
  /**
65359
65377
  * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
65360
65378
  * For other cases, the types ids are used.
65361
65379
  */
65362
- function getRelationKey(source, target, intersectionState, relation) {
65380
+ function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
65363
65381
  if (relation === identityRelation && source.id > target.id) {
65364
65382
  var temp = source;
65365
65383
  source = target;
65366
65384
  target = temp;
65367
65385
  }
65368
65386
  var postFix = intersectionState ? ":" + intersectionState : "";
65369
- if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
65370
- var typeParameters = [];
65371
- return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
65372
- }
65373
- return source.id + "," + target.id + postFix;
65387
+ return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
65388
+ getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
65389
+ source.id + "," + target.id + postFix;
65374
65390
  }
65375
65391
  // Invoke the callback for each underlying property symbol of the given symbol and return the first
65376
65392
  // value that isn't undefined.
@@ -65418,28 +65434,35 @@ var ts;
65418
65434
  !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
65419
65435
  }
65420
65436
  // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
65421
- // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65437
+ // for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65422
65438
  // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
65423
- // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5
65439
+ // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
65424
65440
  // levels, but unequal at some level beyond that.
65425
- // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially
65426
- // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives
65427
- // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65428
- // It also detects when a recursive type reference has expanded 5 or more times, eg, if the true branch of
65441
+ // In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
65442
+ // essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
65443
+ // false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65444
+ // It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
65429
65445
  // `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
65430
- // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
65431
- // in such cases we need to terminate the expansion, and we do so here.
65446
+ // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
65447
+ // to terminate the expansion, and we do so here.
65432
65448
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
65433
- if (maxDepth === void 0) { maxDepth = 5; }
65449
+ if (maxDepth === void 0) { maxDepth = 3; }
65434
65450
  if (depth >= maxDepth) {
65435
65451
  var identity_1 = getRecursionIdentity(type);
65436
65452
  var count = 0;
65453
+ var lastTypeId = 0;
65437
65454
  for (var i = 0; i < depth; i++) {
65438
- if (getRecursionIdentity(stack[i]) === identity_1) {
65439
- count++;
65440
- if (count >= maxDepth) {
65441
- return true;
65455
+ var t = stack[i];
65456
+ if (getRecursionIdentity(t) === identity_1) {
65457
+ // We only count occurrences with a higher type id than the previous occurrence, since higher
65458
+ // type ids are an indicator of newer instantiations caused by recursion.
65459
+ if (t.id >= lastTypeId) {
65460
+ count++;
65461
+ if (count >= maxDepth) {
65462
+ return true;
65463
+ }
65442
65464
  }
65465
+ lastTypeId = t.id;
65443
65466
  }
65444
65467
  }
65445
65468
  }
@@ -66178,7 +66201,8 @@ var ts;
66178
66201
  (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
66179
66202
  param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
66180
66203
  var newName = "arg" + param.parent.parameters.indexOf(param);
66181
- errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
66204
+ var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
66205
+ errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
66182
66206
  return;
66183
66207
  }
66184
66208
  diagnostic = declaration.dotDotDotToken ?
@@ -67544,29 +67568,6 @@ var ts;
67544
67568
  }
67545
67569
  return false;
67546
67570
  }
67547
- function getPropertyAccess(expr) {
67548
- if (ts.isAccessExpression(expr)) {
67549
- return expr;
67550
- }
67551
- if (ts.isIdentifier(expr)) {
67552
- var symbol = getResolvedSymbol(expr);
67553
- if (isConstVariable(symbol)) {
67554
- var declaration = symbol.valueDeclaration;
67555
- // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
67556
- if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) {
67557
- return declaration.initializer;
67558
- }
67559
- // Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
67560
- if (ts.isBindingElement(declaration) && !declaration.initializer) {
67561
- var parent = declaration.parent.parent;
67562
- if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) {
67563
- return declaration;
67564
- }
67565
- }
67566
- }
67567
- }
67568
- return undefined;
67569
- }
67570
67571
  function getAccessedPropertyName(access) {
67571
67572
  var propertyName;
67572
67573
  return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
@@ -68465,20 +68466,21 @@ var ts;
68465
68466
  }
68466
68467
  return false;
68467
68468
  }
68468
- function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
68469
+ function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
68469
68470
  if (initialType === void 0) { initialType = declaredType; }
68471
+ if (flowNode === void 0) { flowNode = reference.flowNode; }
68470
68472
  var key;
68471
68473
  var isKeySet = false;
68472
68474
  var flowDepth = 0;
68473
68475
  if (flowAnalysisDisabled) {
68474
68476
  return errorType;
68475
68477
  }
68476
- if (!reference.flowNode) {
68478
+ if (!flowNode) {
68477
68479
  return declaredType;
68478
68480
  }
68479
68481
  flowInvocationCount++;
68480
68482
  var sharedFlowStart = sharedFlowCount;
68481
- var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
68483
+ var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
68482
68484
  sharedFlowCount = sharedFlowStart;
68483
68485
  // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation,
68484
68486
  // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
@@ -68910,13 +68912,57 @@ var ts;
68910
68912
  }
68911
68913
  return result;
68912
68914
  }
68915
+ function getCandidateDiscriminantPropertyAccess(expr) {
68916
+ if (ts.isBindingPattern(reference)) {
68917
+ // When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
68918
+ // An identifier for a destructuring variable declared in the same binding pattern is a candidate.
68919
+ if (ts.isIdentifier(expr)) {
68920
+ var symbol = getResolvedSymbol(expr);
68921
+ var declaration = symbol.valueDeclaration;
68922
+ if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
68923
+ return declaration;
68924
+ }
68925
+ }
68926
+ }
68927
+ else if (ts.isAccessExpression(expr)) {
68928
+ // An access expression is a candidate if the reference matches the left hand expression.
68929
+ if (isMatchingReference(reference, expr.expression)) {
68930
+ return expr;
68931
+ }
68932
+ }
68933
+ else if (ts.isIdentifier(expr)) {
68934
+ var symbol = getResolvedSymbol(expr);
68935
+ if (isConstVariable(symbol)) {
68936
+ var declaration = symbol.valueDeclaration;
68937
+ // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
68938
+ if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
68939
+ isMatchingReference(reference, declaration.initializer.expression)) {
68940
+ return declaration.initializer;
68941
+ }
68942
+ // Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
68943
+ if (ts.isBindingElement(declaration) && !declaration.initializer) {
68944
+ var parent = declaration.parent.parent;
68945
+ if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
68946
+ isMatchingReference(reference, parent.initializer)) {
68947
+ return declaration;
68948
+ }
68949
+ }
68950
+ }
68951
+ }
68952
+ return undefined;
68953
+ }
68913
68954
  function getDiscriminantPropertyAccess(expr, computedType) {
68914
- var access, name;
68915
68955
  var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
68916
- return type.flags & 1048576 /* Union */ && (access = getPropertyAccess(expr)) && (name = getAccessedPropertyName(access)) &&
68917
- isMatchingReference(reference, ts.isAccessExpression(access) ? access.expression : access.parent.parent.initializer) &&
68918
- isDiscriminantProperty(type, name) ?
68919
- access : undefined;
68956
+ if (type.flags & 1048576 /* Union */) {
68957
+ var access = getCandidateDiscriminantPropertyAccess(expr);
68958
+ if (access) {
68959
+ var name = getAccessedPropertyName(access);
68960
+ if (name && isDiscriminantProperty(type, name)) {
68961
+ return access;
68962
+ }
68963
+ }
68964
+ }
68965
+ return undefined;
68920
68966
  }
68921
68967
  function narrowTypeByDiscriminant(type, access, narrowType) {
68922
68968
  var propName = getAccessedPropertyName(access);
@@ -69674,6 +69720,49 @@ var ts;
69674
69720
  }
69675
69721
  }
69676
69722
  }
69723
+ function getNarrowedTypeOfSymbol(symbol, location) {
69724
+ // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69725
+ // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69726
+ // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69727
+ // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69728
+ // other binding elements from the same destructuring. Consider:
69729
+ //
69730
+ // type Action =
69731
+ // | { kind: 'A', payload: number }
69732
+ // | { kind: 'B', payload: string };
69733
+ //
69734
+ // function f1({ kind, payload }: Action) {
69735
+ // if (kind === 'A') {
69736
+ // payload.toFixed();
69737
+ // }
69738
+ // if (kind === 'B') {
69739
+ // payload.toUpperCase();
69740
+ // }
69741
+ // }
69742
+ //
69743
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69744
+ // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69745
+ // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69746
+ // destructuring from the narrowed parent type.
69747
+ var declaration = symbol.valueDeclaration;
69748
+ if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69749
+ var parent = declaration.parent.parent;
69750
+ if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69751
+ var links = getNodeLinks(location);
69752
+ if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69753
+ links.flags |= 268435456 /* InCheckIdentifier */;
69754
+ var parentType = getTypeForBindingElementParent(parent);
69755
+ links.flags &= ~268435456 /* InCheckIdentifier */;
69756
+ if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69757
+ var pattern = declaration.parent;
69758
+ var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69759
+ return getBindingElementTypeFromParentType(declaration, narrowedType);
69760
+ }
69761
+ }
69762
+ }
69763
+ }
69764
+ return getTypeOfSymbol(symbol);
69765
+ }
69677
69766
  function checkIdentifier(node, checkMode) {
69678
69767
  var symbol = getResolvedSymbol(node);
69679
69768
  if (symbol === unknownSymbol) {
@@ -69747,7 +69836,7 @@ var ts;
69747
69836
  }
69748
69837
  }
69749
69838
  checkNestedBlockScopedBinding(node, symbol);
69750
- var type = getTypeOfSymbol(localOrExportSymbol);
69839
+ var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
69751
69840
  var assignmentKind = ts.getAssignmentTargetKind(node);
69752
69841
  if (assignmentKind) {
69753
69842
  if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
@@ -70790,13 +70879,13 @@ var ts;
70790
70879
  function isCircularMappedProperty(symbol) {
70791
70880
  return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
70792
70881
  }
70793
- function getTypeOfPropertyOfContextualType(type, name) {
70882
+ function getTypeOfPropertyOfContextualType(type, name, nameType) {
70794
70883
  return mapType(type, function (t) {
70795
70884
  var _a;
70796
70885
  if (isGenericMappedType(t)) {
70797
70886
  var constraint = getConstraintTypeFromMappedType(t);
70798
70887
  var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
70799
- var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
70888
+ var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
70800
70889
  if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
70801
70890
  return substituteIndexedMappedType(t, propertyNameType);
70802
70891
  }
@@ -70812,7 +70901,7 @@ var ts;
70812
70901
  return restType;
70813
70902
  }
70814
70903
  }
70815
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
70904
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
70816
70905
  }
70817
70906
  return undefined;
70818
70907
  }, /*noReductions*/ true);
@@ -70840,7 +70929,8 @@ var ts;
70840
70929
  // For a (non-symbol) computed property, there is no reason to look up the name
70841
70930
  // in the type. It will just be "__computed", which does not appear in any
70842
70931
  // SymbolTable.
70843
- return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName);
70932
+ var symbol = getSymbolOfNode(element);
70933
+ return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
70844
70934
  }
70845
70935
  if (element.name) {
70846
70936
  var nameType_2 = getLiteralTypeFromPropertyName(element.name);
@@ -78551,7 +78641,9 @@ var ts;
78551
78641
  var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
78552
78642
  if (!typeReferenceNode)
78553
78643
  return undefined;
78554
- var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217
78644
+ var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
78645
+ if (!typeParameters)
78646
+ return undefined;
78555
78647
  var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
78556
78648
  return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
78557
78649
  }
@@ -82961,8 +83053,11 @@ var ts;
82961
83053
  function checkAssertClause(declaration) {
82962
83054
  var _a;
82963
83055
  if (declaration.assertClause) {
82964
- if (moduleKind !== ts.ModuleKind.ESNext) {
82965
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext);
83056
+ var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
83057
+ if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
83058
+ return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
83059
+ ? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
83060
+ : ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
82966
83061
  }
82967
83062
  if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
82968
83063
  return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
@@ -86809,12 +86904,12 @@ var ts;
86809
86904
  return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
86810
86905
  }
86811
86906
  var nodeArguments = node.arguments;
86812
- if (moduleKind !== ts.ModuleKind.ESNext) {
86907
+ if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
86813
86908
  // We are allowed trailing comma after proposal-import-assertions.
86814
86909
  checkGrammarForDisallowedTrailingComma(nodeArguments);
86815
86910
  if (nodeArguments.length > 1) {
86816
86911
  var assertionArgument = nodeArguments[1];
86817
- return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext);
86912
+ return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
86818
86913
  }
86819
86914
  }
86820
86915
  if (nodeArguments.length === 0 || nodeArguments.length > 2) {
@@ -119547,13 +119642,15 @@ var ts;
119547
119642
  if (host.fileExists(packageJsonPath)) {
119548
119643
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119549
119644
  // TODO: Inject `require` or `import` condition based on the intended import mode
119550
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119551
- if (fromExports) {
119552
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119553
- return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119554
- }
119555
- if (packageJsonContent.exports) {
119556
- return { moduleFileToTry: path, blockedByExports: true };
119645
+ if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119646
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119647
+ if (fromExports) {
119648
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119649
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119650
+ }
119651
+ if (packageJsonContent.exports) {
119652
+ return { moduleFileToTry: path, blockedByExports: true };
119653
+ }
119557
119654
  }
119558
119655
  var versionPaths = packageJsonContent.typesVersions
119559
119656
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
@@ -129329,7 +129426,7 @@ var ts;
129329
129426
  }
129330
129427
  node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
129331
129428
  completionNodes.push(node);
129332
- }, body, isAbstract);
129429
+ }, body, 2 /* Property */, isAbstract);
129333
129430
  if (completionNodes.length) {
129334
129431
  insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129335
129432
  }
@@ -134871,7 +134968,8 @@ var ts;
134871
134968
  }
134872
134969
  }
134873
134970
  else {
134874
- return nodeEntry(ref, 2 /* StringLiteral */);
134971
+ return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined :
134972
+ nodeEntry(ref, 2 /* StringLiteral */);
134875
134973
  }
134876
134974
  }
134877
134975
  });
@@ -146695,9 +146793,6 @@ var ts;
146695
146793
  });
146696
146794
  function makeChange(changeTracker, sourceFile, pos) {
146697
146795
  var token = ts.getTokenAtPosition(sourceFile, pos);
146698
- if (!ts.isIdentifier(token)) {
146699
- return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind));
146700
- }
146701
146796
  var param = token.parent;
146702
146797
  if (!ts.isParameter(param)) {
146703
146798
  return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind));
@@ -146705,9 +146800,10 @@ var ts;
146705
146800
  var i = param.parent.parameters.indexOf(param);
146706
146801
  ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one.");
146707
146802
  ts.Debug.assert(i > -1, "Parameter not found in parent parameter list.");
146803
+ var typeNode = ts.factory.createTypeReferenceNode(param.name, /*typeArguments*/ undefined);
146708
146804
  var replacement = ts.factory.createParameterDeclaration(
146709
- /*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, ts.factory.createTypeReferenceNode(token, /*typeArguments*/ undefined), param.initializer);
146710
- changeTracker.replaceNode(sourceFile, token, replacement);
146805
+ /*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, param.dotDotDotToken ? ts.factory.createArrayTypeNode(typeNode) : typeNode, param.initializer);
146806
+ changeTracker.replaceNode(sourceFile, param, replacement);
146711
146807
  }
146712
146808
  })(codefix = ts.codefix || (ts.codefix = {}));
146713
146809
  })(ts || (ts = {}));
@@ -153161,11 +153257,18 @@ var ts;
153161
153257
  };
153162
153258
  }
153163
153259
  codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
153260
+ var PreserveOptionalFlags;
153261
+ (function (PreserveOptionalFlags) {
153262
+ PreserveOptionalFlags[PreserveOptionalFlags["Method"] = 1] = "Method";
153263
+ PreserveOptionalFlags[PreserveOptionalFlags["Property"] = 2] = "Property";
153264
+ PreserveOptionalFlags[PreserveOptionalFlags["All"] = 3] = "All";
153265
+ })(PreserveOptionalFlags = codefix.PreserveOptionalFlags || (codefix.PreserveOptionalFlags = {}));
153164
153266
  /**
153165
153267
  * `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
153166
153268
  * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
153167
153269
  */
153168
- function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
153270
+ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) {
153271
+ if (preserveOptional === void 0) { preserveOptional = 3 /* All */; }
153169
153272
  if (isAmbient === void 0) { isAmbient = false; }
153170
153273
  var declarations = symbol.getDeclarations();
153171
153274
  if (!(declarations && declarations.length)) {
@@ -153194,7 +153297,7 @@ var ts;
153194
153297
  }
153195
153298
  }
153196
153299
  addClassElement(ts.factory.createPropertyDeclaration(
153197
- /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
153300
+ /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode,
153198
153301
  /*initializer*/ undefined));
153199
153302
  break;
153200
153303
  case 171 /* GetAccessor */:
@@ -153258,13 +153361,13 @@ var ts;
153258
153361
  }
153259
153362
  else {
153260
153363
  ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
153261
- addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
153364
+ addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body));
153262
153365
  }
153263
153366
  }
153264
153367
  break;
153265
153368
  }
153266
153369
  function outputMethod(quotePreference, signature, modifiers, name, body) {
153267
- var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder);
153370
+ var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder);
153268
153371
  if (method)
153269
153372
  addClassElement(method);
153270
153373
  }