typescript 4.7.0-dev.20220403 → 4.7.0-dev.20220406

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.20220403";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220406";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -4404,10 +4404,11 @@ var ts;
4404
4404
  NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
4405
4405
  NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
4406
4406
  NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
4407
- NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError";
4408
- NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile";
4409
- NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError";
4410
- NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData";
4407
+ NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
4408
+ NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
4409
+ NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
4410
+ NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
4411
+ NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
4411
4412
  // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
4412
4413
  // walking the tree if the flags are not set. However, these flags are just a approximation
4413
4414
  // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
@@ -4417,25 +4418,25 @@ var ts;
4417
4418
  // removal, it is likely that users will add the import anyway.
4418
4419
  // The advantage of this approach is its simplicity. For the case of batch compilation,
4419
4420
  // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
4420
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport";
4421
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta";
4422
- NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
4423
- /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
4424
- /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
4425
- NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
4426
- /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 67108864] = "TypeCached";
4427
- /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 134217728] = "Deprecated";
4421
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
4422
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
4423
+ NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
4424
+ /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
4425
+ /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
4426
+ NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
4427
+ /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
4428
+ /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
4428
4429
  NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
4429
4430
  NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
4430
4431
  NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
4431
4432
  // Parsing context flags
4432
- NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags";
4433
+ NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
4433
4434
  // Exclude these flags when parsing a Type
4434
4435
  NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
4435
4436
  // Represents all flags that are potentially set once and
4436
4437
  // never cleared on SourceFiles which get re-used in between incremental parses.
4437
4438
  // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
4438
- /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags";
4439
+ /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
4439
4440
  })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
4440
4441
  var ModifierFlags;
4441
4442
  (function (ModifierFlags) {
@@ -8877,6 +8878,7 @@ var ts;
8877
8878
  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}'?"),
8878
8879
  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."),
8879
8880
  Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8881
+ All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
8880
8882
  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}'."),
8881
8883
  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}'."),
8882
8884
  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}'."),
@@ -14291,24 +14293,24 @@ var ts;
14291
14293
  // Returns true if this node contains a parse error anywhere underneath it.
14292
14294
  function containsParseError(node) {
14293
14295
  aggregateChildData(node);
14294
- return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14296
+ return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14295
14297
  }
14296
14298
  ts.containsParseError = containsParseError;
14297
14299
  function aggregateChildData(node) {
14298
- if (!(node.flags & 524288 /* HasAggregatedChildData */)) {
14300
+ if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
14299
14301
  // A node is considered to contain a parse error if:
14300
14302
  // a) the parser explicitly marked that it had an error
14301
14303
  // b) any of it's children reported that it had an error.
14302
- var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) ||
14304
+ var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
14303
14305
  ts.forEachChild(node, containsParseError);
14304
14306
  // If so, mark ourselves accordingly.
14305
14307
  if (thisNodeOrAnySubNodesHasError) {
14306
- node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */;
14308
+ node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
14307
14309
  }
14308
14310
  // Also mark that we've propagated the child information to this node. This way we can
14309
14311
  // always consult the bit directly on this node without needing to check its children
14310
14312
  // again.
14311
- node.flags |= 524288 /* HasAggregatedChildData */;
14313
+ node.flags |= 1048576 /* HasAggregatedChildData */;
14312
14314
  }
14313
14315
  }
14314
14316
  function getSourceFileOfNode(node) {
@@ -16115,11 +16117,11 @@ var ts;
16115
16117
  }
16116
16118
  ts.isSourceFileNotJS = isSourceFileNotJS;
16117
16119
  function isInJSFile(node) {
16118
- return !!node && !!(node.flags & 131072 /* JavaScriptFile */);
16120
+ return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
16119
16121
  }
16120
16122
  ts.isInJSFile = isInJSFile;
16121
16123
  function isInJsonFile(node) {
16122
- return !!node && !!(node.flags & 33554432 /* JsonFile */);
16124
+ return !!node && !!(node.flags & 67108864 /* JsonFile */);
16123
16125
  }
16124
16126
  ts.isInJsonFile = isInJsonFile;
16125
16127
  function isSourceFileNotJson(file) {
@@ -16127,7 +16129,7 @@ var ts;
16127
16129
  }
16128
16130
  ts.isSourceFileNotJson = isSourceFileNotJson;
16129
16131
  function isInJSDoc(node) {
16130
- return !!node && !!(node.flags & 4194304 /* JSDoc */);
16132
+ return !!node && !!(node.flags & 8388608 /* JSDoc */);
16131
16133
  }
16132
16134
  ts.isInJSDoc = isInJSDoc;
16133
16135
  function isJSDocIndexSignature(node) {
@@ -16513,7 +16515,7 @@ var ts;
16513
16515
  function setValueDeclaration(symbol, node) {
16514
16516
  var valueDeclaration = symbol.valueDeclaration;
16515
16517
  if (!valueDeclaration ||
16516
- !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) &&
16518
+ !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
16517
16519
  (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
16518
16520
  (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
16519
16521
  // other kinds of value declarations take precedence over modules and assignment declarations
@@ -16786,7 +16788,11 @@ var ts;
16786
16788
  ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
16787
16789
  function getHostSignatureFromJSDoc(node) {
16788
16790
  var host = getEffectiveJSDocHost(node);
16789
- return host && ts.isFunctionLike(host) ? host : undefined;
16791
+ if (host) {
16792
+ return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
16793
+ ts.isFunctionLike(host) ? host : undefined;
16794
+ }
16795
+ return undefined;
16790
16796
  }
16791
16797
  ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
16792
16798
  function getEffectiveJSDocHost(node) {
@@ -20811,7 +20817,7 @@ var ts;
20811
20817
  }
20812
20818
  ts.pseudoBigIntToString = pseudoBigIntToString;
20813
20819
  function isValidTypeOnlyAliasUseSite(useSite) {
20814
- return !!(useSite.flags & 8388608 /* Ambient */)
20820
+ return !!(useSite.flags & 16777216 /* Ambient */)
20815
20821
  || isPartOfTypeQuery(useSite)
20816
20822
  || isIdentifierInNonEmittingHeritageClause(useSite)
20817
20823
  || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
@@ -21264,11 +21270,20 @@ var ts;
21264
21270
  parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
21265
21271
  parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
21266
21272
  parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
21267
- parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
21268
- parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
21269
- parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
21270
- parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
21273
+ parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
21274
+ parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
21275
+ parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
21276
+ parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
21277
+ parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
21278
+ parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
21279
+ parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
21280
+ parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
21281
+ parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
21282
+ parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
21283
+ parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
21284
+ parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
21271
21285
  parenthesizeTypeArguments: parenthesizeTypeArguments,
21286
+ parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
21272
21287
  };
21273
21288
  function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
21274
21289
  binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
@@ -21580,33 +21595,191 @@ var ts;
21580
21595
  }
21581
21596
  return body;
21582
21597
  }
21583
- function parenthesizeMemberOfConditionalType(member) {
21584
- return member.kind === 189 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
21598
+ // Type[Extends] :
21599
+ // FunctionOrConstructorType
21600
+ // ConditionalType[?Extends]
21601
+ // ConditionalType[Extends] :
21602
+ // UnionType[?Extends]
21603
+ // [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
21604
+ //
21605
+ // - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
21606
+ // - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
21607
+ // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
21608
+ function parenthesizeCheckTypeOfConditionalType(checkType) {
21609
+ switch (checkType.kind) {
21610
+ case 179 /* FunctionType */:
21611
+ case 180 /* ConstructorType */:
21612
+ case 189 /* ConditionalType */:
21613
+ return factory.createParenthesizedType(checkType);
21614
+ }
21615
+ return checkType;
21616
+ }
21617
+ function parenthesizeExtendsTypeOfConditionalType(extendsType) {
21618
+ switch (extendsType.kind) {
21619
+ case 189 /* ConditionalType */:
21620
+ return factory.createParenthesizedType(extendsType);
21621
+ }
21622
+ return extendsType;
21585
21623
  }
21586
- function parenthesizeMemberOfElementType(member) {
21587
- switch (member.kind) {
21624
+ // UnionType[Extends] :
21625
+ // `|`? IntersectionType[?Extends]
21626
+ // UnionType[?Extends] `|` IntersectionType[?Extends]
21627
+ //
21628
+ // - A union type constituent has the same precedence as the check type of a conditional type
21629
+ function parenthesizeConstituentTypeOfUnionType(type) {
21630
+ switch (type.kind) {
21631
+ case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
21632
+ case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21633
+ return factory.createParenthesizedType(type);
21634
+ }
21635
+ return parenthesizeCheckTypeOfConditionalType(type);
21636
+ }
21637
+ function parenthesizeConstituentTypesOfUnionType(members) {
21638
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
21639
+ }
21640
+ // IntersectionType[Extends] :
21641
+ // `&`? TypeOperator[?Extends]
21642
+ // IntersectionType[?Extends] `&` TypeOperator[?Extends]
21643
+ //
21644
+ // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
21645
+ function parenthesizeConstituentTypeOfIntersectionType(type) {
21646
+ switch (type.kind) {
21588
21647
  case 187 /* UnionType */:
21648
+ case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
21649
+ return factory.createParenthesizedType(type);
21650
+ }
21651
+ return parenthesizeConstituentTypeOfUnionType(type);
21652
+ }
21653
+ function parenthesizeConstituentTypesOfIntersectionType(members) {
21654
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
21655
+ }
21656
+ // TypeOperator[Extends] :
21657
+ // PostfixType
21658
+ // InferType[?Extends]
21659
+ // `keyof` TypeOperator[?Extends]
21660
+ // `unique` TypeOperator[?Extends]
21661
+ // `readonly` TypeOperator[?Extends]
21662
+ //
21663
+ function parenthesizeOperandOfTypeOperator(type) {
21664
+ switch (type.kind) {
21589
21665
  case 188 /* IntersectionType */:
21590
- case 179 /* FunctionType */:
21591
- case 180 /* ConstructorType */:
21592
- return factory.createParenthesizedType(member);
21666
+ return factory.createParenthesizedType(type);
21593
21667
  }
21594
- return parenthesizeMemberOfConditionalType(member);
21668
+ return parenthesizeConstituentTypeOfIntersectionType(type);
21595
21669
  }
21596
- function parenthesizeElementTypeOfArrayType(member) {
21597
- switch (member.kind) {
21598
- case 181 /* TypeQuery */:
21670
+ function parenthesizeOperandOfReadonlyTypeOperator(type) {
21671
+ switch (type.kind) {
21599
21672
  case 193 /* TypeOperator */:
21673
+ return factory.createParenthesizedType(type);
21674
+ }
21675
+ return parenthesizeOperandOfTypeOperator(type);
21676
+ }
21677
+ // PostfixType :
21678
+ // NonArrayType
21679
+ // NonArrayType [no LineTerminator here] `!` // JSDoc
21680
+ // NonArrayType [no LineTerminator here] `?` // JSDoc
21681
+ // IndexedAccessType
21682
+ // ArrayType
21683
+ //
21684
+ // IndexedAccessType :
21685
+ // NonArrayType `[` Type[~Extends] `]`
21686
+ //
21687
+ // ArrayType :
21688
+ // NonArrayType `[` `]`
21689
+ //
21690
+ function parenthesizeNonArrayTypeOfPostfixType(type) {
21691
+ switch (type.kind) {
21600
21692
  case 190 /* InferType */:
21601
- return factory.createParenthesizedType(member);
21693
+ case 193 /* TypeOperator */:
21694
+ case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21695
+ return factory.createParenthesizedType(type);
21602
21696
  }
21603
- return parenthesizeMemberOfElementType(member);
21697
+ return parenthesizeOperandOfTypeOperator(type);
21604
21698
  }
21605
- function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
21606
- return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
21699
+ // TupleType :
21700
+ // `[` Elision? `]`
21701
+ // `[` NamedTupleElementTypes `]`
21702
+ // `[` NamedTupleElementTypes `,` Elision? `]`
21703
+ // `[` TupleElementTypes `]`
21704
+ // `[` TupleElementTypes `,` Elision? `]`
21705
+ //
21706
+ // NamedTupleElementTypes :
21707
+ // Elision? NamedTupleMember
21708
+ // NamedTupleElementTypes `,` Elision? NamedTupleMember
21709
+ //
21710
+ // NamedTupleMember :
21711
+ // Identifier `?`? `:` Type[~Extends]
21712
+ // `...` Identifier `:` Type[~Extends]
21713
+ //
21714
+ // TupleElementTypes :
21715
+ // Elision? TupleElementType
21716
+ // TupleElementTypes `,` Elision? TupleElementType
21717
+ //
21718
+ // TupleElementType :
21719
+ // Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21720
+ // OptionalType
21721
+ // RestType
21722
+ //
21723
+ // OptionalType :
21724
+ // Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21725
+ //
21726
+ // RestType :
21727
+ // `...` Type[~Extends]
21728
+ //
21729
+ function parenthesizeElementTypesOfTupleType(types) {
21730
+ return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
21731
+ }
21732
+ function parenthesizeElementTypeOfTupleType(type) {
21733
+ if (hasJSDocPostfixQuestion(type))
21734
+ return factory.createParenthesizedType(type);
21735
+ return type;
21736
+ }
21737
+ function hasJSDocPostfixQuestion(type) {
21738
+ if (ts.isJSDocNullableType(type))
21739
+ return type.postfix;
21740
+ if (ts.isNamedTupleMember(type))
21741
+ return hasJSDocPostfixQuestion(type.type);
21742
+ if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
21743
+ return hasJSDocPostfixQuestion(type.type);
21744
+ if (ts.isConditionalTypeNode(type))
21745
+ return hasJSDocPostfixQuestion(type.falseType);
21746
+ if (ts.isUnionTypeNode(type))
21747
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21748
+ if (ts.isIntersectionTypeNode(type))
21749
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21750
+ if (ts.isInferTypeNode(type))
21751
+ return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
21752
+ return false;
21753
+ }
21754
+ function parenthesizeTypeOfOptionalType(type) {
21755
+ if (hasJSDocPostfixQuestion(type))
21756
+ return factory.createParenthesizedType(type);
21757
+ return parenthesizeNonArrayTypeOfPostfixType(type);
21758
+ }
21759
+ // function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
21760
+ // switch (member.kind) {
21761
+ // case SyntaxKind.UnionType:
21762
+ // case SyntaxKind.IntersectionType:
21763
+ // case SyntaxKind.FunctionType:
21764
+ // case SyntaxKind.ConstructorType:
21765
+ // return factory.createParenthesizedType(member);
21766
+ // }
21767
+ // return parenthesizeMemberOfConditionalType(member);
21768
+ // }
21769
+ // function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
21770
+ // switch (member.kind) {
21771
+ // case SyntaxKind.TypeQuery:
21772
+ // case SyntaxKind.TypeOperator:
21773
+ // case SyntaxKind.InferType:
21774
+ // return factory.createParenthesizedType(member);
21775
+ // }
21776
+ // return parenthesizeMemberOfElementType(member);
21777
+ // }
21778
+ function parenthesizeLeadingTypeArgument(node) {
21779
+ return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21607
21780
  }
21608
21781
  function parenthesizeOrdinalTypeArgument(node, i) {
21609
- return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21782
+ return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
21610
21783
  }
21611
21784
  function parenthesizeTypeArguments(typeArguments) {
21612
21785
  if (ts.some(typeArguments)) {
@@ -21632,11 +21805,20 @@ var ts;
21632
21805
  parenthesizeExpressionForDisallowedComma: ts.identity,
21633
21806
  parenthesizeExpressionOfExpressionStatement: ts.identity,
21634
21807
  parenthesizeConciseBodyOfArrowFunction: ts.identity,
21635
- parenthesizeMemberOfConditionalType: ts.identity,
21636
- parenthesizeMemberOfElementType: ts.identity,
21637
- parenthesizeElementTypeOfArrayType: ts.identity,
21638
- parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21808
+ parenthesizeCheckTypeOfConditionalType: ts.identity,
21809
+ parenthesizeExtendsTypeOfConditionalType: ts.identity,
21810
+ parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21811
+ parenthesizeConstituentTypeOfUnionType: ts.identity,
21812
+ parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21813
+ parenthesizeConstituentTypeOfIntersectionType: ts.identity,
21814
+ parenthesizeOperandOfTypeOperator: ts.identity,
21815
+ parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
21816
+ parenthesizeNonArrayTypeOfPostfixType: ts.identity,
21817
+ parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21818
+ parenthesizeElementTypeOfTupleType: ts.identity,
21819
+ parenthesizeTypeOfOptionalType: ts.identity,
21639
21820
  parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
21821
+ parenthesizeLeadingTypeArgument: ts.identity,
21640
21822
  };
21641
21823
  })(ts || (ts = {}));
21642
21824
  /* @internal */
@@ -21776,6 +21958,8 @@ var ts;
21776
21958
  var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
21777
21959
  var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
21778
21960
  var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
21961
+ var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
21962
+ var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
21779
21963
  var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
21780
21964
  var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
21781
21965
  var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
@@ -21783,6 +21967,8 @@ var ts;
21783
21967
  var factory = {
21784
21968
  get parenthesizer() { return parenthesizerRules(); },
21785
21969
  get converters() { return converters(); },
21970
+ baseFactory: baseFactory,
21971
+ flags: flags,
21786
21972
  createNodeArray: createNodeArray,
21787
21973
  createNumericLiteral: createNumericLiteral,
21788
21974
  createBigIntLiteral: createBigIntLiteral,
@@ -22058,10 +22244,10 @@ var ts;
22058
22244
  // lazily load factory members for JSDoc types with similar structure
22059
22245
  get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
22060
22246
  get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
22061
- get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22062
- get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22063
- get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22064
- get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22247
+ get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22248
+ get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22249
+ get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22250
+ get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22065
22251
  get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
22066
22252
  get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
22067
22253
  get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
@@ -23177,7 +23363,7 @@ var ts;
23177
23363
  // @api
23178
23364
  function createArrayTypeNode(elementType) {
23179
23365
  var node = createBaseNode(183 /* ArrayType */);
23180
- node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
23366
+ node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
23181
23367
  node.transformFlags = 1 /* ContainsTypeScript */;
23182
23368
  return node;
23183
23369
  }
@@ -23190,7 +23376,7 @@ var ts;
23190
23376
  // @api
23191
23377
  function createTupleTypeNode(elements) {
23192
23378
  var node = createBaseNode(184 /* TupleType */);
23193
- node.elements = createNodeArray(elements);
23379
+ node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
23194
23380
  node.transformFlags = 1 /* ContainsTypeScript */;
23195
23381
  return node;
23196
23382
  }
@@ -23222,7 +23408,7 @@ var ts;
23222
23408
  // @api
23223
23409
  function createOptionalTypeNode(type) {
23224
23410
  var node = createBaseNode(185 /* OptionalType */);
23225
- node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
23411
+ node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
23226
23412
  node.transformFlags = 1 /* ContainsTypeScript */;
23227
23413
  return node;
23228
23414
  }
@@ -23245,38 +23431,38 @@ var ts;
23245
23431
  ? update(createRestTypeNode(type), node)
23246
23432
  : node;
23247
23433
  }
23248
- function createUnionOrIntersectionTypeNode(kind, types) {
23434
+ function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
23249
23435
  var node = createBaseNode(kind);
23250
- node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
23436
+ node.types = factory.createNodeArray(parenthesize(types));
23251
23437
  node.transformFlags = 1 /* ContainsTypeScript */;
23252
23438
  return node;
23253
23439
  }
23254
- function updateUnionOrIntersectionTypeNode(node, types) {
23440
+ function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
23255
23441
  return node.types !== types
23256
- ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
23442
+ ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
23257
23443
  : node;
23258
23444
  }
23259
23445
  // @api
23260
23446
  function createUnionTypeNode(types) {
23261
- return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
23447
+ return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23262
23448
  }
23263
23449
  // @api
23264
23450
  function updateUnionTypeNode(node, types) {
23265
- return updateUnionOrIntersectionTypeNode(node, types);
23451
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23266
23452
  }
23267
23453
  // @api
23268
23454
  function createIntersectionTypeNode(types) {
23269
- return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
23455
+ return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23270
23456
  }
23271
23457
  // @api
23272
23458
  function updateIntersectionTypeNode(node, types) {
23273
- return updateUnionOrIntersectionTypeNode(node, types);
23459
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23274
23460
  }
23275
23461
  // @api
23276
23462
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
23277
23463
  var node = createBaseNode(189 /* ConditionalType */);
23278
- node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
23279
- node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
23464
+ node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
23465
+ node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
23280
23466
  node.trueType = trueType;
23281
23467
  node.falseType = falseType;
23282
23468
  node.transformFlags = 1 /* ContainsTypeScript */;
@@ -23371,7 +23557,9 @@ var ts;
23371
23557
  function createTypeOperatorNode(operator, type) {
23372
23558
  var node = createBaseNode(193 /* TypeOperator */);
23373
23559
  node.operator = operator;
23374
- node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
23560
+ node.type = operator === 145 /* ReadonlyKeyword */ ?
23561
+ parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
23562
+ parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
23375
23563
  node.transformFlags = 1 /* ContainsTypeScript */;
23376
23564
  return node;
23377
23565
  }
@@ -23384,7 +23572,7 @@ var ts;
23384
23572
  // @api
23385
23573
  function createIndexedAccessTypeNode(objectType, indexType) {
23386
23574
  var node = createBaseNode(194 /* IndexedAccessType */);
23387
- node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
23575
+ node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
23388
23576
  node.indexType = indexType;
23389
23577
  node.transformFlags = 1 /* ContainsTypeScript */;
23390
23578
  return node;
@@ -25120,8 +25308,15 @@ var ts;
25120
25308
  return createBaseNode(kind);
25121
25309
  }
25122
25310
  // @api
25123
- // createJSDocNonNullableType
25124
25311
  // createJSDocNullableType
25312
+ // createJSDocNonNullableType
25313
+ function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
25314
+ if (postfix === void 0) { postfix = false; }
25315
+ var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
25316
+ node.postfix = postfix;
25317
+ return node;
25318
+ }
25319
+ // @api
25125
25320
  // createJSDocOptionalType
25126
25321
  // createJSDocVariadicType
25127
25322
  // createJSDocNamepathType
@@ -25133,6 +25328,12 @@ var ts;
25133
25328
  // @api
25134
25329
  // updateJSDocNonNullableType
25135
25330
  // updateJSDocNullableType
25331
+ function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
25332
+ return node.type !== type
25333
+ ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
25334
+ : node;
25335
+ }
25336
+ // @api
25136
25337
  // updateJSDocOptionalType
25137
25338
  // updateJSDocVariadicType
25138
25339
  // updateJSDocNamepathType
@@ -30213,7 +30414,7 @@ var ts;
30213
30414
  || ts.isExportDeclaration(node) ? node : undefined;
30214
30415
  }
30215
30416
  function getImportMetaIfNecessary(sourceFile) {
30216
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30417
+ return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
30217
30418
  walkTreeForImportMeta(sourceFile) :
30218
30419
  undefined;
30219
30420
  }
@@ -30868,7 +31069,7 @@ var ts;
30868
31069
  var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
30869
31070
  // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
30870
31071
  // We will manually port the flag to the new source file.
30871
- newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */);
31072
+ newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
30872
31073
  return newSourceFile;
30873
31074
  }
30874
31075
  ts.updateSourceFile = updateSourceFile;
@@ -31152,10 +31353,10 @@ var ts;
31152
31353
  switch (scriptKind) {
31153
31354
  case 1 /* JS */:
31154
31355
  case 2 /* JSX */:
31155
- contextFlags = 131072 /* JavaScriptFile */;
31356
+ contextFlags = 262144 /* JavaScriptFile */;
31156
31357
  break;
31157
31358
  case 6 /* JSON */:
31158
- contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */;
31359
+ contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
31159
31360
  break;
31160
31361
  default:
31161
31362
  contextFlags = 0 /* None */;
@@ -31190,7 +31391,7 @@ var ts;
31190
31391
  function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31191
31392
  var isDeclarationFile = isDeclarationFileName(fileName);
31192
31393
  if (isDeclarationFile) {
31193
- contextFlags |= 8388608 /* Ambient */;
31394
+ contextFlags |= 16777216 /* Ambient */;
31194
31395
  }
31195
31396
  sourceFlags = contextFlags;
31196
31397
  // Prime the scanner.
@@ -31229,7 +31430,7 @@ var ts;
31229
31430
  node.jsDoc = jsDoc;
31230
31431
  if (hasDeprecatedTag) {
31231
31432
  hasDeprecatedTag = false;
31232
- node.flags |= 134217728 /* Deprecated */;
31433
+ node.flags |= 268435456 /* Deprecated */;
31233
31434
  }
31234
31435
  return node;
31235
31436
  }
@@ -31424,6 +31625,12 @@ var ts;
31424
31625
  function disallowInAnd(func) {
31425
31626
  return doInsideOfContext(4096 /* DisallowInContext */, func);
31426
31627
  }
31628
+ function allowConditionalTypesAnd(func) {
31629
+ return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31630
+ }
31631
+ function disallowConditionalTypesAnd(func) {
31632
+ return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31633
+ }
31427
31634
  function doInYieldContext(func) {
31428
31635
  return doInsideOfContext(8192 /* YieldContext */, func);
31429
31636
  }
@@ -31451,6 +31658,9 @@ var ts;
31451
31658
  function inDisallowInContext() {
31452
31659
  return inContext(4096 /* DisallowInContext */);
31453
31660
  }
31661
+ function inDisallowConditionalTypesContext() {
31662
+ return inContext(65536 /* DisallowConditionalTypesContext */);
31663
+ }
31454
31664
  function inDecoratorContext() {
31455
31665
  return inContext(16384 /* DecoratorContext */);
31456
31666
  }
@@ -31835,7 +32045,7 @@ var ts;
31835
32045
  // flag so that we don't mark any subsequent nodes.
31836
32046
  if (parseErrorBeforeNextFinishedNode) {
31837
32047
  parseErrorBeforeNextFinishedNode = false;
31838
- node.flags |= 65536 /* ThisNodeHasError */;
32048
+ node.flags |= 131072 /* ThisNodeHasError */;
31839
32049
  }
31840
32050
  return node;
31841
32051
  }
@@ -32293,7 +32503,7 @@ var ts;
32293
32503
  // differently depending on what mode it is in.
32294
32504
  //
32295
32505
  // This also applies to all our other context flags as well.
32296
- var nodeContextFlags = node.flags & 25358336 /* ContextFlags */;
32506
+ var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
32297
32507
  if (nodeContextFlags !== contextFlags) {
32298
32508
  return undefined;
32299
32509
  }
@@ -32552,7 +32762,6 @@ var ts;
32552
32762
  default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
32553
32763
  }
32554
32764
  }
32555
- // Parses a comma-delimited list of elements
32556
32765
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
32557
32766
  var saveParsingContext = parsingContext;
32558
32767
  parsingContext |= 1 << kind;
@@ -32562,7 +32771,11 @@ var ts;
32562
32771
  while (true) {
32563
32772
  if (isListElement(kind, /*inErrorRecovery*/ false)) {
32564
32773
  var startPos = scanner.getStartPos();
32565
- list.push(parseListElement(kind, parseElement));
32774
+ var result = parseListElement(kind, parseElement);
32775
+ if (!result) {
32776
+ return undefined;
32777
+ }
32778
+ list.push(result);
32566
32779
  commaStart = scanner.getTokenPos();
32567
32780
  if (parseOptional(27 /* CommaToken */)) {
32568
32781
  // No need to check for a zero length node since we know we parsed a comma
@@ -32815,7 +33028,7 @@ var ts;
32815
33028
  function parseJSDocNonNullableType() {
32816
33029
  var pos = getNodePos();
32817
33030
  nextToken();
32818
- return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
33031
+ return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
32819
33032
  }
32820
33033
  function parseJSDocUnknownOrNullableType() {
32821
33034
  var pos = getNodePos();
@@ -32839,7 +33052,7 @@ var ts;
32839
33052
  return finishNode(factory.createJSDocUnknownType(), pos);
32840
33053
  }
32841
33054
  else {
32842
- return finishNode(factory.createJSDocNullableType(parseType()), pos);
33055
+ return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
32843
33056
  }
32844
33057
  }
32845
33058
  function parseJSDocFunctionType() {
@@ -32967,13 +33180,20 @@ var ts;
32967
33180
  }
32968
33181
  return name;
32969
33182
  }
32970
- function parseParameterInOuterAwaitContext() {
32971
- return parseParameterWorker(/*inOuterAwaitContext*/ true);
33183
+ function isParameterNameStart() {
33184
+ // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
33185
+ // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
33186
+ // complaining about the use of the keywords.
33187
+ return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */;
32972
33188
  }
32973
- function parseParameter() {
32974
- return parseParameterWorker(/*inOuterAwaitContext*/ false);
33189
+ function parseParameter(inOuterAwaitContext) {
33190
+ return parseParameterWorker(inOuterAwaitContext);
32975
33191
  }
32976
- function parseParameterWorker(inOuterAwaitContext) {
33192
+ function parseParameterForSpeculation(inOuterAwaitContext) {
33193
+ return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
33194
+ }
33195
+ function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
33196
+ if (allowAmbiguity === void 0) { allowAmbiguity = true; }
32977
33197
  var pos = getNodePos();
32978
33198
  var hasJSDoc = hasPrecedingJSDocComment();
32979
33199
  // FormalParameter [Yield,Await]:
@@ -32994,13 +33214,17 @@ var ts;
32994
33214
  var savedTopLevel = topLevel;
32995
33215
  topLevel = false;
32996
33216
  var modifiers = parseModifiers();
32997
- var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33217
+ var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
33218
+ if (!allowAmbiguity && !isParameterNameStart()) {
33219
+ return undefined;
33220
+ }
33221
+ var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
32998
33222
  topLevel = savedTopLevel;
32999
33223
  return node;
33000
33224
  }
33001
33225
  function parseReturnType(returnToken, isType) {
33002
33226
  if (shouldParseReturnType(returnToken, isType)) {
33003
- return parseTypeOrTypePredicate();
33227
+ return allowConditionalTypesAnd(parseTypeOrTypePredicate);
33004
33228
  }
33005
33229
  }
33006
33230
  function shouldParseReturnType(returnToken, isType) {
@@ -33019,7 +33243,7 @@ var ts;
33019
33243
  }
33020
33244
  return false;
33021
33245
  }
33022
- function parseParametersWorker(flags) {
33246
+ function parseParametersWorker(flags, allowAmbiguity) {
33023
33247
  // FormalParameters [Yield,Await]: (modified)
33024
33248
  // [empty]
33025
33249
  // FormalParameterList[?Yield,Await]
@@ -33039,7 +33263,7 @@ var ts;
33039
33263
  setAwaitContext(!!(flags & 2 /* Await */));
33040
33264
  var parameters = flags & 32 /* JSDoc */ ?
33041
33265
  parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
33042
- parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
33266
+ parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
33043
33267
  setYieldContext(savedYieldContext);
33044
33268
  setAwaitContext(savedAwaitContext);
33045
33269
  return parameters;
@@ -33061,7 +33285,7 @@ var ts;
33061
33285
  if (!parseExpected(20 /* OpenParenToken */)) {
33062
33286
  return createMissingList();
33063
33287
  }
33064
- var parameters = parseParametersWorker(flags);
33288
+ var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
33065
33289
  parseExpected(21 /* CloseParenToken */);
33066
33290
  return parameters;
33067
33291
  }
@@ -33143,7 +33367,7 @@ var ts;
33143
33367
  return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
33144
33368
  }
33145
33369
  function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
33146
- var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33370
+ var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33147
33371
  var type = parseTypeAnnotation();
33148
33372
  parseTypeMemberSemicolon();
33149
33373
  var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
@@ -33415,7 +33639,7 @@ var ts;
33415
33639
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
33416
33640
  }
33417
33641
  function parseImportType() {
33418
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
33642
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
33419
33643
  var pos = getNodePos();
33420
33644
  var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
33421
33645
  parseExpected(100 /* ImportKeyword */);
@@ -33565,7 +33789,7 @@ var ts;
33565
33789
  switch (token()) {
33566
33790
  case 53 /* ExclamationToken */:
33567
33791
  nextToken();
33568
- type = finishNode(factory.createJSDocNonNullableType(type), pos);
33792
+ type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
33569
33793
  break;
33570
33794
  case 57 /* QuestionToken */:
33571
33795
  // If next token is start of a type we have a conditional type
@@ -33573,7 +33797,7 @@ var ts;
33573
33797
  return type;
33574
33798
  }
33575
33799
  nextToken();
33576
- type = finishNode(factory.createJSDocNullableType(type), pos);
33800
+ type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
33577
33801
  break;
33578
33802
  case 22 /* OpenBracketToken */:
33579
33803
  parseExpected(22 /* OpenBracketToken */);
@@ -33598,12 +33822,20 @@ var ts;
33598
33822
  parseExpected(operator);
33599
33823
  return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
33600
33824
  }
33825
+ function tryParseConstraintOfInferType() {
33826
+ if (parseOptional(94 /* ExtendsKeyword */)) {
33827
+ var constraint = disallowConditionalTypesAnd(parseType);
33828
+ if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
33829
+ return constraint;
33830
+ }
33831
+ }
33832
+ }
33601
33833
  function parseTypeParameterOfInferType() {
33602
33834
  var pos = getNodePos();
33603
- return finishNode(factory.createTypeParameterDeclaration(
33604
- /*modifiers*/ undefined, parseIdentifier(),
33605
- /*constraint*/ undefined,
33606
- /*defaultType*/ undefined), pos);
33835
+ var name = parseIdentifier();
33836
+ var constraint = tryParse(tryParseConstraintOfInferType);
33837
+ var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
33838
+ return finishNode(node, pos);
33607
33839
  }
33608
33840
  function parseInferType() {
33609
33841
  var pos = getNodePos();
@@ -33620,7 +33852,7 @@ var ts;
33620
33852
  case 137 /* InferKeyword */:
33621
33853
  return parseInferType();
33622
33854
  }
33623
- return parsePostfixTypeOrHigher();
33855
+ return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
33624
33856
  }
33625
33857
  function parseFunctionOrConstructorTypeToError(isInUnionType) {
33626
33858
  // the function type and constructor type shorthand notation
@@ -33750,23 +33982,21 @@ var ts;
33750
33982
  return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
33751
33983
  }
33752
33984
  function parseType() {
33753
- // The rules about 'yield' only apply to actual code/expression contexts. They don't
33754
- // apply to 'type' contexts. So we disable these parameters here before moving on.
33755
- return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker);
33756
- }
33757
- function parseTypeWorker(noConditionalTypes) {
33985
+ if (contextFlags & 40960 /* TypeExcludesFlags */) {
33986
+ return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
33987
+ }
33758
33988
  if (isStartOfFunctionTypeOrConstructorType()) {
33759
33989
  return parseFunctionOrConstructorType();
33760
33990
  }
33761
33991
  var pos = getNodePos();
33762
33992
  var type = parseUnionTypeOrHigher();
33763
- if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
33993
+ if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
33764
33994
  // The type following 'extends' is not permitted to be another conditional type
33765
- var extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
33995
+ var extendsType = disallowConditionalTypesAnd(parseType);
33766
33996
  parseExpected(57 /* QuestionToken */);
33767
- var trueType = parseTypeWorker();
33997
+ var trueType = allowConditionalTypesAnd(parseType);
33768
33998
  parseExpected(58 /* ColonToken */);
33769
- var falseType = parseTypeWorker();
33999
+ var falseType = allowConditionalTypesAnd(parseType);
33770
34000
  return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
33771
34001
  }
33772
34002
  return type;
@@ -34193,7 +34423,16 @@ var ts;
34193
34423
  parameters = createMissingList();
34194
34424
  }
34195
34425
  else {
34196
- parameters = parseParametersWorker(isAsync);
34426
+ if (!allowAmbiguity) {
34427
+ var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
34428
+ if (!maybeParameters) {
34429
+ return undefined;
34430
+ }
34431
+ parameters = maybeParameters;
34432
+ }
34433
+ else {
34434
+ parameters = parseParametersWorker(isAsync, allowAmbiguity);
34435
+ }
34197
34436
  if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
34198
34437
  return undefined;
34199
34438
  }
@@ -34594,7 +34833,7 @@ var ts;
34594
34833
  // var foo3 = require("subfolder
34595
34834
  // import * as foo1 from "module-from-node
34596
34835
  // We want this import to be a statement rather than import call expression
34597
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
34836
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
34598
34837
  expression = parseTokenNode();
34599
34838
  }
34600
34839
  else if (lookAhead(nextTokenIsDot)) {
@@ -34602,7 +34841,7 @@ var ts;
34602
34841
  nextToken(); // advance past the 'import'
34603
34842
  nextToken(); // advance past the dot
34604
34843
  expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
34605
- sourceFlags |= 2097152 /* PossiblyContainsImportMeta */;
34844
+ sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
34606
34845
  }
34607
34846
  else {
34608
34847
  expression = parseMemberExpressionOrHigher();
@@ -34818,7 +35057,7 @@ var ts;
34818
35057
  return finishNode(factory.createJsxOpeningFragment(), pos);
34819
35058
  }
34820
35059
  var tagName = parseJsxElementName();
34821
- var typeArguments = (contextFlags & 131072 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
35060
+ var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
34822
35061
  var attributes = parseJsxAttributes();
34823
35062
  var node;
34824
35063
  if (token() === 31 /* GreaterThanToken */) {
@@ -35096,7 +35335,7 @@ var ts;
35096
35335
  return result;
35097
35336
  }
35098
35337
  function parseTypeArgumentsInExpression() {
35099
- if ((contextFlags & 131072 /* JavaScriptFile */) !== 0) {
35338
+ if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
35100
35339
  // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
35101
35340
  return undefined;
35102
35341
  }
@@ -35492,7 +35731,7 @@ var ts;
35492
35731
  var openParenParsed = parseExpected(20 /* OpenParenToken */);
35493
35732
  var expression = allowInAnd(parseExpression);
35494
35733
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35495
- var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35734
+ var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
35496
35735
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35497
35736
  }
35498
35737
  function parseCaseClause() {
@@ -35867,16 +36106,16 @@ var ts;
35867
36106
  if (isAmbient) {
35868
36107
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
35869
36108
  var m = _a[_i];
35870
- m.flags |= 8388608 /* Ambient */;
36109
+ m.flags |= 16777216 /* Ambient */;
35871
36110
  }
35872
- return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
36111
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
35873
36112
  }
35874
36113
  else {
35875
36114
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
35876
36115
  }
35877
36116
  }
35878
36117
  function tryReuseAmbientDeclaration() {
35879
- return doInsideOfContext(8388608 /* Ambient */, function () {
36118
+ return doInsideOfContext(16777216 /* Ambient */, function () {
35880
36119
  var node = currentNode(parsingContext);
35881
36120
  if (node) {
35882
36121
  return consumeNode(node);
@@ -36343,9 +36582,9 @@ var ts;
36343
36582
  if (isAmbient) {
36344
36583
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36345
36584
  var m = _a[_i];
36346
- m.flags |= 8388608 /* Ambient */;
36585
+ m.flags |= 16777216 /* Ambient */;
36347
36586
  }
36348
- return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36587
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36349
36588
  }
36350
36589
  else {
36351
36590
  return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -36910,7 +37149,7 @@ var ts;
36910
37149
  function parseJSDocTypeExpression(mayOmitBraces) {
36911
37150
  var pos = getNodePos();
36912
37151
  var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
36913
- var type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
37152
+ var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
36914
37153
  if (!mayOmitBraces || hasBrace) {
36915
37154
  parseExpectedJSDoc(19 /* CloseBraceToken */);
36916
37155
  }
@@ -36939,7 +37178,7 @@ var ts;
36939
37178
  JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
36940
37179
  function parseIsolatedJSDocComment(content, start, length) {
36941
37180
  initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
36942
- var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37181
+ var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36943
37182
  var sourceFile = { languageVariant: 0 /* Standard */, text: content };
36944
37183
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36945
37184
  clearState();
@@ -36950,9 +37189,9 @@ var ts;
36950
37189
  var saveToken = currentToken;
36951
37190
  var saveParseDiagnosticsLength = parseDiagnostics.length;
36952
37191
  var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
36953
- var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37192
+ var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36954
37193
  ts.setParent(comment, parent);
36955
- if (contextFlags & 131072 /* JavaScriptFile */) {
37194
+ if (contextFlags & 262144 /* JavaScriptFile */) {
36956
37195
  if (!jsDocDiagnostics) {
36957
37196
  jsDocDiagnostics = [];
36958
37197
  }
@@ -37768,7 +38007,7 @@ var ts;
37768
38007
  if (isBracketed) {
37769
38008
  skipWhitespace();
37770
38009
  parseExpected(63 /* EqualsToken */);
37771
- defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
38010
+ defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
37772
38011
  parseExpected(23 /* CloseBracketToken */);
37773
38012
  }
37774
38013
  if (ts.nodeIsMissing(name)) {
@@ -45656,7 +45895,7 @@ var ts;
45656
45895
  function setExportContextFlag(node) {
45657
45896
  // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
45658
45897
  // declarations with export modifiers) is an export context in which declarations are implicitly exported.
45659
- if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) {
45898
+ if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
45660
45899
  node.flags |= 64 /* ExportContext */;
45661
45900
  }
45662
45901
  else {
@@ -45859,8 +46098,8 @@ var ts;
45859
46098
  function checkContextualIdentifier(node) {
45860
46099
  // Report error only if there are no parse errors in file
45861
46100
  if (!file.parseDiagnostics.length &&
45862
- !(node.flags & 8388608 /* Ambient */) &&
45863
- !(node.flags & 4194304 /* JSDoc */) &&
46101
+ !(node.flags & 16777216 /* Ambient */) &&
46102
+ !(node.flags & 8388608 /* JSDoc */) &&
45864
46103
  !ts.isIdentifierName(node)) {
45865
46104
  // strict mode identifiers
45866
46105
  if (inStrictMode &&
@@ -46889,7 +47128,7 @@ var ts;
46889
47128
  if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
46890
47129
  return;
46891
47130
  }
46892
- if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) {
47131
+ if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
46893
47132
  // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
46894
47133
  // strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
46895
47134
  checkStrictModeEvalOrArguments(node, node.name);
@@ -46908,7 +47147,7 @@ var ts;
46908
47147
  }
46909
47148
  }
46910
47149
  function bindFunctionDeclaration(node) {
46911
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47150
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46912
47151
  if (ts.isAsyncFunction(node)) {
46913
47152
  emitFlags |= 2048 /* HasAsyncFunctions */;
46914
47153
  }
@@ -46923,7 +47162,7 @@ var ts;
46923
47162
  }
46924
47163
  }
46925
47164
  function bindFunctionExpression(node) {
46926
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47165
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46927
47166
  if (ts.isAsyncFunction(node)) {
46928
47167
  emitFlags |= 2048 /* HasAsyncFunctions */;
46929
47168
  }
@@ -46936,7 +47175,7 @@ var ts;
46936
47175
  return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
46937
47176
  }
46938
47177
  function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
46939
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) {
47178
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
46940
47179
  emitFlags |= 2048 /* HasAsyncFunctions */;
46941
47180
  }
46942
47181
  if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
@@ -47009,7 +47248,7 @@ var ts;
47009
47248
  // Rationale: we don't want to report errors on non-initialized var's since they are hoisted
47010
47249
  // On the other side we do want to report errors on non-initialized 'lets' because of TDZ
47011
47250
  var isError_1 = ts.unreachableCodeIsError(options) &&
47012
- !(node.flags & 8388608 /* Ambient */) &&
47251
+ !(node.flags & 16777216 /* Ambient */) &&
47013
47252
  (!ts.isVariableStatement(node) ||
47014
47253
  !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
47015
47254
  node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
@@ -47909,7 +48148,7 @@ var ts;
47909
48148
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
47910
48149
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
47911
48150
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
47912
- if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
48151
+ if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
47913
48152
  (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
47914
48153
  }
47915
48154
  });
@@ -48360,7 +48599,7 @@ var ts;
48360
48599
  return diagnostic;
48361
48600
  }
48362
48601
  function isDeprecatedSymbol(symbol) {
48363
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
48602
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
48364
48603
  }
48365
48604
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
48366
48605
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -48588,7 +48827,7 @@ var ts;
48588
48827
  else {
48589
48828
  // find a module that about to be augmented
48590
48829
  // do not validate names of augmentations that are defined in ambient context
48591
- var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */)
48830
+ var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
48592
48831
  ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
48593
48832
  : undefined;
48594
48833
  var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -48702,7 +48941,7 @@ var ts;
48702
48941
  if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
48703
48942
  (!ts.outFile(compilerOptions)) ||
48704
48943
  isInTypeQuery(usage) ||
48705
- declaration.flags & 8388608 /* Ambient */) {
48944
+ declaration.flags & 16777216 /* Ambient */) {
48706
48945
  // nodes are in different files and order cannot be determined
48707
48946
  return true;
48708
48947
  }
@@ -48764,7 +49003,7 @@ var ts;
48764
49003
  if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
48765
49004
  return true;
48766
49005
  }
48767
- if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
49006
+ if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
48768
49007
  return true;
48769
49008
  }
48770
49009
  if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
@@ -49029,7 +49268,7 @@ var ts;
49029
49268
  // falls through
49030
49269
  case 261 /* ModuleDeclaration */:
49031
49270
  var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
49032
- if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49271
+ if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49033
49272
  // It's an external module. First see if the module has an export default and if the local
49034
49273
  // name of that export default matches.
49035
49274
  if (result = moduleExports.get("default" /* Default */)) {
@@ -49352,7 +49591,7 @@ var ts;
49352
49591
  }
49353
49592
  }
49354
49593
  // If we're in an external module, we can't reference value symbols created from UMD export declarations
49355
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49594
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
49356
49595
  var merged = getMergedSymbol(result);
49357
49596
  if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49358
49597
  errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
@@ -49607,7 +49846,7 @@ var ts;
49607
49846
  var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); });
49608
49847
  if (declaration === undefined)
49609
49848
  return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
49610
- if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49849
+ if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49611
49850
  var diagnosticMessage = void 0;
49612
49851
  var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
49613
49852
  if (result.flags & 2 /* BlockScopedVariable */) {
@@ -50380,7 +50619,7 @@ var ts;
50380
50619
  }
50381
50620
  }
50382
50621
  function getAssignmentDeclarationLocation(node) {
50383
- var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50622
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50384
50623
  if (typeAlias) {
50385
50624
  return;
50386
50625
  }
@@ -51848,7 +52087,20 @@ var ts;
51848
52087
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
51849
52088
  if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
51850
52089
  context.approximateLength += (ts.symbolName(type.symbol).length + 6);
51851
- return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined));
52090
+ var constraintNode = void 0;
52091
+ var constraint = getConstraintOfTypeParameter(type);
52092
+ if (constraint) {
52093
+ // If the infer type has a constraint that is not the same as the constraint
52094
+ // we would have normally inferred based on context, we emit the constraint
52095
+ // using `infer T extends ?`. We omit inferred constraints from type references
52096
+ // as they may be elided.
52097
+ var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
52098
+ if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
52099
+ context.approximateLength += 9;
52100
+ constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
52101
+ }
52102
+ }
52103
+ return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
51852
52104
  }
51853
52105
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
51854
52106
  type.flags & 262144 /* TypeParameter */ &&
@@ -53804,7 +54056,7 @@ var ts;
53804
54056
  newModifierFlags |= 1 /* Export */;
53805
54057
  }
53806
54058
  if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
53807
- (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* Ambient */)) &&
54059
+ (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
53808
54060
  (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
53809
54061
  // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
53810
54062
  newModifierFlags |= 2 /* Ambient */;
@@ -54774,7 +55026,7 @@ var ts;
54774
55026
  var parent = getDeclarationContainer(node);
54775
55027
  // If the node is not exported or it is not ambient module element (except import declaration)
54776
55028
  if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
54777
- !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) {
55029
+ !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
54778
55030
  return isGlobalSourceFile(parent);
54779
55031
  }
54780
55032
  // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
@@ -55114,7 +55366,7 @@ var ts;
55114
55366
  }
55115
55367
  var pattern = declaration.parent;
55116
55368
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
55117
- if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55369
+ if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55118
55370
  parentType = getNonNullableType(parentType);
55119
55371
  }
55120
55372
  // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
@@ -55230,7 +55482,7 @@ var ts;
55230
55482
  }
55231
55483
  if ((noImplicitAny || ts.isInJSFile(declaration)) &&
55232
55484
  ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
55233
- !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) {
55485
+ !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
55234
55486
  // If --noImplicitAny is on or the declaration is in a Javascript file,
55235
55487
  // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
55236
55488
  // initializer or a 'null' or 'undefined' initializer.
@@ -56686,7 +56938,7 @@ var ts;
56686
56938
  function isLiteralEnumMember(member) {
56687
56939
  var expr = member.initializer;
56688
56940
  if (!expr) {
56689
- return !(member.flags & 8388608 /* Ambient */);
56941
+ return !(member.flags & 16777216 /* Ambient */);
56690
56942
  }
56691
56943
  switch (expr.kind) {
56692
56944
  case 10 /* StringLiteral */:
@@ -59319,7 +59571,7 @@ var ts;
59319
59571
  function getConstraintDeclaration(type) {
59320
59572
  return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
59321
59573
  }
59322
- function getInferredTypeParameterConstraint(typeParameter) {
59574
+ function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
59323
59575
  var _a;
59324
59576
  var inferences;
59325
59577
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
@@ -59331,7 +59583,7 @@ var ts;
59331
59583
  // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
59332
59584
  // present, we form an intersection of the inferred constraint types.
59333
59585
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
59334
- if (grandParent.kind === 178 /* TypeReference */) {
59586
+ if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
59335
59587
  var typeReference = grandParent;
59336
59588
  var typeParameters = getTypeParametersForTypeReference(typeReference);
59337
59589
  if (typeParameters) {
@@ -59753,7 +60005,7 @@ var ts;
59753
60005
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
59754
60006
  }
59755
60007
  function isJSDocTypeReference(node) {
59756
- return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
60008
+ return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
59757
60009
  }
59758
60010
  function checkNoTypeArguments(node, symbol) {
59759
60011
  if (node.typeArguments) {
@@ -61312,7 +61564,7 @@ var ts;
61312
61564
  if (ts.isCallLikeExpression(parent)) {
61313
61565
  return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
61314
61566
  }
61315
- return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
61567
+ return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
61316
61568
  }
61317
61569
  return true;
61318
61570
  }
@@ -61753,7 +62005,11 @@ var ts;
61753
62005
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61754
62006
  }
61755
62007
  function isSingletonTupleType(node) {
61756
- return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]);
62008
+ return ts.isTupleTypeNode(node) &&
62009
+ ts.length(node.elements) === 1 &&
62010
+ !ts.isOptionalTypeNode(node.elements[0]) &&
62011
+ !ts.isRestTypeNode(node.elements[0]) &&
62012
+ !(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
61757
62013
  }
61758
62014
  /**
61759
62015
  * We syntactually check for common nondistributive conditional shapes and unwrap them into
@@ -62001,7 +62257,7 @@ var ts;
62001
62257
  links.resolvedSymbol = unknownSymbol;
62002
62258
  return links.resolvedType = errorType;
62003
62259
  }
62004
- var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62260
+ var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62005
62261
  // TODO: Future work: support unions/generics/whatever via a deferred import-type
62006
62262
  var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
62007
62263
  if (!innerModuleSymbol) {
@@ -62337,7 +62593,7 @@ var ts;
62337
62593
  }
62338
62594
  // /** @return {this} */
62339
62595
  // x.prototype.m = function() { ... }
62340
- var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62596
+ var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62341
62597
  if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
62342
62598
  return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
62343
62599
  }
@@ -62412,7 +62668,7 @@ var ts;
62412
62668
  case 143 /* NeverKeyword */:
62413
62669
  return neverType;
62414
62670
  case 148 /* ObjectKeyword */:
62415
- return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62671
+ return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62416
62672
  case 138 /* IntrinsicKeyword */:
62417
62673
  return intrinsicMarkerType;
62418
62674
  case 192 /* ThisType */:
@@ -66273,6 +66529,9 @@ var ts;
66273
66529
  function createMarkerType(symbol, source, target) {
66274
66530
  var mapper = makeUnaryTypeMapper(source, target);
66275
66531
  var type = getDeclaredTypeOfSymbol(symbol);
66532
+ if (isErrorType(type)) {
66533
+ return type;
66534
+ }
66276
66535
  var result = symbol.flags & 524288 /* TypeAlias */ ?
66277
66536
  getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) :
66278
66537
  createTypeReference(type, instantiateTypes(type.typeParameters, mapper));
@@ -67286,6 +67545,9 @@ var ts;
67286
67545
  var inference = inferences[i];
67287
67546
  if (t === inference.typeParameter) {
67288
67547
  if (fix && !inference.isFixed) {
67548
+ // Before we commit to a particular inference (and thus lock out any further inferences),
67549
+ // we infer from any intra-expression inference sites we have collected.
67550
+ inferFromIntraExpressionSites(context);
67289
67551
  clearCachedInferences(inferences);
67290
67552
  inference.isFixed = true;
67291
67553
  }
@@ -67302,6 +67564,37 @@ var ts;
67302
67564
  }
67303
67565
  }
67304
67566
  }
67567
+ function addIntraExpressionInferenceSite(context, node, type) {
67568
+ var _a;
67569
+ ((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
67570
+ }
67571
+ // We collect intra-expression inference sites within object and array literals to handle cases where
67572
+ // inferred types flow between context sensitive element expressions. For example:
67573
+ //
67574
+ // declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
67575
+ // foo([_a => 0, n => n.toFixed()]);
67576
+ //
67577
+ // Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
67578
+ // pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
67579
+ // pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
67580
+ // parameter in the second arrow function, but we want to first infer from the return type of the first
67581
+ // arrow function. This happens automatically when the arrow functions are discrete arguments (because we
67582
+ // infer from each argument before processing the next), but when the arrow functions are elements of an
67583
+ // object or array literal, we need to perform intra-expression inferences early.
67584
+ function inferFromIntraExpressionSites(context) {
67585
+ if (context.intraExpressionInferenceSites) {
67586
+ for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
67587
+ var _b = _a[_i], node = _b.node, type = _b.type;
67588
+ var contextualType = node.kind === 169 /* MethodDeclaration */ ?
67589
+ getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
67590
+ getContextualType(node, 2 /* NoConstraints */);
67591
+ if (contextualType) {
67592
+ inferTypes(context.inferences, type, contextualType);
67593
+ }
67594
+ }
67595
+ context.intraExpressionInferenceSites = undefined;
67596
+ }
67597
+ }
67305
67598
  function createInferenceInfo(typeParameter) {
67306
67599
  return {
67307
67600
  typeParameter: typeParameter,
@@ -69284,7 +69577,7 @@ var ts;
69284
69577
  // parameter symbols with declarations that have explicit type annotations. Such references are
69285
69578
  // resolvable with no possibility of triggering circularities in control flow analysis.
69286
69579
  function getTypeOfDottedName(node, diagnostic) {
69287
- if (!(node.flags & 16777216 /* InWithStatement */)) {
69580
+ if (!(node.flags & 33554432 /* InWithStatement */)) {
69288
69581
  switch (node.kind) {
69289
69582
  case 79 /* Identifier */:
69290
69583
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
@@ -70688,6 +70981,7 @@ var ts;
70688
70981
  // a generic type without a nullable constraint and x is a generic type. This is because when both obj
70689
70982
  // and x are of generic types T and K, we want the resulting type to be T[K].
70690
70983
  return parent.kind === 206 /* PropertyAccessExpression */ ||
70984
+ parent.kind === 161 /* QualifiedName */ ||
70691
70985
  parent.kind === 208 /* CallExpression */ && parent.expression === node ||
70692
70986
  parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
70693
70987
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
@@ -70981,7 +71275,7 @@ var ts;
70981
71275
  isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
70982
71276
  node.parent.kind === 230 /* NonNullExpression */ ||
70983
71277
  declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
70984
- declaration.flags & 8388608 /* Ambient */;
71278
+ declaration.flags & 16777216 /* Ambient */;
70985
71279
  var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
70986
71280
  type === autoType || type === autoArrayType ? undefinedType :
70987
71281
  getOptionalType(type);
@@ -71989,7 +72283,7 @@ var ts;
71989
72283
  // exists. Otherwise, it is the type of the string index signature in T, if one exists.
71990
72284
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
71991
72285
  ts.Debug.assert(ts.isObjectLiteralMethod(node));
71992
- if (node.flags & 16777216 /* InWithStatement */) {
72286
+ if (node.flags & 33554432 /* InWithStatement */) {
71993
72287
  // We cannot answer semantic questions within a with block, do not proceed any further
71994
72288
  return undefined;
71995
72289
  }
@@ -72177,7 +72471,7 @@ var ts;
72177
72471
  * @returns the contextual type of an expression.
72178
72472
  */
72179
72473
  function getContextualType(node, contextFlags) {
72180
- if (node.flags & 16777216 /* InWithStatement */) {
72474
+ if (node.flags & 33554432 /* InWithStatement */) {
72181
72475
  // We cannot answer semantic questions within a with block, do not proceed any further
72182
72476
  return undefined;
72183
72477
  }
@@ -72595,6 +72889,11 @@ var ts;
72595
72889
  var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
72596
72890
  elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
72597
72891
  elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
72892
+ if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
72893
+ var inferenceContext = getInferenceContext(node);
72894
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
72895
+ addIntraExpressionInferenceSite(inferenceContext, e, type);
72896
+ }
72598
72897
  }
72599
72898
  }
72600
72899
  if (inDestructuringPattern) {
@@ -72796,6 +73095,13 @@ var ts;
72796
73095
  prop.target = member;
72797
73096
  member = prop;
72798
73097
  allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
73098
+ if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
73099
+ (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
73100
+ var inferenceContext = getInferenceContext(node);
73101
+ ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
73102
+ var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
73103
+ addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
73104
+ }
72799
73105
  }
72800
73106
  else if (memberDecl.kind === 298 /* SpreadAssignment */) {
72801
73107
  if (languageVersion < 2 /* ES2015 */) {
@@ -73888,7 +74194,7 @@ var ts;
73888
74194
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
73889
74195
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
73890
74196
  }
73891
- if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
74197
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
73892
74198
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73893
74199
  }
73894
74200
  }
@@ -73956,7 +74262,7 @@ var ts;
73956
74262
  if (declaration && isPropertyWithoutInitializer(declaration)) {
73957
74263
  if (!ts.isStatic(declaration)) {
73958
74264
  var flowContainer = getControlFlowContainer(node);
73959
- if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) {
74265
+ if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
73960
74266
  assumeUninitialized = true;
73961
74267
  }
73962
74268
  }
@@ -73993,7 +74299,7 @@ var ts;
73993
74299
  }
73994
74300
  else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
73995
74301
  node.parent.kind !== 178 /* TypeReference */ &&
73996
- !(valueDeclaration.flags & 8388608 /* Ambient */) &&
74302
+ !(valueDeclaration.flags & 16777216 /* Ambient */) &&
73997
74303
  !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
73998
74304
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
73999
74305
  }
@@ -74658,34 +74964,36 @@ var ts;
74658
74964
  if (node.kind !== 165 /* Decorator */) {
74659
74965
  var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
74660
74966
  if (contextualType) {
74661
- // We clone the inference context to avoid disturbing a resolution in progress for an
74662
- // outer call expression. Effectively we just want a snapshot of whatever has been
74663
- // inferred for any outer call expression so far.
74664
- var outerContext = getInferenceContext(node);
74665
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
74666
- var instantiatedType = instantiateType(contextualType, outerMapper);
74667
- // If the contextual type is a generic function type with a single call signature, we
74668
- // instantiate the type with its own type parameters and type arguments. This ensures that
74669
- // the type parameters are not erased to type any during type inference such that they can
74670
- // be inferred as actual types from the contextual type. For example:
74671
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
74672
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
74673
- // Above, the type of the 'value' parameter is inferred to be 'A'.
74674
- var contextualSignature = getSingleCallSignature(instantiatedType);
74675
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
74676
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
74677
- instantiatedType;
74678
74967
  var inferenceTargetType = getReturnTypeOfSignature(signature);
74679
- // Inferences made from return types have lower priority than all other inferences.
74680
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
74681
- // Create a type mapper for instantiating generic contextual types using the inferences made
74682
- // from the return type. We need a separate inference pass here because (a) instantiation of
74683
- // the source type uses the outer context's return mapper (which excludes inferences made from
74684
- // outer arguments), and (b) we don't want any further inferences going into this context.
74685
- var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
74686
- var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
74687
- inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
74688
- context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
74968
+ if (couldContainTypeVariables(inferenceTargetType)) {
74969
+ // We clone the inference context to avoid disturbing a resolution in progress for an
74970
+ // outer call expression. Effectively we just want a snapshot of whatever has been
74971
+ // inferred for any outer call expression so far.
74972
+ var outerContext = getInferenceContext(node);
74973
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
74974
+ var instantiatedType = instantiateType(contextualType, outerMapper);
74975
+ // If the contextual type is a generic function type with a single call signature, we
74976
+ // instantiate the type with its own type parameters and type arguments. This ensures that
74977
+ // the type parameters are not erased to type any during type inference such that they can
74978
+ // be inferred as actual types from the contextual type. For example:
74979
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
74980
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
74981
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
74982
+ var contextualSignature = getSingleCallSignature(instantiatedType);
74983
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
74984
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
74985
+ instantiatedType;
74986
+ // Inferences made from return types have lower priority than all other inferences.
74987
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
74988
+ // Create a type mapper for instantiating generic contextual types using the inferences made
74989
+ // from the return type. We need a separate inference pass here because (a) instantiation of
74990
+ // the source type uses the outer context's return mapper (which excludes inferences made from
74991
+ // outer arguments), and (b) we don't want any further inferences going into this context.
74992
+ var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
74993
+ var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
74994
+ inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
74995
+ context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
74996
+ }
74689
74997
  }
74690
74998
  }
74691
74999
  var restType = getNonArrayRestType(signature);
@@ -74697,7 +75005,7 @@ var ts;
74697
75005
  }
74698
75006
  }
74699
75007
  var thisType = getThisTypeOfSignature(signature);
74700
- if (thisType) {
75008
+ if (thisType && couldContainTypeVariables(thisType)) {
74701
75009
  var thisArgumentNode = getThisArgumentOfCall(node);
74702
75010
  inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
74703
75011
  }
@@ -74705,11 +75013,13 @@ var ts;
74705
75013
  var arg = args[i];
74706
75014
  if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
74707
75015
  var paramType = getTypeAtPosition(signature, i);
74708
- var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
74709
- inferTypes(context.inferences, argType, paramType);
75016
+ if (couldContainTypeVariables(paramType)) {
75017
+ var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
75018
+ inferTypes(context.inferences, argType, paramType);
75019
+ }
74710
75020
  }
74711
75021
  }
74712
- if (restType) {
75022
+ if (restType && couldContainTypeVariables(restType)) {
74713
75023
  var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
74714
75024
  inferTypes(context.inferences, spreadType, restType);
74715
75025
  }
@@ -76289,7 +76599,7 @@ var ts;
76289
76599
  return returnType;
76290
76600
  }
76291
76601
  function checkDeprecatedSignature(signature, node) {
76292
- if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
76602
+ if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
76293
76603
  var suggestionNode = getDeprecatedSuggestionNode(node);
76294
76604
  var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
76295
76605
  addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
@@ -76433,7 +76743,7 @@ var ts;
76433
76743
  if (targetDeclarationKind !== 0 /* Unknown */) {
76434
76744
  var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
76435
76745
  // function/variable declaration should be ambient
76436
- return !!decl && !!(decl.flags & 8388608 /* Ambient */);
76746
+ return !!decl && !!(decl.flags & 16777216 /* Ambient */);
76437
76747
  }
76438
76748
  return false;
76439
76749
  }
@@ -76628,7 +76938,7 @@ var ts;
76628
76938
  error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
76629
76939
  }
76630
76940
  var file = ts.getSourceFileOfNode(node);
76631
- ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76941
+ ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76632
76942
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
76633
76943
  }
76634
76944
  function getTypeOfParameter(symbol) {
@@ -78642,6 +78952,11 @@ var ts;
78642
78952
  context.contextualType = contextualType;
78643
78953
  context.inferenceContext = inferenceContext;
78644
78954
  var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
78955
+ // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
78956
+ // parameters. This information is no longer needed after the call to checkExpression.
78957
+ if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
78958
+ inferenceContext.intraExpressionInferenceSites = undefined;
78959
+ }
78645
78960
  // We strip literal freshness when an appropriate contextual type is present such that contextually typed
78646
78961
  // literals always preserve their literal types (otherwise they might widen during type inference). An alternative
78647
78962
  // here would be to not mark contextually typed literals as fresh in the first place.
@@ -78933,7 +79248,7 @@ var ts;
78933
79248
  return quickType;
78934
79249
  }
78935
79250
  // If a type has been cached for the node, return it.
78936
- if (node.flags & 67108864 /* TypeCached */ && flowTypeCache) {
79251
+ if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
78937
79252
  var cachedType = flowTypeCache[getNodeId(node)];
78938
79253
  if (cachedType) {
78939
79254
  return cachedType;
@@ -78945,7 +79260,7 @@ var ts;
78945
79260
  if (flowInvocationCount !== startInvocationCount) {
78946
79261
  var cache = flowTypeCache || (flowTypeCache = []);
78947
79262
  cache[getNodeId(node)] = type;
78948
- ts.setNodeFlags(node, node.flags | 67108864 /* TypeCached */);
79263
+ ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
78949
79264
  }
78950
79265
  return type;
78951
79266
  }
@@ -79031,7 +79346,7 @@ var ts;
79031
79346
  if (compilerOptions.isolatedModules) {
79032
79347
  ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
79033
79348
  var constEnumDeclaration = type.symbol.valueDeclaration;
79034
- if (constEnumDeclaration.flags & 8388608 /* Ambient */) {
79349
+ if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
79035
79350
  error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
79036
79351
  }
79037
79352
  }
@@ -79724,7 +80039,7 @@ var ts;
79724
80039
  checkDecorators(node);
79725
80040
  checkSignatureDeclaration(node);
79726
80041
  if (node.kind === 172 /* GetAccessor */) {
79727
- if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
80042
+ if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
79728
80043
  if (!(node.flags & 512 /* HasExplicitReturn */)) {
79729
80044
  error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
79730
80045
  }
@@ -79819,7 +80134,7 @@ var ts;
79819
80134
  }
79820
80135
  var symbol = getNodeLinks(node).resolvedSymbol;
79821
80136
  if (symbol) {
79822
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
80137
+ if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
79823
80138
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
79824
80139
  }
79825
80140
  if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
@@ -79979,6 +80294,23 @@ var ts;
79979
80294
  grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
79980
80295
  }
79981
80296
  checkSourceElement(node.typeParameter);
80297
+ var symbol = getSymbolOfNode(node.typeParameter);
80298
+ if (symbol.declarations && symbol.declarations.length > 1) {
80299
+ var links = getSymbolLinks(symbol);
80300
+ if (!links.typeParametersChecked) {
80301
+ links.typeParametersChecked = true;
80302
+ var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
80303
+ var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
80304
+ if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
80305
+ // Report an error on every conflicting declaration.
80306
+ var name = symbolToString(symbol);
80307
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80308
+ var declaration = declarations_4[_i];
80309
+ error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
80310
+ }
80311
+ }
80312
+ }
80313
+ }
79982
80314
  registerForUnusedIdentifiersCheck(node);
79983
80315
  }
79984
80316
  function checkTemplateLiteralType(node) {
@@ -80016,7 +80348,7 @@ var ts;
80016
80348
  getTypeFromTypeNode(node);
80017
80349
  }
80018
80350
  function isPrivateWithinAmbient(node) {
80019
- return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
80351
+ return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
80020
80352
  }
80021
80353
  function getEffectiveDeclarationFlags(n, flagsToCheck) {
80022
80354
  var flags = ts.getCombinedModifierFlags(n);
@@ -80025,7 +80357,7 @@ var ts;
80025
80357
  if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
80026
80358
  n.parent.kind !== 257 /* ClassDeclaration */ &&
80027
80359
  n.parent.kind !== 226 /* ClassExpression */ &&
80028
- n.flags & 8388608 /* Ambient */) {
80360
+ n.flags & 16777216 /* Ambient */) {
80029
80361
  if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
80030
80362
  // It is nested in an ambient context, which means it is automatically exported
80031
80363
  flags |= 1 /* Export */;
@@ -80158,10 +80490,10 @@ var ts;
80158
80490
  var hasNonAmbientClass = false;
80159
80491
  var functionDeclarations = [];
80160
80492
  if (declarations) {
80161
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80162
- var current = declarations_4[_i];
80493
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
80494
+ var current = declarations_5[_i];
80163
80495
  var node = current;
80164
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
80496
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
80165
80497
  var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
80166
80498
  if (inAmbientContextOrInterface) {
80167
80499
  // check if declarations are consecutive only if they are non-ambient
@@ -81013,7 +81345,7 @@ var ts;
81013
81345
  // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
81014
81346
  var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
81015
81347
  // Get first non javascript function declaration
81016
- function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); });
81348
+ function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
81017
81349
  // Only type check the symbol once
81018
81350
  if (node === firstDeclaration) {
81019
81351
  checkFunctionOrConstructorSymbol(localSymbol);
@@ -81135,7 +81467,7 @@ var ts;
81135
81467
  var symbol = getSymbolOfNode(member);
81136
81468
  if (!symbol.isReferenced
81137
81469
  && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
81138
- && !(member.flags & 8388608 /* Ambient */)) {
81470
+ && !(member.flags & 16777216 /* Ambient */)) {
81139
81471
  addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
81140
81472
  }
81141
81473
  break;
@@ -81325,8 +81657,8 @@ var ts;
81325
81657
  : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
81326
81658
  }
81327
81659
  else {
81328
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
81329
- var decl = declarations_5[_i];
81660
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
81661
+ var decl = declarations_6[_i];
81330
81662
  addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
81331
81663
  }
81332
81664
  }
@@ -81368,7 +81700,7 @@ var ts;
81368
81700
  }
81369
81701
  function checkCollisionWithArgumentsInGeneratedCode(node) {
81370
81702
  // no rest parameters \ declaration context \ overload - no codegen impact
81371
- if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81703
+ if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81372
81704
  return;
81373
81705
  }
81374
81706
  ts.forEach(node.parameters, function (p) {
@@ -81396,7 +81728,7 @@ var ts;
81396
81728
  // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
81397
81729
  return false;
81398
81730
  }
81399
- if (node.flags & 8388608 /* Ambient */) {
81731
+ if (node.flags & 16777216 /* Ambient */) {
81400
81732
  // ambient context - no codegen impact
81401
81733
  return false;
81402
81734
  }
@@ -81535,7 +81867,7 @@ var ts;
81535
81867
  recordPotentialCollisionWithReflectInGeneratedCode(node, name);
81536
81868
  if (ts.isClassLike(node)) {
81537
81869
  checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
81538
- if (!(node.flags & 8388608 /* Ambient */)) {
81870
+ if (!(node.flags & 16777216 /* Ambient */)) {
81539
81871
  checkClassNameCollisionWithObject(name);
81540
81872
  }
81541
81873
  }
@@ -83129,23 +83461,23 @@ var ts;
83129
83461
  return;
83130
83462
  }
83131
83463
  var type = getDeclaredTypeOfSymbol(symbol);
83132
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
83464
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
83133
83465
  // Report an error on every conflicting declaration.
83134
83466
  var name = symbolToString(symbol);
83135
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
83136
- var declaration = declarations_6[_i];
83467
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83468
+ var declaration = declarations_7[_i];
83137
83469
  error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
83138
83470
  }
83139
83471
  }
83140
83472
  }
83141
83473
  }
83142
- function areTypeParametersIdentical(declarations, targetParameters) {
83474
+ function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
83143
83475
  var maxTypeArgumentCount = ts.length(targetParameters);
83144
83476
  var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
83145
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83146
- var declaration = declarations_7[_i];
83477
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
83478
+ var declaration = declarations_8[_i];
83147
83479
  // If this declaration has too few or too many type parameters, we report an error
83148
- var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
83480
+ var sourceParameters = getTypeParameterDeclarations(declaration);
83149
83481
  var numTypeParameters = sourceParameters.length;
83150
83482
  if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
83151
83483
  return false;
@@ -83213,7 +83545,7 @@ var ts;
83213
83545
  checkFunctionOrConstructorSymbol(symbol);
83214
83546
  checkClassForDuplicateDeclarations(node);
83215
83547
  // Only check for reserved static identifiers on non-ambient context.
83216
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83548
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83217
83549
  if (!nodeInAmbientContext) {
83218
83550
  checkClassForStaticPropertyNameConflicts(node);
83219
83551
  }
@@ -83363,7 +83695,7 @@ var ts;
83363
83695
  */
83364
83696
  function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
83365
83697
  var isJs = ts.isInJSFile(node);
83366
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83698
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83367
83699
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
83368
83700
  var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
83369
83701
  var thisType = memberIsStatic ? staticType : typeWithThis;
@@ -83591,7 +83923,7 @@ var ts;
83591
83923
  && !(derived.flags & 33554432 /* Transient */)
83592
83924
  && !(baseDeclarationFlags & 128 /* Abstract */)
83593
83925
  && !(derivedDeclarationFlags & 128 /* Abstract */)
83594
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) {
83926
+ && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
83595
83927
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
83596
83928
  var propName = uninitialized.name;
83597
83929
  if (uninitialized.exclamationToken
@@ -83683,7 +84015,7 @@ var ts;
83683
84015
  return ok;
83684
84016
  }
83685
84017
  function checkPropertyInitialization(node) {
83686
- if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) {
84018
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
83687
84019
  return;
83688
84020
  }
83689
84021
  var constructor = findConstructorDeclaration(node);
@@ -83820,7 +84152,7 @@ var ts;
83820
84152
  }
83821
84153
  // In ambient non-const numeric enum declarations, enum members without initializers are
83822
84154
  // considered computed members (as opposed to having auto-incremented values).
83823
- if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
84155
+ if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
83824
84156
  return undefined;
83825
84157
  }
83826
84158
  // If the member declaration specifies no value, the member is considered a constant enum member.
@@ -83852,7 +84184,7 @@ var ts;
83852
84184
  else if (isConstEnum) {
83853
84185
  error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
83854
84186
  }
83855
- else if (member.parent.flags & 8388608 /* Ambient */) {
84187
+ else if (member.parent.flags & 16777216 /* Ambient */) {
83856
84188
  error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
83857
84189
  }
83858
84190
  else {
@@ -84020,11 +84352,11 @@ var ts;
84020
84352
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
84021
84353
  var declarations = symbol.declarations;
84022
84354
  if (declarations) {
84023
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
84024
- var declaration = declarations_8[_i];
84355
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
84356
+ var declaration = declarations_9[_i];
84025
84357
  if ((declaration.kind === 257 /* ClassDeclaration */ ||
84026
84358
  (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
84027
- !(declaration.flags & 8388608 /* Ambient */)) {
84359
+ !(declaration.flags & 16777216 /* Ambient */)) {
84028
84360
  return declaration;
84029
84361
  }
84030
84362
  }
@@ -84055,7 +84387,7 @@ var ts;
84055
84387
  function checkModuleDeclarationDiagnostics() {
84056
84388
  // Grammar checking
84057
84389
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
84058
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
84390
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
84059
84391
  if (isGlobalAugmentation && !inAmbientContext) {
84060
84392
  error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
84061
84393
  }
@@ -84273,7 +84605,7 @@ var ts;
84273
84605
  }
84274
84606
  if (compilerOptions.isolatedModules
84275
84607
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
84276
- && !(node.flags & 8388608 /* Ambient */)) {
84608
+ && !(node.flags & 16777216 /* Ambient */)) {
84277
84609
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
84278
84610
  var isType = !(target.flags & 111551 /* Value */);
84279
84611
  if (isType || typeOnlyAlias) {
@@ -84319,7 +84651,7 @@ var ts;
84319
84651
  }
84320
84652
  }
84321
84653
  function isDeprecatedAliasedSymbol(symbol) {
84322
- return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
84654
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
84323
84655
  }
84324
84656
  function checkDeprecatedAliasedSymbol(symbol, location) {
84325
84657
  if (!(symbol.flags & 2097152 /* Alias */))
@@ -84448,7 +84780,7 @@ var ts;
84448
84780
  }
84449
84781
  }
84450
84782
  else {
84451
- if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
84783
+ if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
84452
84784
  // Import equals declaration is deprecated in es6 or above
84453
84785
  grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
84454
84786
  }
@@ -84474,7 +84806,7 @@ var ts;
84474
84806
  ts.forEach(node.exportClause.elements, checkExportSpecifier);
84475
84807
  var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
84476
84808
  var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
84477
- !node.moduleSpecifier && node.flags & 8388608 /* Ambient */;
84809
+ !node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
84478
84810
  if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
84479
84811
  error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
84480
84812
  }
@@ -84639,10 +84971,10 @@ var ts;
84639
84971
  checkExpressionCached(node.expression);
84640
84972
  }
84641
84973
  checkExternalModuleExports(container);
84642
- if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
84974
+ if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
84643
84975
  grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
84644
84976
  }
84645
- if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
84977
+ if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
84646
84978
  if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
84647
84979
  // export assignment is not supported in es6 modules
84648
84980
  grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -85075,7 +85407,7 @@ var ts;
85075
85407
  // This relies on the results of other lazy diagnostics, so must be computed after them
85076
85408
  if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85077
85409
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85078
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85410
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
85079
85411
  diagnostics.add(diag);
85080
85412
  }
85081
85413
  });
@@ -85175,7 +85507,7 @@ var ts;
85175
85507
  }
85176
85508
  // Language service support
85177
85509
  function getSymbolsInScope(location, meaning) {
85178
- if (location.flags & 16777216 /* InWithStatement */) {
85510
+ if (location.flags & 33554432 /* InWithStatement */) {
85179
85511
  // We cannot answer semantic questions within a with block, do not proceed any further
85180
85512
  return [];
85181
85513
  }
@@ -85525,7 +85857,7 @@ var ts;
85525
85857
  }
85526
85858
  var parent = node.parent;
85527
85859
  var grandParent = parent.parent;
85528
- if (node.flags & 16777216 /* InWithStatement */) {
85860
+ if (node.flags & 33554432 /* InWithStatement */) {
85529
85861
  // We cannot answer semantic questions within a with block, do not proceed any further
85530
85862
  return undefined;
85531
85863
  }
@@ -85667,7 +85999,7 @@ var ts;
85667
85999
  if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
85668
86000
  return errorType;
85669
86001
  }
85670
- if (node.flags & 16777216 /* InWithStatement */) {
86002
+ if (node.flags & 33554432 /* InWithStatement */) {
85671
86003
  // We cannot answer semantic questions within a with block, do not proceed any further
85672
86004
  return errorType;
85673
86005
  }
@@ -86720,7 +87052,7 @@ var ts;
86720
87052
  function checkExternalEmitHelpers(location, helpers) {
86721
87053
  if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
86722
87054
  var sourceFile = ts.getSourceFileOfNode(location);
86723
- if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) {
87055
+ if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
86724
87056
  var helpersModule = resolveHelpersModule(sourceFile, location);
86725
87057
  if (helpersModule !== unknownSymbol) {
86726
87058
  var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
@@ -86973,7 +87305,7 @@ var ts;
86973
87305
  else if (node.kind === 164 /* Parameter */) {
86974
87306
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
86975
87307
  }
86976
- else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87308
+ else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
86977
87309
  return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
86978
87310
  }
86979
87311
  else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
@@ -87019,7 +87351,7 @@ var ts;
87019
87351
  if (flags & 256 /* Async */) {
87020
87352
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
87021
87353
  }
87022
- else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) {
87354
+ else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
87023
87355
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
87024
87356
  }
87025
87357
  else if (node.kind === 164 /* Parameter */) {
@@ -87165,7 +87497,7 @@ var ts;
87165
87497
  if (i !== (parameterCount - 1)) {
87166
87498
  return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
87167
87499
  }
87168
- if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87500
+ if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87169
87501
  checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
87170
87502
  }
87171
87503
  if (parameter.questionToken) {
@@ -87376,7 +87708,7 @@ var ts;
87376
87708
  ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
87377
87709
  node.kind === 213 /* FunctionExpression */ ||
87378
87710
  node.kind === 169 /* MethodDeclaration */);
87379
- if (node.flags & 8388608 /* Ambient */) {
87711
+ if (node.flags & 16777216 /* Ambient */) {
87380
87712
  return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
87381
87713
  }
87382
87714
  if (!node.body) {
@@ -87614,7 +87946,7 @@ var ts;
87614
87946
  return false;
87615
87947
  }
87616
87948
  function checkGrammarAccessor(accessor) {
87617
- if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87949
+ if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87618
87950
  if (languageVersion < 1 /* ES5 */) {
87619
87951
  return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
87620
87952
  }
@@ -87754,7 +88086,7 @@ var ts;
87754
88086
  // However, property declarations disallow computed names in general,
87755
88087
  // and accessors are not allowed in ambient contexts in general,
87756
88088
  // so this error only really matters for methods.
87757
- if (node.flags & 8388608 /* Ambient */) {
88089
+ if (node.flags & 16777216 /* Ambient */) {
87758
88090
  return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
87759
88091
  }
87760
88092
  else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
@@ -87870,7 +88202,7 @@ var ts;
87870
88202
  }
87871
88203
  function checkGrammarVariableDeclaration(node) {
87872
88204
  if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
87873
- if (node.flags & 8388608 /* Ambient */) {
88205
+ if (node.flags & 16777216 /* Ambient */) {
87874
88206
  checkAmbientInitializer(node);
87875
88207
  }
87876
88208
  else if (!node.initializer) {
@@ -87882,7 +88214,7 @@ var ts;
87882
88214
  }
87883
88215
  }
87884
88216
  }
87885
- if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
88217
+ if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
87886
88218
  var message = node.initializer
87887
88219
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
87888
88220
  : !node.type
@@ -87891,7 +88223,7 @@ var ts;
87891
88223
  return grammarErrorOnNode(node.exclamationToken, message);
87892
88224
  }
87893
88225
  if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
87894
- !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
88226
+ !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
87895
88227
  checkESModuleMarker(node.name);
87896
88228
  }
87897
88229
  var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
@@ -88068,11 +88400,11 @@ var ts;
88068
88400
  return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
88069
88401
  }
88070
88402
  }
88071
- if (node.flags & 8388608 /* Ambient */) {
88403
+ if (node.flags & 16777216 /* Ambient */) {
88072
88404
  checkAmbientInitializer(node);
88073
88405
  }
88074
88406
  if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
88075
- node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88407
+ node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88076
88408
  var message = node.initializer
88077
88409
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
88078
88410
  : !node.type
@@ -88118,10 +88450,10 @@ var ts;
88118
88450
  return false;
88119
88451
  }
88120
88452
  function checkGrammarSourceFile(node) {
88121
- return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88453
+ return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88122
88454
  }
88123
88455
  function checkGrammarStatementInAmbientContext(node) {
88124
- if (node.flags & 8388608 /* Ambient */) {
88456
+ if (node.flags & 16777216 /* Ambient */) {
88125
88457
  // Find containing block which is either Block, ModuleBlock, SourceFile
88126
88458
  var links = getNodeLinks(node);
88127
88459
  if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
@@ -92239,7 +92571,7 @@ var ts;
92239
92571
  return !ts.nodeIsMissing(node.body);
92240
92572
  }
92241
92573
  function visitPropertyDeclaration(node) {
92242
- if (node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92574
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92243
92575
  return undefined;
92244
92576
  }
92245
92577
  var updated = factory.updatePropertyDeclaration(node,
@@ -99129,8 +99461,8 @@ var ts;
99129
99461
  // declarations may not be sorted by position.
99130
99462
  // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
99131
99463
  var pos = -1, end = -1;
99132
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
99133
- var node = declarations_9[_i];
99464
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
99465
+ var node = declarations_10[_i];
99134
99466
  pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
99135
99467
  end = Math.max(end, node.end);
99136
99468
  }
@@ -108173,7 +108505,7 @@ var ts;
108173
108505
  needsScopeFixMarker = false;
108174
108506
  var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
108175
108507
  var lateStatements = transformAndReplaceLatePaintedStatements(statements);
108176
- if (input.flags & 8388608 /* Ambient */) {
108508
+ if (input.flags & 16777216 /* Ambient */) {
108177
108509
  needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
108178
108510
  }
108179
108511
  // With the final list of statements, there are 3 possibilities:
@@ -109821,6 +110153,9 @@ var ts;
109821
110153
  var currentParenthesizerRule;
109822
110154
  var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
109823
110155
  var parenthesizer = ts.factory.parenthesizer;
110156
+ var typeArgumentParenthesizerRuleSelector = {
110157
+ select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
110158
+ };
109824
110159
  var emitBinaryExpression = createEmitBinaryExpression();
109825
110160
  reset();
109826
110161
  return {
@@ -111033,7 +111368,7 @@ var ts;
111033
111368
  writePunctuation("}");
111034
111369
  }
111035
111370
  function emitArrayType(node) {
111036
- emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType);
111371
+ emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111037
111372
  writePunctuation("[");
111038
111373
  writePunctuation("]");
111039
111374
  }
@@ -111044,7 +111379,7 @@ var ts;
111044
111379
  function emitTupleType(node) {
111045
111380
  emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
111046
111381
  var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
111047
- emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */);
111382
+ emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
111048
111383
  emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
111049
111384
  }
111050
111385
  function emitNamedTupleMember(node) {
@@ -111056,21 +111391,21 @@ var ts;
111056
111391
  emit(node.type);
111057
111392
  }
111058
111393
  function emitOptionalType(node) {
111059
- emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType);
111394
+ emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
111060
111395
  writePunctuation("?");
111061
111396
  }
111062
111397
  function emitUnionType(node) {
111063
- emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111398
+ emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
111064
111399
  }
111065
111400
  function emitIntersectionType(node) {
111066
- emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111401
+ emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
111067
111402
  }
111068
111403
  function emitConditionalType(node) {
111069
- emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType);
111404
+ emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
111070
111405
  writeSpace();
111071
111406
  writeKeyword("extends");
111072
111407
  writeSpace();
111073
- emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType);
111408
+ emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
111074
111409
  writeSpace();
111075
111410
  writePunctuation("?");
111076
111411
  writeSpace();
@@ -111096,10 +111431,13 @@ var ts;
111096
111431
  function emitTypeOperator(node) {
111097
111432
  writeTokenText(node.operator, writeKeyword);
111098
111433
  writeSpace();
111099
- emit(node.type, parenthesizer.parenthesizeMemberOfElementType);
111434
+ var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
111435
+ parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
111436
+ parenthesizer.parenthesizeOperandOfTypeOperator;
111437
+ emit(node.type, parenthesizerRule);
111100
111438
  }
111101
111439
  function emitIndexedAccessType(node) {
111102
- emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType);
111440
+ emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111103
111441
  writePunctuation("[");
111104
111442
  emit(node.indexType);
111105
111443
  writePunctuation("]");
@@ -112833,7 +113171,7 @@ var ts;
112833
113171
  emitList(parentNode, decorators, 2146305 /* Decorators */);
112834
113172
  }
112835
113173
  function emitTypeArguments(parentNode, typeArguments) {
112836
- emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType);
113174
+ emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
112837
113175
  }
112838
113176
  function emitTypeParameters(parentNode, typeParameters) {
112839
113177
  if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
@@ -112952,6 +113290,7 @@ var ts;
112952
113290
  if (format & 128 /* Indented */) {
112953
113291
  increaseIndent();
112954
113292
  }
113293
+ var emitListItem = getEmitListItem(emit, parenthesizerRule);
112955
113294
  // Emit each child.
112956
113295
  var previousSibling = void 0;
112957
113296
  var previousSourceFileTextKind = void 0;
@@ -113002,12 +113341,7 @@ var ts;
113002
113341
  shouldEmitInterveningComments = mayEmitInterveningComments;
113003
113342
  }
113004
113343
  nextListElementPos = child.pos;
113005
- if (emit.length === 1) {
113006
- emit(child);
113007
- }
113008
- else {
113009
- emit(child, parenthesizerRule);
113010
- }
113344
+ emitListItem(child, emit, parenthesizerRule, i);
113011
113345
  if (shouldDecreaseIndentAfterEmit) {
113012
113346
  decreaseIndent();
113013
113347
  shouldDecreaseIndentAfterEmit = false;
@@ -114248,6 +114582,20 @@ var ts;
114248
114582
  TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
114249
114583
  TempFlags[TempFlags["_i"] = 268435456] = "_i";
114250
114584
  })(TempFlags || (TempFlags = {}));
114585
+ function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
114586
+ emit(node);
114587
+ }
114588
+ function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
114589
+ emit(node, parenthesizerRuleSelector.select(index));
114590
+ }
114591
+ function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
114592
+ emit(node, parenthesizerRule);
114593
+ }
114594
+ function getEmitListItem(emit, parenthesizerRule) {
114595
+ return emit.length === 1 ? emitListItemNoParenthesizer :
114596
+ typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
114597
+ emitListItemWithParenthesizerRule;
114598
+ }
114251
114599
  })(ts || (ts = {}));
114252
114600
  /* @internal */
114253
114601
  var ts;
@@ -116314,7 +116662,7 @@ var ts;
116314
116662
  // moduleAugmentations has changed
116315
116663
  structureIsReused = 1 /* SafeModules */;
116316
116664
  }
116317
- if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) {
116665
+ if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
116318
116666
  // dynamicImport has changed
116319
116667
  structureIsReused = 1 /* SafeModules */;
116320
116668
  }
@@ -116478,6 +116826,9 @@ var ts;
116478
116826
  return !!sourceFilesFoundSearchingNodeModules.get(file.path);
116479
116827
  }
116480
116828
  function isSourceFileDefaultLibrary(file) {
116829
+ if (!file.isDeclarationFile) {
116830
+ return false;
116831
+ }
116481
116832
  if (file.hasNoDefaultLib) {
116482
116833
  return true;
116483
116834
  }
@@ -116989,7 +117340,7 @@ var ts;
116989
117340
  var node = _a[_i];
116990
117341
  collectModuleReferences(node, /*inAmbientModule*/ false);
116991
117342
  }
116992
- if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117343
+ if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
116993
117344
  collectDynamicImportOrRequireCalls(file);
116994
117345
  }
116995
117346
  file.imports = imports || ts.emptyArray;
@@ -117587,7 +117938,7 @@ var ts;
117587
117938
  && index < file.imports.length
117588
117939
  && !elideImport
117589
117940
  && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
117590
- && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */));
117941
+ && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
117591
117942
  if (elideImport) {
117592
117943
  modulesWithElidedImports.set(file.path, true);
117593
117944
  }
@@ -117668,21 +118019,6 @@ var ts;
117668
118019
  return resolvedRef;
117669
118020
  }
117670
118021
  function verifyCompilerOptions() {
117671
- var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
117672
- if (!isNightly) {
117673
- if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
117674
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
117675
- }
117676
- else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
117677
- createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
117678
- }
117679
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
117680
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
117681
- }
117682
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
117683
- createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
117684
- }
117685
- }
117686
118022
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
117687
118023
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
117688
118024
  }