typescript 4.7.0-dev.20220405 → 4.7.0-dev.20220406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.dom.d.ts +404 -31
- package/lib/lib.dom.iterable.d.ts +16 -3
- package/lib/lib.es2020.intl.d.ts +15 -13
- package/lib/lib.es2021.intl.d.ts +102 -0
- package/lib/lib.es5.d.ts +1 -1
- package/lib/lib.webworker.d.ts +110 -25
- package/lib/lib.webworker.iterable.d.ts +3 -3
- package/lib/protocol.d.ts +5 -2
- package/lib/tsc.js +436 -228
- package/lib/tsserver.js +677 -296
- package/lib/tsserverlibrary.d.ts +21 -13
- package/lib/tsserverlibrary.js +677 -296
- package/lib/typescript.d.ts +16 -11
- package/lib/typescript.js +673 -296
- package/lib/typescriptServices.d.ts +16 -11
- package/lib/typescriptServices.js +673 -296
- package/lib/typingsInstaller.js +581 -264
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220406";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -4609,10 +4609,11 @@ var ts;
|
|
|
4609
4609
|
NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
|
|
4610
4610
|
NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
|
|
4611
4611
|
NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
|
|
4612
|
-
NodeFlags[NodeFlags["
|
|
4613
|
-
NodeFlags[NodeFlags["
|
|
4614
|
-
NodeFlags[NodeFlags["
|
|
4615
|
-
NodeFlags[NodeFlags["
|
|
4612
|
+
NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
|
|
4613
|
+
NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
|
|
4614
|
+
NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
|
|
4615
|
+
NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
|
|
4616
|
+
NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
|
|
4616
4617
|
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
|
4617
4618
|
// walking the tree if the flags are not set. However, these flags are just a approximation
|
|
4618
4619
|
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
|
@@ -4622,25 +4623,25 @@ var ts;
|
|
|
4622
4623
|
// removal, it is likely that users will add the import anyway.
|
|
4623
4624
|
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
|
4624
4625
|
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
|
4625
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] =
|
|
4626
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] =
|
|
4627
|
-
NodeFlags[NodeFlags["JSDoc"] =
|
|
4628
|
-
/* @internal */ NodeFlags[NodeFlags["Ambient"] =
|
|
4629
|
-
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] =
|
|
4630
|
-
NodeFlags[NodeFlags["JsonFile"] =
|
|
4631
|
-
/* @internal */ NodeFlags[NodeFlags["TypeCached"] =
|
|
4632
|
-
/* @internal */ NodeFlags[NodeFlags["Deprecated"] =
|
|
4626
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
|
|
4627
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
|
|
4628
|
+
NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
|
|
4629
|
+
/* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
|
|
4630
|
+
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
|
|
4631
|
+
NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
|
|
4632
|
+
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
|
4633
|
+
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
|
4633
4634
|
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
|
4634
4635
|
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
|
4635
4636
|
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
|
4636
4637
|
// Parsing context flags
|
|
4637
|
-
NodeFlags[NodeFlags["ContextFlags"] =
|
|
4638
|
+
NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
|
|
4638
4639
|
// Exclude these flags when parsing a Type
|
|
4639
4640
|
NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
|
|
4640
4641
|
// Represents all flags that are potentially set once and
|
|
4641
4642
|
// never cleared on SourceFiles which get re-used in between incremental parses.
|
|
4642
4643
|
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
|
4643
|
-
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] =
|
|
4644
|
+
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
|
|
4644
4645
|
})(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
|
|
4645
4646
|
var ModifierFlags;
|
|
4646
4647
|
(function (ModifierFlags) {
|
|
@@ -9082,6 +9083,7 @@ var ts;
|
|
|
9082
9083
|
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}'?"),
|
|
9083
9084
|
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."),
|
|
9084
9085
|
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."),
|
|
9086
|
+
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."),
|
|
9085
9087
|
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}'."),
|
|
9086
9088
|
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}'."),
|
|
9087
9089
|
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}'."),
|
|
@@ -14496,24 +14498,24 @@ var ts;
|
|
|
14496
14498
|
// Returns true if this node contains a parse error anywhere underneath it.
|
|
14497
14499
|
function containsParseError(node) {
|
|
14498
14500
|
aggregateChildData(node);
|
|
14499
|
-
return (node.flags &
|
|
14501
|
+
return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
|
|
14500
14502
|
}
|
|
14501
14503
|
ts.containsParseError = containsParseError;
|
|
14502
14504
|
function aggregateChildData(node) {
|
|
14503
|
-
if (!(node.flags &
|
|
14505
|
+
if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
|
|
14504
14506
|
// A node is considered to contain a parse error if:
|
|
14505
14507
|
// a) the parser explicitly marked that it had an error
|
|
14506
14508
|
// b) any of it's children reported that it had an error.
|
|
14507
|
-
var thisNodeOrAnySubNodesHasError = ((node.flags &
|
|
14509
|
+
var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
|
|
14508
14510
|
ts.forEachChild(node, containsParseError);
|
|
14509
14511
|
// If so, mark ourselves accordingly.
|
|
14510
14512
|
if (thisNodeOrAnySubNodesHasError) {
|
|
14511
|
-
node.flags |=
|
|
14513
|
+
node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
|
|
14512
14514
|
}
|
|
14513
14515
|
// Also mark that we've propagated the child information to this node. This way we can
|
|
14514
14516
|
// always consult the bit directly on this node without needing to check its children
|
|
14515
14517
|
// again.
|
|
14516
|
-
node.flags |=
|
|
14518
|
+
node.flags |= 1048576 /* HasAggregatedChildData */;
|
|
14517
14519
|
}
|
|
14518
14520
|
}
|
|
14519
14521
|
function getSourceFileOfNode(node) {
|
|
@@ -16320,11 +16322,11 @@ var ts;
|
|
|
16320
16322
|
}
|
|
16321
16323
|
ts.isSourceFileNotJS = isSourceFileNotJS;
|
|
16322
16324
|
function isInJSFile(node) {
|
|
16323
|
-
return !!node && !!(node.flags &
|
|
16325
|
+
return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
|
|
16324
16326
|
}
|
|
16325
16327
|
ts.isInJSFile = isInJSFile;
|
|
16326
16328
|
function isInJsonFile(node) {
|
|
16327
|
-
return !!node && !!(node.flags &
|
|
16329
|
+
return !!node && !!(node.flags & 67108864 /* JsonFile */);
|
|
16328
16330
|
}
|
|
16329
16331
|
ts.isInJsonFile = isInJsonFile;
|
|
16330
16332
|
function isSourceFileNotJson(file) {
|
|
@@ -16332,7 +16334,7 @@ var ts;
|
|
|
16332
16334
|
}
|
|
16333
16335
|
ts.isSourceFileNotJson = isSourceFileNotJson;
|
|
16334
16336
|
function isInJSDoc(node) {
|
|
16335
|
-
return !!node && !!(node.flags &
|
|
16337
|
+
return !!node && !!(node.flags & 8388608 /* JSDoc */);
|
|
16336
16338
|
}
|
|
16337
16339
|
ts.isInJSDoc = isInJSDoc;
|
|
16338
16340
|
function isJSDocIndexSignature(node) {
|
|
@@ -16718,7 +16720,7 @@ var ts;
|
|
|
16718
16720
|
function setValueDeclaration(symbol, node) {
|
|
16719
16721
|
var valueDeclaration = symbol.valueDeclaration;
|
|
16720
16722
|
if (!valueDeclaration ||
|
|
16721
|
-
!(node.flags &
|
|
16723
|
+
!(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
|
|
16722
16724
|
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
|
16723
16725
|
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
|
16724
16726
|
// other kinds of value declarations take precedence over modules and assignment declarations
|
|
@@ -21020,7 +21022,7 @@ var ts;
|
|
|
21020
21022
|
}
|
|
21021
21023
|
ts.pseudoBigIntToString = pseudoBigIntToString;
|
|
21022
21024
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
21023
|
-
return !!(useSite.flags &
|
|
21025
|
+
return !!(useSite.flags & 16777216 /* Ambient */)
|
|
21024
21026
|
|| isPartOfTypeQuery(useSite)
|
|
21025
21027
|
|| isIdentifierInNonEmittingHeritageClause(useSite)
|
|
21026
21028
|
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
|
|
@@ -21473,11 +21475,20 @@ var ts;
|
|
|
21473
21475
|
parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
|
|
21474
21476
|
parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
|
|
21475
21477
|
parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
|
|
21476
|
-
|
|
21477
|
-
|
|
21478
|
-
|
|
21479
|
-
|
|
21478
|
+
parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
|
|
21479
|
+
parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
|
|
21480
|
+
parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
|
|
21481
|
+
parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
|
|
21482
|
+
parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
|
|
21483
|
+
parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
|
|
21484
|
+
parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
|
|
21485
|
+
parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
|
|
21486
|
+
parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
|
|
21487
|
+
parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
|
|
21488
|
+
parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
|
|
21489
|
+
parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
|
|
21480
21490
|
parenthesizeTypeArguments: parenthesizeTypeArguments,
|
|
21491
|
+
parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
|
|
21481
21492
|
};
|
|
21482
21493
|
function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
|
|
21483
21494
|
binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
|
|
@@ -21789,33 +21800,191 @@ var ts;
|
|
|
21789
21800
|
}
|
|
21790
21801
|
return body;
|
|
21791
21802
|
}
|
|
21792
|
-
|
|
21793
|
-
|
|
21803
|
+
// Type[Extends] :
|
|
21804
|
+
// FunctionOrConstructorType
|
|
21805
|
+
// ConditionalType[?Extends]
|
|
21806
|
+
// ConditionalType[Extends] :
|
|
21807
|
+
// UnionType[?Extends]
|
|
21808
|
+
// [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
|
|
21809
|
+
//
|
|
21810
|
+
// - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
|
|
21811
|
+
// - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
|
|
21812
|
+
// - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
|
|
21813
|
+
function parenthesizeCheckTypeOfConditionalType(checkType) {
|
|
21814
|
+
switch (checkType.kind) {
|
|
21815
|
+
case 179 /* FunctionType */:
|
|
21816
|
+
case 180 /* ConstructorType */:
|
|
21817
|
+
case 189 /* ConditionalType */:
|
|
21818
|
+
return factory.createParenthesizedType(checkType);
|
|
21819
|
+
}
|
|
21820
|
+
return checkType;
|
|
21794
21821
|
}
|
|
21795
|
-
function
|
|
21796
|
-
switch (
|
|
21822
|
+
function parenthesizeExtendsTypeOfConditionalType(extendsType) {
|
|
21823
|
+
switch (extendsType.kind) {
|
|
21824
|
+
case 189 /* ConditionalType */:
|
|
21825
|
+
return factory.createParenthesizedType(extendsType);
|
|
21826
|
+
}
|
|
21827
|
+
return extendsType;
|
|
21828
|
+
}
|
|
21829
|
+
// UnionType[Extends] :
|
|
21830
|
+
// `|`? IntersectionType[?Extends]
|
|
21831
|
+
// UnionType[?Extends] `|` IntersectionType[?Extends]
|
|
21832
|
+
//
|
|
21833
|
+
// - A union type constituent has the same precedence as the check type of a conditional type
|
|
21834
|
+
function parenthesizeConstituentTypeOfUnionType(type) {
|
|
21835
|
+
switch (type.kind) {
|
|
21836
|
+
case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
|
|
21837
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21838
|
+
return factory.createParenthesizedType(type);
|
|
21839
|
+
}
|
|
21840
|
+
return parenthesizeCheckTypeOfConditionalType(type);
|
|
21841
|
+
}
|
|
21842
|
+
function parenthesizeConstituentTypesOfUnionType(members) {
|
|
21843
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
|
|
21844
|
+
}
|
|
21845
|
+
// IntersectionType[Extends] :
|
|
21846
|
+
// `&`? TypeOperator[?Extends]
|
|
21847
|
+
// IntersectionType[?Extends] `&` TypeOperator[?Extends]
|
|
21848
|
+
//
|
|
21849
|
+
// - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
|
|
21850
|
+
function parenthesizeConstituentTypeOfIntersectionType(type) {
|
|
21851
|
+
switch (type.kind) {
|
|
21797
21852
|
case 187 /* UnionType */:
|
|
21853
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
|
|
21854
|
+
return factory.createParenthesizedType(type);
|
|
21855
|
+
}
|
|
21856
|
+
return parenthesizeConstituentTypeOfUnionType(type);
|
|
21857
|
+
}
|
|
21858
|
+
function parenthesizeConstituentTypesOfIntersectionType(members) {
|
|
21859
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
|
|
21860
|
+
}
|
|
21861
|
+
// TypeOperator[Extends] :
|
|
21862
|
+
// PostfixType
|
|
21863
|
+
// InferType[?Extends]
|
|
21864
|
+
// `keyof` TypeOperator[?Extends]
|
|
21865
|
+
// `unique` TypeOperator[?Extends]
|
|
21866
|
+
// `readonly` TypeOperator[?Extends]
|
|
21867
|
+
//
|
|
21868
|
+
function parenthesizeOperandOfTypeOperator(type) {
|
|
21869
|
+
switch (type.kind) {
|
|
21798
21870
|
case 188 /* IntersectionType */:
|
|
21799
|
-
|
|
21800
|
-
case 180 /* ConstructorType */:
|
|
21801
|
-
return factory.createParenthesizedType(member);
|
|
21871
|
+
return factory.createParenthesizedType(type);
|
|
21802
21872
|
}
|
|
21803
|
-
return
|
|
21873
|
+
return parenthesizeConstituentTypeOfIntersectionType(type);
|
|
21804
21874
|
}
|
|
21805
|
-
function
|
|
21806
|
-
switch (
|
|
21807
|
-
case 181 /* TypeQuery */:
|
|
21875
|
+
function parenthesizeOperandOfReadonlyTypeOperator(type) {
|
|
21876
|
+
switch (type.kind) {
|
|
21808
21877
|
case 193 /* TypeOperator */:
|
|
21878
|
+
return factory.createParenthesizedType(type);
|
|
21879
|
+
}
|
|
21880
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21881
|
+
}
|
|
21882
|
+
// PostfixType :
|
|
21883
|
+
// NonArrayType
|
|
21884
|
+
// NonArrayType [no LineTerminator here] `!` // JSDoc
|
|
21885
|
+
// NonArrayType [no LineTerminator here] `?` // JSDoc
|
|
21886
|
+
// IndexedAccessType
|
|
21887
|
+
// ArrayType
|
|
21888
|
+
//
|
|
21889
|
+
// IndexedAccessType :
|
|
21890
|
+
// NonArrayType `[` Type[~Extends] `]`
|
|
21891
|
+
//
|
|
21892
|
+
// ArrayType :
|
|
21893
|
+
// NonArrayType `[` `]`
|
|
21894
|
+
//
|
|
21895
|
+
function parenthesizeNonArrayTypeOfPostfixType(type) {
|
|
21896
|
+
switch (type.kind) {
|
|
21809
21897
|
case 190 /* InferType */:
|
|
21810
|
-
|
|
21898
|
+
case 193 /* TypeOperator */:
|
|
21899
|
+
case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21900
|
+
return factory.createParenthesizedType(type);
|
|
21811
21901
|
}
|
|
21812
|
-
return
|
|
21902
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21903
|
+
}
|
|
21904
|
+
// TupleType :
|
|
21905
|
+
// `[` Elision? `]`
|
|
21906
|
+
// `[` NamedTupleElementTypes `]`
|
|
21907
|
+
// `[` NamedTupleElementTypes `,` Elision? `]`
|
|
21908
|
+
// `[` TupleElementTypes `]`
|
|
21909
|
+
// `[` TupleElementTypes `,` Elision? `]`
|
|
21910
|
+
//
|
|
21911
|
+
// NamedTupleElementTypes :
|
|
21912
|
+
// Elision? NamedTupleMember
|
|
21913
|
+
// NamedTupleElementTypes `,` Elision? NamedTupleMember
|
|
21914
|
+
//
|
|
21915
|
+
// NamedTupleMember :
|
|
21916
|
+
// Identifier `?`? `:` Type[~Extends]
|
|
21917
|
+
// `...` Identifier `:` Type[~Extends]
|
|
21918
|
+
//
|
|
21919
|
+
// TupleElementTypes :
|
|
21920
|
+
// Elision? TupleElementType
|
|
21921
|
+
// TupleElementTypes `,` Elision? TupleElementType
|
|
21922
|
+
//
|
|
21923
|
+
// TupleElementType :
|
|
21924
|
+
// Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21925
|
+
// OptionalType
|
|
21926
|
+
// RestType
|
|
21927
|
+
//
|
|
21928
|
+
// OptionalType :
|
|
21929
|
+
// Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21930
|
+
//
|
|
21931
|
+
// RestType :
|
|
21932
|
+
// `...` Type[~Extends]
|
|
21933
|
+
//
|
|
21934
|
+
function parenthesizeElementTypesOfTupleType(types) {
|
|
21935
|
+
return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
|
|
21813
21936
|
}
|
|
21814
|
-
function
|
|
21815
|
-
|
|
21937
|
+
function parenthesizeElementTypeOfTupleType(type) {
|
|
21938
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21939
|
+
return factory.createParenthesizedType(type);
|
|
21940
|
+
return type;
|
|
21941
|
+
}
|
|
21942
|
+
function hasJSDocPostfixQuestion(type) {
|
|
21943
|
+
if (ts.isJSDocNullableType(type))
|
|
21944
|
+
return type.postfix;
|
|
21945
|
+
if (ts.isNamedTupleMember(type))
|
|
21946
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21947
|
+
if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
|
|
21948
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21949
|
+
if (ts.isConditionalTypeNode(type))
|
|
21950
|
+
return hasJSDocPostfixQuestion(type.falseType);
|
|
21951
|
+
if (ts.isUnionTypeNode(type))
|
|
21952
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21953
|
+
if (ts.isIntersectionTypeNode(type))
|
|
21954
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21955
|
+
if (ts.isInferTypeNode(type))
|
|
21956
|
+
return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
|
|
21957
|
+
return false;
|
|
21958
|
+
}
|
|
21959
|
+
function parenthesizeTypeOfOptionalType(type) {
|
|
21960
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21961
|
+
return factory.createParenthesizedType(type);
|
|
21962
|
+
return parenthesizeNonArrayTypeOfPostfixType(type);
|
|
21963
|
+
}
|
|
21964
|
+
// function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
|
|
21965
|
+
// switch (member.kind) {
|
|
21966
|
+
// case SyntaxKind.UnionType:
|
|
21967
|
+
// case SyntaxKind.IntersectionType:
|
|
21968
|
+
// case SyntaxKind.FunctionType:
|
|
21969
|
+
// case SyntaxKind.ConstructorType:
|
|
21970
|
+
// return factory.createParenthesizedType(member);
|
|
21971
|
+
// }
|
|
21972
|
+
// return parenthesizeMemberOfConditionalType(member);
|
|
21973
|
+
// }
|
|
21974
|
+
// function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
|
|
21975
|
+
// switch (member.kind) {
|
|
21976
|
+
// case SyntaxKind.TypeQuery:
|
|
21977
|
+
// case SyntaxKind.TypeOperator:
|
|
21978
|
+
// case SyntaxKind.InferType:
|
|
21979
|
+
// return factory.createParenthesizedType(member);
|
|
21980
|
+
// }
|
|
21981
|
+
// return parenthesizeMemberOfElementType(member);
|
|
21982
|
+
// }
|
|
21983
|
+
function parenthesizeLeadingTypeArgument(node) {
|
|
21984
|
+
return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
|
|
21816
21985
|
}
|
|
21817
21986
|
function parenthesizeOrdinalTypeArgument(node, i) {
|
|
21818
|
-
return i === 0
|
|
21987
|
+
return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
|
|
21819
21988
|
}
|
|
21820
21989
|
function parenthesizeTypeArguments(typeArguments) {
|
|
21821
21990
|
if (ts.some(typeArguments)) {
|
|
@@ -21841,11 +22010,20 @@ var ts;
|
|
|
21841
22010
|
parenthesizeExpressionForDisallowedComma: ts.identity,
|
|
21842
22011
|
parenthesizeExpressionOfExpressionStatement: ts.identity,
|
|
21843
22012
|
parenthesizeConciseBodyOfArrowFunction: ts.identity,
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
22013
|
+
parenthesizeCheckTypeOfConditionalType: ts.identity,
|
|
22014
|
+
parenthesizeExtendsTypeOfConditionalType: ts.identity,
|
|
22015
|
+
parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
22016
|
+
parenthesizeConstituentTypeOfUnionType: ts.identity,
|
|
22017
|
+
parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
22018
|
+
parenthesizeConstituentTypeOfIntersectionType: ts.identity,
|
|
22019
|
+
parenthesizeOperandOfTypeOperator: ts.identity,
|
|
22020
|
+
parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
|
|
22021
|
+
parenthesizeNonArrayTypeOfPostfixType: ts.identity,
|
|
22022
|
+
parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
22023
|
+
parenthesizeElementTypeOfTupleType: ts.identity,
|
|
22024
|
+
parenthesizeTypeOfOptionalType: ts.identity,
|
|
21848
22025
|
parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
|
|
22026
|
+
parenthesizeLeadingTypeArgument: ts.identity,
|
|
21849
22027
|
};
|
|
21850
22028
|
})(ts || (ts = {}));
|
|
21851
22029
|
/* @internal */
|
|
@@ -21985,6 +22163,8 @@ var ts;
|
|
|
21985
22163
|
var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
|
|
21986
22164
|
var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
|
|
21987
22165
|
var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
|
|
22166
|
+
var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
|
|
22167
|
+
var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
|
|
21988
22168
|
var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
|
|
21989
22169
|
var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
|
|
21990
22170
|
var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
|
|
@@ -21992,6 +22172,8 @@ var ts;
|
|
|
21992
22172
|
var factory = {
|
|
21993
22173
|
get parenthesizer() { return parenthesizerRules(); },
|
|
21994
22174
|
get converters() { return converters(); },
|
|
22175
|
+
baseFactory: baseFactory,
|
|
22176
|
+
flags: flags,
|
|
21995
22177
|
createNodeArray: createNodeArray,
|
|
21996
22178
|
createNumericLiteral: createNumericLiteral,
|
|
21997
22179
|
createBigIntLiteral: createBigIntLiteral,
|
|
@@ -22267,10 +22449,10 @@ var ts;
|
|
|
22267
22449
|
// lazily load factory members for JSDoc types with similar structure
|
|
22268
22450
|
get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
|
|
22269
22451
|
get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
|
|
22270
|
-
get createJSDocNonNullableType() { return
|
|
22271
|
-
get updateJSDocNonNullableType() { return
|
|
22272
|
-
get createJSDocNullableType() { return
|
|
22273
|
-
get updateJSDocNullableType() { return
|
|
22452
|
+
get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
|
|
22453
|
+
get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
|
|
22454
|
+
get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
|
|
22455
|
+
get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
|
|
22274
22456
|
get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
|
|
22275
22457
|
get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
|
|
22276
22458
|
get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
|
|
@@ -23386,7 +23568,7 @@ var ts;
|
|
|
23386
23568
|
// @api
|
|
23387
23569
|
function createArrayTypeNode(elementType) {
|
|
23388
23570
|
var node = createBaseNode(183 /* ArrayType */);
|
|
23389
|
-
node.elementType = parenthesizerRules().
|
|
23571
|
+
node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
|
|
23390
23572
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23391
23573
|
return node;
|
|
23392
23574
|
}
|
|
@@ -23399,7 +23581,7 @@ var ts;
|
|
|
23399
23581
|
// @api
|
|
23400
23582
|
function createTupleTypeNode(elements) {
|
|
23401
23583
|
var node = createBaseNode(184 /* TupleType */);
|
|
23402
|
-
node.elements = createNodeArray(elements);
|
|
23584
|
+
node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
|
|
23403
23585
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23404
23586
|
return node;
|
|
23405
23587
|
}
|
|
@@ -23431,7 +23613,7 @@ var ts;
|
|
|
23431
23613
|
// @api
|
|
23432
23614
|
function createOptionalTypeNode(type) {
|
|
23433
23615
|
var node = createBaseNode(185 /* OptionalType */);
|
|
23434
|
-
node.type = parenthesizerRules().
|
|
23616
|
+
node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
|
|
23435
23617
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23436
23618
|
return node;
|
|
23437
23619
|
}
|
|
@@ -23454,38 +23636,38 @@ var ts;
|
|
|
23454
23636
|
? update(createRestTypeNode(type), node)
|
|
23455
23637
|
: node;
|
|
23456
23638
|
}
|
|
23457
|
-
function createUnionOrIntersectionTypeNode(kind, types) {
|
|
23639
|
+
function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
|
|
23458
23640
|
var node = createBaseNode(kind);
|
|
23459
|
-
node.types =
|
|
23641
|
+
node.types = factory.createNodeArray(parenthesize(types));
|
|
23460
23642
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23461
23643
|
return node;
|
|
23462
23644
|
}
|
|
23463
|
-
function updateUnionOrIntersectionTypeNode(node, types) {
|
|
23645
|
+
function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
|
|
23464
23646
|
return node.types !== types
|
|
23465
|
-
? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
|
|
23647
|
+
? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
|
|
23466
23648
|
: node;
|
|
23467
23649
|
}
|
|
23468
23650
|
// @api
|
|
23469
23651
|
function createUnionTypeNode(types) {
|
|
23470
|
-
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
|
|
23652
|
+
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23471
23653
|
}
|
|
23472
23654
|
// @api
|
|
23473
23655
|
function updateUnionTypeNode(node, types) {
|
|
23474
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23656
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23475
23657
|
}
|
|
23476
23658
|
// @api
|
|
23477
23659
|
function createIntersectionTypeNode(types) {
|
|
23478
|
-
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
|
|
23660
|
+
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23479
23661
|
}
|
|
23480
23662
|
// @api
|
|
23481
23663
|
function updateIntersectionTypeNode(node, types) {
|
|
23482
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23664
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23483
23665
|
}
|
|
23484
23666
|
// @api
|
|
23485
23667
|
function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
|
|
23486
23668
|
var node = createBaseNode(189 /* ConditionalType */);
|
|
23487
|
-
node.checkType = parenthesizerRules().
|
|
23488
|
-
node.extendsType = parenthesizerRules().
|
|
23669
|
+
node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
|
|
23670
|
+
node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
|
|
23489
23671
|
node.trueType = trueType;
|
|
23490
23672
|
node.falseType = falseType;
|
|
23491
23673
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
@@ -23580,7 +23762,9 @@ var ts;
|
|
|
23580
23762
|
function createTypeOperatorNode(operator, type) {
|
|
23581
23763
|
var node = createBaseNode(193 /* TypeOperator */);
|
|
23582
23764
|
node.operator = operator;
|
|
23583
|
-
node.type =
|
|
23765
|
+
node.type = operator === 145 /* ReadonlyKeyword */ ?
|
|
23766
|
+
parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
|
|
23767
|
+
parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
|
|
23584
23768
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23585
23769
|
return node;
|
|
23586
23770
|
}
|
|
@@ -23593,7 +23777,7 @@ var ts;
|
|
|
23593
23777
|
// @api
|
|
23594
23778
|
function createIndexedAccessTypeNode(objectType, indexType) {
|
|
23595
23779
|
var node = createBaseNode(194 /* IndexedAccessType */);
|
|
23596
|
-
node.objectType = parenthesizerRules().
|
|
23780
|
+
node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
|
|
23597
23781
|
node.indexType = indexType;
|
|
23598
23782
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23599
23783
|
return node;
|
|
@@ -25329,8 +25513,15 @@ var ts;
|
|
|
25329
25513
|
return createBaseNode(kind);
|
|
25330
25514
|
}
|
|
25331
25515
|
// @api
|
|
25332
|
-
// createJSDocNonNullableType
|
|
25333
25516
|
// createJSDocNullableType
|
|
25517
|
+
// createJSDocNonNullableType
|
|
25518
|
+
function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
|
|
25519
|
+
if (postfix === void 0) { postfix = false; }
|
|
25520
|
+
var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
|
|
25521
|
+
node.postfix = postfix;
|
|
25522
|
+
return node;
|
|
25523
|
+
}
|
|
25524
|
+
// @api
|
|
25334
25525
|
// createJSDocOptionalType
|
|
25335
25526
|
// createJSDocVariadicType
|
|
25336
25527
|
// createJSDocNamepathType
|
|
@@ -25342,6 +25533,12 @@ var ts;
|
|
|
25342
25533
|
// @api
|
|
25343
25534
|
// updateJSDocNonNullableType
|
|
25344
25535
|
// updateJSDocNullableType
|
|
25536
|
+
function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
|
|
25537
|
+
return node.type !== type
|
|
25538
|
+
? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
|
|
25539
|
+
: node;
|
|
25540
|
+
}
|
|
25541
|
+
// @api
|
|
25345
25542
|
// updateJSDocOptionalType
|
|
25346
25543
|
// updateJSDocVariadicType
|
|
25347
25544
|
// updateJSDocNamepathType
|
|
@@ -30422,7 +30619,7 @@ var ts;
|
|
|
30422
30619
|
|| ts.isExportDeclaration(node) ? node : undefined;
|
|
30423
30620
|
}
|
|
30424
30621
|
function getImportMetaIfNecessary(sourceFile) {
|
|
30425
|
-
return sourceFile.flags &
|
|
30622
|
+
return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
|
|
30426
30623
|
walkTreeForImportMeta(sourceFile) :
|
|
30427
30624
|
undefined;
|
|
30428
30625
|
}
|
|
@@ -31077,7 +31274,7 @@ var ts;
|
|
|
31077
31274
|
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
31078
31275
|
// 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.
|
|
31079
31276
|
// We will manually port the flag to the new source file.
|
|
31080
|
-
newSourceFile.flags |= (sourceFile.flags &
|
|
31277
|
+
newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
|
|
31081
31278
|
return newSourceFile;
|
|
31082
31279
|
}
|
|
31083
31280
|
ts.updateSourceFile = updateSourceFile;
|
|
@@ -31361,10 +31558,10 @@ var ts;
|
|
|
31361
31558
|
switch (scriptKind) {
|
|
31362
31559
|
case 1 /* JS */:
|
|
31363
31560
|
case 2 /* JSX */:
|
|
31364
|
-
contextFlags =
|
|
31561
|
+
contextFlags = 262144 /* JavaScriptFile */;
|
|
31365
31562
|
break;
|
|
31366
31563
|
case 6 /* JSON */:
|
|
31367
|
-
contextFlags =
|
|
31564
|
+
contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
|
|
31368
31565
|
break;
|
|
31369
31566
|
default:
|
|
31370
31567
|
contextFlags = 0 /* None */;
|
|
@@ -31399,7 +31596,7 @@ var ts;
|
|
|
31399
31596
|
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
|
|
31400
31597
|
var isDeclarationFile = isDeclarationFileName(fileName);
|
|
31401
31598
|
if (isDeclarationFile) {
|
|
31402
|
-
contextFlags |=
|
|
31599
|
+
contextFlags |= 16777216 /* Ambient */;
|
|
31403
31600
|
}
|
|
31404
31601
|
sourceFlags = contextFlags;
|
|
31405
31602
|
// Prime the scanner.
|
|
@@ -31438,7 +31635,7 @@ var ts;
|
|
|
31438
31635
|
node.jsDoc = jsDoc;
|
|
31439
31636
|
if (hasDeprecatedTag) {
|
|
31440
31637
|
hasDeprecatedTag = false;
|
|
31441
|
-
node.flags |=
|
|
31638
|
+
node.flags |= 268435456 /* Deprecated */;
|
|
31442
31639
|
}
|
|
31443
31640
|
return node;
|
|
31444
31641
|
}
|
|
@@ -31633,6 +31830,12 @@ var ts;
|
|
|
31633
31830
|
function disallowInAnd(func) {
|
|
31634
31831
|
return doInsideOfContext(4096 /* DisallowInContext */, func);
|
|
31635
31832
|
}
|
|
31833
|
+
function allowConditionalTypesAnd(func) {
|
|
31834
|
+
return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31835
|
+
}
|
|
31836
|
+
function disallowConditionalTypesAnd(func) {
|
|
31837
|
+
return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31838
|
+
}
|
|
31636
31839
|
function doInYieldContext(func) {
|
|
31637
31840
|
return doInsideOfContext(8192 /* YieldContext */, func);
|
|
31638
31841
|
}
|
|
@@ -31660,6 +31863,9 @@ var ts;
|
|
|
31660
31863
|
function inDisallowInContext() {
|
|
31661
31864
|
return inContext(4096 /* DisallowInContext */);
|
|
31662
31865
|
}
|
|
31866
|
+
function inDisallowConditionalTypesContext() {
|
|
31867
|
+
return inContext(65536 /* DisallowConditionalTypesContext */);
|
|
31868
|
+
}
|
|
31663
31869
|
function inDecoratorContext() {
|
|
31664
31870
|
return inContext(16384 /* DecoratorContext */);
|
|
31665
31871
|
}
|
|
@@ -32044,7 +32250,7 @@ var ts;
|
|
|
32044
32250
|
// flag so that we don't mark any subsequent nodes.
|
|
32045
32251
|
if (parseErrorBeforeNextFinishedNode) {
|
|
32046
32252
|
parseErrorBeforeNextFinishedNode = false;
|
|
32047
|
-
node.flags |=
|
|
32253
|
+
node.flags |= 131072 /* ThisNodeHasError */;
|
|
32048
32254
|
}
|
|
32049
32255
|
return node;
|
|
32050
32256
|
}
|
|
@@ -32502,7 +32708,7 @@ var ts;
|
|
|
32502
32708
|
// differently depending on what mode it is in.
|
|
32503
32709
|
//
|
|
32504
32710
|
// This also applies to all our other context flags as well.
|
|
32505
|
-
var nodeContextFlags = node.flags &
|
|
32711
|
+
var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
|
|
32506
32712
|
if (nodeContextFlags !== contextFlags) {
|
|
32507
32713
|
return undefined;
|
|
32508
32714
|
}
|
|
@@ -33027,7 +33233,7 @@ var ts;
|
|
|
33027
33233
|
function parseJSDocNonNullableType() {
|
|
33028
33234
|
var pos = getNodePos();
|
|
33029
33235
|
nextToken();
|
|
33030
|
-
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
|
|
33236
|
+
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
|
|
33031
33237
|
}
|
|
33032
33238
|
function parseJSDocUnknownOrNullableType() {
|
|
33033
33239
|
var pos = getNodePos();
|
|
@@ -33051,7 +33257,7 @@ var ts;
|
|
|
33051
33257
|
return finishNode(factory.createJSDocUnknownType(), pos);
|
|
33052
33258
|
}
|
|
33053
33259
|
else {
|
|
33054
|
-
return finishNode(factory.createJSDocNullableType(parseType()), pos);
|
|
33260
|
+
return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
|
|
33055
33261
|
}
|
|
33056
33262
|
}
|
|
33057
33263
|
function parseJSDocFunctionType() {
|
|
@@ -33223,7 +33429,7 @@ var ts;
|
|
|
33223
33429
|
}
|
|
33224
33430
|
function parseReturnType(returnToken, isType) {
|
|
33225
33431
|
if (shouldParseReturnType(returnToken, isType)) {
|
|
33226
|
-
return parseTypeOrTypePredicate
|
|
33432
|
+
return allowConditionalTypesAnd(parseTypeOrTypePredicate);
|
|
33227
33433
|
}
|
|
33228
33434
|
}
|
|
33229
33435
|
function shouldParseReturnType(returnToken, isType) {
|
|
@@ -33638,7 +33844,7 @@ var ts;
|
|
|
33638
33844
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
33639
33845
|
}
|
|
33640
33846
|
function parseImportType() {
|
|
33641
|
-
sourceFlags |=
|
|
33847
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
33642
33848
|
var pos = getNodePos();
|
|
33643
33849
|
var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
|
|
33644
33850
|
parseExpected(100 /* ImportKeyword */);
|
|
@@ -33788,7 +33994,7 @@ var ts;
|
|
|
33788
33994
|
switch (token()) {
|
|
33789
33995
|
case 53 /* ExclamationToken */:
|
|
33790
33996
|
nextToken();
|
|
33791
|
-
type = finishNode(factory.createJSDocNonNullableType(type), pos);
|
|
33997
|
+
type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
|
|
33792
33998
|
break;
|
|
33793
33999
|
case 57 /* QuestionToken */:
|
|
33794
34000
|
// If next token is start of a type we have a conditional type
|
|
@@ -33796,7 +34002,7 @@ var ts;
|
|
|
33796
34002
|
return type;
|
|
33797
34003
|
}
|
|
33798
34004
|
nextToken();
|
|
33799
|
-
type = finishNode(factory.createJSDocNullableType(type), pos);
|
|
34005
|
+
type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
|
|
33800
34006
|
break;
|
|
33801
34007
|
case 22 /* OpenBracketToken */:
|
|
33802
34008
|
parseExpected(22 /* OpenBracketToken */);
|
|
@@ -33821,12 +34027,20 @@ var ts;
|
|
|
33821
34027
|
parseExpected(operator);
|
|
33822
34028
|
return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
|
|
33823
34029
|
}
|
|
34030
|
+
function tryParseConstraintOfInferType() {
|
|
34031
|
+
if (parseOptional(94 /* ExtendsKeyword */)) {
|
|
34032
|
+
var constraint = disallowConditionalTypesAnd(parseType);
|
|
34033
|
+
if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
|
|
34034
|
+
return constraint;
|
|
34035
|
+
}
|
|
34036
|
+
}
|
|
34037
|
+
}
|
|
33824
34038
|
function parseTypeParameterOfInferType() {
|
|
33825
34039
|
var pos = getNodePos();
|
|
33826
|
-
|
|
33827
|
-
|
|
33828
|
-
/*
|
|
33829
|
-
|
|
34040
|
+
var name = parseIdentifier();
|
|
34041
|
+
var constraint = tryParse(tryParseConstraintOfInferType);
|
|
34042
|
+
var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
|
|
34043
|
+
return finishNode(node, pos);
|
|
33830
34044
|
}
|
|
33831
34045
|
function parseInferType() {
|
|
33832
34046
|
var pos = getNodePos();
|
|
@@ -33843,7 +34057,7 @@ var ts;
|
|
|
33843
34057
|
case 137 /* InferKeyword */:
|
|
33844
34058
|
return parseInferType();
|
|
33845
34059
|
}
|
|
33846
|
-
return parsePostfixTypeOrHigher
|
|
34060
|
+
return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
|
|
33847
34061
|
}
|
|
33848
34062
|
function parseFunctionOrConstructorTypeToError(isInUnionType) {
|
|
33849
34063
|
// the function type and constructor type shorthand notation
|
|
@@ -33973,23 +34187,21 @@ var ts;
|
|
|
33973
34187
|
return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
|
|
33974
34188
|
}
|
|
33975
34189
|
function parseType() {
|
|
33976
|
-
|
|
33977
|
-
|
|
33978
|
-
|
|
33979
|
-
}
|
|
33980
|
-
function parseTypeWorker(noConditionalTypes) {
|
|
34190
|
+
if (contextFlags & 40960 /* TypeExcludesFlags */) {
|
|
34191
|
+
return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
|
|
34192
|
+
}
|
|
33981
34193
|
if (isStartOfFunctionTypeOrConstructorType()) {
|
|
33982
34194
|
return parseFunctionOrConstructorType();
|
|
33983
34195
|
}
|
|
33984
34196
|
var pos = getNodePos();
|
|
33985
34197
|
var type = parseUnionTypeOrHigher();
|
|
33986
|
-
if (!
|
|
34198
|
+
if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
|
|
33987
34199
|
// The type following 'extends' is not permitted to be another conditional type
|
|
33988
|
-
var extendsType =
|
|
34200
|
+
var extendsType = disallowConditionalTypesAnd(parseType);
|
|
33989
34201
|
parseExpected(57 /* QuestionToken */);
|
|
33990
|
-
var trueType =
|
|
34202
|
+
var trueType = allowConditionalTypesAnd(parseType);
|
|
33991
34203
|
parseExpected(58 /* ColonToken */);
|
|
33992
|
-
var falseType =
|
|
34204
|
+
var falseType = allowConditionalTypesAnd(parseType);
|
|
33993
34205
|
return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
|
|
33994
34206
|
}
|
|
33995
34207
|
return type;
|
|
@@ -34826,7 +35038,7 @@ var ts;
|
|
|
34826
35038
|
// var foo3 = require("subfolder
|
|
34827
35039
|
// import * as foo1 from "module-from-node
|
|
34828
35040
|
// We want this import to be a statement rather than import call expression
|
|
34829
|
-
sourceFlags |=
|
|
35041
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
34830
35042
|
expression = parseTokenNode();
|
|
34831
35043
|
}
|
|
34832
35044
|
else if (lookAhead(nextTokenIsDot)) {
|
|
@@ -34834,7 +35046,7 @@ var ts;
|
|
|
34834
35046
|
nextToken(); // advance past the 'import'
|
|
34835
35047
|
nextToken(); // advance past the dot
|
|
34836
35048
|
expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
|
|
34837
|
-
sourceFlags |=
|
|
35049
|
+
sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
|
|
34838
35050
|
}
|
|
34839
35051
|
else {
|
|
34840
35052
|
expression = parseMemberExpressionOrHigher();
|
|
@@ -35050,7 +35262,7 @@ var ts;
|
|
|
35050
35262
|
return finishNode(factory.createJsxOpeningFragment(), pos);
|
|
35051
35263
|
}
|
|
35052
35264
|
var tagName = parseJsxElementName();
|
|
35053
|
-
var typeArguments = (contextFlags &
|
|
35265
|
+
var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
|
|
35054
35266
|
var attributes = parseJsxAttributes();
|
|
35055
35267
|
var node;
|
|
35056
35268
|
if (token() === 31 /* GreaterThanToken */) {
|
|
@@ -35328,7 +35540,7 @@ var ts;
|
|
|
35328
35540
|
return result;
|
|
35329
35541
|
}
|
|
35330
35542
|
function parseTypeArgumentsInExpression() {
|
|
35331
|
-
if ((contextFlags &
|
|
35543
|
+
if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
|
|
35332
35544
|
// TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
|
|
35333
35545
|
return undefined;
|
|
35334
35546
|
}
|
|
@@ -35724,7 +35936,7 @@ var ts;
|
|
|
35724
35936
|
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35725
35937
|
var expression = allowInAnd(parseExpression);
|
|
35726
35938
|
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35727
|
-
var statement = doInsideOfContext(
|
|
35939
|
+
var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
|
|
35728
35940
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35729
35941
|
}
|
|
35730
35942
|
function parseCaseClause() {
|
|
@@ -36099,16 +36311,16 @@ var ts;
|
|
|
36099
36311
|
if (isAmbient) {
|
|
36100
36312
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
36101
36313
|
var m = _a[_i];
|
|
36102
|
-
m.flags |=
|
|
36314
|
+
m.flags |= 16777216 /* Ambient */;
|
|
36103
36315
|
}
|
|
36104
|
-
return doInsideOfContext(
|
|
36316
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
|
|
36105
36317
|
}
|
|
36106
36318
|
else {
|
|
36107
36319
|
return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
|
|
36108
36320
|
}
|
|
36109
36321
|
}
|
|
36110
36322
|
function tryReuseAmbientDeclaration() {
|
|
36111
|
-
return doInsideOfContext(
|
|
36323
|
+
return doInsideOfContext(16777216 /* Ambient */, function () {
|
|
36112
36324
|
var node = currentNode(parsingContext);
|
|
36113
36325
|
if (node) {
|
|
36114
36326
|
return consumeNode(node);
|
|
@@ -36575,9 +36787,9 @@ var ts;
|
|
|
36575
36787
|
if (isAmbient) {
|
|
36576
36788
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
36577
36789
|
var m = _a[_i];
|
|
36578
|
-
m.flags |=
|
|
36790
|
+
m.flags |= 16777216 /* Ambient */;
|
|
36579
36791
|
}
|
|
36580
|
-
return doInsideOfContext(
|
|
36792
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
|
|
36581
36793
|
}
|
|
36582
36794
|
else {
|
|
36583
36795
|
return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -37142,7 +37354,7 @@ var ts;
|
|
|
37142
37354
|
function parseJSDocTypeExpression(mayOmitBraces) {
|
|
37143
37355
|
var pos = getNodePos();
|
|
37144
37356
|
var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
|
|
37145
|
-
var type = doInsideOfContext(
|
|
37357
|
+
var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
37146
37358
|
if (!mayOmitBraces || hasBrace) {
|
|
37147
37359
|
parseExpectedJSDoc(19 /* CloseBraceToken */);
|
|
37148
37360
|
}
|
|
@@ -37171,7 +37383,7 @@ var ts;
|
|
|
37171
37383
|
JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
|
|
37172
37384
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
37173
37385
|
initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
37174
|
-
var jsDoc = doInsideOfContext(
|
|
37386
|
+
var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
37175
37387
|
var sourceFile = { languageVariant: 0 /* Standard */, text: content };
|
|
37176
37388
|
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
|
|
37177
37389
|
clearState();
|
|
@@ -37182,9 +37394,9 @@ var ts;
|
|
|
37182
37394
|
var saveToken = currentToken;
|
|
37183
37395
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
37184
37396
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
37185
|
-
var comment = doInsideOfContext(
|
|
37397
|
+
var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
37186
37398
|
ts.setParent(comment, parent);
|
|
37187
|
-
if (contextFlags &
|
|
37399
|
+
if (contextFlags & 262144 /* JavaScriptFile */) {
|
|
37188
37400
|
if (!jsDocDiagnostics) {
|
|
37189
37401
|
jsDocDiagnostics = [];
|
|
37190
37402
|
}
|
|
@@ -38000,7 +38212,7 @@ var ts;
|
|
|
38000
38212
|
if (isBracketed) {
|
|
38001
38213
|
skipWhitespace();
|
|
38002
38214
|
parseExpected(63 /* EqualsToken */);
|
|
38003
|
-
defaultType = doInsideOfContext(
|
|
38215
|
+
defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
38004
38216
|
parseExpected(23 /* CloseBracketToken */);
|
|
38005
38217
|
}
|
|
38006
38218
|
if (ts.nodeIsMissing(name)) {
|
|
@@ -45888,7 +46100,7 @@ var ts;
|
|
|
45888
46100
|
function setExportContextFlag(node) {
|
|
45889
46101
|
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
|
45890
46102
|
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
|
45891
|
-
if (node.flags &
|
|
46103
|
+
if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
|
|
45892
46104
|
node.flags |= 64 /* ExportContext */;
|
|
45893
46105
|
}
|
|
45894
46106
|
else {
|
|
@@ -46091,8 +46303,8 @@ var ts;
|
|
|
46091
46303
|
function checkContextualIdentifier(node) {
|
|
46092
46304
|
// Report error only if there are no parse errors in file
|
|
46093
46305
|
if (!file.parseDiagnostics.length &&
|
|
46094
|
-
!(node.flags &
|
|
46095
|
-
!(node.flags &
|
|
46306
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
46307
|
+
!(node.flags & 8388608 /* JSDoc */) &&
|
|
46096
46308
|
!ts.isIdentifierName(node)) {
|
|
46097
46309
|
// strict mode identifiers
|
|
46098
46310
|
if (inStrictMode &&
|
|
@@ -47121,7 +47333,7 @@ var ts;
|
|
|
47121
47333
|
if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
|
|
47122
47334
|
return;
|
|
47123
47335
|
}
|
|
47124
|
-
if (inStrictMode && !(node.flags &
|
|
47336
|
+
if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
|
|
47125
47337
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
|
47126
47338
|
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
|
47127
47339
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
@@ -47140,7 +47352,7 @@ var ts;
|
|
|
47140
47352
|
}
|
|
47141
47353
|
}
|
|
47142
47354
|
function bindFunctionDeclaration(node) {
|
|
47143
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47355
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
47144
47356
|
if (ts.isAsyncFunction(node)) {
|
|
47145
47357
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
47146
47358
|
}
|
|
@@ -47155,7 +47367,7 @@ var ts;
|
|
|
47155
47367
|
}
|
|
47156
47368
|
}
|
|
47157
47369
|
function bindFunctionExpression(node) {
|
|
47158
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47370
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
47159
47371
|
if (ts.isAsyncFunction(node)) {
|
|
47160
47372
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
47161
47373
|
}
|
|
@@ -47168,7 +47380,7 @@ var ts;
|
|
|
47168
47380
|
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
|
|
47169
47381
|
}
|
|
47170
47382
|
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
|
|
47171
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47383
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
|
|
47172
47384
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
47173
47385
|
}
|
|
47174
47386
|
if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
|
@@ -47241,7 +47453,7 @@ var ts;
|
|
|
47241
47453
|
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
|
|
47242
47454
|
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
|
|
47243
47455
|
var isError_1 = ts.unreachableCodeIsError(options) &&
|
|
47244
|
-
!(node.flags &
|
|
47456
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
47245
47457
|
(!ts.isVariableStatement(node) ||
|
|
47246
47458
|
!!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
|
|
47247
47459
|
node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
|
|
@@ -48141,7 +48353,7 @@ var ts;
|
|
|
48141
48353
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
48142
48354
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
48143
48355
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
48144
|
-
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags &
|
|
48356
|
+
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
48145
48357
|
(diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
|
|
48146
48358
|
}
|
|
48147
48359
|
});
|
|
@@ -48592,7 +48804,7 @@ var ts;
|
|
|
48592
48804
|
return diagnostic;
|
|
48593
48805
|
}
|
|
48594
48806
|
function isDeprecatedSymbol(symbol) {
|
|
48595
|
-
return !!(getDeclarationNodeFlagsFromSymbol(symbol) &
|
|
48807
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
|
|
48596
48808
|
}
|
|
48597
48809
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
48598
48810
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
@@ -48820,7 +49032,7 @@ var ts;
|
|
|
48820
49032
|
else {
|
|
48821
49033
|
// find a module that about to be augmented
|
|
48822
49034
|
// do not validate names of augmentations that are defined in ambient context
|
|
48823
|
-
var moduleNotFoundError = !(moduleName.parent.parent.flags &
|
|
49035
|
+
var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
|
|
48824
49036
|
? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
|
|
48825
49037
|
: undefined;
|
|
48826
49038
|
var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
|
|
@@ -48934,7 +49146,7 @@ var ts;
|
|
|
48934
49146
|
if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
|
|
48935
49147
|
(!ts.outFile(compilerOptions)) ||
|
|
48936
49148
|
isInTypeQuery(usage) ||
|
|
48937
|
-
declaration.flags &
|
|
49149
|
+
declaration.flags & 16777216 /* Ambient */) {
|
|
48938
49150
|
// nodes are in different files and order cannot be determined
|
|
48939
49151
|
return true;
|
|
48940
49152
|
}
|
|
@@ -48996,7 +49208,7 @@ var ts;
|
|
|
48996
49208
|
if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
|
|
48997
49209
|
return true;
|
|
48998
49210
|
}
|
|
48999
|
-
if (!!(usage.flags &
|
|
49211
|
+
if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
|
|
49000
49212
|
return true;
|
|
49001
49213
|
}
|
|
49002
49214
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
@@ -49261,7 +49473,7 @@ var ts;
|
|
|
49261
49473
|
// falls through
|
|
49262
49474
|
case 261 /* ModuleDeclaration */:
|
|
49263
49475
|
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
49264
|
-
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags &
|
|
49476
|
+
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
49265
49477
|
// It's an external module. First see if the module has an export default and if the local
|
|
49266
49478
|
// name of that export default matches.
|
|
49267
49479
|
if (result = moduleExports.get("default" /* Default */)) {
|
|
@@ -49584,7 +49796,7 @@ var ts;
|
|
|
49584
49796
|
}
|
|
49585
49797
|
}
|
|
49586
49798
|
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49587
|
-
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags &
|
|
49799
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
|
|
49588
49800
|
var merged = getMergedSymbol(result);
|
|
49589
49801
|
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49590
49802
|
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));
|
|
@@ -49839,7 +50051,7 @@ var ts;
|
|
|
49839
50051
|
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 */); });
|
|
49840
50052
|
if (declaration === undefined)
|
|
49841
50053
|
return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
|
|
49842
|
-
if (!(declaration.flags &
|
|
50054
|
+
if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
|
|
49843
50055
|
var diagnosticMessage = void 0;
|
|
49844
50056
|
var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
|
|
49845
50057
|
if (result.flags & 2 /* BlockScopedVariable */) {
|
|
@@ -50612,7 +50824,7 @@ var ts;
|
|
|
50612
50824
|
}
|
|
50613
50825
|
}
|
|
50614
50826
|
function getAssignmentDeclarationLocation(node) {
|
|
50615
|
-
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags &
|
|
50827
|
+
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
|
|
50616
50828
|
if (typeAlias) {
|
|
50617
50829
|
return;
|
|
50618
50830
|
}
|
|
@@ -52080,7 +52292,20 @@ var ts;
|
|
|
52080
52292
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
52081
52293
|
if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
|
|
52082
52294
|
context.approximateLength += (ts.symbolName(type.symbol).length + 6);
|
|
52083
|
-
|
|
52295
|
+
var constraintNode = void 0;
|
|
52296
|
+
var constraint = getConstraintOfTypeParameter(type);
|
|
52297
|
+
if (constraint) {
|
|
52298
|
+
// If the infer type has a constraint that is not the same as the constraint
|
|
52299
|
+
// we would have normally inferred based on context, we emit the constraint
|
|
52300
|
+
// using `infer T extends ?`. We omit inferred constraints from type references
|
|
52301
|
+
// as they may be elided.
|
|
52302
|
+
var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
|
|
52303
|
+
if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
|
|
52304
|
+
context.approximateLength += 9;
|
|
52305
|
+
constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
52306
|
+
}
|
|
52307
|
+
}
|
|
52308
|
+
return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
|
|
52084
52309
|
}
|
|
52085
52310
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
|
|
52086
52311
|
type.flags & 262144 /* TypeParameter */ &&
|
|
@@ -54036,7 +54261,7 @@ var ts;
|
|
|
54036
54261
|
newModifierFlags |= 1 /* Export */;
|
|
54037
54262
|
}
|
|
54038
54263
|
if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
|
|
54039
|
-
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags &
|
|
54264
|
+
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
|
|
54040
54265
|
(ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
|
|
54041
54266
|
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
|
|
54042
54267
|
newModifierFlags |= 2 /* Ambient */;
|
|
@@ -55006,7 +55231,7 @@ var ts;
|
|
|
55006
55231
|
var parent = getDeclarationContainer(node);
|
|
55007
55232
|
// If the node is not exported or it is not ambient module element (except import declaration)
|
|
55008
55233
|
if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
|
|
55009
|
-
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags &
|
|
55234
|
+
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
|
|
55010
55235
|
return isGlobalSourceFile(parent);
|
|
55011
55236
|
}
|
|
55012
55237
|
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
|
|
@@ -55346,7 +55571,7 @@ var ts;
|
|
|
55346
55571
|
}
|
|
55347
55572
|
var pattern = declaration.parent;
|
|
55348
55573
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
55349
|
-
if (strictNullChecks && declaration.flags &
|
|
55574
|
+
if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
55350
55575
|
parentType = getNonNullableType(parentType);
|
|
55351
55576
|
}
|
|
55352
55577
|
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
|
|
@@ -55462,7 +55687,7 @@ var ts;
|
|
|
55462
55687
|
}
|
|
55463
55688
|
if ((noImplicitAny || ts.isInJSFile(declaration)) &&
|
|
55464
55689
|
ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
|
|
55465
|
-
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags &
|
|
55690
|
+
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
55466
55691
|
// If --noImplicitAny is on or the declaration is in a Javascript file,
|
|
55467
55692
|
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
|
|
55468
55693
|
// initializer or a 'null' or 'undefined' initializer.
|
|
@@ -56918,7 +57143,7 @@ var ts;
|
|
|
56918
57143
|
function isLiteralEnumMember(member) {
|
|
56919
57144
|
var expr = member.initializer;
|
|
56920
57145
|
if (!expr) {
|
|
56921
|
-
return !(member.flags &
|
|
57146
|
+
return !(member.flags & 16777216 /* Ambient */);
|
|
56922
57147
|
}
|
|
56923
57148
|
switch (expr.kind) {
|
|
56924
57149
|
case 10 /* StringLiteral */:
|
|
@@ -59551,7 +59776,7 @@ var ts;
|
|
|
59551
59776
|
function getConstraintDeclaration(type) {
|
|
59552
59777
|
return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
|
|
59553
59778
|
}
|
|
59554
|
-
function getInferredTypeParameterConstraint(typeParameter) {
|
|
59779
|
+
function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
|
|
59555
59780
|
var _a;
|
|
59556
59781
|
var inferences;
|
|
59557
59782
|
if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
|
|
@@ -59563,7 +59788,7 @@ var ts;
|
|
|
59563
59788
|
// corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
|
|
59564
59789
|
// present, we form an intersection of the inferred constraint types.
|
|
59565
59790
|
var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
|
|
59566
|
-
if (grandParent.kind === 178 /* TypeReference */) {
|
|
59791
|
+
if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
|
|
59567
59792
|
var typeReference = grandParent;
|
|
59568
59793
|
var typeParameters = getTypeParametersForTypeReference(typeReference);
|
|
59569
59794
|
if (typeParameters) {
|
|
@@ -59985,7 +60210,7 @@ var ts;
|
|
|
59985
60210
|
return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
|
|
59986
60211
|
}
|
|
59987
60212
|
function isJSDocTypeReference(node) {
|
|
59988
|
-
return !!(node.flags &
|
|
60213
|
+
return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
|
|
59989
60214
|
}
|
|
59990
60215
|
function checkNoTypeArguments(node, symbol) {
|
|
59991
60216
|
if (node.typeArguments) {
|
|
@@ -61544,7 +61769,7 @@ var ts;
|
|
|
61544
61769
|
if (ts.isCallLikeExpression(parent)) {
|
|
61545
61770
|
return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
|
|
61546
61771
|
}
|
|
61547
|
-
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) &
|
|
61772
|
+
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
61548
61773
|
}
|
|
61549
61774
|
return true;
|
|
61550
61775
|
}
|
|
@@ -62237,7 +62462,7 @@ var ts;
|
|
|
62237
62462
|
links.resolvedSymbol = unknownSymbol;
|
|
62238
62463
|
return links.resolvedType = errorType;
|
|
62239
62464
|
}
|
|
62240
|
-
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags &
|
|
62465
|
+
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
|
|
62241
62466
|
// TODO: Future work: support unions/generics/whatever via a deferred import-type
|
|
62242
62467
|
var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
|
|
62243
62468
|
if (!innerModuleSymbol) {
|
|
@@ -62573,7 +62798,7 @@ var ts;
|
|
|
62573
62798
|
}
|
|
62574
62799
|
// /** @return {this} */
|
|
62575
62800
|
// x.prototype.m = function() { ... }
|
|
62576
|
-
var host = node.flags &
|
|
62801
|
+
var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
|
|
62577
62802
|
if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
|
|
62578
62803
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
|
|
62579
62804
|
}
|
|
@@ -62648,7 +62873,7 @@ var ts;
|
|
|
62648
62873
|
case 143 /* NeverKeyword */:
|
|
62649
62874
|
return neverType;
|
|
62650
62875
|
case 148 /* ObjectKeyword */:
|
|
62651
|
-
return node.flags &
|
|
62876
|
+
return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
|
|
62652
62877
|
case 138 /* IntrinsicKeyword */:
|
|
62653
62878
|
return intrinsicMarkerType;
|
|
62654
62879
|
case 192 /* ThisType */:
|
|
@@ -67525,6 +67750,9 @@ var ts;
|
|
|
67525
67750
|
var inference = inferences[i];
|
|
67526
67751
|
if (t === inference.typeParameter) {
|
|
67527
67752
|
if (fix && !inference.isFixed) {
|
|
67753
|
+
// Before we commit to a particular inference (and thus lock out any further inferences),
|
|
67754
|
+
// we infer from any intra-expression inference sites we have collected.
|
|
67755
|
+
inferFromIntraExpressionSites(context);
|
|
67528
67756
|
clearCachedInferences(inferences);
|
|
67529
67757
|
inference.isFixed = true;
|
|
67530
67758
|
}
|
|
@@ -67541,6 +67769,37 @@ var ts;
|
|
|
67541
67769
|
}
|
|
67542
67770
|
}
|
|
67543
67771
|
}
|
|
67772
|
+
function addIntraExpressionInferenceSite(context, node, type) {
|
|
67773
|
+
var _a;
|
|
67774
|
+
((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
|
|
67775
|
+
}
|
|
67776
|
+
// We collect intra-expression inference sites within object and array literals to handle cases where
|
|
67777
|
+
// inferred types flow between context sensitive element expressions. For example:
|
|
67778
|
+
//
|
|
67779
|
+
// declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
|
|
67780
|
+
// foo([_a => 0, n => n.toFixed()]);
|
|
67781
|
+
//
|
|
67782
|
+
// Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
|
|
67783
|
+
// pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
|
|
67784
|
+
// pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
|
|
67785
|
+
// parameter in the second arrow function, but we want to first infer from the return type of the first
|
|
67786
|
+
// arrow function. This happens automatically when the arrow functions are discrete arguments (because we
|
|
67787
|
+
// infer from each argument before processing the next), but when the arrow functions are elements of an
|
|
67788
|
+
// object or array literal, we need to perform intra-expression inferences early.
|
|
67789
|
+
function inferFromIntraExpressionSites(context) {
|
|
67790
|
+
if (context.intraExpressionInferenceSites) {
|
|
67791
|
+
for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
|
|
67792
|
+
var _b = _a[_i], node = _b.node, type = _b.type;
|
|
67793
|
+
var contextualType = node.kind === 169 /* MethodDeclaration */ ?
|
|
67794
|
+
getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
|
|
67795
|
+
getContextualType(node, 2 /* NoConstraints */);
|
|
67796
|
+
if (contextualType) {
|
|
67797
|
+
inferTypes(context.inferences, type, contextualType);
|
|
67798
|
+
}
|
|
67799
|
+
}
|
|
67800
|
+
context.intraExpressionInferenceSites = undefined;
|
|
67801
|
+
}
|
|
67802
|
+
}
|
|
67544
67803
|
function createInferenceInfo(typeParameter) {
|
|
67545
67804
|
return {
|
|
67546
67805
|
typeParameter: typeParameter,
|
|
@@ -69523,7 +69782,7 @@ var ts;
|
|
|
69523
69782
|
// parameter symbols with declarations that have explicit type annotations. Such references are
|
|
69524
69783
|
// resolvable with no possibility of triggering circularities in control flow analysis.
|
|
69525
69784
|
function getTypeOfDottedName(node, diagnostic) {
|
|
69526
|
-
if (!(node.flags &
|
|
69785
|
+
if (!(node.flags & 33554432 /* InWithStatement */)) {
|
|
69527
69786
|
switch (node.kind) {
|
|
69528
69787
|
case 79 /* Identifier */:
|
|
69529
69788
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
@@ -70927,6 +71186,7 @@ var ts;
|
|
|
70927
71186
|
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
|
|
70928
71187
|
// and x are of generic types T and K, we want the resulting type to be T[K].
|
|
70929
71188
|
return parent.kind === 206 /* PropertyAccessExpression */ ||
|
|
71189
|
+
parent.kind === 161 /* QualifiedName */ ||
|
|
70930
71190
|
parent.kind === 208 /* CallExpression */ && parent.expression === node ||
|
|
70931
71191
|
parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
|
|
70932
71192
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
@@ -71220,7 +71480,7 @@ var ts;
|
|
|
71220
71480
|
isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
|
|
71221
71481
|
node.parent.kind === 230 /* NonNullExpression */ ||
|
|
71222
71482
|
declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
|
|
71223
|
-
declaration.flags &
|
|
71483
|
+
declaration.flags & 16777216 /* Ambient */;
|
|
71224
71484
|
var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
|
|
71225
71485
|
type === autoType || type === autoArrayType ? undefinedType :
|
|
71226
71486
|
getOptionalType(type);
|
|
@@ -72228,7 +72488,7 @@ var ts;
|
|
|
72228
72488
|
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
|
72229
72489
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
72230
72490
|
ts.Debug.assert(ts.isObjectLiteralMethod(node));
|
|
72231
|
-
if (node.flags &
|
|
72491
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72232
72492
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72233
72493
|
return undefined;
|
|
72234
72494
|
}
|
|
@@ -72416,7 +72676,7 @@ var ts;
|
|
|
72416
72676
|
* @returns the contextual type of an expression.
|
|
72417
72677
|
*/
|
|
72418
72678
|
function getContextualType(node, contextFlags) {
|
|
72419
|
-
if (node.flags &
|
|
72679
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72420
72680
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72421
72681
|
return undefined;
|
|
72422
72682
|
}
|
|
@@ -72834,6 +73094,11 @@ var ts;
|
|
|
72834
73094
|
var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
|
|
72835
73095
|
elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
|
|
72836
73096
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
73097
|
+
if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
73098
|
+
var inferenceContext = getInferenceContext(node);
|
|
73099
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
73100
|
+
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
73101
|
+
}
|
|
72837
73102
|
}
|
|
72838
73103
|
}
|
|
72839
73104
|
if (inDestructuringPattern) {
|
|
@@ -73035,6 +73300,13 @@ var ts;
|
|
|
73035
73300
|
prop.target = member;
|
|
73036
73301
|
member = prop;
|
|
73037
73302
|
allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
73303
|
+
if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
|
|
73304
|
+
(memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
73305
|
+
var inferenceContext = getInferenceContext(node);
|
|
73306
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
73307
|
+
var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
73308
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73309
|
+
}
|
|
73038
73310
|
}
|
|
73039
73311
|
else if (memberDecl.kind === 298 /* SpreadAssignment */) {
|
|
73040
73312
|
if (languageVersion < 2 /* ES2015 */) {
|
|
@@ -74127,7 +74399,7 @@ var ts;
|
|
|
74127
74399
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
74128
74400
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
74129
74401
|
}
|
|
74130
|
-
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) &
|
|
74402
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
|
|
74131
74403
|
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
74132
74404
|
}
|
|
74133
74405
|
}
|
|
@@ -74195,7 +74467,7 @@ var ts;
|
|
|
74195
74467
|
if (declaration && isPropertyWithoutInitializer(declaration)) {
|
|
74196
74468
|
if (!ts.isStatic(declaration)) {
|
|
74197
74469
|
var flowContainer = getControlFlowContainer(node);
|
|
74198
|
-
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags &
|
|
74470
|
+
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
74199
74471
|
assumeUninitialized = true;
|
|
74200
74472
|
}
|
|
74201
74473
|
}
|
|
@@ -74232,7 +74504,7 @@ var ts;
|
|
|
74232
74504
|
}
|
|
74233
74505
|
else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
|
|
74234
74506
|
node.parent.kind !== 178 /* TypeReference */ &&
|
|
74235
|
-
!(valueDeclaration.flags &
|
|
74507
|
+
!(valueDeclaration.flags & 16777216 /* Ambient */) &&
|
|
74236
74508
|
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74237
74509
|
diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
74238
74510
|
}
|
|
@@ -74897,34 +75169,36 @@ var ts;
|
|
|
74897
75169
|
if (node.kind !== 165 /* Decorator */) {
|
|
74898
75170
|
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
74899
75171
|
if (contextualType) {
|
|
74900
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
74901
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
74902
|
-
// inferred for any outer call expression so far.
|
|
74903
|
-
var outerContext = getInferenceContext(node);
|
|
74904
|
-
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
74905
|
-
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
74906
|
-
// If the contextual type is a generic function type with a single call signature, we
|
|
74907
|
-
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
74908
|
-
// the type parameters are not erased to type any during type inference such that they can
|
|
74909
|
-
// be inferred as actual types from the contextual type. For example:
|
|
74910
|
-
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
74911
|
-
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
74912
|
-
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
74913
|
-
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
74914
|
-
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
74915
|
-
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
74916
|
-
instantiatedType;
|
|
74917
75172
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
74918
|
-
|
|
74919
|
-
|
|
74920
|
-
|
|
74921
|
-
|
|
74922
|
-
|
|
74923
|
-
|
|
74924
|
-
|
|
74925
|
-
|
|
74926
|
-
|
|
74927
|
-
|
|
75173
|
+
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75174
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75175
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75176
|
+
// inferred for any outer call expression so far.
|
|
75177
|
+
var outerContext = getInferenceContext(node);
|
|
75178
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75179
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75180
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75181
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75182
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75183
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75184
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75185
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75186
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75187
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75188
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75189
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75190
|
+
instantiatedType;
|
|
75191
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75192
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75193
|
+
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75194
|
+
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75195
|
+
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
75196
|
+
// outer arguments), and (b) we don't want any further inferences going into this context.
|
|
75197
|
+
var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
75198
|
+
var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
75199
|
+
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
75200
|
+
context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
|
75201
|
+
}
|
|
74928
75202
|
}
|
|
74929
75203
|
}
|
|
74930
75204
|
var restType = getNonArrayRestType(signature);
|
|
@@ -74936,7 +75210,7 @@ var ts;
|
|
|
74936
75210
|
}
|
|
74937
75211
|
}
|
|
74938
75212
|
var thisType = getThisTypeOfSignature(signature);
|
|
74939
|
-
if (thisType) {
|
|
75213
|
+
if (thisType && couldContainTypeVariables(thisType)) {
|
|
74940
75214
|
var thisArgumentNode = getThisArgumentOfCall(node);
|
|
74941
75215
|
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
74942
75216
|
}
|
|
@@ -74944,11 +75218,13 @@ var ts;
|
|
|
74944
75218
|
var arg = args[i];
|
|
74945
75219
|
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74946
75220
|
var paramType = getTypeAtPosition(signature, i);
|
|
74947
|
-
|
|
74948
|
-
|
|
75221
|
+
if (couldContainTypeVariables(paramType)) {
|
|
75222
|
+
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
75223
|
+
inferTypes(context.inferences, argType, paramType);
|
|
75224
|
+
}
|
|
74949
75225
|
}
|
|
74950
75226
|
}
|
|
74951
|
-
if (restType) {
|
|
75227
|
+
if (restType && couldContainTypeVariables(restType)) {
|
|
74952
75228
|
var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
|
|
74953
75229
|
inferTypes(context.inferences, spreadType, restType);
|
|
74954
75230
|
}
|
|
@@ -76528,7 +76804,7 @@ var ts;
|
|
|
76528
76804
|
return returnType;
|
|
76529
76805
|
}
|
|
76530
76806
|
function checkDeprecatedSignature(signature, node) {
|
|
76531
|
-
if (signature.declaration && signature.declaration.flags &
|
|
76807
|
+
if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
|
|
76532
76808
|
var suggestionNode = getDeprecatedSuggestionNode(node);
|
|
76533
76809
|
var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
|
|
76534
76810
|
addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
|
|
@@ -76672,7 +76948,7 @@ var ts;
|
|
|
76672
76948
|
if (targetDeclarationKind !== 0 /* Unknown */) {
|
|
76673
76949
|
var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
|
|
76674
76950
|
// function/variable declaration should be ambient
|
|
76675
|
-
return !!decl && !!(decl.flags &
|
|
76951
|
+
return !!decl && !!(decl.flags & 16777216 /* Ambient */);
|
|
76676
76952
|
}
|
|
76677
76953
|
return false;
|
|
76678
76954
|
}
|
|
@@ -76867,7 +77143,7 @@ var ts;
|
|
|
76867
77143
|
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
76868
77144
|
}
|
|
76869
77145
|
var file = ts.getSourceFileOfNode(node);
|
|
76870
|
-
ts.Debug.assert(!!(file.flags &
|
|
77146
|
+
ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
76871
77147
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
76872
77148
|
}
|
|
76873
77149
|
function getTypeOfParameter(symbol) {
|
|
@@ -78881,6 +79157,11 @@ var ts;
|
|
|
78881
79157
|
context.contextualType = contextualType;
|
|
78882
79158
|
context.inferenceContext = inferenceContext;
|
|
78883
79159
|
var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
|
|
79160
|
+
// In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
|
|
79161
|
+
// parameters. This information is no longer needed after the call to checkExpression.
|
|
79162
|
+
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
79163
|
+
inferenceContext.intraExpressionInferenceSites = undefined;
|
|
79164
|
+
}
|
|
78884
79165
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
78885
79166
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
78886
79167
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
@@ -79172,7 +79453,7 @@ var ts;
|
|
|
79172
79453
|
return quickType;
|
|
79173
79454
|
}
|
|
79174
79455
|
// If a type has been cached for the node, return it.
|
|
79175
|
-
if (node.flags &
|
|
79456
|
+
if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
|
|
79176
79457
|
var cachedType = flowTypeCache[getNodeId(node)];
|
|
79177
79458
|
if (cachedType) {
|
|
79178
79459
|
return cachedType;
|
|
@@ -79184,7 +79465,7 @@ var ts;
|
|
|
79184
79465
|
if (flowInvocationCount !== startInvocationCount) {
|
|
79185
79466
|
var cache = flowTypeCache || (flowTypeCache = []);
|
|
79186
79467
|
cache[getNodeId(node)] = type;
|
|
79187
|
-
ts.setNodeFlags(node, node.flags |
|
|
79468
|
+
ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
|
|
79188
79469
|
}
|
|
79189
79470
|
return type;
|
|
79190
79471
|
}
|
|
@@ -79270,7 +79551,7 @@ var ts;
|
|
|
79270
79551
|
if (compilerOptions.isolatedModules) {
|
|
79271
79552
|
ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
79272
79553
|
var constEnumDeclaration = type.symbol.valueDeclaration;
|
|
79273
|
-
if (constEnumDeclaration.flags &
|
|
79554
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
79274
79555
|
error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
|
|
79275
79556
|
}
|
|
79276
79557
|
}
|
|
@@ -79963,7 +80244,7 @@ var ts;
|
|
|
79963
80244
|
checkDecorators(node);
|
|
79964
80245
|
checkSignatureDeclaration(node);
|
|
79965
80246
|
if (node.kind === 172 /* GetAccessor */) {
|
|
79966
|
-
if (!(node.flags &
|
|
80247
|
+
if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
|
|
79967
80248
|
if (!(node.flags & 512 /* HasExplicitReturn */)) {
|
|
79968
80249
|
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
|
|
79969
80250
|
}
|
|
@@ -80058,7 +80339,7 @@ var ts;
|
|
|
80058
80339
|
}
|
|
80059
80340
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
80060
80341
|
if (symbol) {
|
|
80061
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags &
|
|
80342
|
+
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
|
|
80062
80343
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
80063
80344
|
}
|
|
80064
80345
|
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80218,6 +80499,23 @@ var ts;
|
|
|
80218
80499
|
grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
|
|
80219
80500
|
}
|
|
80220
80501
|
checkSourceElement(node.typeParameter);
|
|
80502
|
+
var symbol = getSymbolOfNode(node.typeParameter);
|
|
80503
|
+
if (symbol.declarations && symbol.declarations.length > 1) {
|
|
80504
|
+
var links = getSymbolLinks(symbol);
|
|
80505
|
+
if (!links.typeParametersChecked) {
|
|
80506
|
+
links.typeParametersChecked = true;
|
|
80507
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
|
|
80508
|
+
var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
|
|
80509
|
+
if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
|
|
80510
|
+
// Report an error on every conflicting declaration.
|
|
80511
|
+
var name = symbolToString(symbol);
|
|
80512
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
80513
|
+
var declaration = declarations_4[_i];
|
|
80514
|
+
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
|
|
80515
|
+
}
|
|
80516
|
+
}
|
|
80517
|
+
}
|
|
80518
|
+
}
|
|
80221
80519
|
registerForUnusedIdentifiersCheck(node);
|
|
80222
80520
|
}
|
|
80223
80521
|
function checkTemplateLiteralType(node) {
|
|
@@ -80255,7 +80553,7 @@ var ts;
|
|
|
80255
80553
|
getTypeFromTypeNode(node);
|
|
80256
80554
|
}
|
|
80257
80555
|
function isPrivateWithinAmbient(node) {
|
|
80258
|
-
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags &
|
|
80556
|
+
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
|
|
80259
80557
|
}
|
|
80260
80558
|
function getEffectiveDeclarationFlags(n, flagsToCheck) {
|
|
80261
80559
|
var flags = ts.getCombinedModifierFlags(n);
|
|
@@ -80264,7 +80562,7 @@ var ts;
|
|
|
80264
80562
|
if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
|
|
80265
80563
|
n.parent.kind !== 257 /* ClassDeclaration */ &&
|
|
80266
80564
|
n.parent.kind !== 226 /* ClassExpression */ &&
|
|
80267
|
-
n.flags &
|
|
80565
|
+
n.flags & 16777216 /* Ambient */) {
|
|
80268
80566
|
if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
|
|
80269
80567
|
// It is nested in an ambient context, which means it is automatically exported
|
|
80270
80568
|
flags |= 1 /* Export */;
|
|
@@ -80397,10 +80695,10 @@ var ts;
|
|
|
80397
80695
|
var hasNonAmbientClass = false;
|
|
80398
80696
|
var functionDeclarations = [];
|
|
80399
80697
|
if (declarations) {
|
|
80400
|
-
for (var _i = 0,
|
|
80401
|
-
var current =
|
|
80698
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
80699
|
+
var current = declarations_5[_i];
|
|
80402
80700
|
var node = current;
|
|
80403
|
-
var inAmbientContext = node.flags &
|
|
80701
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
80404
80702
|
var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
|
|
80405
80703
|
if (inAmbientContextOrInterface) {
|
|
80406
80704
|
// check if declarations are consecutive only if they are non-ambient
|
|
@@ -81252,7 +81550,7 @@ var ts;
|
|
|
81252
81550
|
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
|
|
81253
81551
|
var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
|
|
81254
81552
|
// Get first non javascript function declaration
|
|
81255
|
-
function (declaration) { return declaration.kind === node.kind && !(declaration.flags &
|
|
81553
|
+
function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
|
|
81256
81554
|
// Only type check the symbol once
|
|
81257
81555
|
if (node === firstDeclaration) {
|
|
81258
81556
|
checkFunctionOrConstructorSymbol(localSymbol);
|
|
@@ -81374,7 +81672,7 @@ var ts;
|
|
|
81374
81672
|
var symbol = getSymbolOfNode(member);
|
|
81375
81673
|
if (!symbol.isReferenced
|
|
81376
81674
|
&& (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
|
|
81377
|
-
&& !(member.flags &
|
|
81675
|
+
&& !(member.flags & 16777216 /* Ambient */)) {
|
|
81378
81676
|
addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
|
|
81379
81677
|
}
|
|
81380
81678
|
break;
|
|
@@ -81564,8 +81862,8 @@ var ts;
|
|
|
81564
81862
|
: ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
|
|
81565
81863
|
}
|
|
81566
81864
|
else {
|
|
81567
|
-
for (var _i = 0,
|
|
81568
|
-
var decl =
|
|
81865
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
81866
|
+
var decl = declarations_6[_i];
|
|
81569
81867
|
addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
|
|
81570
81868
|
}
|
|
81571
81869
|
}
|
|
@@ -81607,7 +81905,7 @@ var ts;
|
|
|
81607
81905
|
}
|
|
81608
81906
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
81609
81907
|
// no rest parameters \ declaration context \ overload - no codegen impact
|
|
81610
|
-
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags &
|
|
81908
|
+
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
|
|
81611
81909
|
return;
|
|
81612
81910
|
}
|
|
81613
81911
|
ts.forEach(node.parameters, function (p) {
|
|
@@ -81635,7 +81933,7 @@ var ts;
|
|
|
81635
81933
|
// it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
|
|
81636
81934
|
return false;
|
|
81637
81935
|
}
|
|
81638
|
-
if (node.flags &
|
|
81936
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
81639
81937
|
// ambient context - no codegen impact
|
|
81640
81938
|
return false;
|
|
81641
81939
|
}
|
|
@@ -81774,7 +82072,7 @@ var ts;
|
|
|
81774
82072
|
recordPotentialCollisionWithReflectInGeneratedCode(node, name);
|
|
81775
82073
|
if (ts.isClassLike(node)) {
|
|
81776
82074
|
checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
|
|
81777
|
-
if (!(node.flags &
|
|
82075
|
+
if (!(node.flags & 16777216 /* Ambient */)) {
|
|
81778
82076
|
checkClassNameCollisionWithObject(name);
|
|
81779
82077
|
}
|
|
81780
82078
|
}
|
|
@@ -83368,23 +83666,23 @@ var ts;
|
|
|
83368
83666
|
return;
|
|
83369
83667
|
}
|
|
83370
83668
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
83371
|
-
if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
|
|
83669
|
+
if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
|
|
83372
83670
|
// Report an error on every conflicting declaration.
|
|
83373
83671
|
var name = symbolToString(symbol);
|
|
83374
|
-
for (var _i = 0,
|
|
83375
|
-
var declaration =
|
|
83672
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
83673
|
+
var declaration = declarations_7[_i];
|
|
83376
83674
|
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
|
|
83377
83675
|
}
|
|
83378
83676
|
}
|
|
83379
83677
|
}
|
|
83380
83678
|
}
|
|
83381
|
-
function areTypeParametersIdentical(declarations, targetParameters) {
|
|
83679
|
+
function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
|
|
83382
83680
|
var maxTypeArgumentCount = ts.length(targetParameters);
|
|
83383
83681
|
var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
|
|
83384
|
-
for (var _i = 0,
|
|
83385
|
-
var declaration =
|
|
83682
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
83683
|
+
var declaration = declarations_8[_i];
|
|
83386
83684
|
// If this declaration has too few or too many type parameters, we report an error
|
|
83387
|
-
var sourceParameters =
|
|
83685
|
+
var sourceParameters = getTypeParameterDeclarations(declaration);
|
|
83388
83686
|
var numTypeParameters = sourceParameters.length;
|
|
83389
83687
|
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
|
|
83390
83688
|
return false;
|
|
@@ -83452,7 +83750,7 @@ var ts;
|
|
|
83452
83750
|
checkFunctionOrConstructorSymbol(symbol);
|
|
83453
83751
|
checkClassForDuplicateDeclarations(node);
|
|
83454
83752
|
// Only check for reserved static identifiers on non-ambient context.
|
|
83455
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83753
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83456
83754
|
if (!nodeInAmbientContext) {
|
|
83457
83755
|
checkClassForStaticPropertyNameConflicts(node);
|
|
83458
83756
|
}
|
|
@@ -83602,7 +83900,7 @@ var ts;
|
|
|
83602
83900
|
*/
|
|
83603
83901
|
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
83604
83902
|
var isJs = ts.isInJSFile(node);
|
|
83605
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83903
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83606
83904
|
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
83607
83905
|
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
83608
83906
|
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
@@ -83830,7 +84128,7 @@ var ts;
|
|
|
83830
84128
|
&& !(derived.flags & 33554432 /* Transient */)
|
|
83831
84129
|
&& !(baseDeclarationFlags & 128 /* Abstract */)
|
|
83832
84130
|
&& !(derivedDeclarationFlags & 128 /* Abstract */)
|
|
83833
|
-
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags &
|
|
84131
|
+
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
|
|
83834
84132
|
var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
|
|
83835
84133
|
var propName = uninitialized.name;
|
|
83836
84134
|
if (uninitialized.exclamationToken
|
|
@@ -83922,7 +84220,7 @@ var ts;
|
|
|
83922
84220
|
return ok;
|
|
83923
84221
|
}
|
|
83924
84222
|
function checkPropertyInitialization(node) {
|
|
83925
|
-
if (!strictNullChecks || !strictPropertyInitialization || node.flags &
|
|
84223
|
+
if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
|
|
83926
84224
|
return;
|
|
83927
84225
|
}
|
|
83928
84226
|
var constructor = findConstructorDeclaration(node);
|
|
@@ -84059,7 +84357,7 @@ var ts;
|
|
|
84059
84357
|
}
|
|
84060
84358
|
// In ambient non-const numeric enum declarations, enum members without initializers are
|
|
84061
84359
|
// considered computed members (as opposed to having auto-incremented values).
|
|
84062
|
-
if (member.parent.flags &
|
|
84360
|
+
if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
|
|
84063
84361
|
return undefined;
|
|
84064
84362
|
}
|
|
84065
84363
|
// If the member declaration specifies no value, the member is considered a constant enum member.
|
|
@@ -84091,7 +84389,7 @@ var ts;
|
|
|
84091
84389
|
else if (isConstEnum) {
|
|
84092
84390
|
error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
|
|
84093
84391
|
}
|
|
84094
|
-
else if (member.parent.flags &
|
|
84392
|
+
else if (member.parent.flags & 16777216 /* Ambient */) {
|
|
84095
84393
|
error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
|
84096
84394
|
}
|
|
84097
84395
|
else {
|
|
@@ -84259,11 +84557,11 @@ var ts;
|
|
|
84259
84557
|
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
|
|
84260
84558
|
var declarations = symbol.declarations;
|
|
84261
84559
|
if (declarations) {
|
|
84262
|
-
for (var _i = 0,
|
|
84263
|
-
var declaration =
|
|
84560
|
+
for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
|
|
84561
|
+
var declaration = declarations_9[_i];
|
|
84264
84562
|
if ((declaration.kind === 257 /* ClassDeclaration */ ||
|
|
84265
84563
|
(declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
|
|
84266
|
-
!(declaration.flags &
|
|
84564
|
+
!(declaration.flags & 16777216 /* Ambient */)) {
|
|
84267
84565
|
return declaration;
|
|
84268
84566
|
}
|
|
84269
84567
|
}
|
|
@@ -84294,7 +84592,7 @@ var ts;
|
|
|
84294
84592
|
function checkModuleDeclarationDiagnostics() {
|
|
84295
84593
|
// Grammar checking
|
|
84296
84594
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
84297
|
-
var inAmbientContext = node.flags &
|
|
84595
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
84298
84596
|
if (isGlobalAugmentation && !inAmbientContext) {
|
|
84299
84597
|
error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
|
|
84300
84598
|
}
|
|
@@ -84512,7 +84810,7 @@ var ts;
|
|
|
84512
84810
|
}
|
|
84513
84811
|
if (compilerOptions.isolatedModules
|
|
84514
84812
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
84515
|
-
&& !(node.flags &
|
|
84813
|
+
&& !(node.flags & 16777216 /* Ambient */)) {
|
|
84516
84814
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
84517
84815
|
var isType = !(target.flags & 111551 /* Value */);
|
|
84518
84816
|
if (isType || typeOnlyAlias) {
|
|
@@ -84558,7 +84856,7 @@ var ts;
|
|
|
84558
84856
|
}
|
|
84559
84857
|
}
|
|
84560
84858
|
function isDeprecatedAliasedSymbol(symbol) {
|
|
84561
|
-
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) &
|
|
84859
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
84562
84860
|
}
|
|
84563
84861
|
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
84564
84862
|
if (!(symbol.flags & 2097152 /* Alias */))
|
|
@@ -84687,7 +84985,7 @@ var ts;
|
|
|
84687
84985
|
}
|
|
84688
84986
|
}
|
|
84689
84987
|
else {
|
|
84690
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags &
|
|
84988
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
|
|
84691
84989
|
// Import equals declaration is deprecated in es6 or above
|
|
84692
84990
|
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);
|
|
84693
84991
|
}
|
|
@@ -84713,7 +85011,7 @@ var ts;
|
|
|
84713
85011
|
ts.forEach(node.exportClause.elements, checkExportSpecifier);
|
|
84714
85012
|
var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
|
|
84715
85013
|
var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
|
|
84716
|
-
!node.moduleSpecifier && node.flags &
|
|
85014
|
+
!node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
|
|
84717
85015
|
if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
|
|
84718
85016
|
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
|
|
84719
85017
|
}
|
|
@@ -84878,10 +85176,10 @@ var ts;
|
|
|
84878
85176
|
checkExpressionCached(node.expression);
|
|
84879
85177
|
}
|
|
84880
85178
|
checkExternalModuleExports(container);
|
|
84881
|
-
if ((node.flags &
|
|
85179
|
+
if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
|
|
84882
85180
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
84883
85181
|
}
|
|
84884
|
-
if (node.isExportEquals && !(node.flags &
|
|
85182
|
+
if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
|
|
84885
85183
|
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
84886
85184
|
// export assignment is not supported in es6 modules
|
|
84887
85185
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
@@ -85314,7 +85612,7 @@ var ts;
|
|
|
85314
85612
|
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
85315
85613
|
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
85316
85614
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
85317
|
-
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags &
|
|
85615
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
85318
85616
|
diagnostics.add(diag);
|
|
85319
85617
|
}
|
|
85320
85618
|
});
|
|
@@ -85414,7 +85712,7 @@ var ts;
|
|
|
85414
85712
|
}
|
|
85415
85713
|
// Language service support
|
|
85416
85714
|
function getSymbolsInScope(location, meaning) {
|
|
85417
|
-
if (location.flags &
|
|
85715
|
+
if (location.flags & 33554432 /* InWithStatement */) {
|
|
85418
85716
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85419
85717
|
return [];
|
|
85420
85718
|
}
|
|
@@ -85764,7 +86062,7 @@ var ts;
|
|
|
85764
86062
|
}
|
|
85765
86063
|
var parent = node.parent;
|
|
85766
86064
|
var grandParent = parent.parent;
|
|
85767
|
-
if (node.flags &
|
|
86065
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85768
86066
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85769
86067
|
return undefined;
|
|
85770
86068
|
}
|
|
@@ -85906,7 +86204,7 @@ var ts;
|
|
|
85906
86204
|
if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
|
|
85907
86205
|
return errorType;
|
|
85908
86206
|
}
|
|
85909
|
-
if (node.flags &
|
|
86207
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85910
86208
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85911
86209
|
return errorType;
|
|
85912
86210
|
}
|
|
@@ -86959,7 +87257,7 @@ var ts;
|
|
|
86959
87257
|
function checkExternalEmitHelpers(location, helpers) {
|
|
86960
87258
|
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
|
|
86961
87259
|
var sourceFile = ts.getSourceFileOfNode(location);
|
|
86962
|
-
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags &
|
|
87260
|
+
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
|
|
86963
87261
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
86964
87262
|
if (helpersModule !== unknownSymbol) {
|
|
86965
87263
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
@@ -87212,7 +87510,7 @@ var ts;
|
|
|
87212
87510
|
else if (node.kind === 164 /* Parameter */) {
|
|
87213
87511
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
|
|
87214
87512
|
}
|
|
87215
|
-
else if ((node.parent.flags &
|
|
87513
|
+
else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
|
|
87216
87514
|
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
|
87217
87515
|
}
|
|
87218
87516
|
else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
|
|
@@ -87258,7 +87556,7 @@ var ts;
|
|
|
87258
87556
|
if (flags & 256 /* Async */) {
|
|
87259
87557
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
|
|
87260
87558
|
}
|
|
87261
|
-
else if (flags & 2 /* Ambient */ || node.parent.flags &
|
|
87559
|
+
else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
|
|
87262
87560
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
|
87263
87561
|
}
|
|
87264
87562
|
else if (node.kind === 164 /* Parameter */) {
|
|
@@ -87404,7 +87702,7 @@ var ts;
|
|
|
87404
87702
|
if (i !== (parameterCount - 1)) {
|
|
87405
87703
|
return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
87406
87704
|
}
|
|
87407
|
-
if (!(parameter.flags &
|
|
87705
|
+
if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
|
|
87408
87706
|
checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
|
|
87409
87707
|
}
|
|
87410
87708
|
if (parameter.questionToken) {
|
|
@@ -87615,7 +87913,7 @@ var ts;
|
|
|
87615
87913
|
ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
|
|
87616
87914
|
node.kind === 213 /* FunctionExpression */ ||
|
|
87617
87915
|
node.kind === 169 /* MethodDeclaration */);
|
|
87618
|
-
if (node.flags &
|
|
87916
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87619
87917
|
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
|
|
87620
87918
|
}
|
|
87621
87919
|
if (!node.body) {
|
|
@@ -87853,7 +88151,7 @@ var ts;
|
|
|
87853
88151
|
return false;
|
|
87854
88152
|
}
|
|
87855
88153
|
function checkGrammarAccessor(accessor) {
|
|
87856
|
-
if (!(accessor.flags &
|
|
88154
|
+
if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
|
|
87857
88155
|
if (languageVersion < 1 /* ES5 */) {
|
|
87858
88156
|
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
|
87859
88157
|
}
|
|
@@ -87993,7 +88291,7 @@ var ts;
|
|
|
87993
88291
|
// However, property declarations disallow computed names in general,
|
|
87994
88292
|
// and accessors are not allowed in ambient contexts in general,
|
|
87995
88293
|
// so this error only really matters for methods.
|
|
87996
|
-
if (node.flags &
|
|
88294
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87997
88295
|
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);
|
|
87998
88296
|
}
|
|
87999
88297
|
else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
|
|
@@ -88109,7 +88407,7 @@ var ts;
|
|
|
88109
88407
|
}
|
|
88110
88408
|
function checkGrammarVariableDeclaration(node) {
|
|
88111
88409
|
if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
|
|
88112
|
-
if (node.flags &
|
|
88410
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88113
88411
|
checkAmbientInitializer(node);
|
|
88114
88412
|
}
|
|
88115
88413
|
else if (!node.initializer) {
|
|
@@ -88121,7 +88419,7 @@ var ts;
|
|
|
88121
88419
|
}
|
|
88122
88420
|
}
|
|
88123
88421
|
}
|
|
88124
|
-
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags &
|
|
88422
|
+
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
|
|
88125
88423
|
var message = node.initializer
|
|
88126
88424
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
88127
88425
|
: !node.type
|
|
@@ -88130,7 +88428,7 @@ var ts;
|
|
|
88130
88428
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
88131
88429
|
}
|
|
88132
88430
|
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
88133
|
-
!(node.parent.parent.flags &
|
|
88431
|
+
!(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
88134
88432
|
checkESModuleMarker(node.name);
|
|
88135
88433
|
}
|
|
88136
88434
|
var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
|
|
@@ -88307,11 +88605,11 @@ var ts;
|
|
|
88307
88605
|
return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
|
|
88308
88606
|
}
|
|
88309
88607
|
}
|
|
88310
|
-
if (node.flags &
|
|
88608
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88311
88609
|
checkAmbientInitializer(node);
|
|
88312
88610
|
}
|
|
88313
88611
|
if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
|
|
88314
|
-
node.flags &
|
|
88612
|
+
node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
|
|
88315
88613
|
var message = node.initializer
|
|
88316
88614
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
88317
88615
|
: !node.type
|
|
@@ -88357,10 +88655,10 @@ var ts;
|
|
|
88357
88655
|
return false;
|
|
88358
88656
|
}
|
|
88359
88657
|
function checkGrammarSourceFile(node) {
|
|
88360
|
-
return !!(node.flags &
|
|
88658
|
+
return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
|
|
88361
88659
|
}
|
|
88362
88660
|
function checkGrammarStatementInAmbientContext(node) {
|
|
88363
|
-
if (node.flags &
|
|
88661
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88364
88662
|
// Find containing block which is either Block, ModuleBlock, SourceFile
|
|
88365
88663
|
var links = getNodeLinks(node);
|
|
88366
88664
|
if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
|
|
@@ -92478,7 +92776,7 @@ var ts;
|
|
|
92478
92776
|
return !ts.nodeIsMissing(node.body);
|
|
92479
92777
|
}
|
|
92480
92778
|
function visitPropertyDeclaration(node) {
|
|
92481
|
-
if (node.flags &
|
|
92779
|
+
if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
92482
92780
|
return undefined;
|
|
92483
92781
|
}
|
|
92484
92782
|
var updated = factory.updatePropertyDeclaration(node,
|
|
@@ -99368,8 +99666,8 @@ var ts;
|
|
|
99368
99666
|
// declarations may not be sorted by position.
|
|
99369
99667
|
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
|
|
99370
99668
|
var pos = -1, end = -1;
|
|
99371
|
-
for (var _i = 0,
|
|
99372
|
-
var node =
|
|
99669
|
+
for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
|
|
99670
|
+
var node = declarations_10[_i];
|
|
99373
99671
|
pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
|
|
99374
99672
|
end = Math.max(end, node.end);
|
|
99375
99673
|
}
|
|
@@ -108412,7 +108710,7 @@ var ts;
|
|
|
108412
108710
|
needsScopeFixMarker = false;
|
|
108413
108711
|
var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
|
|
108414
108712
|
var lateStatements = transformAndReplaceLatePaintedStatements(statements);
|
|
108415
|
-
if (input.flags &
|
|
108713
|
+
if (input.flags & 16777216 /* Ambient */) {
|
|
108416
108714
|
needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
|
|
108417
108715
|
}
|
|
108418
108716
|
// With the final list of statements, there are 3 possibilities:
|
|
@@ -110060,6 +110358,9 @@ var ts;
|
|
|
110060
110358
|
var currentParenthesizerRule;
|
|
110061
110359
|
var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
|
|
110062
110360
|
var parenthesizer = ts.factory.parenthesizer;
|
|
110361
|
+
var typeArgumentParenthesizerRuleSelector = {
|
|
110362
|
+
select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
|
|
110363
|
+
};
|
|
110063
110364
|
var emitBinaryExpression = createEmitBinaryExpression();
|
|
110064
110365
|
reset();
|
|
110065
110366
|
return {
|
|
@@ -111272,7 +111573,7 @@ var ts;
|
|
|
111272
111573
|
writePunctuation("}");
|
|
111273
111574
|
}
|
|
111274
111575
|
function emitArrayType(node) {
|
|
111275
|
-
emit(node.elementType, parenthesizer.
|
|
111576
|
+
emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111276
111577
|
writePunctuation("[");
|
|
111277
111578
|
writePunctuation("]");
|
|
111278
111579
|
}
|
|
@@ -111283,7 +111584,7 @@ var ts;
|
|
|
111283
111584
|
function emitTupleType(node) {
|
|
111284
111585
|
emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
|
|
111285
111586
|
var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
|
|
111286
|
-
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty
|
|
111587
|
+
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
|
|
111287
111588
|
emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
|
|
111288
111589
|
}
|
|
111289
111590
|
function emitNamedTupleMember(node) {
|
|
@@ -111295,21 +111596,21 @@ var ts;
|
|
|
111295
111596
|
emit(node.type);
|
|
111296
111597
|
}
|
|
111297
111598
|
function emitOptionalType(node) {
|
|
111298
|
-
emit(node.type, parenthesizer.
|
|
111599
|
+
emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
|
|
111299
111600
|
writePunctuation("?");
|
|
111300
111601
|
}
|
|
111301
111602
|
function emitUnionType(node) {
|
|
111302
|
-
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.
|
|
111603
|
+
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
|
|
111303
111604
|
}
|
|
111304
111605
|
function emitIntersectionType(node) {
|
|
111305
|
-
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.
|
|
111606
|
+
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
|
|
111306
111607
|
}
|
|
111307
111608
|
function emitConditionalType(node) {
|
|
111308
|
-
emit(node.checkType, parenthesizer.
|
|
111609
|
+
emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
|
|
111309
111610
|
writeSpace();
|
|
111310
111611
|
writeKeyword("extends");
|
|
111311
111612
|
writeSpace();
|
|
111312
|
-
emit(node.extendsType, parenthesizer.
|
|
111613
|
+
emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
|
|
111313
111614
|
writeSpace();
|
|
111314
111615
|
writePunctuation("?");
|
|
111315
111616
|
writeSpace();
|
|
@@ -111335,10 +111636,13 @@ var ts;
|
|
|
111335
111636
|
function emitTypeOperator(node) {
|
|
111336
111637
|
writeTokenText(node.operator, writeKeyword);
|
|
111337
111638
|
writeSpace();
|
|
111338
|
-
|
|
111639
|
+
var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
|
|
111640
|
+
parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
|
|
111641
|
+
parenthesizer.parenthesizeOperandOfTypeOperator;
|
|
111642
|
+
emit(node.type, parenthesizerRule);
|
|
111339
111643
|
}
|
|
111340
111644
|
function emitIndexedAccessType(node) {
|
|
111341
|
-
emit(node.objectType, parenthesizer.
|
|
111645
|
+
emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111342
111646
|
writePunctuation("[");
|
|
111343
111647
|
emit(node.indexType);
|
|
111344
111648
|
writePunctuation("]");
|
|
@@ -113072,7 +113376,7 @@ var ts;
|
|
|
113072
113376
|
emitList(parentNode, decorators, 2146305 /* Decorators */);
|
|
113073
113377
|
}
|
|
113074
113378
|
function emitTypeArguments(parentNode, typeArguments) {
|
|
113075
|
-
emitList(parentNode, typeArguments, 53776 /* TypeArguments */,
|
|
113379
|
+
emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
|
|
113076
113380
|
}
|
|
113077
113381
|
function emitTypeParameters(parentNode, typeParameters) {
|
|
113078
113382
|
if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
|
@@ -113191,6 +113495,7 @@ var ts;
|
|
|
113191
113495
|
if (format & 128 /* Indented */) {
|
|
113192
113496
|
increaseIndent();
|
|
113193
113497
|
}
|
|
113498
|
+
var emitListItem = getEmitListItem(emit, parenthesizerRule);
|
|
113194
113499
|
// Emit each child.
|
|
113195
113500
|
var previousSibling = void 0;
|
|
113196
113501
|
var previousSourceFileTextKind = void 0;
|
|
@@ -113241,12 +113546,7 @@ var ts;
|
|
|
113241
113546
|
shouldEmitInterveningComments = mayEmitInterveningComments;
|
|
113242
113547
|
}
|
|
113243
113548
|
nextListElementPos = child.pos;
|
|
113244
|
-
|
|
113245
|
-
emit(child);
|
|
113246
|
-
}
|
|
113247
|
-
else {
|
|
113248
|
-
emit(child, parenthesizerRule);
|
|
113249
|
-
}
|
|
113549
|
+
emitListItem(child, emit, parenthesizerRule, i);
|
|
113250
113550
|
if (shouldDecreaseIndentAfterEmit) {
|
|
113251
113551
|
decreaseIndent();
|
|
113252
113552
|
shouldDecreaseIndentAfterEmit = false;
|
|
@@ -114487,6 +114787,20 @@ var ts;
|
|
|
114487
114787
|
TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
|
|
114488
114788
|
TempFlags[TempFlags["_i"] = 268435456] = "_i";
|
|
114489
114789
|
})(TempFlags || (TempFlags = {}));
|
|
114790
|
+
function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
|
|
114791
|
+
emit(node);
|
|
114792
|
+
}
|
|
114793
|
+
function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
|
|
114794
|
+
emit(node, parenthesizerRuleSelector.select(index));
|
|
114795
|
+
}
|
|
114796
|
+
function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
|
|
114797
|
+
emit(node, parenthesizerRule);
|
|
114798
|
+
}
|
|
114799
|
+
function getEmitListItem(emit, parenthesizerRule) {
|
|
114800
|
+
return emit.length === 1 ? emitListItemNoParenthesizer :
|
|
114801
|
+
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
|
|
114802
|
+
emitListItemWithParenthesizerRule;
|
|
114803
|
+
}
|
|
114490
114804
|
})(ts || (ts = {}));
|
|
114491
114805
|
/* @internal */
|
|
114492
114806
|
var ts;
|
|
@@ -116553,7 +116867,7 @@ var ts;
|
|
|
116553
116867
|
// moduleAugmentations has changed
|
|
116554
116868
|
structureIsReused = 1 /* SafeModules */;
|
|
116555
116869
|
}
|
|
116556
|
-
if ((oldSourceFile.flags &
|
|
116870
|
+
if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
116557
116871
|
// dynamicImport has changed
|
|
116558
116872
|
structureIsReused = 1 /* SafeModules */;
|
|
116559
116873
|
}
|
|
@@ -116717,6 +117031,9 @@ var ts;
|
|
|
116717
117031
|
return !!sourceFilesFoundSearchingNodeModules.get(file.path);
|
|
116718
117032
|
}
|
|
116719
117033
|
function isSourceFileDefaultLibrary(file) {
|
|
117034
|
+
if (!file.isDeclarationFile) {
|
|
117035
|
+
return false;
|
|
117036
|
+
}
|
|
116720
117037
|
if (file.hasNoDefaultLib) {
|
|
116721
117038
|
return true;
|
|
116722
117039
|
}
|
|
@@ -117228,7 +117545,7 @@ var ts;
|
|
|
117228
117545
|
var node = _a[_i];
|
|
117229
117546
|
collectModuleReferences(node, /*inAmbientModule*/ false);
|
|
117230
117547
|
}
|
|
117231
|
-
if ((file.flags &
|
|
117548
|
+
if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
|
|
117232
117549
|
collectDynamicImportOrRequireCalls(file);
|
|
117233
117550
|
}
|
|
117234
117551
|
file.imports = imports || ts.emptyArray;
|
|
@@ -117826,7 +118143,7 @@ var ts;
|
|
|
117826
118143
|
&& index < file.imports.length
|
|
117827
118144
|
&& !elideImport
|
|
117828
118145
|
&& !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
|
|
117829
|
-
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags &
|
|
118146
|
+
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
117830
118147
|
if (elideImport) {
|
|
117831
118148
|
modulesWithElidedImports.set(file.path, true);
|
|
117832
118149
|
}
|
|
@@ -127110,7 +127427,7 @@ var ts;
|
|
|
127110
127427
|
result.push("export" /* exportedModifier */);
|
|
127111
127428
|
if (flags & 8192 /* Deprecated */)
|
|
127112
127429
|
result.push("deprecated" /* deprecatedModifier */);
|
|
127113
|
-
if (node.flags &
|
|
127430
|
+
if (node.flags & 16777216 /* Ambient */)
|
|
127114
127431
|
result.push("declare" /* ambientModifier */);
|
|
127115
127432
|
if (node.kind === 271 /* ExportAssignment */)
|
|
127116
127433
|
result.push("export" /* exportedModifier */);
|
|
@@ -133426,7 +133743,7 @@ var ts;
|
|
|
133426
133743
|
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
|
|
133427
133744
|
// Check completions for Object property value shorthand
|
|
133428
133745
|
if (instantiatedType === undefined) {
|
|
133429
|
-
if (objectLikeContainer.flags &
|
|
133746
|
+
if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
|
|
133430
133747
|
return 2 /* Fail */;
|
|
133431
133748
|
}
|
|
133432
133749
|
isNonContextualObjectLiteral = true;
|
|
@@ -136089,17 +136406,25 @@ var ts;
|
|
|
136089
136406
|
var options = { use: 1 /* References */ };
|
|
136090
136407
|
var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
|
|
136091
136408
|
var checker = program.getTypeChecker();
|
|
136092
|
-
|
|
136409
|
+
// Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
|
|
136410
|
+
var adjustedNode = Core.getAdjustedNode(node, options);
|
|
136411
|
+
var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
|
|
136093
136412
|
return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
|
|
136094
136413
|
var definition = _a.definition, references = _a.references;
|
|
136095
136414
|
// Only include referenced symbols that have a valid definition.
|
|
136096
136415
|
return definition && {
|
|
136097
136416
|
definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
|
|
136098
|
-
references: references.map(function (r) { return
|
|
136417
|
+
references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
|
|
136099
136418
|
};
|
|
136100
136419
|
});
|
|
136101
136420
|
}
|
|
136102
136421
|
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
|
|
136422
|
+
function isDefinitionForReference(node) {
|
|
136423
|
+
return node.kind === 88 /* DefaultKeyword */
|
|
136424
|
+
|| !!ts.getDeclarationFromName(node)
|
|
136425
|
+
|| ts.isLiteralComputedPropertyDeclarationName(node)
|
|
136426
|
+
|| (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
|
|
136427
|
+
}
|
|
136103
136428
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
136104
136429
|
var node = ts.getTouchingPropertyName(sourceFile, position);
|
|
136105
136430
|
var referenceEntries;
|
|
@@ -136228,13 +136553,19 @@ var ts;
|
|
|
136228
136553
|
return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
|
|
136229
136554
|
}
|
|
136230
136555
|
FindAllReferences.toRenameLocation = toRenameLocation;
|
|
136231
|
-
function
|
|
136556
|
+
function toReferencedSymbolEntry(entry, symbol) {
|
|
136557
|
+
var referenceEntry = toReferenceEntry(entry);
|
|
136558
|
+
if (!symbol)
|
|
136559
|
+
return referenceEntry;
|
|
136560
|
+
return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
|
|
136561
|
+
}
|
|
136562
|
+
function toReferenceEntry(entry) {
|
|
136232
136563
|
var documentSpan = entryToDocumentSpan(entry);
|
|
136233
136564
|
if (entry.kind === 0 /* Span */) {
|
|
136234
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: false
|
|
136565
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: false });
|
|
136235
136566
|
}
|
|
136236
136567
|
var kind = entry.kind, node = entry.node;
|
|
136237
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node),
|
|
136568
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
|
136238
136569
|
}
|
|
136239
136570
|
FindAllReferences.toReferenceEntry = toReferenceEntry;
|
|
136240
136571
|
function entryToDocumentSpan(entry) {
|
|
@@ -136377,7 +136708,7 @@ var ts;
|
|
|
136377
136708
|
*/
|
|
136378
136709
|
function declarationIsWriteAccess(decl) {
|
|
136379
136710
|
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
|
|
136380
|
-
if (!!(decl.flags &
|
|
136711
|
+
if (!!(decl.flags & 16777216 /* Ambient */))
|
|
136381
136712
|
return true;
|
|
136382
136713
|
switch (decl.kind) {
|
|
136383
136714
|
case 221 /* BinaryExpression */:
|
|
@@ -136942,15 +137273,21 @@ var ts;
|
|
|
136942
137273
|
}
|
|
136943
137274
|
function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
|
|
136944
137275
|
var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
|
|
136945
|
-
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
|
|
137276
|
+
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
|
|
136946
137277
|
for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
|
|
136947
137278
|
var importLocation = importSearches_2[_i][0];
|
|
136948
137279
|
cb(importLocation);
|
|
136949
137280
|
}
|
|
136950
|
-
for (var _b = 0,
|
|
136951
|
-
var
|
|
136952
|
-
|
|
136953
|
-
|
|
137281
|
+
for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
|
|
137282
|
+
var singleReference = singleReferences_2[_b];
|
|
137283
|
+
if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
|
|
137284
|
+
cb(singleReference);
|
|
137285
|
+
}
|
|
137286
|
+
}
|
|
137287
|
+
for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
|
|
137288
|
+
var indirectUser = indirectUsers_2[_c];
|
|
137289
|
+
for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
|
|
137290
|
+
var node = _e[_d];
|
|
136954
137291
|
// Import specifiers should be handled by importSearches
|
|
136955
137292
|
var symbol = checker.getSymbolAtLocation(node);
|
|
136956
137293
|
var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
|
|
@@ -137952,7 +138289,7 @@ var ts;
|
|
|
137952
138289
|
}
|
|
137953
138290
|
Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
|
|
137954
138291
|
function isImplementation(node) {
|
|
137955
|
-
return !!(node.flags &
|
|
138292
|
+
return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
|
|
137956
138293
|
(ts.isVariableLike(node) ? ts.hasInitializer(node) :
|
|
137957
138294
|
ts.isFunctionLikeDeclaration(node) ? !!node.body :
|
|
137958
138295
|
ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
|
|
@@ -138330,7 +138667,7 @@ var ts;
|
|
|
138330
138667
|
function collect(node) {
|
|
138331
138668
|
if (!node)
|
|
138332
138669
|
return;
|
|
138333
|
-
if (node.flags &
|
|
138670
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
138334
138671
|
// do not descend into ambient nodes.
|
|
138335
138672
|
return;
|
|
138336
138673
|
}
|
|
@@ -138489,7 +138826,7 @@ var ts;
|
|
|
138489
138826
|
}
|
|
138490
138827
|
/** Gets the call sites that call out of the provided call hierarchy declaration. */
|
|
138491
138828
|
function getOutgoingCalls(program, declaration) {
|
|
138492
|
-
if (declaration.flags &
|
|
138829
|
+
if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
|
|
138493
138830
|
return [];
|
|
138494
138831
|
}
|
|
138495
138832
|
return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
|
|
@@ -140623,8 +140960,8 @@ var ts;
|
|
|
140623
140960
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
140624
140961
|
var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
|
|
140625
140962
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
140626
|
-
var
|
|
140627
|
-
organizeImportsWorker(
|
|
140963
|
+
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
140964
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140628
140965
|
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
140629
140966
|
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
140630
140967
|
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
@@ -140632,8 +140969,8 @@ var ts;
|
|
|
140632
140969
|
var ambientModule = _a[_i];
|
|
140633
140970
|
if (!ambientModule.body)
|
|
140634
140971
|
continue;
|
|
140635
|
-
var
|
|
140636
|
-
organizeImportsWorker(
|
|
140972
|
+
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
140973
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140637
140974
|
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
140638
140975
|
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
140639
140976
|
}
|
|
@@ -140679,6 +141016,40 @@ var ts;
|
|
|
140679
141016
|
}
|
|
140680
141017
|
}
|
|
140681
141018
|
OrganizeImports.organizeImports = organizeImports;
|
|
141019
|
+
function groupImportsByNewlineContiguous(sourceFile, importDecls) {
|
|
141020
|
+
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
|
|
141021
|
+
var groupImports = [];
|
|
141022
|
+
var groupIndex = 0;
|
|
141023
|
+
for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
|
|
141024
|
+
var topLevelImportDecl = importDecls_1[_i];
|
|
141025
|
+
if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
|
|
141026
|
+
groupIndex++;
|
|
141027
|
+
}
|
|
141028
|
+
if (!groupImports[groupIndex]) {
|
|
141029
|
+
groupImports[groupIndex] = [];
|
|
141030
|
+
}
|
|
141031
|
+
groupImports[groupIndex].push(topLevelImportDecl);
|
|
141032
|
+
}
|
|
141033
|
+
return groupImports;
|
|
141034
|
+
}
|
|
141035
|
+
// a new group is created if an import includes at least two new line
|
|
141036
|
+
// new line from multi-line comment doesn't count
|
|
141037
|
+
function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
|
|
141038
|
+
var startPos = topLevelImportDecl.getFullStart();
|
|
141039
|
+
var endPos = topLevelImportDecl.getStart();
|
|
141040
|
+
scanner.setText(sourceFile.text, startPos, endPos - startPos);
|
|
141041
|
+
var numberOfNewLines = 0;
|
|
141042
|
+
while (scanner.getTokenPos() < endPos) {
|
|
141043
|
+
var tokenKind = scanner.scan();
|
|
141044
|
+
if (tokenKind === 4 /* NewLineTrivia */) {
|
|
141045
|
+
numberOfNewLines++;
|
|
141046
|
+
if (numberOfNewLines >= 2) {
|
|
141047
|
+
return true;
|
|
141048
|
+
}
|
|
141049
|
+
}
|
|
141050
|
+
}
|
|
141051
|
+
return false;
|
|
141052
|
+
}
|
|
140682
141053
|
function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
|
|
140683
141054
|
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
140684
141055
|
if (skipDestructiveCodeActions) {
|
|
@@ -148639,8 +149010,11 @@ var ts;
|
|
|
148639
149010
|
function isTrivia(s) {
|
|
148640
149011
|
return ts.skipTrivia(s, 0) === s.length;
|
|
148641
149012
|
}
|
|
149013
|
+
// A transformation context that won't perform parenthesization, as some parenthesization rules
|
|
149014
|
+
// are more aggressive than is strictly necessary.
|
|
149015
|
+
var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
|
|
148642
149016
|
function assignPositionsToNode(node) {
|
|
148643
|
-
var visited = ts.visitEachChild(node, assignPositionsToNode,
|
|
149017
|
+
var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
|
148644
149018
|
// create proxy node for non synthesized nodes
|
|
148645
149019
|
var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
|
|
148646
149020
|
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
|
|
@@ -156605,7 +156979,7 @@ var ts;
|
|
|
156605
156979
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
156606
156980
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
156607
156981
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
156608
|
-
var ambient = !!(enclosingDeclaration.flags &
|
|
156982
|
+
var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
|
|
156609
156983
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
156610
156984
|
switch (declaration.kind) {
|
|
156611
156985
|
case 166 /* PropertySignature */:
|
|
@@ -158182,6 +158556,10 @@ var ts;
|
|
|
158182
158556
|
}
|
|
158183
158557
|
break;
|
|
158184
158558
|
}
|
|
158559
|
+
case 200 /* ImportType */:
|
|
158560
|
+
var importTypeNode = parent;
|
|
158561
|
+
changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
|
|
158562
|
+
break;
|
|
158185
158563
|
default:
|
|
158186
158564
|
ts.Debug.failBadSyntaxKind(parent);
|
|
158187
158565
|
}
|
|
@@ -159122,7 +159500,7 @@ var ts;
|
|
|
159122
159500
|
// cannot find either start or end node
|
|
159123
159501
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
159124
159502
|
}
|
|
159125
|
-
if (start.flags &
|
|
159503
|
+
if (start.flags & 8388608 /* JSDoc */) {
|
|
159126
159504
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
159127
159505
|
}
|
|
159128
159506
|
if (start.parent !== end.parent) {
|
|
@@ -159248,7 +159626,7 @@ var ts;
|
|
|
159248
159626
|
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
159249
159627
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
159250
159628
|
}
|
|
159251
|
-
if (nodeToCheck.flags &
|
|
159629
|
+
if (nodeToCheck.flags & 16777216 /* Ambient */) {
|
|
159252
159630
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
|
|
159253
159631
|
}
|
|
159254
159632
|
// If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
|
|
@@ -160780,6 +161158,7 @@ var ts;
|
|
|
160780
161158
|
}
|
|
160781
161159
|
function doTypedefChange(changes, file, name, info) {
|
|
160782
161160
|
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
|
|
161161
|
+
ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
|
|
160783
161162
|
var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
|
|
160784
161163
|
var templates = [];
|
|
160785
161164
|
ts.forEach(typeParameters, function (typeParameter) {
|
|
@@ -162810,7 +163189,7 @@ var ts;
|
|
|
162810
163189
|
kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
|
|
162811
163190
|
new TokenObject(kind, pos, end);
|
|
162812
163191
|
node.parent = parent;
|
|
162813
|
-
node.flags = parent.flags &
|
|
163192
|
+
node.flags = parent.flags & 50720768 /* ContextFlags */;
|
|
162814
163193
|
return node;
|
|
162815
163194
|
}
|
|
162816
163195
|
var NodeObject = /** @class */ (function () {
|
|
@@ -164266,7 +164645,7 @@ var ts;
|
|
|
164266
164645
|
}
|
|
164267
164646
|
/// References and Occurrences
|
|
164268
164647
|
function getOccurrencesAtPosition(fileName, position) {
|
|
164269
|
-
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
|
|
164648
|
+
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 })); }); });
|
|
164270
164649
|
}
|
|
164271
164650
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
164272
164651
|
var normalizedFileName = ts.normalizePath(fileName);
|
|
@@ -164295,7 +164674,7 @@ var ts;
|
|
|
164295
164674
|
}
|
|
164296
164675
|
function getReferencesAtPosition(fileName, position) {
|
|
164297
164676
|
synchronizeHostData();
|
|
164298
|
-
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ },
|
|
164677
|
+
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
|
|
164299
164678
|
}
|
|
164300
164679
|
function getReferencesWorker(node, position, options, cb) {
|
|
164301
164680
|
synchronizeHostData();
|
|
@@ -164310,10 +164689,8 @@ var ts;
|
|
|
164310
164689
|
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
164311
164690
|
}
|
|
164312
164691
|
function getFileReferences(fileName) {
|
|
164313
|
-
var _a;
|
|
164314
164692
|
synchronizeHostData();
|
|
164315
|
-
|
|
164316
|
-
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
|
|
164693
|
+
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
|
|
164317
164694
|
}
|
|
164318
164695
|
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
|
|
164319
164696
|
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
|
|
@@ -164786,7 +165163,7 @@ var ts;
|
|
|
164786
165163
|
}
|
|
164787
165164
|
function isUnclosedFragment(_a) {
|
|
164788
165165
|
var closingFragment = _a.closingFragment, parent = _a.parent;
|
|
164789
|
-
return !!(closingFragment.flags &
|
|
165166
|
+
return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
|
|
164790
165167
|
}
|
|
164791
165168
|
function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
|
|
164792
165169
|
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
|
@@ -165234,7 +165611,7 @@ var ts;
|
|
|
165234
165611
|
tokenAtLocation = preceding;
|
|
165235
165612
|
}
|
|
165236
165613
|
// Cannot set breakpoint in ambient declarations
|
|
165237
|
-
if (tokenAtLocation.flags &
|
|
165614
|
+
if (tokenAtLocation.flags & 16777216 /* Ambient */) {
|
|
165238
165615
|
return undefined;
|
|
165239
165616
|
}
|
|
165240
165617
|
// Get the span in the node based on its syntax
|