@typescript-deploys/pr-build 4.7.0-pr-48538-10 → 4.7.0-pr-48581-7

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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220404";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220406";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -4415,10 +4415,11 @@ var ts;
4415
4415
  NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
4416
4416
  NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
4417
4417
  NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
4418
- NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError";
4419
- NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile";
4420
- NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError";
4421
- NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData";
4418
+ NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
4419
+ NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
4420
+ NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
4421
+ NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
4422
+ NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
4422
4423
  // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
4423
4424
  // walking the tree if the flags are not set. However, these flags are just a approximation
4424
4425
  // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
@@ -4428,25 +4429,25 @@ var ts;
4428
4429
  // removal, it is likely that users will add the import anyway.
4429
4430
  // The advantage of this approach is its simplicity. For the case of batch compilation,
4430
4431
  // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
4431
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport";
4432
- /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta";
4433
- NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
4434
- /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
4435
- /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
4436
- NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
4437
- /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 67108864] = "TypeCached";
4438
- /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 134217728] = "Deprecated";
4432
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
4433
+ /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
4434
+ NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
4435
+ /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
4436
+ /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
4437
+ NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
4438
+ /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
4439
+ /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
4439
4440
  NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
4440
4441
  NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
4441
4442
  NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
4442
4443
  // Parsing context flags
4443
- NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags";
4444
+ NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
4444
4445
  // Exclude these flags when parsing a Type
4445
4446
  NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
4446
4447
  // Represents all flags that are potentially set once and
4447
4448
  // never cleared on SourceFiles which get re-used in between incremental parses.
4448
4449
  // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
4449
- /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags";
4450
+ /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
4450
4451
  })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
4451
4452
  var ModifierFlags;
4452
4453
  (function (ModifierFlags) {
@@ -8888,6 +8889,7 @@ var ts;
8888
8889
  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}'?"),
8889
8890
  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."),
8890
8891
  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."),
8892
+ 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."),
8891
8893
  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}'."),
8892
8894
  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}'."),
8893
8895
  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}'."),
@@ -14302,24 +14304,24 @@ var ts;
14302
14304
  // Returns true if this node contains a parse error anywhere underneath it.
14303
14305
  function containsParseError(node) {
14304
14306
  aggregateChildData(node);
14305
- return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14307
+ return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
14306
14308
  }
14307
14309
  ts.containsParseError = containsParseError;
14308
14310
  function aggregateChildData(node) {
14309
- if (!(node.flags & 524288 /* HasAggregatedChildData */)) {
14311
+ if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
14310
14312
  // A node is considered to contain a parse error if:
14311
14313
  // a) the parser explicitly marked that it had an error
14312
14314
  // b) any of it's children reported that it had an error.
14313
- var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) ||
14315
+ var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
14314
14316
  ts.forEachChild(node, containsParseError);
14315
14317
  // If so, mark ourselves accordingly.
14316
14318
  if (thisNodeOrAnySubNodesHasError) {
14317
- node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */;
14319
+ node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
14318
14320
  }
14319
14321
  // Also mark that we've propagated the child information to this node. This way we can
14320
14322
  // always consult the bit directly on this node without needing to check its children
14321
14323
  // again.
14322
- node.flags |= 524288 /* HasAggregatedChildData */;
14324
+ node.flags |= 1048576 /* HasAggregatedChildData */;
14323
14325
  }
14324
14326
  }
14325
14327
  function getSourceFileOfNode(node) {
@@ -16126,11 +16128,11 @@ var ts;
16126
16128
  }
16127
16129
  ts.isSourceFileNotJS = isSourceFileNotJS;
16128
16130
  function isInJSFile(node) {
16129
- return !!node && !!(node.flags & 131072 /* JavaScriptFile */);
16131
+ return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
16130
16132
  }
16131
16133
  ts.isInJSFile = isInJSFile;
16132
16134
  function isInJsonFile(node) {
16133
- return !!node && !!(node.flags & 33554432 /* JsonFile */);
16135
+ return !!node && !!(node.flags & 67108864 /* JsonFile */);
16134
16136
  }
16135
16137
  ts.isInJsonFile = isInJsonFile;
16136
16138
  function isSourceFileNotJson(file) {
@@ -16138,7 +16140,7 @@ var ts;
16138
16140
  }
16139
16141
  ts.isSourceFileNotJson = isSourceFileNotJson;
16140
16142
  function isInJSDoc(node) {
16141
- return !!node && !!(node.flags & 4194304 /* JSDoc */);
16143
+ return !!node && !!(node.flags & 8388608 /* JSDoc */);
16142
16144
  }
16143
16145
  ts.isInJSDoc = isInJSDoc;
16144
16146
  function isJSDocIndexSignature(node) {
@@ -16524,7 +16526,7 @@ var ts;
16524
16526
  function setValueDeclaration(symbol, node) {
16525
16527
  var valueDeclaration = symbol.valueDeclaration;
16526
16528
  if (!valueDeclaration ||
16527
- !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) &&
16529
+ !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
16528
16530
  (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
16529
16531
  (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
16530
16532
  // other kinds of value declarations take precedence over modules and assignment declarations
@@ -16797,7 +16799,11 @@ var ts;
16797
16799
  ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
16798
16800
  function getHostSignatureFromJSDoc(node) {
16799
16801
  var host = getEffectiveJSDocHost(node);
16800
- return host && ts.isFunctionLike(host) ? host : undefined;
16802
+ if (host) {
16803
+ return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
16804
+ ts.isFunctionLike(host) ? host : undefined;
16805
+ }
16806
+ return undefined;
16801
16807
  }
16802
16808
  ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
16803
16809
  function getEffectiveJSDocHost(node) {
@@ -20822,7 +20828,7 @@ var ts;
20822
20828
  }
20823
20829
  ts.pseudoBigIntToString = pseudoBigIntToString;
20824
20830
  function isValidTypeOnlyAliasUseSite(useSite) {
20825
- return !!(useSite.flags & 8388608 /* Ambient */)
20831
+ return !!(useSite.flags & 16777216 /* Ambient */)
20826
20832
  || isPartOfTypeQuery(useSite)
20827
20833
  || isIdentifierInNonEmittingHeritageClause(useSite)
20828
20834
  || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
@@ -21275,11 +21281,20 @@ var ts;
21275
21281
  parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
21276
21282
  parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
21277
21283
  parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
21278
- parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
21279
- parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
21280
- parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
21281
- parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
21284
+ parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
21285
+ parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
21286
+ parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
21287
+ parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
21288
+ parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
21289
+ parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
21290
+ parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
21291
+ parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
21292
+ parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
21293
+ parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
21294
+ parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
21295
+ parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
21282
21296
  parenthesizeTypeArguments: parenthesizeTypeArguments,
21297
+ parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
21283
21298
  };
21284
21299
  function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
21285
21300
  binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
@@ -21591,33 +21606,191 @@ var ts;
21591
21606
  }
21592
21607
  return body;
21593
21608
  }
21594
- function parenthesizeMemberOfConditionalType(member) {
21595
- return member.kind === 189 /* ConditionalType */ ? factory.createParenthesizedType(member) : member;
21609
+ // Type[Extends] :
21610
+ // FunctionOrConstructorType
21611
+ // ConditionalType[?Extends]
21612
+ // ConditionalType[Extends] :
21613
+ // UnionType[?Extends]
21614
+ // [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
21615
+ //
21616
+ // - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
21617
+ // - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
21618
+ // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
21619
+ function parenthesizeCheckTypeOfConditionalType(checkType) {
21620
+ switch (checkType.kind) {
21621
+ case 179 /* FunctionType */:
21622
+ case 180 /* ConstructorType */:
21623
+ case 189 /* ConditionalType */:
21624
+ return factory.createParenthesizedType(checkType);
21625
+ }
21626
+ return checkType;
21596
21627
  }
21597
- function parenthesizeMemberOfElementType(member) {
21598
- switch (member.kind) {
21628
+ function parenthesizeExtendsTypeOfConditionalType(extendsType) {
21629
+ switch (extendsType.kind) {
21630
+ case 189 /* ConditionalType */:
21631
+ return factory.createParenthesizedType(extendsType);
21632
+ }
21633
+ return extendsType;
21634
+ }
21635
+ // UnionType[Extends] :
21636
+ // `|`? IntersectionType[?Extends]
21637
+ // UnionType[?Extends] `|` IntersectionType[?Extends]
21638
+ //
21639
+ // - A union type constituent has the same precedence as the check type of a conditional type
21640
+ function parenthesizeConstituentTypeOfUnionType(type) {
21641
+ switch (type.kind) {
21642
+ case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
21643
+ case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21644
+ return factory.createParenthesizedType(type);
21645
+ }
21646
+ return parenthesizeCheckTypeOfConditionalType(type);
21647
+ }
21648
+ function parenthesizeConstituentTypesOfUnionType(members) {
21649
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
21650
+ }
21651
+ // IntersectionType[Extends] :
21652
+ // `&`? TypeOperator[?Extends]
21653
+ // IntersectionType[?Extends] `&` TypeOperator[?Extends]
21654
+ //
21655
+ // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
21656
+ function parenthesizeConstituentTypeOfIntersectionType(type) {
21657
+ switch (type.kind) {
21599
21658
  case 187 /* UnionType */:
21659
+ case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
21660
+ return factory.createParenthesizedType(type);
21661
+ }
21662
+ return parenthesizeConstituentTypeOfUnionType(type);
21663
+ }
21664
+ function parenthesizeConstituentTypesOfIntersectionType(members) {
21665
+ return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
21666
+ }
21667
+ // TypeOperator[Extends] :
21668
+ // PostfixType
21669
+ // InferType[?Extends]
21670
+ // `keyof` TypeOperator[?Extends]
21671
+ // `unique` TypeOperator[?Extends]
21672
+ // `readonly` TypeOperator[?Extends]
21673
+ //
21674
+ function parenthesizeOperandOfTypeOperator(type) {
21675
+ switch (type.kind) {
21600
21676
  case 188 /* IntersectionType */:
21601
- case 179 /* FunctionType */:
21602
- case 180 /* ConstructorType */:
21603
- return factory.createParenthesizedType(member);
21677
+ return factory.createParenthesizedType(type);
21604
21678
  }
21605
- return parenthesizeMemberOfConditionalType(member);
21679
+ return parenthesizeConstituentTypeOfIntersectionType(type);
21606
21680
  }
21607
- function parenthesizeElementTypeOfArrayType(member) {
21608
- switch (member.kind) {
21609
- case 181 /* TypeQuery */:
21681
+ function parenthesizeOperandOfReadonlyTypeOperator(type) {
21682
+ switch (type.kind) {
21610
21683
  case 193 /* TypeOperator */:
21684
+ return factory.createParenthesizedType(type);
21685
+ }
21686
+ return parenthesizeOperandOfTypeOperator(type);
21687
+ }
21688
+ // PostfixType :
21689
+ // NonArrayType
21690
+ // NonArrayType [no LineTerminator here] `!` // JSDoc
21691
+ // NonArrayType [no LineTerminator here] `?` // JSDoc
21692
+ // IndexedAccessType
21693
+ // ArrayType
21694
+ //
21695
+ // IndexedAccessType :
21696
+ // NonArrayType `[` Type[~Extends] `]`
21697
+ //
21698
+ // ArrayType :
21699
+ // NonArrayType `[` `]`
21700
+ //
21701
+ function parenthesizeNonArrayTypeOfPostfixType(type) {
21702
+ switch (type.kind) {
21611
21703
  case 190 /* InferType */:
21612
- return factory.createParenthesizedType(member);
21704
+ case 193 /* TypeOperator */:
21705
+ case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
21706
+ return factory.createParenthesizedType(type);
21613
21707
  }
21614
- return parenthesizeMemberOfElementType(member);
21708
+ return parenthesizeOperandOfTypeOperator(type);
21709
+ }
21710
+ // TupleType :
21711
+ // `[` Elision? `]`
21712
+ // `[` NamedTupleElementTypes `]`
21713
+ // `[` NamedTupleElementTypes `,` Elision? `]`
21714
+ // `[` TupleElementTypes `]`
21715
+ // `[` TupleElementTypes `,` Elision? `]`
21716
+ //
21717
+ // NamedTupleElementTypes :
21718
+ // Elision? NamedTupleMember
21719
+ // NamedTupleElementTypes `,` Elision? NamedTupleMember
21720
+ //
21721
+ // NamedTupleMember :
21722
+ // Identifier `?`? `:` Type[~Extends]
21723
+ // `...` Identifier `:` Type[~Extends]
21724
+ //
21725
+ // TupleElementTypes :
21726
+ // Elision? TupleElementType
21727
+ // TupleElementTypes `,` Elision? TupleElementType
21728
+ //
21729
+ // TupleElementType :
21730
+ // Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21731
+ // OptionalType
21732
+ // RestType
21733
+ //
21734
+ // OptionalType :
21735
+ // Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
21736
+ //
21737
+ // RestType :
21738
+ // `...` Type[~Extends]
21739
+ //
21740
+ function parenthesizeElementTypesOfTupleType(types) {
21741
+ return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
21615
21742
  }
21616
- function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
21617
- return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
21743
+ function parenthesizeElementTypeOfTupleType(type) {
21744
+ if (hasJSDocPostfixQuestion(type))
21745
+ return factory.createParenthesizedType(type);
21746
+ return type;
21747
+ }
21748
+ function hasJSDocPostfixQuestion(type) {
21749
+ if (ts.isJSDocNullableType(type))
21750
+ return type.postfix;
21751
+ if (ts.isNamedTupleMember(type))
21752
+ return hasJSDocPostfixQuestion(type.type);
21753
+ if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
21754
+ return hasJSDocPostfixQuestion(type.type);
21755
+ if (ts.isConditionalTypeNode(type))
21756
+ return hasJSDocPostfixQuestion(type.falseType);
21757
+ if (ts.isUnionTypeNode(type))
21758
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21759
+ if (ts.isIntersectionTypeNode(type))
21760
+ return hasJSDocPostfixQuestion(ts.last(type.types));
21761
+ if (ts.isInferTypeNode(type))
21762
+ return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
21763
+ return false;
21764
+ }
21765
+ function parenthesizeTypeOfOptionalType(type) {
21766
+ if (hasJSDocPostfixQuestion(type))
21767
+ return factory.createParenthesizedType(type);
21768
+ return parenthesizeNonArrayTypeOfPostfixType(type);
21769
+ }
21770
+ // function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
21771
+ // switch (member.kind) {
21772
+ // case SyntaxKind.UnionType:
21773
+ // case SyntaxKind.IntersectionType:
21774
+ // case SyntaxKind.FunctionType:
21775
+ // case SyntaxKind.ConstructorType:
21776
+ // return factory.createParenthesizedType(member);
21777
+ // }
21778
+ // return parenthesizeMemberOfConditionalType(member);
21779
+ // }
21780
+ // function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
21781
+ // switch (member.kind) {
21782
+ // case SyntaxKind.TypeQuery:
21783
+ // case SyntaxKind.TypeOperator:
21784
+ // case SyntaxKind.InferType:
21785
+ // return factory.createParenthesizedType(member);
21786
+ // }
21787
+ // return parenthesizeMemberOfElementType(member);
21788
+ // }
21789
+ function parenthesizeLeadingTypeArgument(node) {
21790
+ return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21618
21791
  }
21619
21792
  function parenthesizeOrdinalTypeArgument(node, i) {
21620
- return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
21793
+ return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
21621
21794
  }
21622
21795
  function parenthesizeTypeArguments(typeArguments) {
21623
21796
  if (ts.some(typeArguments)) {
@@ -21643,11 +21816,20 @@ var ts;
21643
21816
  parenthesizeExpressionForDisallowedComma: ts.identity,
21644
21817
  parenthesizeExpressionOfExpressionStatement: ts.identity,
21645
21818
  parenthesizeConciseBodyOfArrowFunction: ts.identity,
21646
- parenthesizeMemberOfConditionalType: ts.identity,
21647
- parenthesizeMemberOfElementType: ts.identity,
21648
- parenthesizeElementTypeOfArrayType: ts.identity,
21649
- parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21819
+ parenthesizeCheckTypeOfConditionalType: ts.identity,
21820
+ parenthesizeExtendsTypeOfConditionalType: ts.identity,
21821
+ parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21822
+ parenthesizeConstituentTypeOfUnionType: ts.identity,
21823
+ parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21824
+ parenthesizeConstituentTypeOfIntersectionType: ts.identity,
21825
+ parenthesizeOperandOfTypeOperator: ts.identity,
21826
+ parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
21827
+ parenthesizeNonArrayTypeOfPostfixType: ts.identity,
21828
+ parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
21829
+ parenthesizeElementTypeOfTupleType: ts.identity,
21830
+ parenthesizeTypeOfOptionalType: ts.identity,
21650
21831
  parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
21832
+ parenthesizeLeadingTypeArgument: ts.identity,
21651
21833
  };
21652
21834
  })(ts || (ts = {}));
21653
21835
  /* @internal */
@@ -21787,6 +21969,8 @@ var ts;
21787
21969
  var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
21788
21970
  var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
21789
21971
  var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
21972
+ var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
21973
+ var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
21790
21974
  var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
21791
21975
  var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
21792
21976
  var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
@@ -21794,6 +21978,8 @@ var ts;
21794
21978
  var factory = {
21795
21979
  get parenthesizer() { return parenthesizerRules(); },
21796
21980
  get converters() { return converters(); },
21981
+ baseFactory: baseFactory,
21982
+ flags: flags,
21797
21983
  createNodeArray: createNodeArray,
21798
21984
  createNumericLiteral: createNumericLiteral,
21799
21985
  createBigIntLiteral: createBigIntLiteral,
@@ -22069,10 +22255,10 @@ var ts;
22069
22255
  // lazily load factory members for JSDoc types with similar structure
22070
22256
  get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
22071
22257
  get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
22072
- get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22073
- get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22074
- get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22075
- get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22258
+ get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
22259
+ get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
22260
+ get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
22261
+ get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
22076
22262
  get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
22077
22263
  get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
22078
22264
  get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
@@ -23188,7 +23374,7 @@ var ts;
23188
23374
  // @api
23189
23375
  function createArrayTypeNode(elementType) {
23190
23376
  var node = createBaseNode(183 /* ArrayType */);
23191
- node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
23377
+ node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
23192
23378
  node.transformFlags = 1 /* ContainsTypeScript */;
23193
23379
  return node;
23194
23380
  }
@@ -23201,7 +23387,7 @@ var ts;
23201
23387
  // @api
23202
23388
  function createTupleTypeNode(elements) {
23203
23389
  var node = createBaseNode(184 /* TupleType */);
23204
- node.elements = createNodeArray(elements);
23390
+ node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
23205
23391
  node.transformFlags = 1 /* ContainsTypeScript */;
23206
23392
  return node;
23207
23393
  }
@@ -23233,7 +23419,7 @@ var ts;
23233
23419
  // @api
23234
23420
  function createOptionalTypeNode(type) {
23235
23421
  var node = createBaseNode(185 /* OptionalType */);
23236
- node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
23422
+ node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
23237
23423
  node.transformFlags = 1 /* ContainsTypeScript */;
23238
23424
  return node;
23239
23425
  }
@@ -23256,38 +23442,38 @@ var ts;
23256
23442
  ? update(createRestTypeNode(type), node)
23257
23443
  : node;
23258
23444
  }
23259
- function createUnionOrIntersectionTypeNode(kind, types) {
23445
+ function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
23260
23446
  var node = createBaseNode(kind);
23261
- node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
23447
+ node.types = factory.createNodeArray(parenthesize(types));
23262
23448
  node.transformFlags = 1 /* ContainsTypeScript */;
23263
23449
  return node;
23264
23450
  }
23265
- function updateUnionOrIntersectionTypeNode(node, types) {
23451
+ function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
23266
23452
  return node.types !== types
23267
- ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
23453
+ ? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
23268
23454
  : node;
23269
23455
  }
23270
23456
  // @api
23271
23457
  function createUnionTypeNode(types) {
23272
- return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
23458
+ return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23273
23459
  }
23274
23460
  // @api
23275
23461
  function updateUnionTypeNode(node, types) {
23276
- return updateUnionOrIntersectionTypeNode(node, types);
23462
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
23277
23463
  }
23278
23464
  // @api
23279
23465
  function createIntersectionTypeNode(types) {
23280
- return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
23466
+ return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23281
23467
  }
23282
23468
  // @api
23283
23469
  function updateIntersectionTypeNode(node, types) {
23284
- return updateUnionOrIntersectionTypeNode(node, types);
23470
+ return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
23285
23471
  }
23286
23472
  // @api
23287
23473
  function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
23288
23474
  var node = createBaseNode(189 /* ConditionalType */);
23289
- node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
23290
- node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
23475
+ node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
23476
+ node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
23291
23477
  node.trueType = trueType;
23292
23478
  node.falseType = falseType;
23293
23479
  node.transformFlags = 1 /* ContainsTypeScript */;
@@ -23382,7 +23568,9 @@ var ts;
23382
23568
  function createTypeOperatorNode(operator, type) {
23383
23569
  var node = createBaseNode(193 /* TypeOperator */);
23384
23570
  node.operator = operator;
23385
- node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
23571
+ node.type = operator === 145 /* ReadonlyKeyword */ ?
23572
+ parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
23573
+ parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
23386
23574
  node.transformFlags = 1 /* ContainsTypeScript */;
23387
23575
  return node;
23388
23576
  }
@@ -23395,7 +23583,7 @@ var ts;
23395
23583
  // @api
23396
23584
  function createIndexedAccessTypeNode(objectType, indexType) {
23397
23585
  var node = createBaseNode(194 /* IndexedAccessType */);
23398
- node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
23586
+ node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
23399
23587
  node.indexType = indexType;
23400
23588
  node.transformFlags = 1 /* ContainsTypeScript */;
23401
23589
  return node;
@@ -25131,8 +25319,15 @@ var ts;
25131
25319
  return createBaseNode(kind);
25132
25320
  }
25133
25321
  // @api
25134
- // createJSDocNonNullableType
25135
25322
  // createJSDocNullableType
25323
+ // createJSDocNonNullableType
25324
+ function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
25325
+ if (postfix === void 0) { postfix = false; }
25326
+ var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
25327
+ node.postfix = postfix;
25328
+ return node;
25329
+ }
25330
+ // @api
25136
25331
  // createJSDocOptionalType
25137
25332
  // createJSDocVariadicType
25138
25333
  // createJSDocNamepathType
@@ -25144,6 +25339,12 @@ var ts;
25144
25339
  // @api
25145
25340
  // updateJSDocNonNullableType
25146
25341
  // updateJSDocNullableType
25342
+ function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
25343
+ return node.type !== type
25344
+ ? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
25345
+ : node;
25346
+ }
25347
+ // @api
25147
25348
  // updateJSDocOptionalType
25148
25349
  // updateJSDocVariadicType
25149
25350
  // updateJSDocNamepathType
@@ -30224,7 +30425,7 @@ var ts;
30224
30425
  || ts.isExportDeclaration(node) ? node : undefined;
30225
30426
  }
30226
30427
  function getImportMetaIfNecessary(sourceFile) {
30227
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30428
+ return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
30228
30429
  walkTreeForImportMeta(sourceFile) :
30229
30430
  undefined;
30230
30431
  }
@@ -30879,7 +31080,7 @@ var ts;
30879
31080
  var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
30880
31081
  // 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.
30881
31082
  // We will manually port the flag to the new source file.
30882
- newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */);
31083
+ newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
30883
31084
  return newSourceFile;
30884
31085
  }
30885
31086
  ts.updateSourceFile = updateSourceFile;
@@ -31163,10 +31364,10 @@ var ts;
31163
31364
  switch (scriptKind) {
31164
31365
  case 1 /* JS */:
31165
31366
  case 2 /* JSX */:
31166
- contextFlags = 131072 /* JavaScriptFile */;
31367
+ contextFlags = 262144 /* JavaScriptFile */;
31167
31368
  break;
31168
31369
  case 6 /* JSON */:
31169
- contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */;
31370
+ contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
31170
31371
  break;
31171
31372
  default:
31172
31373
  contextFlags = 0 /* None */;
@@ -31201,7 +31402,7 @@ var ts;
31201
31402
  function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31202
31403
  var isDeclarationFile = isDeclarationFileName(fileName);
31203
31404
  if (isDeclarationFile) {
31204
- contextFlags |= 8388608 /* Ambient */;
31405
+ contextFlags |= 16777216 /* Ambient */;
31205
31406
  }
31206
31407
  sourceFlags = contextFlags;
31207
31408
  // Prime the scanner.
@@ -31240,7 +31441,7 @@ var ts;
31240
31441
  node.jsDoc = jsDoc;
31241
31442
  if (hasDeprecatedTag) {
31242
31443
  hasDeprecatedTag = false;
31243
- node.flags |= 134217728 /* Deprecated */;
31444
+ node.flags |= 268435456 /* Deprecated */;
31244
31445
  }
31245
31446
  return node;
31246
31447
  }
@@ -31435,6 +31636,12 @@ var ts;
31435
31636
  function disallowInAnd(func) {
31436
31637
  return doInsideOfContext(4096 /* DisallowInContext */, func);
31437
31638
  }
31639
+ function allowConditionalTypesAnd(func) {
31640
+ return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31641
+ }
31642
+ function disallowConditionalTypesAnd(func) {
31643
+ return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
31644
+ }
31438
31645
  function doInYieldContext(func) {
31439
31646
  return doInsideOfContext(8192 /* YieldContext */, func);
31440
31647
  }
@@ -31462,6 +31669,9 @@ var ts;
31462
31669
  function inDisallowInContext() {
31463
31670
  return inContext(4096 /* DisallowInContext */);
31464
31671
  }
31672
+ function inDisallowConditionalTypesContext() {
31673
+ return inContext(65536 /* DisallowConditionalTypesContext */);
31674
+ }
31465
31675
  function inDecoratorContext() {
31466
31676
  return inContext(16384 /* DecoratorContext */);
31467
31677
  }
@@ -31846,7 +32056,7 @@ var ts;
31846
32056
  // flag so that we don't mark any subsequent nodes.
31847
32057
  if (parseErrorBeforeNextFinishedNode) {
31848
32058
  parseErrorBeforeNextFinishedNode = false;
31849
- node.flags |= 65536 /* ThisNodeHasError */;
32059
+ node.flags |= 131072 /* ThisNodeHasError */;
31850
32060
  }
31851
32061
  return node;
31852
32062
  }
@@ -32304,7 +32514,7 @@ var ts;
32304
32514
  // differently depending on what mode it is in.
32305
32515
  //
32306
32516
  // This also applies to all our other context flags as well.
32307
- var nodeContextFlags = node.flags & 25358336 /* ContextFlags */;
32517
+ var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
32308
32518
  if (nodeContextFlags !== contextFlags) {
32309
32519
  return undefined;
32310
32520
  }
@@ -32563,7 +32773,6 @@ var ts;
32563
32773
  default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
32564
32774
  }
32565
32775
  }
32566
- // Parses a comma-delimited list of elements
32567
32776
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
32568
32777
  var saveParsingContext = parsingContext;
32569
32778
  parsingContext |= 1 << kind;
@@ -32573,7 +32782,11 @@ var ts;
32573
32782
  while (true) {
32574
32783
  if (isListElement(kind, /*inErrorRecovery*/ false)) {
32575
32784
  var startPos = scanner.getStartPos();
32576
- list.push(parseListElement(kind, parseElement));
32785
+ var result = parseListElement(kind, parseElement);
32786
+ if (!result) {
32787
+ return undefined;
32788
+ }
32789
+ list.push(result);
32577
32790
  commaStart = scanner.getTokenPos();
32578
32791
  if (parseOptional(27 /* CommaToken */)) {
32579
32792
  // No need to check for a zero length node since we know we parsed a comma
@@ -32826,7 +33039,7 @@ var ts;
32826
33039
  function parseJSDocNonNullableType() {
32827
33040
  var pos = getNodePos();
32828
33041
  nextToken();
32829
- return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
33042
+ return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
32830
33043
  }
32831
33044
  function parseJSDocUnknownOrNullableType() {
32832
33045
  var pos = getNodePos();
@@ -32850,7 +33063,7 @@ var ts;
32850
33063
  return finishNode(factory.createJSDocUnknownType(), pos);
32851
33064
  }
32852
33065
  else {
32853
- return finishNode(factory.createJSDocNullableType(parseType()), pos);
33066
+ return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
32854
33067
  }
32855
33068
  }
32856
33069
  function parseJSDocFunctionType() {
@@ -32978,13 +33191,20 @@ var ts;
32978
33191
  }
32979
33192
  return name;
32980
33193
  }
32981
- function parseParameterInOuterAwaitContext() {
32982
- return parseParameterWorker(/*inOuterAwaitContext*/ true);
33194
+ function isParameterNameStart() {
33195
+ // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
33196
+ // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
33197
+ // complaining about the use of the keywords.
33198
+ return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */;
32983
33199
  }
32984
- function parseParameter() {
32985
- return parseParameterWorker(/*inOuterAwaitContext*/ false);
33200
+ function parseParameter(inOuterAwaitContext) {
33201
+ return parseParameterWorker(inOuterAwaitContext);
32986
33202
  }
32987
- function parseParameterWorker(inOuterAwaitContext) {
33203
+ function parseParameterForSpeculation(inOuterAwaitContext) {
33204
+ return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
33205
+ }
33206
+ function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
33207
+ if (allowAmbiguity === void 0) { allowAmbiguity = true; }
32988
33208
  var pos = getNodePos();
32989
33209
  var hasJSDoc = hasPrecedingJSDocComment();
32990
33210
  // FormalParameter [Yield,Await]:
@@ -33005,13 +33225,17 @@ var ts;
33005
33225
  var savedTopLevel = topLevel;
33006
33226
  topLevel = false;
33007
33227
  var modifiers = parseModifiers();
33008
- var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25 /* DotDotDotToken */), parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33228
+ var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
33229
+ if (!allowAmbiguity && !isParameterNameStart()) {
33230
+ return undefined;
33231
+ }
33232
+ var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
33009
33233
  topLevel = savedTopLevel;
33010
33234
  return node;
33011
33235
  }
33012
33236
  function parseReturnType(returnToken, isType) {
33013
33237
  if (shouldParseReturnType(returnToken, isType)) {
33014
- return parseTypeOrTypePredicate();
33238
+ return allowConditionalTypesAnd(parseTypeOrTypePredicate);
33015
33239
  }
33016
33240
  }
33017
33241
  function shouldParseReturnType(returnToken, isType) {
@@ -33030,7 +33254,7 @@ var ts;
33030
33254
  }
33031
33255
  return false;
33032
33256
  }
33033
- function parseParametersWorker(flags) {
33257
+ function parseParametersWorker(flags, allowAmbiguity) {
33034
33258
  // FormalParameters [Yield,Await]: (modified)
33035
33259
  // [empty]
33036
33260
  // FormalParameterList[?Yield,Await]
@@ -33050,7 +33274,7 @@ var ts;
33050
33274
  setAwaitContext(!!(flags & 2 /* Await */));
33051
33275
  var parameters = flags & 32 /* JSDoc */ ?
33052
33276
  parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
33053
- parseDelimitedList(16 /* Parameters */, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
33277
+ parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
33054
33278
  setYieldContext(savedYieldContext);
33055
33279
  setAwaitContext(savedAwaitContext);
33056
33280
  return parameters;
@@ -33072,7 +33296,7 @@ var ts;
33072
33296
  if (!parseExpected(20 /* OpenParenToken */)) {
33073
33297
  return createMissingList();
33074
33298
  }
33075
- var parameters = parseParametersWorker(flags);
33299
+ var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
33076
33300
  parseExpected(21 /* CloseParenToken */);
33077
33301
  return parameters;
33078
33302
  }
@@ -33154,7 +33378,7 @@ var ts;
33154
33378
  return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
33155
33379
  }
33156
33380
  function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
33157
- var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33381
+ var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
33158
33382
  var type = parseTypeAnnotation();
33159
33383
  parseTypeMemberSemicolon();
33160
33384
  var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
@@ -33426,7 +33650,7 @@ var ts;
33426
33650
  return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
33427
33651
  }
33428
33652
  function parseImportType() {
33429
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
33653
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
33430
33654
  var pos = getNodePos();
33431
33655
  var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
33432
33656
  parseExpected(100 /* ImportKeyword */);
@@ -33576,7 +33800,7 @@ var ts;
33576
33800
  switch (token()) {
33577
33801
  case 53 /* ExclamationToken */:
33578
33802
  nextToken();
33579
- type = finishNode(factory.createJSDocNonNullableType(type), pos);
33803
+ type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
33580
33804
  break;
33581
33805
  case 57 /* QuestionToken */:
33582
33806
  // If next token is start of a type we have a conditional type
@@ -33584,7 +33808,7 @@ var ts;
33584
33808
  return type;
33585
33809
  }
33586
33810
  nextToken();
33587
- type = finishNode(factory.createJSDocNullableType(type), pos);
33811
+ type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
33588
33812
  break;
33589
33813
  case 22 /* OpenBracketToken */:
33590
33814
  parseExpected(22 /* OpenBracketToken */);
@@ -33609,12 +33833,20 @@ var ts;
33609
33833
  parseExpected(operator);
33610
33834
  return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
33611
33835
  }
33836
+ function tryParseConstraintOfInferType() {
33837
+ if (parseOptional(94 /* ExtendsKeyword */)) {
33838
+ var constraint = disallowConditionalTypesAnd(parseType);
33839
+ if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
33840
+ return constraint;
33841
+ }
33842
+ }
33843
+ }
33612
33844
  function parseTypeParameterOfInferType() {
33613
33845
  var pos = getNodePos();
33614
- return finishNode(factory.createTypeParameterDeclaration(
33615
- /*modifiers*/ undefined, parseIdentifier(),
33616
- /*constraint*/ undefined,
33617
- /*defaultType*/ undefined), pos);
33846
+ var name = parseIdentifier();
33847
+ var constraint = tryParse(tryParseConstraintOfInferType);
33848
+ var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
33849
+ return finishNode(node, pos);
33618
33850
  }
33619
33851
  function parseInferType() {
33620
33852
  var pos = getNodePos();
@@ -33631,7 +33863,7 @@ var ts;
33631
33863
  case 137 /* InferKeyword */:
33632
33864
  return parseInferType();
33633
33865
  }
33634
- return parsePostfixTypeOrHigher();
33866
+ return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
33635
33867
  }
33636
33868
  function parseFunctionOrConstructorTypeToError(isInUnionType) {
33637
33869
  // the function type and constructor type shorthand notation
@@ -33761,23 +33993,21 @@ var ts;
33761
33993
  return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
33762
33994
  }
33763
33995
  function parseType() {
33764
- // The rules about 'yield' only apply to actual code/expression contexts. They don't
33765
- // apply to 'type' contexts. So we disable these parameters here before moving on.
33766
- return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker);
33767
- }
33768
- function parseTypeWorker(noConditionalTypes) {
33996
+ if (contextFlags & 40960 /* TypeExcludesFlags */) {
33997
+ return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
33998
+ }
33769
33999
  if (isStartOfFunctionTypeOrConstructorType()) {
33770
34000
  return parseFunctionOrConstructorType();
33771
34001
  }
33772
34002
  var pos = getNodePos();
33773
34003
  var type = parseUnionTypeOrHigher();
33774
- if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
34004
+ if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
33775
34005
  // The type following 'extends' is not permitted to be another conditional type
33776
- var extendsType = parseTypeWorker(/*noConditionalTypes*/ true);
34006
+ var extendsType = disallowConditionalTypesAnd(parseType);
33777
34007
  parseExpected(57 /* QuestionToken */);
33778
- var trueType = parseTypeWorker();
34008
+ var trueType = allowConditionalTypesAnd(parseType);
33779
34009
  parseExpected(58 /* ColonToken */);
33780
- var falseType = parseTypeWorker();
34010
+ var falseType = allowConditionalTypesAnd(parseType);
33781
34011
  return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
33782
34012
  }
33783
34013
  return type;
@@ -34204,7 +34434,16 @@ var ts;
34204
34434
  parameters = createMissingList();
34205
34435
  }
34206
34436
  else {
34207
- parameters = parseParametersWorker(isAsync);
34437
+ if (!allowAmbiguity) {
34438
+ var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
34439
+ if (!maybeParameters) {
34440
+ return undefined;
34441
+ }
34442
+ parameters = maybeParameters;
34443
+ }
34444
+ else {
34445
+ parameters = parseParametersWorker(isAsync, allowAmbiguity);
34446
+ }
34208
34447
  if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
34209
34448
  return undefined;
34210
34449
  }
@@ -34605,7 +34844,7 @@ var ts;
34605
34844
  // var foo3 = require("subfolder
34606
34845
  // import * as foo1 from "module-from-node
34607
34846
  // We want this import to be a statement rather than import call expression
34608
- sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */;
34847
+ sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
34609
34848
  expression = parseTokenNode();
34610
34849
  }
34611
34850
  else if (lookAhead(nextTokenIsDot)) {
@@ -34613,7 +34852,7 @@ var ts;
34613
34852
  nextToken(); // advance past the 'import'
34614
34853
  nextToken(); // advance past the dot
34615
34854
  expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
34616
- sourceFlags |= 2097152 /* PossiblyContainsImportMeta */;
34855
+ sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
34617
34856
  }
34618
34857
  else {
34619
34858
  expression = parseMemberExpressionOrHigher();
@@ -34829,7 +35068,7 @@ var ts;
34829
35068
  return finishNode(factory.createJsxOpeningFragment(), pos);
34830
35069
  }
34831
35070
  var tagName = parseJsxElementName();
34832
- var typeArguments = (contextFlags & 131072 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
35071
+ var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
34833
35072
  var attributes = parseJsxAttributes();
34834
35073
  var node;
34835
35074
  if (token() === 31 /* GreaterThanToken */) {
@@ -35107,7 +35346,7 @@ var ts;
35107
35346
  return result;
35108
35347
  }
35109
35348
  function parseTypeArgumentsInExpression() {
35110
- if ((contextFlags & 131072 /* JavaScriptFile */) !== 0) {
35349
+ if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
35111
35350
  // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
35112
35351
  return undefined;
35113
35352
  }
@@ -35503,7 +35742,7 @@ var ts;
35503
35742
  var openParenParsed = parseExpected(20 /* OpenParenToken */);
35504
35743
  var expression = allowInAnd(parseExpression);
35505
35744
  parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
35506
- var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
35745
+ var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
35507
35746
  return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
35508
35747
  }
35509
35748
  function parseCaseClause() {
@@ -35878,16 +36117,16 @@ var ts;
35878
36117
  if (isAmbient) {
35879
36118
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
35880
36119
  var m = _a[_i];
35881
- m.flags |= 8388608 /* Ambient */;
36120
+ m.flags |= 16777216 /* Ambient */;
35882
36121
  }
35883
- return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
36122
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
35884
36123
  }
35885
36124
  else {
35886
36125
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
35887
36126
  }
35888
36127
  }
35889
36128
  function tryReuseAmbientDeclaration() {
35890
- return doInsideOfContext(8388608 /* Ambient */, function () {
36129
+ return doInsideOfContext(16777216 /* Ambient */, function () {
35891
36130
  var node = currentNode(parsingContext);
35892
36131
  if (node) {
35893
36132
  return consumeNode(node);
@@ -36354,9 +36593,9 @@ var ts;
36354
36593
  if (isAmbient) {
36355
36594
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36356
36595
  var m = _a[_i];
36357
- m.flags |= 8388608 /* Ambient */;
36596
+ m.flags |= 16777216 /* Ambient */;
36358
36597
  }
36359
- return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36598
+ return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
36360
36599
  }
36361
36600
  else {
36362
36601
  return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -36921,7 +37160,7 @@ var ts;
36921
37160
  function parseJSDocTypeExpression(mayOmitBraces) {
36922
37161
  var pos = getNodePos();
36923
37162
  var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
36924
- var type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
37163
+ var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
36925
37164
  if (!mayOmitBraces || hasBrace) {
36926
37165
  parseExpectedJSDoc(19 /* CloseBraceToken */);
36927
37166
  }
@@ -36950,7 +37189,7 @@ var ts;
36950
37189
  JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
36951
37190
  function parseIsolatedJSDocComment(content, start, length) {
36952
37191
  initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
36953
- var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37192
+ var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36954
37193
  var sourceFile = { languageVariant: 0 /* Standard */, text: content };
36955
37194
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36956
37195
  clearState();
@@ -36961,9 +37200,9 @@ var ts;
36961
37200
  var saveToken = currentToken;
36962
37201
  var saveParseDiagnosticsLength = parseDiagnostics.length;
36963
37202
  var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
36964
- var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
37203
+ var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
36965
37204
  ts.setParent(comment, parent);
36966
- if (contextFlags & 131072 /* JavaScriptFile */) {
37205
+ if (contextFlags & 262144 /* JavaScriptFile */) {
36967
37206
  if (!jsDocDiagnostics) {
36968
37207
  jsDocDiagnostics = [];
36969
37208
  }
@@ -37779,7 +38018,7 @@ var ts;
37779
38018
  if (isBracketed) {
37780
38019
  skipWhitespace();
37781
38020
  parseExpected(63 /* EqualsToken */);
37782
- defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType);
38021
+ defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
37783
38022
  parseExpected(23 /* CloseBracketToken */);
37784
38023
  }
37785
38024
  if (ts.nodeIsMissing(name)) {
@@ -45667,7 +45906,7 @@ var ts;
45667
45906
  function setExportContextFlag(node) {
45668
45907
  // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
45669
45908
  // declarations with export modifiers) is an export context in which declarations are implicitly exported.
45670
- if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) {
45909
+ if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
45671
45910
  node.flags |= 64 /* ExportContext */;
45672
45911
  }
45673
45912
  else {
@@ -45870,8 +46109,8 @@ var ts;
45870
46109
  function checkContextualIdentifier(node) {
45871
46110
  // Report error only if there are no parse errors in file
45872
46111
  if (!file.parseDiagnostics.length &&
45873
- !(node.flags & 8388608 /* Ambient */) &&
45874
- !(node.flags & 4194304 /* JSDoc */) &&
46112
+ !(node.flags & 16777216 /* Ambient */) &&
46113
+ !(node.flags & 8388608 /* JSDoc */) &&
45875
46114
  !ts.isIdentifierName(node)) {
45876
46115
  // strict mode identifiers
45877
46116
  if (inStrictMode &&
@@ -46900,7 +47139,7 @@ var ts;
46900
47139
  if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
46901
47140
  return;
46902
47141
  }
46903
- if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) {
47142
+ if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
46904
47143
  // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
46905
47144
  // strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
46906
47145
  checkStrictModeEvalOrArguments(node, node.name);
@@ -46919,7 +47158,7 @@ var ts;
46919
47158
  }
46920
47159
  }
46921
47160
  function bindFunctionDeclaration(node) {
46922
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47161
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46923
47162
  if (ts.isAsyncFunction(node)) {
46924
47163
  emitFlags |= 2048 /* HasAsyncFunctions */;
46925
47164
  }
@@ -46934,7 +47173,7 @@ var ts;
46934
47173
  }
46935
47174
  }
46936
47175
  function bindFunctionExpression(node) {
46937
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) {
47176
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
46938
47177
  if (ts.isAsyncFunction(node)) {
46939
47178
  emitFlags |= 2048 /* HasAsyncFunctions */;
46940
47179
  }
@@ -46947,7 +47186,7 @@ var ts;
46947
47186
  return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
46948
47187
  }
46949
47188
  function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
46950
- if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) {
47189
+ if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
46951
47190
  emitFlags |= 2048 /* HasAsyncFunctions */;
46952
47191
  }
46953
47192
  if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
@@ -47020,7 +47259,7 @@ var ts;
47020
47259
  // Rationale: we don't want to report errors on non-initialized var's since they are hoisted
47021
47260
  // On the other side we do want to report errors on non-initialized 'lets' because of TDZ
47022
47261
  var isError_1 = ts.unreachableCodeIsError(options) &&
47023
- !(node.flags & 8388608 /* Ambient */) &&
47262
+ !(node.flags & 16777216 /* Ambient */) &&
47024
47263
  (!ts.isVariableStatement(node) ||
47025
47264
  !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
47026
47265
  node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
@@ -47920,7 +48159,7 @@ var ts;
47920
48159
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
47921
48160
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
47922
48161
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
47923
- if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
48162
+ if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
47924
48163
  (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
47925
48164
  }
47926
48165
  });
@@ -48371,7 +48610,7 @@ var ts;
48371
48610
  return diagnostic;
48372
48611
  }
48373
48612
  function isDeprecatedSymbol(symbol) {
48374
- return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
48613
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
48375
48614
  }
48376
48615
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
48377
48616
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
@@ -48599,7 +48838,7 @@ var ts;
48599
48838
  else {
48600
48839
  // find a module that about to be augmented
48601
48840
  // do not validate names of augmentations that are defined in ambient context
48602
- var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */)
48841
+ var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
48603
48842
  ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
48604
48843
  : undefined;
48605
48844
  var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
@@ -48713,7 +48952,7 @@ var ts;
48713
48952
  if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
48714
48953
  (!ts.outFile(compilerOptions)) ||
48715
48954
  isInTypeQuery(usage) ||
48716
- declaration.flags & 8388608 /* Ambient */) {
48955
+ declaration.flags & 16777216 /* Ambient */) {
48717
48956
  // nodes are in different files and order cannot be determined
48718
48957
  return true;
48719
48958
  }
@@ -48775,7 +49014,7 @@ var ts;
48775
49014
  if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
48776
49015
  return true;
48777
49016
  }
48778
- if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
49017
+ if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
48779
49018
  return true;
48780
49019
  }
48781
49020
  if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
@@ -49040,7 +49279,7 @@ var ts;
49040
49279
  // falls through
49041
49280
  case 261 /* ModuleDeclaration */:
49042
49281
  var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
49043
- if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49282
+ if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
49044
49283
  // It's an external module. First see if the module has an export default and if the local
49045
49284
  // name of that export default matches.
49046
49285
  if (result = moduleExports.get("default" /* Default */)) {
@@ -49363,7 +49602,7 @@ var ts;
49363
49602
  }
49364
49603
  }
49365
49604
  // If we're in an external module, we can't reference value symbols created from UMD export declarations
49366
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49605
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
49367
49606
  var merged = getMergedSymbol(result);
49368
49607
  if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49369
49608
  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));
@@ -49618,7 +49857,7 @@ var ts;
49618
49857
  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 */); });
49619
49858
  if (declaration === undefined)
49620
49859
  return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
49621
- if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49860
+ if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
49622
49861
  var diagnosticMessage = void 0;
49623
49862
  var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
49624
49863
  if (result.flags & 2 /* BlockScopedVariable */) {
@@ -50391,7 +50630,7 @@ var ts;
50391
50630
  }
50392
50631
  }
50393
50632
  function getAssignmentDeclarationLocation(node) {
50394
- var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50633
+ var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
50395
50634
  if (typeAlias) {
50396
50635
  return;
50397
50636
  }
@@ -51859,7 +52098,20 @@ var ts;
51859
52098
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
51860
52099
  if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
51861
52100
  context.approximateLength += (ts.symbolName(type.symbol).length + 6);
51862
- return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined));
52101
+ var constraintNode = void 0;
52102
+ var constraint = getConstraintOfTypeParameter(type);
52103
+ if (constraint) {
52104
+ // If the infer type has a constraint that is not the same as the constraint
52105
+ // we would have normally inferred based on context, we emit the constraint
52106
+ // using `infer T extends ?`. We omit inferred constraints from type references
52107
+ // as they may be elided.
52108
+ var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
52109
+ if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
52110
+ context.approximateLength += 9;
52111
+ constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
52112
+ }
52113
+ }
52114
+ return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
51863
52115
  }
51864
52116
  if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
51865
52117
  type.flags & 262144 /* TypeParameter */ &&
@@ -52053,7 +52305,7 @@ var ts;
52053
52305
  // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
52054
52306
  // of types allows us to catch circular references to instantiations of the same anonymous type
52055
52307
  if (!context.visitedTypes) {
52056
- context.visitedTypes = new ts.Set();
52308
+ context.visitedTypes = new ts.Map();
52057
52309
  }
52058
52310
  if (id && !context.symbolDepth) {
52059
52311
  context.symbolDepth = new ts.Map();
@@ -52071,15 +52323,22 @@ var ts;
52071
52323
  context.approximateLength += cachedResult.addedLength;
52072
52324
  return deepCloneOrReuseNode(cachedResult);
52073
52325
  }
52074
- var depth;
52326
+ var totalDepth = 0;
52327
+ var symbolDepth = id ? context.symbolDepth.get(id) : undefined;
52328
+ if (symbolDepth) {
52329
+ totalDepth += symbolDepth;
52330
+ }
52331
+ var visitedTypeDepth = context.visitedTypes.get(typeId);
52332
+ if (visitedTypeDepth) {
52333
+ totalDepth += visitedTypeDepth;
52334
+ }
52335
+ if (totalDepth > 10) {
52336
+ return createElidedInformationPlaceholder(context);
52337
+ }
52075
52338
  if (id) {
52076
- depth = context.symbolDepth.get(id) || 0;
52077
- if (depth > 10) {
52078
- return createElidedInformationPlaceholder(context);
52079
- }
52080
- context.symbolDepth.set(id, depth + 1);
52339
+ context.symbolDepth.set(id, (symbolDepth || 0) + 1);
52081
52340
  }
52082
- context.visitedTypes.add(typeId);
52341
+ context.visitedTypes.set(typeId, (visitedTypeDepth || 0) + 1);
52083
52342
  var startLength = context.approximateLength;
52084
52343
  var result = transform(type);
52085
52344
  var addedLength = context.approximateLength - startLength;
@@ -52090,9 +52349,19 @@ var ts;
52090
52349
  result.addedLength = addedLength;
52091
52350
  (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result);
52092
52351
  }
52093
- context.visitedTypes.delete(typeId);
52352
+ if (visitedTypeDepth !== undefined) {
52353
+ context.visitedTypes.set(typeId, visitedTypeDepth);
52354
+ }
52355
+ else {
52356
+ context.visitedTypes.delete(typeId);
52357
+ }
52094
52358
  if (id) {
52095
- context.symbolDepth.set(id, depth);
52359
+ if (symbolDepth !== undefined) {
52360
+ context.symbolDepth.set(id, symbolDepth);
52361
+ }
52362
+ else {
52363
+ context.symbolDepth.delete(id);
52364
+ }
52096
52365
  }
52097
52366
  return result;
52098
52367
  function deepCloneOrReuseNode(node) {
@@ -53815,7 +54084,7 @@ var ts;
53815
54084
  newModifierFlags |= 1 /* Export */;
53816
54085
  }
53817
54086
  if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
53818
- (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* Ambient */)) &&
54087
+ (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
53819
54088
  (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
53820
54089
  // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
53821
54090
  newModifierFlags |= 2 /* Ambient */;
@@ -54785,7 +55054,7 @@ var ts;
54785
55054
  var parent = getDeclarationContainer(node);
54786
55055
  // If the node is not exported or it is not ambient module element (except import declaration)
54787
55056
  if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
54788
- !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) {
55057
+ !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
54789
55058
  return isGlobalSourceFile(parent);
54790
55059
  }
54791
55060
  // Exported members/ambient module elements (exception import declaration) are visible if parent is visible
@@ -55125,7 +55394,7 @@ var ts;
55125
55394
  }
55126
55395
  var pattern = declaration.parent;
55127
55396
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
55128
- if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55397
+ if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
55129
55398
  parentType = getNonNullableType(parentType);
55130
55399
  }
55131
55400
  // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
@@ -55241,7 +55510,7 @@ var ts;
55241
55510
  }
55242
55511
  if ((noImplicitAny || ts.isInJSFile(declaration)) &&
55243
55512
  ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
55244
- !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) {
55513
+ !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
55245
55514
  // If --noImplicitAny is on or the declaration is in a Javascript file,
55246
55515
  // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
55247
55516
  // initializer or a 'null' or 'undefined' initializer.
@@ -56697,7 +56966,7 @@ var ts;
56697
56966
  function isLiteralEnumMember(member) {
56698
56967
  var expr = member.initializer;
56699
56968
  if (!expr) {
56700
- return !(member.flags & 8388608 /* Ambient */);
56969
+ return !(member.flags & 16777216 /* Ambient */);
56701
56970
  }
56702
56971
  switch (expr.kind) {
56703
56972
  case 10 /* StringLiteral */:
@@ -59330,7 +59599,7 @@ var ts;
59330
59599
  function getConstraintDeclaration(type) {
59331
59600
  return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
59332
59601
  }
59333
- function getInferredTypeParameterConstraint(typeParameter) {
59602
+ function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
59334
59603
  var _a;
59335
59604
  var inferences;
59336
59605
  if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
@@ -59342,7 +59611,7 @@ var ts;
59342
59611
  // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
59343
59612
  // present, we form an intersection of the inferred constraint types.
59344
59613
  var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
59345
- if (grandParent.kind === 178 /* TypeReference */) {
59614
+ if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
59346
59615
  var typeReference = grandParent;
59347
59616
  var typeParameters = getTypeParametersForTypeReference(typeReference);
59348
59617
  if (typeParameters) {
@@ -59764,7 +60033,7 @@ var ts;
59764
60033
  return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
59765
60034
  }
59766
60035
  function isJSDocTypeReference(node) {
59767
- return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
60036
+ return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
59768
60037
  }
59769
60038
  function checkNoTypeArguments(node, symbol) {
59770
60039
  if (node.typeArguments) {
@@ -61323,7 +61592,7 @@ var ts;
61323
61592
  if (ts.isCallLikeExpression(parent)) {
61324
61593
  return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
61325
61594
  }
61326
- return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
61595
+ return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
61327
61596
  }
61328
61597
  return true;
61329
61598
  }
@@ -61764,7 +62033,11 @@ var ts;
61764
62033
  return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
61765
62034
  }
61766
62035
  function isSingletonTupleType(node) {
61767
- return ts.isTupleTypeNode(node) && ts.length(node.elements) === 1 && !ts.isOptionalTypeNode(node.elements[0]) && !ts.isRestTypeNode(node.elements[0]);
62036
+ return ts.isTupleTypeNode(node) &&
62037
+ ts.length(node.elements) === 1 &&
62038
+ !ts.isOptionalTypeNode(node.elements[0]) &&
62039
+ !ts.isRestTypeNode(node.elements[0]) &&
62040
+ !(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
61768
62041
  }
61769
62042
  /**
61770
62043
  * We syntactually check for common nondistributive conditional shapes and unwrap them into
@@ -62012,7 +62285,7 @@ var ts;
62012
62285
  links.resolvedSymbol = unknownSymbol;
62013
62286
  return links.resolvedType = errorType;
62014
62287
  }
62015
- var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62288
+ var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
62016
62289
  // TODO: Future work: support unions/generics/whatever via a deferred import-type
62017
62290
  var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
62018
62291
  if (!innerModuleSymbol) {
@@ -62348,7 +62621,7 @@ var ts;
62348
62621
  }
62349
62622
  // /** @return {this} */
62350
62623
  // x.prototype.m = function() { ... }
62351
- var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62624
+ var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
62352
62625
  if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
62353
62626
  return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
62354
62627
  }
@@ -62423,7 +62696,7 @@ var ts;
62423
62696
  case 143 /* NeverKeyword */:
62424
62697
  return neverType;
62425
62698
  case 148 /* ObjectKeyword */:
62426
- return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62699
+ return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
62427
62700
  case 138 /* IntrinsicKeyword */:
62428
62701
  return intrinsicMarkerType;
62429
62702
  case 192 /* ThisType */:
@@ -69332,7 +69605,7 @@ var ts;
69332
69605
  // parameter symbols with declarations that have explicit type annotations. Such references are
69333
69606
  // resolvable with no possibility of triggering circularities in control flow analysis.
69334
69607
  function getTypeOfDottedName(node, diagnostic) {
69335
- if (!(node.flags & 16777216 /* InWithStatement */)) {
69608
+ if (!(node.flags & 33554432 /* InWithStatement */)) {
69336
69609
  switch (node.kind) {
69337
69610
  case 79 /* Identifier */:
69338
69611
  var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
@@ -70736,6 +71009,7 @@ var ts;
70736
71009
  // a generic type without a nullable constraint and x is a generic type. This is because when both obj
70737
71010
  // and x are of generic types T and K, we want the resulting type to be T[K].
70738
71011
  return parent.kind === 206 /* PropertyAccessExpression */ ||
71012
+ parent.kind === 161 /* QualifiedName */ ||
70739
71013
  parent.kind === 208 /* CallExpression */ && parent.expression === node ||
70740
71014
  parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
70741
71015
  !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
@@ -71029,7 +71303,7 @@ var ts;
71029
71303
  isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
71030
71304
  node.parent.kind === 230 /* NonNullExpression */ ||
71031
71305
  declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
71032
- declaration.flags & 8388608 /* Ambient */;
71306
+ declaration.flags & 16777216 /* Ambient */;
71033
71307
  var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
71034
71308
  type === autoType || type === autoArrayType ? undefinedType :
71035
71309
  getOptionalType(type);
@@ -72037,7 +72311,7 @@ var ts;
72037
72311
  // exists. Otherwise, it is the type of the string index signature in T, if one exists.
72038
72312
  function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
72039
72313
  ts.Debug.assert(ts.isObjectLiteralMethod(node));
72040
- if (node.flags & 16777216 /* InWithStatement */) {
72314
+ if (node.flags & 33554432 /* InWithStatement */) {
72041
72315
  // We cannot answer semantic questions within a with block, do not proceed any further
72042
72316
  return undefined;
72043
72317
  }
@@ -72225,7 +72499,7 @@ var ts;
72225
72499
  * @returns the contextual type of an expression.
72226
72500
  */
72227
72501
  function getContextualType(node, contextFlags) {
72228
- if (node.flags & 16777216 /* InWithStatement */) {
72502
+ if (node.flags & 33554432 /* InWithStatement */) {
72229
72503
  // We cannot answer semantic questions within a with block, do not proceed any further
72230
72504
  return undefined;
72231
72505
  }
@@ -73948,7 +74222,7 @@ var ts;
73948
74222
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
73949
74223
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
73950
74224
  }
73951
- if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
74225
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
73952
74226
  addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73953
74227
  }
73954
74228
  }
@@ -74016,7 +74290,7 @@ var ts;
74016
74290
  if (declaration && isPropertyWithoutInitializer(declaration)) {
74017
74291
  if (!ts.isStatic(declaration)) {
74018
74292
  var flowContainer = getControlFlowContainer(node);
74019
- if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) {
74293
+ if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
74020
74294
  assumeUninitialized = true;
74021
74295
  }
74022
74296
  }
@@ -74053,7 +74327,7 @@ var ts;
74053
74327
  }
74054
74328
  else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
74055
74329
  node.parent.kind !== 178 /* TypeReference */ &&
74056
- !(valueDeclaration.flags & 8388608 /* Ambient */) &&
74330
+ !(valueDeclaration.flags & 16777216 /* Ambient */) &&
74057
74331
  !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
74058
74332
  diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
74059
74333
  }
@@ -76353,7 +76627,7 @@ var ts;
76353
76627
  return returnType;
76354
76628
  }
76355
76629
  function checkDeprecatedSignature(signature, node) {
76356
- if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) {
76630
+ if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
76357
76631
  var suggestionNode = getDeprecatedSuggestionNode(node);
76358
76632
  var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
76359
76633
  addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
@@ -76497,7 +76771,7 @@ var ts;
76497
76771
  if (targetDeclarationKind !== 0 /* Unknown */) {
76498
76772
  var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
76499
76773
  // function/variable declaration should be ambient
76500
- return !!decl && !!(decl.flags & 8388608 /* Ambient */);
76774
+ return !!decl && !!(decl.flags & 16777216 /* Ambient */);
76501
76775
  }
76502
76776
  return false;
76503
76777
  }
@@ -76692,7 +76966,7 @@ var ts;
76692
76966
  error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
76693
76967
  }
76694
76968
  var file = ts.getSourceFileOfNode(node);
76695
- ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76969
+ ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
76696
76970
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
76697
76971
  }
76698
76972
  function getTypeOfParameter(symbol) {
@@ -79002,7 +79276,7 @@ var ts;
79002
79276
  return quickType;
79003
79277
  }
79004
79278
  // If a type has been cached for the node, return it.
79005
- if (node.flags & 67108864 /* TypeCached */ && flowTypeCache) {
79279
+ if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
79006
79280
  var cachedType = flowTypeCache[getNodeId(node)];
79007
79281
  if (cachedType) {
79008
79282
  return cachedType;
@@ -79014,7 +79288,7 @@ var ts;
79014
79288
  if (flowInvocationCount !== startInvocationCount) {
79015
79289
  var cache = flowTypeCache || (flowTypeCache = []);
79016
79290
  cache[getNodeId(node)] = type;
79017
- ts.setNodeFlags(node, node.flags | 67108864 /* TypeCached */);
79291
+ ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
79018
79292
  }
79019
79293
  return type;
79020
79294
  }
@@ -79100,7 +79374,7 @@ var ts;
79100
79374
  if (compilerOptions.isolatedModules) {
79101
79375
  ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
79102
79376
  var constEnumDeclaration = type.symbol.valueDeclaration;
79103
- if (constEnumDeclaration.flags & 8388608 /* Ambient */) {
79377
+ if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
79104
79378
  error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
79105
79379
  }
79106
79380
  }
@@ -79793,7 +80067,7 @@ var ts;
79793
80067
  checkDecorators(node);
79794
80068
  checkSignatureDeclaration(node);
79795
80069
  if (node.kind === 172 /* GetAccessor */) {
79796
- if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
80070
+ if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
79797
80071
  if (!(node.flags & 512 /* HasExplicitReturn */)) {
79798
80072
  error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
79799
80073
  }
@@ -79888,7 +80162,7 @@ var ts;
79888
80162
  }
79889
80163
  var symbol = getNodeLinks(node).resolvedSymbol;
79890
80164
  if (symbol) {
79891
- if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) {
80165
+ if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
79892
80166
  addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
79893
80167
  }
79894
80168
  if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
@@ -80048,6 +80322,23 @@ var ts;
80048
80322
  grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
80049
80323
  }
80050
80324
  checkSourceElement(node.typeParameter);
80325
+ var symbol = getSymbolOfNode(node.typeParameter);
80326
+ if (symbol.declarations && symbol.declarations.length > 1) {
80327
+ var links = getSymbolLinks(symbol);
80328
+ if (!links.typeParametersChecked) {
80329
+ links.typeParametersChecked = true;
80330
+ var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
80331
+ var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
80332
+ if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
80333
+ // Report an error on every conflicting declaration.
80334
+ var name = symbolToString(symbol);
80335
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80336
+ var declaration = declarations_4[_i];
80337
+ error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
80338
+ }
80339
+ }
80340
+ }
80341
+ }
80051
80342
  registerForUnusedIdentifiersCheck(node);
80052
80343
  }
80053
80344
  function checkTemplateLiteralType(node) {
@@ -80085,7 +80376,7 @@ var ts;
80085
80376
  getTypeFromTypeNode(node);
80086
80377
  }
80087
80378
  function isPrivateWithinAmbient(node) {
80088
- return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */);
80379
+ return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
80089
80380
  }
80090
80381
  function getEffectiveDeclarationFlags(n, flagsToCheck) {
80091
80382
  var flags = ts.getCombinedModifierFlags(n);
@@ -80094,7 +80385,7 @@ var ts;
80094
80385
  if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
80095
80386
  n.parent.kind !== 257 /* ClassDeclaration */ &&
80096
80387
  n.parent.kind !== 226 /* ClassExpression */ &&
80097
- n.flags & 8388608 /* Ambient */) {
80388
+ n.flags & 16777216 /* Ambient */) {
80098
80389
  if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
80099
80390
  // It is nested in an ambient context, which means it is automatically exported
80100
80391
  flags |= 1 /* Export */;
@@ -80227,10 +80518,10 @@ var ts;
80227
80518
  var hasNonAmbientClass = false;
80228
80519
  var functionDeclarations = [];
80229
80520
  if (declarations) {
80230
- for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
80231
- var current = declarations_4[_i];
80521
+ for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
80522
+ var current = declarations_5[_i];
80232
80523
  var node = current;
80233
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
80524
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
80234
80525
  var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
80235
80526
  if (inAmbientContextOrInterface) {
80236
80527
  // check if declarations are consecutive only if they are non-ambient
@@ -81082,7 +81373,7 @@ var ts;
81082
81373
  // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
81083
81374
  var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
81084
81375
  // Get first non javascript function declaration
81085
- function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); });
81376
+ function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
81086
81377
  // Only type check the symbol once
81087
81378
  if (node === firstDeclaration) {
81088
81379
  checkFunctionOrConstructorSymbol(localSymbol);
@@ -81204,7 +81495,7 @@ var ts;
81204
81495
  var symbol = getSymbolOfNode(member);
81205
81496
  if (!symbol.isReferenced
81206
81497
  && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
81207
- && !(member.flags & 8388608 /* Ambient */)) {
81498
+ && !(member.flags & 16777216 /* Ambient */)) {
81208
81499
  addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
81209
81500
  }
81210
81501
  break;
@@ -81394,8 +81685,8 @@ var ts;
81394
81685
  : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
81395
81686
  }
81396
81687
  else {
81397
- for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
81398
- var decl = declarations_5[_i];
81688
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
81689
+ var decl = declarations_6[_i];
81399
81690
  addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
81400
81691
  }
81401
81692
  }
@@ -81437,7 +81728,7 @@ var ts;
81437
81728
  }
81438
81729
  function checkCollisionWithArgumentsInGeneratedCode(node) {
81439
81730
  // no rest parameters \ declaration context \ overload - no codegen impact
81440
- if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81731
+ if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
81441
81732
  return;
81442
81733
  }
81443
81734
  ts.forEach(node.parameters, function (p) {
@@ -81465,7 +81756,7 @@ var ts;
81465
81756
  // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
81466
81757
  return false;
81467
81758
  }
81468
- if (node.flags & 8388608 /* Ambient */) {
81759
+ if (node.flags & 16777216 /* Ambient */) {
81469
81760
  // ambient context - no codegen impact
81470
81761
  return false;
81471
81762
  }
@@ -81604,7 +81895,7 @@ var ts;
81604
81895
  recordPotentialCollisionWithReflectInGeneratedCode(node, name);
81605
81896
  if (ts.isClassLike(node)) {
81606
81897
  checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
81607
- if (!(node.flags & 8388608 /* Ambient */)) {
81898
+ if (!(node.flags & 16777216 /* Ambient */)) {
81608
81899
  checkClassNameCollisionWithObject(name);
81609
81900
  }
81610
81901
  }
@@ -83198,23 +83489,23 @@ var ts;
83198
83489
  return;
83199
83490
  }
83200
83491
  var type = getDeclaredTypeOfSymbol(symbol);
83201
- if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
83492
+ if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
83202
83493
  // Report an error on every conflicting declaration.
83203
83494
  var name = symbolToString(symbol);
83204
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
83205
- var declaration = declarations_6[_i];
83495
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83496
+ var declaration = declarations_7[_i];
83206
83497
  error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
83207
83498
  }
83208
83499
  }
83209
83500
  }
83210
83501
  }
83211
- function areTypeParametersIdentical(declarations, targetParameters) {
83502
+ function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
83212
83503
  var maxTypeArgumentCount = ts.length(targetParameters);
83213
83504
  var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
83214
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
83215
- var declaration = declarations_7[_i];
83505
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
83506
+ var declaration = declarations_8[_i];
83216
83507
  // If this declaration has too few or too many type parameters, we report an error
83217
- var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
83508
+ var sourceParameters = getTypeParameterDeclarations(declaration);
83218
83509
  var numTypeParameters = sourceParameters.length;
83219
83510
  if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
83220
83511
  return false;
@@ -83282,7 +83573,7 @@ var ts;
83282
83573
  checkFunctionOrConstructorSymbol(symbol);
83283
83574
  checkClassForDuplicateDeclarations(node);
83284
83575
  // Only check for reserved static identifiers on non-ambient context.
83285
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83576
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83286
83577
  if (!nodeInAmbientContext) {
83287
83578
  checkClassForStaticPropertyNameConflicts(node);
83288
83579
  }
@@ -83432,7 +83723,7 @@ var ts;
83432
83723
  */
83433
83724
  function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
83434
83725
  var isJs = ts.isInJSFile(node);
83435
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
83726
+ var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
83436
83727
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
83437
83728
  var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
83438
83729
  var thisType = memberIsStatic ? staticType : typeWithThis;
@@ -83660,7 +83951,7 @@ var ts;
83660
83951
  && !(derived.flags & 33554432 /* Transient */)
83661
83952
  && !(baseDeclarationFlags & 128 /* Abstract */)
83662
83953
  && !(derivedDeclarationFlags & 128 /* Abstract */)
83663
- && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) {
83954
+ && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
83664
83955
  var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
83665
83956
  var propName = uninitialized.name;
83666
83957
  if (uninitialized.exclamationToken
@@ -83752,7 +84043,7 @@ var ts;
83752
84043
  return ok;
83753
84044
  }
83754
84045
  function checkPropertyInitialization(node) {
83755
- if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) {
84046
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
83756
84047
  return;
83757
84048
  }
83758
84049
  var constructor = findConstructorDeclaration(node);
@@ -83889,7 +84180,7 @@ var ts;
83889
84180
  }
83890
84181
  // In ambient non-const numeric enum declarations, enum members without initializers are
83891
84182
  // considered computed members (as opposed to having auto-incremented values).
83892
- if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
84183
+ if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
83893
84184
  return undefined;
83894
84185
  }
83895
84186
  // If the member declaration specifies no value, the member is considered a constant enum member.
@@ -83921,7 +84212,7 @@ var ts;
83921
84212
  else if (isConstEnum) {
83922
84213
  error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
83923
84214
  }
83924
- else if (member.parent.flags & 8388608 /* Ambient */) {
84215
+ else if (member.parent.flags & 16777216 /* Ambient */) {
83925
84216
  error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
83926
84217
  }
83927
84218
  else {
@@ -84089,11 +84380,11 @@ var ts;
84089
84380
  function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
84090
84381
  var declarations = symbol.declarations;
84091
84382
  if (declarations) {
84092
- for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
84093
- var declaration = declarations_8[_i];
84383
+ for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
84384
+ var declaration = declarations_9[_i];
84094
84385
  if ((declaration.kind === 257 /* ClassDeclaration */ ||
84095
84386
  (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
84096
- !(declaration.flags & 8388608 /* Ambient */)) {
84387
+ !(declaration.flags & 16777216 /* Ambient */)) {
84097
84388
  return declaration;
84098
84389
  }
84099
84390
  }
@@ -84124,7 +84415,7 @@ var ts;
84124
84415
  function checkModuleDeclarationDiagnostics() {
84125
84416
  // Grammar checking
84126
84417
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
84127
- var inAmbientContext = node.flags & 8388608 /* Ambient */;
84418
+ var inAmbientContext = node.flags & 16777216 /* Ambient */;
84128
84419
  if (isGlobalAugmentation && !inAmbientContext) {
84129
84420
  error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
84130
84421
  }
@@ -84342,7 +84633,7 @@ var ts;
84342
84633
  }
84343
84634
  if (compilerOptions.isolatedModules
84344
84635
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
84345
- && !(node.flags & 8388608 /* Ambient */)) {
84636
+ && !(node.flags & 16777216 /* Ambient */)) {
84346
84637
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
84347
84638
  var isType = !(target.flags & 111551 /* Value */);
84348
84639
  if (isType || typeOnlyAlias) {
@@ -84388,7 +84679,7 @@ var ts;
84388
84679
  }
84389
84680
  }
84390
84681
  function isDeprecatedAliasedSymbol(symbol) {
84391
- return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
84682
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
84392
84683
  }
84393
84684
  function checkDeprecatedAliasedSymbol(symbol, location) {
84394
84685
  if (!(symbol.flags & 2097152 /* Alias */))
@@ -84517,7 +84808,7 @@ var ts;
84517
84808
  }
84518
84809
  }
84519
84810
  else {
84520
- if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
84811
+ if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
84521
84812
  // Import equals declaration is deprecated in es6 or above
84522
84813
  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);
84523
84814
  }
@@ -84543,7 +84834,7 @@ var ts;
84543
84834
  ts.forEach(node.exportClause.elements, checkExportSpecifier);
84544
84835
  var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
84545
84836
  var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
84546
- !node.moduleSpecifier && node.flags & 8388608 /* Ambient */;
84837
+ !node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
84547
84838
  if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
84548
84839
  error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
84549
84840
  }
@@ -84708,10 +84999,10 @@ var ts;
84708
84999
  checkExpressionCached(node.expression);
84709
85000
  }
84710
85001
  checkExternalModuleExports(container);
84711
- if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
85002
+ if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
84712
85003
  grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
84713
85004
  }
84714
- if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
85005
+ if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
84715
85006
  if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
84716
85007
  // export assignment is not supported in es6 modules
84717
85008
  grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
@@ -85144,7 +85435,7 @@ var ts;
85144
85435
  // This relies on the results of other lazy diagnostics, so must be computed after them
85145
85436
  if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85146
85437
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85147
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85438
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
85148
85439
  diagnostics.add(diag);
85149
85440
  }
85150
85441
  });
@@ -85244,7 +85535,7 @@ var ts;
85244
85535
  }
85245
85536
  // Language service support
85246
85537
  function getSymbolsInScope(location, meaning) {
85247
- if (location.flags & 16777216 /* InWithStatement */) {
85538
+ if (location.flags & 33554432 /* InWithStatement */) {
85248
85539
  // We cannot answer semantic questions within a with block, do not proceed any further
85249
85540
  return [];
85250
85541
  }
@@ -85594,7 +85885,7 @@ var ts;
85594
85885
  }
85595
85886
  var parent = node.parent;
85596
85887
  var grandParent = parent.parent;
85597
- if (node.flags & 16777216 /* InWithStatement */) {
85888
+ if (node.flags & 33554432 /* InWithStatement */) {
85598
85889
  // We cannot answer semantic questions within a with block, do not proceed any further
85599
85890
  return undefined;
85600
85891
  }
@@ -85736,7 +86027,7 @@ var ts;
85736
86027
  if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
85737
86028
  return errorType;
85738
86029
  }
85739
- if (node.flags & 16777216 /* InWithStatement */) {
86030
+ if (node.flags & 33554432 /* InWithStatement */) {
85740
86031
  // We cannot answer semantic questions within a with block, do not proceed any further
85741
86032
  return errorType;
85742
86033
  }
@@ -86789,7 +87080,7 @@ var ts;
86789
87080
  function checkExternalEmitHelpers(location, helpers) {
86790
87081
  if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
86791
87082
  var sourceFile = ts.getSourceFileOfNode(location);
86792
- if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) {
87083
+ if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
86793
87084
  var helpersModule = resolveHelpersModule(sourceFile, location);
86794
87085
  if (helpersModule !== unknownSymbol) {
86795
87086
  var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
@@ -87042,7 +87333,7 @@ var ts;
87042
87333
  else if (node.kind === 164 /* Parameter */) {
87043
87334
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
87044
87335
  }
87045
- else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87336
+ else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
87046
87337
  return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
87047
87338
  }
87048
87339
  else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
@@ -87088,7 +87379,7 @@ var ts;
87088
87379
  if (flags & 256 /* Async */) {
87089
87380
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
87090
87381
  }
87091
- else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) {
87382
+ else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
87092
87383
  return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
87093
87384
  }
87094
87385
  else if (node.kind === 164 /* Parameter */) {
@@ -87234,7 +87525,7 @@ var ts;
87234
87525
  if (i !== (parameterCount - 1)) {
87235
87526
  return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
87236
87527
  }
87237
- if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87528
+ if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
87238
87529
  checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
87239
87530
  }
87240
87531
  if (parameter.questionToken) {
@@ -87445,7 +87736,7 @@ var ts;
87445
87736
  ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
87446
87737
  node.kind === 213 /* FunctionExpression */ ||
87447
87738
  node.kind === 169 /* MethodDeclaration */);
87448
- if (node.flags & 8388608 /* Ambient */) {
87739
+ if (node.flags & 16777216 /* Ambient */) {
87449
87740
  return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
87450
87741
  }
87451
87742
  if (!node.body) {
@@ -87683,7 +87974,7 @@ var ts;
87683
87974
  return false;
87684
87975
  }
87685
87976
  function checkGrammarAccessor(accessor) {
87686
- if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87977
+ if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
87687
87978
  if (languageVersion < 1 /* ES5 */) {
87688
87979
  return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
87689
87980
  }
@@ -87823,7 +88114,7 @@ var ts;
87823
88114
  // However, property declarations disallow computed names in general,
87824
88115
  // and accessors are not allowed in ambient contexts in general,
87825
88116
  // so this error only really matters for methods.
87826
- if (node.flags & 8388608 /* Ambient */) {
88117
+ if (node.flags & 16777216 /* Ambient */) {
87827
88118
  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);
87828
88119
  }
87829
88120
  else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
@@ -87939,7 +88230,7 @@ var ts;
87939
88230
  }
87940
88231
  function checkGrammarVariableDeclaration(node) {
87941
88232
  if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
87942
- if (node.flags & 8388608 /* Ambient */) {
88233
+ if (node.flags & 16777216 /* Ambient */) {
87943
88234
  checkAmbientInitializer(node);
87944
88235
  }
87945
88236
  else if (!node.initializer) {
@@ -87951,7 +88242,7 @@ var ts;
87951
88242
  }
87952
88243
  }
87953
88244
  }
87954
- if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) {
88245
+ if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
87955
88246
  var message = node.initializer
87956
88247
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
87957
88248
  : !node.type
@@ -87960,7 +88251,7 @@ var ts;
87960
88251
  return grammarErrorOnNode(node.exclamationToken, message);
87961
88252
  }
87962
88253
  if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
87963
- !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
88254
+ !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
87964
88255
  checkESModuleMarker(node.name);
87965
88256
  }
87966
88257
  var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
@@ -88137,11 +88428,11 @@ var ts;
88137
88428
  return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
88138
88429
  }
88139
88430
  }
88140
- if (node.flags & 8388608 /* Ambient */) {
88431
+ if (node.flags & 16777216 /* Ambient */) {
88141
88432
  checkAmbientInitializer(node);
88142
88433
  }
88143
88434
  if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
88144
- node.flags & 8388608 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88435
+ node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
88145
88436
  var message = node.initializer
88146
88437
  ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
88147
88438
  : !node.type
@@ -88187,10 +88478,10 @@ var ts;
88187
88478
  return false;
88188
88479
  }
88189
88480
  function checkGrammarSourceFile(node) {
88190
- return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88481
+ return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
88191
88482
  }
88192
88483
  function checkGrammarStatementInAmbientContext(node) {
88193
- if (node.flags & 8388608 /* Ambient */) {
88484
+ if (node.flags & 16777216 /* Ambient */) {
88194
88485
  // Find containing block which is either Block, ModuleBlock, SourceFile
88195
88486
  var links = getNodeLinks(node);
88196
88487
  if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
@@ -92308,7 +92599,7 @@ var ts;
92308
92599
  return !ts.nodeIsMissing(node.body);
92309
92600
  }
92310
92601
  function visitPropertyDeclaration(node) {
92311
- if (node.flags & 8388608 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92602
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92312
92603
  return undefined;
92313
92604
  }
92314
92605
  var updated = factory.updatePropertyDeclaration(node,
@@ -99198,8 +99489,8 @@ var ts;
99198
99489
  // declarations may not be sorted by position.
99199
99490
  // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
99200
99491
  var pos = -1, end = -1;
99201
- for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
99202
- var node = declarations_9[_i];
99492
+ for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
99493
+ var node = declarations_10[_i];
99203
99494
  pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
99204
99495
  end = Math.max(end, node.end);
99205
99496
  }
@@ -108242,7 +108533,7 @@ var ts;
108242
108533
  needsScopeFixMarker = false;
108243
108534
  var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
108244
108535
  var lateStatements = transformAndReplaceLatePaintedStatements(statements);
108245
- if (input.flags & 8388608 /* Ambient */) {
108536
+ if (input.flags & 16777216 /* Ambient */) {
108246
108537
  needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
108247
108538
  }
108248
108539
  // With the final list of statements, there are 3 possibilities:
@@ -109890,6 +110181,9 @@ var ts;
109890
110181
  var currentParenthesizerRule;
109891
110182
  var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
109892
110183
  var parenthesizer = ts.factory.parenthesizer;
110184
+ var typeArgumentParenthesizerRuleSelector = {
110185
+ select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
110186
+ };
109893
110187
  var emitBinaryExpression = createEmitBinaryExpression();
109894
110188
  reset();
109895
110189
  return {
@@ -111102,7 +111396,7 @@ var ts;
111102
111396
  writePunctuation("}");
111103
111397
  }
111104
111398
  function emitArrayType(node) {
111105
- emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType);
111399
+ emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111106
111400
  writePunctuation("[");
111107
111401
  writePunctuation("]");
111108
111402
  }
@@ -111113,7 +111407,7 @@ var ts;
111113
111407
  function emitTupleType(node) {
111114
111408
  emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
111115
111409
  var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
111116
- emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */);
111410
+ emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
111117
111411
  emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
111118
111412
  }
111119
111413
  function emitNamedTupleMember(node) {
@@ -111125,21 +111419,21 @@ var ts;
111125
111419
  emit(node.type);
111126
111420
  }
111127
111421
  function emitOptionalType(node) {
111128
- emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType);
111422
+ emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
111129
111423
  writePunctuation("?");
111130
111424
  }
111131
111425
  function emitUnionType(node) {
111132
- emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111426
+ emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
111133
111427
  }
111134
111428
  function emitIntersectionType(node) {
111135
- emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType);
111429
+ emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
111136
111430
  }
111137
111431
  function emitConditionalType(node) {
111138
- emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType);
111432
+ emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
111139
111433
  writeSpace();
111140
111434
  writeKeyword("extends");
111141
111435
  writeSpace();
111142
- emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType);
111436
+ emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
111143
111437
  writeSpace();
111144
111438
  writePunctuation("?");
111145
111439
  writeSpace();
@@ -111165,10 +111459,13 @@ var ts;
111165
111459
  function emitTypeOperator(node) {
111166
111460
  writeTokenText(node.operator, writeKeyword);
111167
111461
  writeSpace();
111168
- emit(node.type, parenthesizer.parenthesizeMemberOfElementType);
111462
+ var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
111463
+ parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
111464
+ parenthesizer.parenthesizeOperandOfTypeOperator;
111465
+ emit(node.type, parenthesizerRule);
111169
111466
  }
111170
111467
  function emitIndexedAccessType(node) {
111171
- emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType);
111468
+ emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
111172
111469
  writePunctuation("[");
111173
111470
  emit(node.indexType);
111174
111471
  writePunctuation("]");
@@ -112902,7 +113199,7 @@ var ts;
112902
113199
  emitList(parentNode, decorators, 2146305 /* Decorators */);
112903
113200
  }
112904
113201
  function emitTypeArguments(parentNode, typeArguments) {
112905
- emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType);
113202
+ emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
112906
113203
  }
112907
113204
  function emitTypeParameters(parentNode, typeParameters) {
112908
113205
  if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
@@ -113021,6 +113318,7 @@ var ts;
113021
113318
  if (format & 128 /* Indented */) {
113022
113319
  increaseIndent();
113023
113320
  }
113321
+ var emitListItem = getEmitListItem(emit, parenthesizerRule);
113024
113322
  // Emit each child.
113025
113323
  var previousSibling = void 0;
113026
113324
  var previousSourceFileTextKind = void 0;
@@ -113071,12 +113369,7 @@ var ts;
113071
113369
  shouldEmitInterveningComments = mayEmitInterveningComments;
113072
113370
  }
113073
113371
  nextListElementPos = child.pos;
113074
- if (emit.length === 1) {
113075
- emit(child);
113076
- }
113077
- else {
113078
- emit(child, parenthesizerRule);
113079
- }
113372
+ emitListItem(child, emit, parenthesizerRule, i);
113080
113373
  if (shouldDecreaseIndentAfterEmit) {
113081
113374
  decreaseIndent();
113082
113375
  shouldDecreaseIndentAfterEmit = false;
@@ -114317,6 +114610,20 @@ var ts;
114317
114610
  TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
114318
114611
  TempFlags[TempFlags["_i"] = 268435456] = "_i";
114319
114612
  })(TempFlags || (TempFlags = {}));
114613
+ function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
114614
+ emit(node);
114615
+ }
114616
+ function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
114617
+ emit(node, parenthesizerRuleSelector.select(index));
114618
+ }
114619
+ function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
114620
+ emit(node, parenthesizerRule);
114621
+ }
114622
+ function getEmitListItem(emit, parenthesizerRule) {
114623
+ return emit.length === 1 ? emitListItemNoParenthesizer :
114624
+ typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
114625
+ emitListItemWithParenthesizerRule;
114626
+ }
114320
114627
  })(ts || (ts = {}));
114321
114628
  /* @internal */
114322
114629
  var ts;
@@ -116383,7 +116690,7 @@ var ts;
116383
116690
  // moduleAugmentations has changed
116384
116691
  structureIsReused = 1 /* SafeModules */;
116385
116692
  }
116386
- if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) {
116693
+ if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
116387
116694
  // dynamicImport has changed
116388
116695
  structureIsReused = 1 /* SafeModules */;
116389
116696
  }
@@ -116547,6 +116854,9 @@ var ts;
116547
116854
  return !!sourceFilesFoundSearchingNodeModules.get(file.path);
116548
116855
  }
116549
116856
  function isSourceFileDefaultLibrary(file) {
116857
+ if (!file.isDeclarationFile) {
116858
+ return false;
116859
+ }
116550
116860
  if (file.hasNoDefaultLib) {
116551
116861
  return true;
116552
116862
  }
@@ -117058,7 +117368,7 @@ var ts;
117058
117368
  var node = _a[_i];
117059
117369
  collectModuleReferences(node, /*inAmbientModule*/ false);
117060
117370
  }
117061
- if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117371
+ if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
117062
117372
  collectDynamicImportOrRequireCalls(file);
117063
117373
  }
117064
117374
  file.imports = imports || ts.emptyArray;
@@ -117656,7 +117966,7 @@ var ts;
117656
117966
  && index < file.imports.length
117657
117967
  && !elideImport
117658
117968
  && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
117659
- && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */));
117969
+ && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
117660
117970
  if (elideImport) {
117661
117971
  modulesWithElidedImports.set(file.path, true);
117662
117972
  }
@@ -117737,21 +118047,6 @@ var ts;
117737
118047
  return resolvedRef;
117738
118048
  }
117739
118049
  function verifyCompilerOptions() {
117740
- var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
117741
- if (!isNightly) {
117742
- if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
117743
- 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");
117744
- }
117745
- else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
117746
- 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");
117747
- }
117748
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
117749
- 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");
117750
- }
117751
- else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
117752
- 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");
117753
- }
117754
- }
117755
118050
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
117756
118051
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
117757
118052
  }
@@ -126538,7 +126833,7 @@ var ts;
126538
126833
  result.push("export" /* exportedModifier */);
126539
126834
  if (flags & 8192 /* Deprecated */)
126540
126835
  result.push("deprecated" /* deprecatedModifier */);
126541
- if (node.flags & 8388608 /* Ambient */)
126836
+ if (node.flags & 16777216 /* Ambient */)
126542
126837
  result.push("declare" /* ambientModifier */);
126543
126838
  if (node.kind === 271 /* ExportAssignment */)
126544
126839
  result.push("export" /* exportedModifier */);
@@ -132854,7 +133149,7 @@ var ts;
132854
133149
  var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
132855
133150
  // Check completions for Object property value shorthand
132856
133151
  if (instantiatedType === undefined) {
132857
- if (objectLikeContainer.flags & 16777216 /* InWithStatement */) {
133152
+ if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
132858
133153
  return 2 /* Fail */;
132859
133154
  }
132860
133155
  isNonContextualObjectLiteral = true;
@@ -135517,17 +135812,25 @@ var ts;
135517
135812
  var options = { use: 1 /* References */ };
135518
135813
  var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
135519
135814
  var checker = program.getTypeChecker();
135520
- var symbol = checker.getSymbolAtLocation(ts.getAdjustedReferenceLocation(Core.getAdjustedNode(node, options)));
135815
+ // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
135816
+ var adjustedNode = Core.getAdjustedNode(node, options);
135817
+ var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
135521
135818
  return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
135522
135819
  var definition = _a.definition, references = _a.references;
135523
135820
  // Only include referenced symbols that have a valid definition.
135524
135821
  return definition && {
135525
135822
  definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
135526
- references: references.map(function (r) { return toReferenceEntry(r, symbol); })
135823
+ references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
135527
135824
  };
135528
135825
  });
135529
135826
  }
135530
135827
  FindAllReferences.findReferencedSymbols = findReferencedSymbols;
135828
+ function isDefinitionForReference(node) {
135829
+ return node.kind === 88 /* DefaultKeyword */
135830
+ || !!ts.getDeclarationFromName(node)
135831
+ || ts.isLiteralComputedPropertyDeclarationName(node)
135832
+ || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
135833
+ }
135531
135834
  function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
135532
135835
  var node = ts.getTouchingPropertyName(sourceFile, position);
135533
135836
  var referenceEntries;
@@ -135656,13 +135959,19 @@ var ts;
135656
135959
  return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
135657
135960
  }
135658
135961
  FindAllReferences.toRenameLocation = toRenameLocation;
135659
- function toReferenceEntry(entry, symbol) {
135962
+ function toReferencedSymbolEntry(entry, symbol) {
135963
+ var referenceEntry = toReferenceEntry(entry);
135964
+ if (!symbol)
135965
+ return referenceEntry;
135966
+ return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
135967
+ }
135968
+ function toReferenceEntry(entry) {
135660
135969
  var documentSpan = entryToDocumentSpan(entry);
135661
135970
  if (entry.kind === 0 /* Span */) {
135662
- return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false });
135971
+ return __assign(__assign({}, documentSpan), { isWriteAccess: false });
135663
135972
  }
135664
135973
  var kind = entry.kind, node = entry.node;
135665
- return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDeclarationOfSymbol(node, symbol), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
135974
+ return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
135666
135975
  }
135667
135976
  FindAllReferences.toReferenceEntry = toReferenceEntry;
135668
135977
  function entryToDocumentSpan(entry) {
@@ -135805,7 +136114,7 @@ var ts;
135805
136114
  */
135806
136115
  function declarationIsWriteAccess(decl) {
135807
136116
  // Consider anything in an ambient declaration to be a write access since it may be coming from JS.
135808
- if (!!(decl.flags & 8388608 /* Ambient */))
136117
+ if (!!(decl.flags & 16777216 /* Ambient */))
135809
136118
  return true;
135810
136119
  switch (decl.kind) {
135811
136120
  case 221 /* BinaryExpression */:
@@ -136370,15 +136679,21 @@ var ts;
136370
136679
  }
136371
136680
  function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
136372
136681
  var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
136373
- var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
136682
+ var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
136374
136683
  for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
136375
136684
  var importLocation = importSearches_2[_i][0];
136376
136685
  cb(importLocation);
136377
136686
  }
136378
- for (var _b = 0, indirectUsers_2 = indirectUsers; _b < indirectUsers_2.length; _b++) {
136379
- var indirectUser = indirectUsers_2[_b];
136380
- for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) {
136381
- var node = _d[_c];
136687
+ for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
136688
+ var singleReference = singleReferences_2[_b];
136689
+ if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
136690
+ cb(singleReference);
136691
+ }
136692
+ }
136693
+ for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
136694
+ var indirectUser = indirectUsers_2[_c];
136695
+ for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
136696
+ var node = _e[_d];
136382
136697
  // Import specifiers should be handled by importSearches
136383
136698
  var symbol = checker.getSymbolAtLocation(node);
136384
136699
  var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
@@ -137380,7 +137695,7 @@ var ts;
137380
137695
  }
137381
137696
  Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
137382
137697
  function isImplementation(node) {
137383
- return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
137698
+ return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
137384
137699
  (ts.isVariableLike(node) ? ts.hasInitializer(node) :
137385
137700
  ts.isFunctionLikeDeclaration(node) ? !!node.body :
137386
137701
  ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
@@ -137758,7 +138073,7 @@ var ts;
137758
138073
  function collect(node) {
137759
138074
  if (!node)
137760
138075
  return;
137761
- if (node.flags & 8388608 /* Ambient */) {
138076
+ if (node.flags & 16777216 /* Ambient */) {
137762
138077
  // do not descend into ambient nodes.
137763
138078
  return;
137764
138079
  }
@@ -137917,7 +138232,7 @@ var ts;
137917
138232
  }
137918
138233
  /** Gets the call sites that call out of the provided call hierarchy declaration. */
137919
138234
  function getOutgoingCalls(program, declaration) {
137920
- if (declaration.flags & 8388608 /* Ambient */ || ts.isMethodSignature(declaration)) {
138235
+ if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
137921
138236
  return [];
137922
138237
  }
137923
138238
  return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
@@ -140051,8 +140366,8 @@ var ts;
140051
140366
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
140052
140367
  var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
140053
140368
  // All of the old ImportDeclarations in the file, in syntactic order.
140054
- var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration);
140055
- organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports);
140369
+ var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
140370
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
140056
140371
  // All of the old ExportDeclarations in the file, in syntactic order.
140057
140372
  var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
140058
140373
  organizeImportsWorker(topLevelExportDecls, coalesceExports);
@@ -140060,8 +140375,8 @@ var ts;
140060
140375
  var ambientModule = _a[_i];
140061
140376
  if (!ambientModule.body)
140062
140377
  continue;
140063
- var ambientModuleImportDecls = ambientModule.body.statements.filter(ts.isImportDeclaration);
140064
- organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports);
140378
+ var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
140379
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
140065
140380
  var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
140066
140381
  organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
140067
140382
  }
@@ -140107,6 +140422,40 @@ var ts;
140107
140422
  }
140108
140423
  }
140109
140424
  OrganizeImports.organizeImports = organizeImports;
140425
+ function groupImportsByNewlineContiguous(sourceFile, importDecls) {
140426
+ var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
140427
+ var groupImports = [];
140428
+ var groupIndex = 0;
140429
+ for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
140430
+ var topLevelImportDecl = importDecls_1[_i];
140431
+ if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
140432
+ groupIndex++;
140433
+ }
140434
+ if (!groupImports[groupIndex]) {
140435
+ groupImports[groupIndex] = [];
140436
+ }
140437
+ groupImports[groupIndex].push(topLevelImportDecl);
140438
+ }
140439
+ return groupImports;
140440
+ }
140441
+ // a new group is created if an import includes at least two new line
140442
+ // new line from multi-line comment doesn't count
140443
+ function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
140444
+ var startPos = topLevelImportDecl.getFullStart();
140445
+ var endPos = topLevelImportDecl.getStart();
140446
+ scanner.setText(sourceFile.text, startPos, endPos - startPos);
140447
+ var numberOfNewLines = 0;
140448
+ while (scanner.getTokenPos() < endPos) {
140449
+ var tokenKind = scanner.scan();
140450
+ if (tokenKind === 4 /* NewLineTrivia */) {
140451
+ numberOfNewLines++;
140452
+ if (numberOfNewLines >= 2) {
140453
+ return true;
140454
+ }
140455
+ }
140456
+ }
140457
+ return false;
140458
+ }
140110
140459
  function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
140111
140460
  // As a precaution, consider unused import detection to be destructive (GH #43051)
140112
140461
  if (skipDestructiveCodeActions) {
@@ -142342,10 +142691,13 @@ var ts;
142342
142691
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
142343
142692
  // for optional function condition.
142344
142693
  var nonNullableContextualType = contextualType.getNonNullableType();
142345
- var signatures = nonNullableContextualType.getCallSignatures();
142346
- if (signatures.length !== 1)
142694
+ var symbol = nonNullableContextualType.symbol;
142695
+ if (symbol === undefined)
142696
+ return undefined;
142697
+ var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures());
142698
+ if (signature === undefined)
142347
142699
  return undefined;
142348
- var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
142700
+ var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
142349
142701
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
142350
142702
  }
142351
142703
  function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
@@ -146515,9 +146867,9 @@ var ts;
146515
146867
  // for block indentation, we should look for a line which contains something that's not
146516
146868
  // whitespace.
146517
146869
  var currentToken = ts.getTokenAtPosition(sourceFile, position);
146518
- // for object literal, we want to the indentation work like block
146519
- // if { starts in any position (can be in the middle of line)
146520
- // the following indentation should treat { as starting of that line (including leading whitespace)
146870
+ // For object literals, we want indentation to work just like with blocks.
146871
+ // If the `{` starts in any position (even in the middle of a line), then
146872
+ // the following indentation should treat `{` as the start of that line (including leading whitespace).
146521
146873
  // ```
146522
146874
  // const a: { x: undefined, y: undefined } = {} // leading 4 whitespaces and { starts in the middle of line
146523
146875
  // ->
@@ -146535,7 +146887,8 @@ var ts;
146535
146887
  // y: undefined,
146536
146888
  // }
146537
146889
  // ```
146538
- if (options.indentStyle === ts.IndentStyle.Block || currentToken.kind === 18 /* OpenBraceToken */) {
146890
+ var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */;
146891
+ if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
146539
146892
  return getBlockIndent(sourceFile, position, options);
146540
146893
  }
146541
146894
  if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) {
@@ -146548,7 +146901,9 @@ var ts;
146548
146901
  var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
146549
146902
  // use list position if the preceding token is before any list items
146550
146903
  if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
146551
- return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize; // TODO: GH#18217
146904
+ var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
146905
+ var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
146906
+ return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
146552
146907
  }
146553
146908
  return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
146554
146909
  }
@@ -148061,8 +148416,11 @@ var ts;
148061
148416
  function isTrivia(s) {
148062
148417
  return ts.skipTrivia(s, 0) === s.length;
148063
148418
  }
148419
+ // A transformation context that won't perform parenthesization, as some parenthesization rules
148420
+ // are more aggressive than is strictly necessary.
148421
+ var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
148064
148422
  function assignPositionsToNode(node) {
148065
- var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
148423
+ var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
148066
148424
  // create proxy node for non synthesized nodes
148067
148425
  var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
148068
148426
  ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
@@ -156027,7 +156385,7 @@ var ts;
156027
156385
  var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
156028
156386
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
156029
156387
  var optional = !!(symbol.flags & 16777216 /* Optional */);
156030
- var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
156388
+ var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
156031
156389
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
156032
156390
  switch (declaration.kind) {
156033
156391
  case 166 /* PropertySignature */:
@@ -156122,7 +156480,11 @@ var ts;
156122
156480
  var program = context.program;
156123
156481
  var checker = program.getTypeChecker();
156124
156482
  var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
156125
- var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0);
156483
+ var flags = 1 /* NoTruncation */
156484
+ | 1073741824 /* NoUndefinedOptionalParameterType */
156485
+ | 256 /* SuppressAnyReturnType */
156486
+ | 524288 /* AllowEmptyTuple */
156487
+ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
156126
156488
  var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
156127
156489
  if (!signatureDeclaration) {
156128
156490
  return undefined;
@@ -157600,6 +157962,10 @@ var ts;
157600
157962
  }
157601
157963
  break;
157602
157964
  }
157965
+ case 200 /* ImportType */:
157966
+ var importTypeNode = parent;
157967
+ changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
157968
+ break;
157603
157969
  default:
157604
157970
  ts.Debug.failBadSyntaxKind(parent);
157605
157971
  }
@@ -158540,7 +158906,7 @@ var ts;
158540
158906
  // cannot find either start or end node
158541
158907
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
158542
158908
  }
158543
- if (start.flags & 4194304 /* JSDoc */) {
158909
+ if (start.flags & 8388608 /* JSDoc */) {
158544
158910
  return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
158545
158911
  }
158546
158912
  if (start.parent !== end.parent) {
@@ -158666,7 +159032,7 @@ var ts;
158666
159032
  if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
158667
159033
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
158668
159034
  }
158669
- if (nodeToCheck.flags & 8388608 /* Ambient */) {
159035
+ if (nodeToCheck.flags & 16777216 /* Ambient */) {
158670
159036
  return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
158671
159037
  }
158672
159038
  // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
@@ -158856,7 +159222,8 @@ var ts;
158856
159222
  return undefined;
158857
159223
  }
158858
159224
  function isScope(node) {
158859
- return ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
159225
+ return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
159226
+ ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
158860
159227
  }
158861
159228
  /**
158862
159229
  * Computes possible places we could extract the function into. For example,
@@ -160197,6 +160564,7 @@ var ts;
160197
160564
  }
160198
160565
  function doTypedefChange(changes, file, name, info) {
160199
160566
  var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
160567
+ ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
160200
160568
  var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
160201
160569
  var templates = [];
160202
160570
  ts.forEach(typeParameters, function (typeParameter) {
@@ -162227,7 +162595,7 @@ var ts;
162227
162595
  kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
162228
162596
  new TokenObject(kind, pos, end);
162229
162597
  node.parent = parent;
162230
- node.flags = parent.flags & 25358336 /* ContextFlags */;
162598
+ node.flags = parent.flags & 50720768 /* ContextFlags */;
162231
162599
  return node;
162232
162600
  }
162233
162601
  var NodeObject = /** @class */ (function () {
@@ -163683,7 +164051,7 @@ var ts;
163683
164051
  }
163684
164052
  /// References and Occurrences
163685
164053
  function getOccurrencesAtPosition(fileName, position) {
163686
- return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
164054
+ return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
163687
164055
  }
163688
164056
  function getDocumentHighlights(fileName, position, filesToSearch) {
163689
164057
  var normalizedFileName = ts.normalizePath(fileName);
@@ -163712,7 +164080,7 @@ var ts;
163712
164080
  }
163713
164081
  function getReferencesAtPosition(fileName, position) {
163714
164082
  synchronizeHostData();
163715
- return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, function (entry, node, checker) { return ts.FindAllReferences.toReferenceEntry(entry, checker.getSymbolAtLocation(node)); });
164083
+ return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
163716
164084
  }
163717
164085
  function getReferencesWorker(node, position, options, cb) {
163718
164086
  synchronizeHostData();
@@ -163727,10 +164095,8 @@ var ts;
163727
164095
  return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
163728
164096
  }
163729
164097
  function getFileReferences(fileName) {
163730
- var _a;
163731
164098
  synchronizeHostData();
163732
- var moduleSymbol = (_a = program.getSourceFile(fileName)) === null || _a === void 0 ? void 0 : _a.symbol;
163733
- return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
164099
+ return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
163734
164100
  }
163735
164101
  function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
163736
164102
  if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
@@ -164203,7 +164569,7 @@ var ts;
164203
164569
  }
164204
164570
  function isUnclosedFragment(_a) {
164205
164571
  var closingFragment = _a.closingFragment, parent = _a.parent;
164206
- return !!(closingFragment.flags & 65536 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
164572
+ return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
164207
164573
  }
164208
164574
  function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
164209
164575
  var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
@@ -164651,7 +165017,7 @@ var ts;
164651
165017
  tokenAtLocation = preceding;
164652
165018
  }
164653
165019
  // Cannot set breakpoint in ambient declarations
164654
- if (tokenAtLocation.flags & 8388608 /* Ambient */) {
165020
+ if (tokenAtLocation.flags & 16777216 /* Ambient */) {
164655
165021
  return undefined;
164656
165022
  }
164657
165023
  // Get the span in the node based on its syntax
@@ -173571,6 +173937,7 @@ var ts;
173571
173937
  logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
173572
173938
  var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
173573
173939
  if (projectOutputs) {
173940
+ var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
173574
173941
  var _loop_9 = function (referencedSymbol) {
173575
173942
  var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
173576
173943
  var definition = mappedDefinitionFile === undefined ?
@@ -173584,6 +173951,9 @@ var ts;
173584
173951
  var ref = _b[_a];
173585
173952
  // If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
173586
173953
  if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
173954
+ if (clearIsDefinition) {
173955
+ delete ref.isDefinition;
173956
+ }
173587
173957
  symbolToAddTo.references.push(ref);
173588
173958
  }
173589
173959
  }