typescript 4.7.0-dev.20220404 → 4.7.0-dev.20220408
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 +527 -278
- package/lib/tsserver.js +837 -362
- package/lib/tsserverlibrary.d.ts +22 -14
- package/lib/tsserverlibrary.js +837 -362
- package/lib/typescript.d.ts +17 -12
- package/lib/typescript.js +833 -362
- package/lib/typescriptServices.d.ts +17 -12
- package/lib/typescriptServices.js +833 -362
- package/lib/typingsInstaller.js +685 -315
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220408";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4415,10 +4415,11 @@ var ts;
|
|
|
4415
4415
|
NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
|
|
4416
4416
|
NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
|
|
4417
4417
|
NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
|
|
4418
|
-
NodeFlags[NodeFlags["
|
|
4419
|
-
NodeFlags[NodeFlags["
|
|
4420
|
-
NodeFlags[NodeFlags["
|
|
4421
|
-
NodeFlags[NodeFlags["
|
|
4418
|
+
NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
|
|
4419
|
+
NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
|
|
4420
|
+
NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
|
|
4421
|
+
NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
|
|
4422
|
+
NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
|
|
4422
4423
|
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
|
4423
4424
|
// walking the tree if the flags are not set. However, these flags are just a approximation
|
|
4424
4425
|
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
|
@@ -4428,25 +4429,25 @@ var ts;
|
|
|
4428
4429
|
// removal, it is likely that users will add the import anyway.
|
|
4429
4430
|
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
|
4430
4431
|
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
|
4431
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] =
|
|
4432
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] =
|
|
4433
|
-
NodeFlags[NodeFlags["JSDoc"] =
|
|
4434
|
-
/* @internal */ NodeFlags[NodeFlags["Ambient"] =
|
|
4435
|
-
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] =
|
|
4436
|
-
NodeFlags[NodeFlags["JsonFile"] =
|
|
4437
|
-
/* @internal */ NodeFlags[NodeFlags["TypeCached"] =
|
|
4438
|
-
/* @internal */ NodeFlags[NodeFlags["Deprecated"] =
|
|
4432
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
|
|
4433
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
|
|
4434
|
+
NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
|
|
4435
|
+
/* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
|
|
4436
|
+
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
|
|
4437
|
+
NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
|
|
4438
|
+
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
|
4439
|
+
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
|
4439
4440
|
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
|
4440
4441
|
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
|
4441
4442
|
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
|
4442
4443
|
// Parsing context flags
|
|
4443
|
-
NodeFlags[NodeFlags["ContextFlags"] =
|
|
4444
|
+
NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
|
|
4444
4445
|
// Exclude these flags when parsing a Type
|
|
4445
4446
|
NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
|
|
4446
4447
|
// Represents all flags that are potentially set once and
|
|
4447
4448
|
// never cleared on SourceFiles which get re-used in between incremental parses.
|
|
4448
4449
|
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
|
4449
|
-
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] =
|
|
4450
|
+
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
|
|
4450
4451
|
})(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
|
|
4451
4452
|
var ModifierFlags;
|
|
4452
4453
|
(function (ModifierFlags) {
|
|
@@ -8716,6 +8717,7 @@ var ts;
|
|
|
8716
8717
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8717
8718
|
Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
|
|
8718
8719
|
Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
|
|
8720
|
+
Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
|
|
8719
8721
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
8720
8722
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
8721
8723
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
@@ -8888,6 +8890,7 @@ var ts;
|
|
|
8888
8890
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
|
|
8889
8891
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8890
8892
|
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."),
|
|
8893
|
+
All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
|
|
8891
8894
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8892
8895
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8893
8896
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -14302,24 +14305,24 @@ var ts;
|
|
|
14302
14305
|
// Returns true if this node contains a parse error anywhere underneath it.
|
|
14303
14306
|
function containsParseError(node) {
|
|
14304
14307
|
aggregateChildData(node);
|
|
14305
|
-
return (node.flags &
|
|
14308
|
+
return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
|
|
14306
14309
|
}
|
|
14307
14310
|
ts.containsParseError = containsParseError;
|
|
14308
14311
|
function aggregateChildData(node) {
|
|
14309
|
-
if (!(node.flags &
|
|
14312
|
+
if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
|
|
14310
14313
|
// A node is considered to contain a parse error if:
|
|
14311
14314
|
// a) the parser explicitly marked that it had an error
|
|
14312
14315
|
// b) any of it's children reported that it had an error.
|
|
14313
|
-
var thisNodeOrAnySubNodesHasError = ((node.flags &
|
|
14316
|
+
var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
|
|
14314
14317
|
ts.forEachChild(node, containsParseError);
|
|
14315
14318
|
// If so, mark ourselves accordingly.
|
|
14316
14319
|
if (thisNodeOrAnySubNodesHasError) {
|
|
14317
|
-
node.flags |=
|
|
14320
|
+
node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
|
|
14318
14321
|
}
|
|
14319
14322
|
// Also mark that we've propagated the child information to this node. This way we can
|
|
14320
14323
|
// always consult the bit directly on this node without needing to check its children
|
|
14321
14324
|
// again.
|
|
14322
|
-
node.flags |=
|
|
14325
|
+
node.flags |= 1048576 /* HasAggregatedChildData */;
|
|
14323
14326
|
}
|
|
14324
14327
|
}
|
|
14325
14328
|
function getSourceFileOfNode(node) {
|
|
@@ -16126,11 +16129,11 @@ var ts;
|
|
|
16126
16129
|
}
|
|
16127
16130
|
ts.isSourceFileNotJS = isSourceFileNotJS;
|
|
16128
16131
|
function isInJSFile(node) {
|
|
16129
|
-
return !!node && !!(node.flags &
|
|
16132
|
+
return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
|
|
16130
16133
|
}
|
|
16131
16134
|
ts.isInJSFile = isInJSFile;
|
|
16132
16135
|
function isInJsonFile(node) {
|
|
16133
|
-
return !!node && !!(node.flags &
|
|
16136
|
+
return !!node && !!(node.flags & 67108864 /* JsonFile */);
|
|
16134
16137
|
}
|
|
16135
16138
|
ts.isInJsonFile = isInJsonFile;
|
|
16136
16139
|
function isSourceFileNotJson(file) {
|
|
@@ -16138,7 +16141,7 @@ var ts;
|
|
|
16138
16141
|
}
|
|
16139
16142
|
ts.isSourceFileNotJson = isSourceFileNotJson;
|
|
16140
16143
|
function isInJSDoc(node) {
|
|
16141
|
-
return !!node && !!(node.flags &
|
|
16144
|
+
return !!node && !!(node.flags & 8388608 /* JSDoc */);
|
|
16142
16145
|
}
|
|
16143
16146
|
ts.isInJSDoc = isInJSDoc;
|
|
16144
16147
|
function isJSDocIndexSignature(node) {
|
|
@@ -16524,7 +16527,7 @@ var ts;
|
|
|
16524
16527
|
function setValueDeclaration(symbol, node) {
|
|
16525
16528
|
var valueDeclaration = symbol.valueDeclaration;
|
|
16526
16529
|
if (!valueDeclaration ||
|
|
16527
|
-
!(node.flags &
|
|
16530
|
+
!(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
|
|
16528
16531
|
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
|
16529
16532
|
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
|
16530
16533
|
// other kinds of value declarations take precedence over modules and assignment declarations
|
|
@@ -16797,7 +16800,11 @@ var ts;
|
|
|
16797
16800
|
ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag;
|
|
16798
16801
|
function getHostSignatureFromJSDoc(node) {
|
|
16799
16802
|
var host = getEffectiveJSDocHost(node);
|
|
16800
|
-
|
|
16803
|
+
if (host) {
|
|
16804
|
+
return ts.isPropertySignature(host) && host.type && ts.isFunctionLike(host.type) ? host.type :
|
|
16805
|
+
ts.isFunctionLike(host) ? host : undefined;
|
|
16806
|
+
}
|
|
16807
|
+
return undefined;
|
|
16801
16808
|
}
|
|
16802
16809
|
ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
|
|
16803
16810
|
function getEffectiveJSDocHost(node) {
|
|
@@ -20822,7 +20829,7 @@ var ts;
|
|
|
20822
20829
|
}
|
|
20823
20830
|
ts.pseudoBigIntToString = pseudoBigIntToString;
|
|
20824
20831
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
20825
|
-
return !!(useSite.flags &
|
|
20832
|
+
return !!(useSite.flags & 16777216 /* Ambient */)
|
|
20826
20833
|
|| isPartOfTypeQuery(useSite)
|
|
20827
20834
|
|| isIdentifierInNonEmittingHeritageClause(useSite)
|
|
20828
20835
|
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
|
|
@@ -21275,11 +21282,20 @@ var ts;
|
|
|
21275
21282
|
parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
|
|
21276
21283
|
parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
|
|
21277
21284
|
parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21285
|
+
parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
|
|
21286
|
+
parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
|
|
21287
|
+
parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
|
|
21288
|
+
parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
|
|
21289
|
+
parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
|
|
21290
|
+
parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
|
|
21291
|
+
parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
|
|
21292
|
+
parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
|
|
21293
|
+
parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
|
|
21294
|
+
parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
|
|
21295
|
+
parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
|
|
21296
|
+
parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
|
|
21282
21297
|
parenthesizeTypeArguments: parenthesizeTypeArguments,
|
|
21298
|
+
parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
|
|
21283
21299
|
};
|
|
21284
21300
|
function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
|
|
21285
21301
|
binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
|
|
@@ -21591,33 +21607,191 @@ var ts;
|
|
|
21591
21607
|
}
|
|
21592
21608
|
return body;
|
|
21593
21609
|
}
|
|
21594
|
-
|
|
21595
|
-
|
|
21610
|
+
// Type[Extends] :
|
|
21611
|
+
// FunctionOrConstructorType
|
|
21612
|
+
// ConditionalType[?Extends]
|
|
21613
|
+
// ConditionalType[Extends] :
|
|
21614
|
+
// UnionType[?Extends]
|
|
21615
|
+
// [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
|
|
21616
|
+
//
|
|
21617
|
+
// - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
|
|
21618
|
+
// - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
|
|
21619
|
+
// - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
|
|
21620
|
+
function parenthesizeCheckTypeOfConditionalType(checkType) {
|
|
21621
|
+
switch (checkType.kind) {
|
|
21622
|
+
case 179 /* FunctionType */:
|
|
21623
|
+
case 180 /* ConstructorType */:
|
|
21624
|
+
case 189 /* ConditionalType */:
|
|
21625
|
+
return factory.createParenthesizedType(checkType);
|
|
21626
|
+
}
|
|
21627
|
+
return checkType;
|
|
21596
21628
|
}
|
|
21597
|
-
function
|
|
21598
|
-
switch (
|
|
21629
|
+
function parenthesizeExtendsTypeOfConditionalType(extendsType) {
|
|
21630
|
+
switch (extendsType.kind) {
|
|
21631
|
+
case 189 /* ConditionalType */:
|
|
21632
|
+
return factory.createParenthesizedType(extendsType);
|
|
21633
|
+
}
|
|
21634
|
+
return extendsType;
|
|
21635
|
+
}
|
|
21636
|
+
// UnionType[Extends] :
|
|
21637
|
+
// `|`? IntersectionType[?Extends]
|
|
21638
|
+
// UnionType[?Extends] `|` IntersectionType[?Extends]
|
|
21639
|
+
//
|
|
21640
|
+
// - A union type constituent has the same precedence as the check type of a conditional type
|
|
21641
|
+
function parenthesizeConstituentTypeOfUnionType(type) {
|
|
21642
|
+
switch (type.kind) {
|
|
21643
|
+
case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
|
|
21644
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21645
|
+
return factory.createParenthesizedType(type);
|
|
21646
|
+
}
|
|
21647
|
+
return parenthesizeCheckTypeOfConditionalType(type);
|
|
21648
|
+
}
|
|
21649
|
+
function parenthesizeConstituentTypesOfUnionType(members) {
|
|
21650
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
|
|
21651
|
+
}
|
|
21652
|
+
// IntersectionType[Extends] :
|
|
21653
|
+
// `&`? TypeOperator[?Extends]
|
|
21654
|
+
// IntersectionType[?Extends] `&` TypeOperator[?Extends]
|
|
21655
|
+
//
|
|
21656
|
+
// - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
|
|
21657
|
+
function parenthesizeConstituentTypeOfIntersectionType(type) {
|
|
21658
|
+
switch (type.kind) {
|
|
21599
21659
|
case 187 /* UnionType */:
|
|
21660
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
|
|
21661
|
+
return factory.createParenthesizedType(type);
|
|
21662
|
+
}
|
|
21663
|
+
return parenthesizeConstituentTypeOfUnionType(type);
|
|
21664
|
+
}
|
|
21665
|
+
function parenthesizeConstituentTypesOfIntersectionType(members) {
|
|
21666
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
|
|
21667
|
+
}
|
|
21668
|
+
// TypeOperator[Extends] :
|
|
21669
|
+
// PostfixType
|
|
21670
|
+
// InferType[?Extends]
|
|
21671
|
+
// `keyof` TypeOperator[?Extends]
|
|
21672
|
+
// `unique` TypeOperator[?Extends]
|
|
21673
|
+
// `readonly` TypeOperator[?Extends]
|
|
21674
|
+
//
|
|
21675
|
+
function parenthesizeOperandOfTypeOperator(type) {
|
|
21676
|
+
switch (type.kind) {
|
|
21600
21677
|
case 188 /* IntersectionType */:
|
|
21601
|
-
|
|
21602
|
-
case 180 /* ConstructorType */:
|
|
21603
|
-
return factory.createParenthesizedType(member);
|
|
21678
|
+
return factory.createParenthesizedType(type);
|
|
21604
21679
|
}
|
|
21605
|
-
return
|
|
21680
|
+
return parenthesizeConstituentTypeOfIntersectionType(type);
|
|
21606
21681
|
}
|
|
21607
|
-
function
|
|
21608
|
-
switch (
|
|
21609
|
-
case 181 /* TypeQuery */:
|
|
21682
|
+
function parenthesizeOperandOfReadonlyTypeOperator(type) {
|
|
21683
|
+
switch (type.kind) {
|
|
21610
21684
|
case 193 /* TypeOperator */:
|
|
21685
|
+
return factory.createParenthesizedType(type);
|
|
21686
|
+
}
|
|
21687
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21688
|
+
}
|
|
21689
|
+
// PostfixType :
|
|
21690
|
+
// NonArrayType
|
|
21691
|
+
// NonArrayType [no LineTerminator here] `!` // JSDoc
|
|
21692
|
+
// NonArrayType [no LineTerminator here] `?` // JSDoc
|
|
21693
|
+
// IndexedAccessType
|
|
21694
|
+
// ArrayType
|
|
21695
|
+
//
|
|
21696
|
+
// IndexedAccessType :
|
|
21697
|
+
// NonArrayType `[` Type[~Extends] `]`
|
|
21698
|
+
//
|
|
21699
|
+
// ArrayType :
|
|
21700
|
+
// NonArrayType `[` `]`
|
|
21701
|
+
//
|
|
21702
|
+
function parenthesizeNonArrayTypeOfPostfixType(type) {
|
|
21703
|
+
switch (type.kind) {
|
|
21611
21704
|
case 190 /* InferType */:
|
|
21612
|
-
|
|
21705
|
+
case 193 /* TypeOperator */:
|
|
21706
|
+
case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21707
|
+
return factory.createParenthesizedType(type);
|
|
21613
21708
|
}
|
|
21614
|
-
return
|
|
21709
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21710
|
+
}
|
|
21711
|
+
// TupleType :
|
|
21712
|
+
// `[` Elision? `]`
|
|
21713
|
+
// `[` NamedTupleElementTypes `]`
|
|
21714
|
+
// `[` NamedTupleElementTypes `,` Elision? `]`
|
|
21715
|
+
// `[` TupleElementTypes `]`
|
|
21716
|
+
// `[` TupleElementTypes `,` Elision? `]`
|
|
21717
|
+
//
|
|
21718
|
+
// NamedTupleElementTypes :
|
|
21719
|
+
// Elision? NamedTupleMember
|
|
21720
|
+
// NamedTupleElementTypes `,` Elision? NamedTupleMember
|
|
21721
|
+
//
|
|
21722
|
+
// NamedTupleMember :
|
|
21723
|
+
// Identifier `?`? `:` Type[~Extends]
|
|
21724
|
+
// `...` Identifier `:` Type[~Extends]
|
|
21725
|
+
//
|
|
21726
|
+
// TupleElementTypes :
|
|
21727
|
+
// Elision? TupleElementType
|
|
21728
|
+
// TupleElementTypes `,` Elision? TupleElementType
|
|
21729
|
+
//
|
|
21730
|
+
// TupleElementType :
|
|
21731
|
+
// Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21732
|
+
// OptionalType
|
|
21733
|
+
// RestType
|
|
21734
|
+
//
|
|
21735
|
+
// OptionalType :
|
|
21736
|
+
// Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21737
|
+
//
|
|
21738
|
+
// RestType :
|
|
21739
|
+
// `...` Type[~Extends]
|
|
21740
|
+
//
|
|
21741
|
+
function parenthesizeElementTypesOfTupleType(types) {
|
|
21742
|
+
return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
|
|
21743
|
+
}
|
|
21744
|
+
function parenthesizeElementTypeOfTupleType(type) {
|
|
21745
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21746
|
+
return factory.createParenthesizedType(type);
|
|
21747
|
+
return type;
|
|
21748
|
+
}
|
|
21749
|
+
function hasJSDocPostfixQuestion(type) {
|
|
21750
|
+
if (ts.isJSDocNullableType(type))
|
|
21751
|
+
return type.postfix;
|
|
21752
|
+
if (ts.isNamedTupleMember(type))
|
|
21753
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21754
|
+
if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
|
|
21755
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21756
|
+
if (ts.isConditionalTypeNode(type))
|
|
21757
|
+
return hasJSDocPostfixQuestion(type.falseType);
|
|
21758
|
+
if (ts.isUnionTypeNode(type))
|
|
21759
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21760
|
+
if (ts.isIntersectionTypeNode(type))
|
|
21761
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21762
|
+
if (ts.isInferTypeNode(type))
|
|
21763
|
+
return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
|
|
21764
|
+
return false;
|
|
21615
21765
|
}
|
|
21616
|
-
function
|
|
21617
|
-
|
|
21766
|
+
function parenthesizeTypeOfOptionalType(type) {
|
|
21767
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21768
|
+
return factory.createParenthesizedType(type);
|
|
21769
|
+
return parenthesizeNonArrayTypeOfPostfixType(type);
|
|
21770
|
+
}
|
|
21771
|
+
// function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
|
|
21772
|
+
// switch (member.kind) {
|
|
21773
|
+
// case SyntaxKind.UnionType:
|
|
21774
|
+
// case SyntaxKind.IntersectionType:
|
|
21775
|
+
// case SyntaxKind.FunctionType:
|
|
21776
|
+
// case SyntaxKind.ConstructorType:
|
|
21777
|
+
// return factory.createParenthesizedType(member);
|
|
21778
|
+
// }
|
|
21779
|
+
// return parenthesizeMemberOfConditionalType(member);
|
|
21780
|
+
// }
|
|
21781
|
+
// function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
|
|
21782
|
+
// switch (member.kind) {
|
|
21783
|
+
// case SyntaxKind.TypeQuery:
|
|
21784
|
+
// case SyntaxKind.TypeOperator:
|
|
21785
|
+
// case SyntaxKind.InferType:
|
|
21786
|
+
// return factory.createParenthesizedType(member);
|
|
21787
|
+
// }
|
|
21788
|
+
// return parenthesizeMemberOfElementType(member);
|
|
21789
|
+
// }
|
|
21790
|
+
function parenthesizeLeadingTypeArgument(node) {
|
|
21791
|
+
return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
|
|
21618
21792
|
}
|
|
21619
21793
|
function parenthesizeOrdinalTypeArgument(node, i) {
|
|
21620
|
-
return i === 0
|
|
21794
|
+
return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
|
|
21621
21795
|
}
|
|
21622
21796
|
function parenthesizeTypeArguments(typeArguments) {
|
|
21623
21797
|
if (ts.some(typeArguments)) {
|
|
@@ -21643,11 +21817,20 @@ var ts;
|
|
|
21643
21817
|
parenthesizeExpressionForDisallowedComma: ts.identity,
|
|
21644
21818
|
parenthesizeExpressionOfExpressionStatement: ts.identity,
|
|
21645
21819
|
parenthesizeConciseBodyOfArrowFunction: ts.identity,
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
21820
|
+
parenthesizeCheckTypeOfConditionalType: ts.identity,
|
|
21821
|
+
parenthesizeExtendsTypeOfConditionalType: ts.identity,
|
|
21822
|
+
parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21823
|
+
parenthesizeConstituentTypeOfUnionType: ts.identity,
|
|
21824
|
+
parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21825
|
+
parenthesizeConstituentTypeOfIntersectionType: ts.identity,
|
|
21826
|
+
parenthesizeOperandOfTypeOperator: ts.identity,
|
|
21827
|
+
parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
|
|
21828
|
+
parenthesizeNonArrayTypeOfPostfixType: ts.identity,
|
|
21829
|
+
parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21830
|
+
parenthesizeElementTypeOfTupleType: ts.identity,
|
|
21831
|
+
parenthesizeTypeOfOptionalType: ts.identity,
|
|
21650
21832
|
parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
|
|
21833
|
+
parenthesizeLeadingTypeArgument: ts.identity,
|
|
21651
21834
|
};
|
|
21652
21835
|
})(ts || (ts = {}));
|
|
21653
21836
|
/* @internal */
|
|
@@ -21787,6 +21970,8 @@ var ts;
|
|
|
21787
21970
|
var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
|
|
21788
21971
|
var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
|
|
21789
21972
|
var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
|
|
21973
|
+
var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
|
|
21974
|
+
var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
|
|
21790
21975
|
var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
|
|
21791
21976
|
var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
|
|
21792
21977
|
var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
|
|
@@ -21794,6 +21979,8 @@ var ts;
|
|
|
21794
21979
|
var factory = {
|
|
21795
21980
|
get parenthesizer() { return parenthesizerRules(); },
|
|
21796
21981
|
get converters() { return converters(); },
|
|
21982
|
+
baseFactory: baseFactory,
|
|
21983
|
+
flags: flags,
|
|
21797
21984
|
createNodeArray: createNodeArray,
|
|
21798
21985
|
createNumericLiteral: createNumericLiteral,
|
|
21799
21986
|
createBigIntLiteral: createBigIntLiteral,
|
|
@@ -22069,10 +22256,10 @@ var ts;
|
|
|
22069
22256
|
// lazily load factory members for JSDoc types with similar structure
|
|
22070
22257
|
get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
|
|
22071
22258
|
get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
|
|
22072
|
-
get createJSDocNonNullableType() { return
|
|
22073
|
-
get updateJSDocNonNullableType() { return
|
|
22074
|
-
get createJSDocNullableType() { return
|
|
22075
|
-
get updateJSDocNullableType() { return
|
|
22259
|
+
get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
|
|
22260
|
+
get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
|
|
22261
|
+
get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
|
|
22262
|
+
get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
|
|
22076
22263
|
get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
|
|
22077
22264
|
get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
|
|
22078
22265
|
get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
|
|
@@ -23188,7 +23375,7 @@ var ts;
|
|
|
23188
23375
|
// @api
|
|
23189
23376
|
function createArrayTypeNode(elementType) {
|
|
23190
23377
|
var node = createBaseNode(183 /* ArrayType */);
|
|
23191
|
-
node.elementType = parenthesizerRules().
|
|
23378
|
+
node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
|
|
23192
23379
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23193
23380
|
return node;
|
|
23194
23381
|
}
|
|
@@ -23201,7 +23388,7 @@ var ts;
|
|
|
23201
23388
|
// @api
|
|
23202
23389
|
function createTupleTypeNode(elements) {
|
|
23203
23390
|
var node = createBaseNode(184 /* TupleType */);
|
|
23204
|
-
node.elements = createNodeArray(elements);
|
|
23391
|
+
node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
|
|
23205
23392
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23206
23393
|
return node;
|
|
23207
23394
|
}
|
|
@@ -23233,7 +23420,7 @@ var ts;
|
|
|
23233
23420
|
// @api
|
|
23234
23421
|
function createOptionalTypeNode(type) {
|
|
23235
23422
|
var node = createBaseNode(185 /* OptionalType */);
|
|
23236
|
-
node.type = parenthesizerRules().
|
|
23423
|
+
node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
|
|
23237
23424
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23238
23425
|
return node;
|
|
23239
23426
|
}
|
|
@@ -23256,38 +23443,38 @@ var ts;
|
|
|
23256
23443
|
? update(createRestTypeNode(type), node)
|
|
23257
23444
|
: node;
|
|
23258
23445
|
}
|
|
23259
|
-
function createUnionOrIntersectionTypeNode(kind, types) {
|
|
23446
|
+
function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
|
|
23260
23447
|
var node = createBaseNode(kind);
|
|
23261
|
-
node.types =
|
|
23448
|
+
node.types = factory.createNodeArray(parenthesize(types));
|
|
23262
23449
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23263
23450
|
return node;
|
|
23264
23451
|
}
|
|
23265
|
-
function updateUnionOrIntersectionTypeNode(node, types) {
|
|
23452
|
+
function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
|
|
23266
23453
|
return node.types !== types
|
|
23267
|
-
? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
|
|
23454
|
+
? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
|
|
23268
23455
|
: node;
|
|
23269
23456
|
}
|
|
23270
23457
|
// @api
|
|
23271
23458
|
function createUnionTypeNode(types) {
|
|
23272
|
-
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
|
|
23459
|
+
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23273
23460
|
}
|
|
23274
23461
|
// @api
|
|
23275
23462
|
function updateUnionTypeNode(node, types) {
|
|
23276
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23463
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23277
23464
|
}
|
|
23278
23465
|
// @api
|
|
23279
23466
|
function createIntersectionTypeNode(types) {
|
|
23280
|
-
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
|
|
23467
|
+
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23281
23468
|
}
|
|
23282
23469
|
// @api
|
|
23283
23470
|
function updateIntersectionTypeNode(node, types) {
|
|
23284
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23471
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23285
23472
|
}
|
|
23286
23473
|
// @api
|
|
23287
23474
|
function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
|
|
23288
23475
|
var node = createBaseNode(189 /* ConditionalType */);
|
|
23289
|
-
node.checkType = parenthesizerRules().
|
|
23290
|
-
node.extendsType = parenthesizerRules().
|
|
23476
|
+
node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
|
|
23477
|
+
node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
|
|
23291
23478
|
node.trueType = trueType;
|
|
23292
23479
|
node.falseType = falseType;
|
|
23293
23480
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
@@ -23382,7 +23569,9 @@ var ts;
|
|
|
23382
23569
|
function createTypeOperatorNode(operator, type) {
|
|
23383
23570
|
var node = createBaseNode(193 /* TypeOperator */);
|
|
23384
23571
|
node.operator = operator;
|
|
23385
|
-
node.type =
|
|
23572
|
+
node.type = operator === 145 /* ReadonlyKeyword */ ?
|
|
23573
|
+
parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
|
|
23574
|
+
parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
|
|
23386
23575
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23387
23576
|
return node;
|
|
23388
23577
|
}
|
|
@@ -23395,7 +23584,7 @@ var ts;
|
|
|
23395
23584
|
// @api
|
|
23396
23585
|
function createIndexedAccessTypeNode(objectType, indexType) {
|
|
23397
23586
|
var node = createBaseNode(194 /* IndexedAccessType */);
|
|
23398
|
-
node.objectType = parenthesizerRules().
|
|
23587
|
+
node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
|
|
23399
23588
|
node.indexType = indexType;
|
|
23400
23589
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23401
23590
|
return node;
|
|
@@ -25131,8 +25320,15 @@ var ts;
|
|
|
25131
25320
|
return createBaseNode(kind);
|
|
25132
25321
|
}
|
|
25133
25322
|
// @api
|
|
25134
|
-
// createJSDocNonNullableType
|
|
25135
25323
|
// createJSDocNullableType
|
|
25324
|
+
// createJSDocNonNullableType
|
|
25325
|
+
function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
|
|
25326
|
+
if (postfix === void 0) { postfix = false; }
|
|
25327
|
+
var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
|
|
25328
|
+
node.postfix = postfix;
|
|
25329
|
+
return node;
|
|
25330
|
+
}
|
|
25331
|
+
// @api
|
|
25136
25332
|
// createJSDocOptionalType
|
|
25137
25333
|
// createJSDocVariadicType
|
|
25138
25334
|
// createJSDocNamepathType
|
|
@@ -25144,6 +25340,12 @@ var ts;
|
|
|
25144
25340
|
// @api
|
|
25145
25341
|
// updateJSDocNonNullableType
|
|
25146
25342
|
// updateJSDocNullableType
|
|
25343
|
+
function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
|
|
25344
|
+
return node.type !== type
|
|
25345
|
+
? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
|
|
25346
|
+
: node;
|
|
25347
|
+
}
|
|
25348
|
+
// @api
|
|
25147
25349
|
// updateJSDocOptionalType
|
|
25148
25350
|
// updateJSDocVariadicType
|
|
25149
25351
|
// updateJSDocNamepathType
|
|
@@ -30224,7 +30426,7 @@ var ts;
|
|
|
30224
30426
|
|| ts.isExportDeclaration(node) ? node : undefined;
|
|
30225
30427
|
}
|
|
30226
30428
|
function getImportMetaIfNecessary(sourceFile) {
|
|
30227
|
-
return sourceFile.flags &
|
|
30429
|
+
return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
|
|
30228
30430
|
walkTreeForImportMeta(sourceFile) :
|
|
30229
30431
|
undefined;
|
|
30230
30432
|
}
|
|
@@ -30879,7 +31081,7 @@ var ts;
|
|
|
30879
31081
|
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
30880
31082
|
// Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
|
|
30881
31083
|
// We will manually port the flag to the new source file.
|
|
30882
|
-
newSourceFile.flags |= (sourceFile.flags &
|
|
31084
|
+
newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
|
|
30883
31085
|
return newSourceFile;
|
|
30884
31086
|
}
|
|
30885
31087
|
ts.updateSourceFile = updateSourceFile;
|
|
@@ -31163,10 +31365,10 @@ var ts;
|
|
|
31163
31365
|
switch (scriptKind) {
|
|
31164
31366
|
case 1 /* JS */:
|
|
31165
31367
|
case 2 /* JSX */:
|
|
31166
|
-
contextFlags =
|
|
31368
|
+
contextFlags = 262144 /* JavaScriptFile */;
|
|
31167
31369
|
break;
|
|
31168
31370
|
case 6 /* JSON */:
|
|
31169
|
-
contextFlags =
|
|
31371
|
+
contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
|
|
31170
31372
|
break;
|
|
31171
31373
|
default:
|
|
31172
31374
|
contextFlags = 0 /* None */;
|
|
@@ -31201,7 +31403,7 @@ var ts;
|
|
|
31201
31403
|
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
|
|
31202
31404
|
var isDeclarationFile = isDeclarationFileName(fileName);
|
|
31203
31405
|
if (isDeclarationFile) {
|
|
31204
|
-
contextFlags |=
|
|
31406
|
+
contextFlags |= 16777216 /* Ambient */;
|
|
31205
31407
|
}
|
|
31206
31408
|
sourceFlags = contextFlags;
|
|
31207
31409
|
// Prime the scanner.
|
|
@@ -31240,7 +31442,7 @@ var ts;
|
|
|
31240
31442
|
node.jsDoc = jsDoc;
|
|
31241
31443
|
if (hasDeprecatedTag) {
|
|
31242
31444
|
hasDeprecatedTag = false;
|
|
31243
|
-
node.flags |=
|
|
31445
|
+
node.flags |= 268435456 /* Deprecated */;
|
|
31244
31446
|
}
|
|
31245
31447
|
return node;
|
|
31246
31448
|
}
|
|
@@ -31435,6 +31637,12 @@ var ts;
|
|
|
31435
31637
|
function disallowInAnd(func) {
|
|
31436
31638
|
return doInsideOfContext(4096 /* DisallowInContext */, func);
|
|
31437
31639
|
}
|
|
31640
|
+
function allowConditionalTypesAnd(func) {
|
|
31641
|
+
return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31642
|
+
}
|
|
31643
|
+
function disallowConditionalTypesAnd(func) {
|
|
31644
|
+
return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31645
|
+
}
|
|
31438
31646
|
function doInYieldContext(func) {
|
|
31439
31647
|
return doInsideOfContext(8192 /* YieldContext */, func);
|
|
31440
31648
|
}
|
|
@@ -31462,6 +31670,9 @@ var ts;
|
|
|
31462
31670
|
function inDisallowInContext() {
|
|
31463
31671
|
return inContext(4096 /* DisallowInContext */);
|
|
31464
31672
|
}
|
|
31673
|
+
function inDisallowConditionalTypesContext() {
|
|
31674
|
+
return inContext(65536 /* DisallowConditionalTypesContext */);
|
|
31675
|
+
}
|
|
31465
31676
|
function inDecoratorContext() {
|
|
31466
31677
|
return inContext(16384 /* DecoratorContext */);
|
|
31467
31678
|
}
|
|
@@ -31846,7 +32057,7 @@ var ts;
|
|
|
31846
32057
|
// flag so that we don't mark any subsequent nodes.
|
|
31847
32058
|
if (parseErrorBeforeNextFinishedNode) {
|
|
31848
32059
|
parseErrorBeforeNextFinishedNode = false;
|
|
31849
|
-
node.flags |=
|
|
32060
|
+
node.flags |= 131072 /* ThisNodeHasError */;
|
|
31850
32061
|
}
|
|
31851
32062
|
return node;
|
|
31852
32063
|
}
|
|
@@ -32304,7 +32515,7 @@ var ts;
|
|
|
32304
32515
|
// differently depending on what mode it is in.
|
|
32305
32516
|
//
|
|
32306
32517
|
// This also applies to all our other context flags as well.
|
|
32307
|
-
var nodeContextFlags = node.flags &
|
|
32518
|
+
var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
|
|
32308
32519
|
if (nodeContextFlags !== contextFlags) {
|
|
32309
32520
|
return undefined;
|
|
32310
32521
|
}
|
|
@@ -32563,7 +32774,6 @@ var ts;
|
|
|
32563
32774
|
default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
|
|
32564
32775
|
}
|
|
32565
32776
|
}
|
|
32566
|
-
// Parses a comma-delimited list of elements
|
|
32567
32777
|
function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
|
|
32568
32778
|
var saveParsingContext = parsingContext;
|
|
32569
32779
|
parsingContext |= 1 << kind;
|
|
@@ -32573,7 +32783,11 @@ var ts;
|
|
|
32573
32783
|
while (true) {
|
|
32574
32784
|
if (isListElement(kind, /*inErrorRecovery*/ false)) {
|
|
32575
32785
|
var startPos = scanner.getStartPos();
|
|
32576
|
-
|
|
32786
|
+
var result = parseListElement(kind, parseElement);
|
|
32787
|
+
if (!result) {
|
|
32788
|
+
return undefined;
|
|
32789
|
+
}
|
|
32790
|
+
list.push(result);
|
|
32577
32791
|
commaStart = scanner.getTokenPos();
|
|
32578
32792
|
if (parseOptional(27 /* CommaToken */)) {
|
|
32579
32793
|
// No need to check for a zero length node since we know we parsed a comma
|
|
@@ -32826,7 +33040,7 @@ var ts;
|
|
|
32826
33040
|
function parseJSDocNonNullableType() {
|
|
32827
33041
|
var pos = getNodePos();
|
|
32828
33042
|
nextToken();
|
|
32829
|
-
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
|
|
33043
|
+
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
|
|
32830
33044
|
}
|
|
32831
33045
|
function parseJSDocUnknownOrNullableType() {
|
|
32832
33046
|
var pos = getNodePos();
|
|
@@ -32850,7 +33064,7 @@ var ts;
|
|
|
32850
33064
|
return finishNode(factory.createJSDocUnknownType(), pos);
|
|
32851
33065
|
}
|
|
32852
33066
|
else {
|
|
32853
|
-
return finishNode(factory.createJSDocNullableType(parseType()), pos);
|
|
33067
|
+
return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
|
|
32854
33068
|
}
|
|
32855
33069
|
}
|
|
32856
33070
|
function parseJSDocFunctionType() {
|
|
@@ -32978,13 +33192,20 @@ var ts;
|
|
|
32978
33192
|
}
|
|
32979
33193
|
return name;
|
|
32980
33194
|
}
|
|
32981
|
-
function
|
|
32982
|
-
|
|
33195
|
+
function isParameterNameStart() {
|
|
33196
|
+
// Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing
|
|
33197
|
+
// them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later
|
|
33198
|
+
// complaining about the use of the keywords.
|
|
33199
|
+
return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */;
|
|
33200
|
+
}
|
|
33201
|
+
function parseParameter(inOuterAwaitContext) {
|
|
33202
|
+
return parseParameterWorker(inOuterAwaitContext);
|
|
32983
33203
|
}
|
|
32984
|
-
function
|
|
32985
|
-
return parseParameterWorker(/*
|
|
33204
|
+
function parseParameterForSpeculation(inOuterAwaitContext) {
|
|
33205
|
+
return parseParameterWorker(inOuterAwaitContext, /*allowAmbiguity*/ false);
|
|
32986
33206
|
}
|
|
32987
|
-
function parseParameterWorker(inOuterAwaitContext) {
|
|
33207
|
+
function parseParameterWorker(inOuterAwaitContext, allowAmbiguity) {
|
|
33208
|
+
if (allowAmbiguity === void 0) { allowAmbiguity = true; }
|
|
32988
33209
|
var pos = getNodePos();
|
|
32989
33210
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
32990
33211
|
// FormalParameter [Yield,Await]:
|
|
@@ -33005,13 +33226,17 @@ var ts;
|
|
|
33005
33226
|
var savedTopLevel = topLevel;
|
|
33006
33227
|
topLevel = false;
|
|
33007
33228
|
var modifiers = parseModifiers();
|
|
33008
|
-
var
|
|
33229
|
+
var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */);
|
|
33230
|
+
if (!allowAmbiguity && !isParameterNameStart()) {
|
|
33231
|
+
return undefined;
|
|
33232
|
+
}
|
|
33233
|
+
var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
|
|
33009
33234
|
topLevel = savedTopLevel;
|
|
33010
33235
|
return node;
|
|
33011
33236
|
}
|
|
33012
33237
|
function parseReturnType(returnToken, isType) {
|
|
33013
33238
|
if (shouldParseReturnType(returnToken, isType)) {
|
|
33014
|
-
return parseTypeOrTypePredicate
|
|
33239
|
+
return allowConditionalTypesAnd(parseTypeOrTypePredicate);
|
|
33015
33240
|
}
|
|
33016
33241
|
}
|
|
33017
33242
|
function shouldParseReturnType(returnToken, isType) {
|
|
@@ -33030,7 +33255,7 @@ var ts;
|
|
|
33030
33255
|
}
|
|
33031
33256
|
return false;
|
|
33032
33257
|
}
|
|
33033
|
-
function parseParametersWorker(flags) {
|
|
33258
|
+
function parseParametersWorker(flags, allowAmbiguity) {
|
|
33034
33259
|
// FormalParameters [Yield,Await]: (modified)
|
|
33035
33260
|
// [empty]
|
|
33036
33261
|
// FormalParameterList[?Yield,Await]
|
|
@@ -33050,7 +33275,7 @@ var ts;
|
|
|
33050
33275
|
setAwaitContext(!!(flags & 2 /* Await */));
|
|
33051
33276
|
var parameters = flags & 32 /* JSDoc */ ?
|
|
33052
33277
|
parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) :
|
|
33053
|
-
parseDelimitedList(16 /* Parameters */,
|
|
33278
|
+
parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); });
|
|
33054
33279
|
setYieldContext(savedYieldContext);
|
|
33055
33280
|
setAwaitContext(savedAwaitContext);
|
|
33056
33281
|
return parameters;
|
|
@@ -33072,7 +33297,7 @@ var ts;
|
|
|
33072
33297
|
if (!parseExpected(20 /* OpenParenToken */)) {
|
|
33073
33298
|
return createMissingList();
|
|
33074
33299
|
}
|
|
33075
|
-
var parameters = parseParametersWorker(flags);
|
|
33300
|
+
var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true);
|
|
33076
33301
|
parseExpected(21 /* CloseParenToken */);
|
|
33077
33302
|
return parameters;
|
|
33078
33303
|
}
|
|
@@ -33154,7 +33379,7 @@ var ts;
|
|
|
33154
33379
|
return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */;
|
|
33155
33380
|
}
|
|
33156
33381
|
function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
|
|
33157
|
-
var parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
|
|
33382
|
+
var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */);
|
|
33158
33383
|
var type = parseTypeAnnotation();
|
|
33159
33384
|
parseTypeMemberSemicolon();
|
|
33160
33385
|
var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
|
|
@@ -33426,7 +33651,7 @@ var ts;
|
|
|
33426
33651
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
33427
33652
|
}
|
|
33428
33653
|
function parseImportType() {
|
|
33429
|
-
sourceFlags |=
|
|
33654
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
33430
33655
|
var pos = getNodePos();
|
|
33431
33656
|
var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
|
|
33432
33657
|
parseExpected(100 /* ImportKeyword */);
|
|
@@ -33576,7 +33801,7 @@ var ts;
|
|
|
33576
33801
|
switch (token()) {
|
|
33577
33802
|
case 53 /* ExclamationToken */:
|
|
33578
33803
|
nextToken();
|
|
33579
|
-
type = finishNode(factory.createJSDocNonNullableType(type), pos);
|
|
33804
|
+
type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
|
|
33580
33805
|
break;
|
|
33581
33806
|
case 57 /* QuestionToken */:
|
|
33582
33807
|
// If next token is start of a type we have a conditional type
|
|
@@ -33584,7 +33809,7 @@ var ts;
|
|
|
33584
33809
|
return type;
|
|
33585
33810
|
}
|
|
33586
33811
|
nextToken();
|
|
33587
|
-
type = finishNode(factory.createJSDocNullableType(type), pos);
|
|
33812
|
+
type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
|
|
33588
33813
|
break;
|
|
33589
33814
|
case 22 /* OpenBracketToken */:
|
|
33590
33815
|
parseExpected(22 /* OpenBracketToken */);
|
|
@@ -33609,12 +33834,20 @@ var ts;
|
|
|
33609
33834
|
parseExpected(operator);
|
|
33610
33835
|
return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
|
|
33611
33836
|
}
|
|
33837
|
+
function tryParseConstraintOfInferType() {
|
|
33838
|
+
if (parseOptional(94 /* ExtendsKeyword */)) {
|
|
33839
|
+
var constraint = disallowConditionalTypesAnd(parseType);
|
|
33840
|
+
if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
|
|
33841
|
+
return constraint;
|
|
33842
|
+
}
|
|
33843
|
+
}
|
|
33844
|
+
}
|
|
33612
33845
|
function parseTypeParameterOfInferType() {
|
|
33613
33846
|
var pos = getNodePos();
|
|
33614
|
-
|
|
33615
|
-
|
|
33616
|
-
/*
|
|
33617
|
-
|
|
33847
|
+
var name = parseIdentifier();
|
|
33848
|
+
var constraint = tryParse(tryParseConstraintOfInferType);
|
|
33849
|
+
var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
|
|
33850
|
+
return finishNode(node, pos);
|
|
33618
33851
|
}
|
|
33619
33852
|
function parseInferType() {
|
|
33620
33853
|
var pos = getNodePos();
|
|
@@ -33631,7 +33864,7 @@ var ts;
|
|
|
33631
33864
|
case 137 /* InferKeyword */:
|
|
33632
33865
|
return parseInferType();
|
|
33633
33866
|
}
|
|
33634
|
-
return parsePostfixTypeOrHigher
|
|
33867
|
+
return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
|
|
33635
33868
|
}
|
|
33636
33869
|
function parseFunctionOrConstructorTypeToError(isInUnionType) {
|
|
33637
33870
|
// the function type and constructor type shorthand notation
|
|
@@ -33761,23 +33994,21 @@ var ts;
|
|
|
33761
33994
|
return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
|
|
33762
33995
|
}
|
|
33763
33996
|
function parseType() {
|
|
33764
|
-
|
|
33765
|
-
|
|
33766
|
-
|
|
33767
|
-
}
|
|
33768
|
-
function parseTypeWorker(noConditionalTypes) {
|
|
33997
|
+
if (contextFlags & 40960 /* TypeExcludesFlags */) {
|
|
33998
|
+
return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
|
|
33999
|
+
}
|
|
33769
34000
|
if (isStartOfFunctionTypeOrConstructorType()) {
|
|
33770
34001
|
return parseFunctionOrConstructorType();
|
|
33771
34002
|
}
|
|
33772
34003
|
var pos = getNodePos();
|
|
33773
34004
|
var type = parseUnionTypeOrHigher();
|
|
33774
|
-
if (!
|
|
34005
|
+
if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
|
|
33775
34006
|
// The type following 'extends' is not permitted to be another conditional type
|
|
33776
|
-
var extendsType =
|
|
34007
|
+
var extendsType = disallowConditionalTypesAnd(parseType);
|
|
33777
34008
|
parseExpected(57 /* QuestionToken */);
|
|
33778
|
-
var trueType =
|
|
34009
|
+
var trueType = allowConditionalTypesAnd(parseType);
|
|
33779
34010
|
parseExpected(58 /* ColonToken */);
|
|
33780
|
-
var falseType =
|
|
34011
|
+
var falseType = allowConditionalTypesAnd(parseType);
|
|
33781
34012
|
return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
|
|
33782
34013
|
}
|
|
33783
34014
|
return type;
|
|
@@ -34204,7 +34435,16 @@ var ts;
|
|
|
34204
34435
|
parameters = createMissingList();
|
|
34205
34436
|
}
|
|
34206
34437
|
else {
|
|
34207
|
-
|
|
34438
|
+
if (!allowAmbiguity) {
|
|
34439
|
+
var maybeParameters = parseParametersWorker(isAsync, allowAmbiguity);
|
|
34440
|
+
if (!maybeParameters) {
|
|
34441
|
+
return undefined;
|
|
34442
|
+
}
|
|
34443
|
+
parameters = maybeParameters;
|
|
34444
|
+
}
|
|
34445
|
+
else {
|
|
34446
|
+
parameters = parseParametersWorker(isAsync, allowAmbiguity);
|
|
34447
|
+
}
|
|
34208
34448
|
if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) {
|
|
34209
34449
|
return undefined;
|
|
34210
34450
|
}
|
|
@@ -34605,7 +34845,7 @@ var ts;
|
|
|
34605
34845
|
// var foo3 = require("subfolder
|
|
34606
34846
|
// import * as foo1 from "module-from-node
|
|
34607
34847
|
// We want this import to be a statement rather than import call expression
|
|
34608
|
-
sourceFlags |=
|
|
34848
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
34609
34849
|
expression = parseTokenNode();
|
|
34610
34850
|
}
|
|
34611
34851
|
else if (lookAhead(nextTokenIsDot)) {
|
|
@@ -34613,7 +34853,7 @@ var ts;
|
|
|
34613
34853
|
nextToken(); // advance past the 'import'
|
|
34614
34854
|
nextToken(); // advance past the dot
|
|
34615
34855
|
expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
|
|
34616
|
-
sourceFlags |=
|
|
34856
|
+
sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
|
|
34617
34857
|
}
|
|
34618
34858
|
else {
|
|
34619
34859
|
expression = parseMemberExpressionOrHigher();
|
|
@@ -34829,7 +35069,7 @@ var ts;
|
|
|
34829
35069
|
return finishNode(factory.createJsxOpeningFragment(), pos);
|
|
34830
35070
|
}
|
|
34831
35071
|
var tagName = parseJsxElementName();
|
|
34832
|
-
var typeArguments = (contextFlags &
|
|
35072
|
+
var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
|
|
34833
35073
|
var attributes = parseJsxAttributes();
|
|
34834
35074
|
var node;
|
|
34835
35075
|
if (token() === 31 /* GreaterThanToken */) {
|
|
@@ -35107,7 +35347,7 @@ var ts;
|
|
|
35107
35347
|
return result;
|
|
35108
35348
|
}
|
|
35109
35349
|
function parseTypeArgumentsInExpression() {
|
|
35110
|
-
if ((contextFlags &
|
|
35350
|
+
if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
|
|
35111
35351
|
// TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
|
|
35112
35352
|
return undefined;
|
|
35113
35353
|
}
|
|
@@ -35503,7 +35743,7 @@ var ts;
|
|
|
35503
35743
|
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35504
35744
|
var expression = allowInAnd(parseExpression);
|
|
35505
35745
|
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35506
|
-
var statement = doInsideOfContext(
|
|
35746
|
+
var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
|
|
35507
35747
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35508
35748
|
}
|
|
35509
35749
|
function parseCaseClause() {
|
|
@@ -35878,16 +36118,16 @@ var ts;
|
|
|
35878
36118
|
if (isAmbient) {
|
|
35879
36119
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
35880
36120
|
var m = _a[_i];
|
|
35881
|
-
m.flags |=
|
|
36121
|
+
m.flags |= 16777216 /* Ambient */;
|
|
35882
36122
|
}
|
|
35883
|
-
return doInsideOfContext(
|
|
36123
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
|
|
35884
36124
|
}
|
|
35885
36125
|
else {
|
|
35886
36126
|
return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
|
|
35887
36127
|
}
|
|
35888
36128
|
}
|
|
35889
36129
|
function tryReuseAmbientDeclaration() {
|
|
35890
|
-
return doInsideOfContext(
|
|
36130
|
+
return doInsideOfContext(16777216 /* Ambient */, function () {
|
|
35891
36131
|
var node = currentNode(parsingContext);
|
|
35892
36132
|
if (node) {
|
|
35893
36133
|
return consumeNode(node);
|
|
@@ -36354,9 +36594,9 @@ var ts;
|
|
|
36354
36594
|
if (isAmbient) {
|
|
36355
36595
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
36356
36596
|
var m = _a[_i];
|
|
36357
|
-
m.flags |=
|
|
36597
|
+
m.flags |= 16777216 /* Ambient */;
|
|
36358
36598
|
}
|
|
36359
|
-
return doInsideOfContext(
|
|
36599
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
|
|
36360
36600
|
}
|
|
36361
36601
|
else {
|
|
36362
36602
|
return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -36921,7 +37161,7 @@ var ts;
|
|
|
36921
37161
|
function parseJSDocTypeExpression(mayOmitBraces) {
|
|
36922
37162
|
var pos = getNodePos();
|
|
36923
37163
|
var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
|
|
36924
|
-
var type = doInsideOfContext(
|
|
37164
|
+
var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
36925
37165
|
if (!mayOmitBraces || hasBrace) {
|
|
36926
37166
|
parseExpectedJSDoc(19 /* CloseBraceToken */);
|
|
36927
37167
|
}
|
|
@@ -36950,7 +37190,7 @@ var ts;
|
|
|
36950
37190
|
JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
|
|
36951
37191
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
36952
37192
|
initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
36953
|
-
var jsDoc = doInsideOfContext(
|
|
37193
|
+
var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36954
37194
|
var sourceFile = { languageVariant: 0 /* Standard */, text: content };
|
|
36955
37195
|
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
|
|
36956
37196
|
clearState();
|
|
@@ -36961,9 +37201,9 @@ var ts;
|
|
|
36961
37201
|
var saveToken = currentToken;
|
|
36962
37202
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
36963
37203
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
36964
|
-
var comment = doInsideOfContext(
|
|
37204
|
+
var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36965
37205
|
ts.setParent(comment, parent);
|
|
36966
|
-
if (contextFlags &
|
|
37206
|
+
if (contextFlags & 262144 /* JavaScriptFile */) {
|
|
36967
37207
|
if (!jsDocDiagnostics) {
|
|
36968
37208
|
jsDocDiagnostics = [];
|
|
36969
37209
|
}
|
|
@@ -37779,7 +38019,7 @@ var ts;
|
|
|
37779
38019
|
if (isBracketed) {
|
|
37780
38020
|
skipWhitespace();
|
|
37781
38021
|
parseExpected(63 /* EqualsToken */);
|
|
37782
|
-
defaultType = doInsideOfContext(
|
|
38022
|
+
defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
37783
38023
|
parseExpected(23 /* CloseBracketToken */);
|
|
37784
38024
|
}
|
|
37785
38025
|
if (ts.nodeIsMissing(name)) {
|
|
@@ -45533,6 +45773,7 @@ var ts;
|
|
|
45533
45773
|
case 261 /* ModuleDeclaration */:
|
|
45534
45774
|
case 259 /* TypeAliasDeclaration */:
|
|
45535
45775
|
case 195 /* MappedType */:
|
|
45776
|
+
case 176 /* IndexSignature */:
|
|
45536
45777
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45537
45778
|
case 305 /* SourceFile */:
|
|
45538
45779
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45551,7 +45792,6 @@ var ts;
|
|
|
45551
45792
|
case 317 /* JSDocFunctionType */:
|
|
45552
45793
|
case 179 /* FunctionType */:
|
|
45553
45794
|
case 175 /* ConstructSignature */:
|
|
45554
|
-
case 176 /* IndexSignature */:
|
|
45555
45795
|
case 180 /* ConstructorType */:
|
|
45556
45796
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45557
45797
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -45667,7 +45907,7 @@ var ts;
|
|
|
45667
45907
|
function setExportContextFlag(node) {
|
|
45668
45908
|
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
|
45669
45909
|
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
|
45670
|
-
if (node.flags &
|
|
45910
|
+
if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
|
|
45671
45911
|
node.flags |= 64 /* ExportContext */;
|
|
45672
45912
|
}
|
|
45673
45913
|
else {
|
|
@@ -45870,8 +46110,8 @@ var ts;
|
|
|
45870
46110
|
function checkContextualIdentifier(node) {
|
|
45871
46111
|
// Report error only if there are no parse errors in file
|
|
45872
46112
|
if (!file.parseDiagnostics.length &&
|
|
45873
|
-
!(node.flags &
|
|
45874
|
-
!(node.flags &
|
|
46113
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
46114
|
+
!(node.flags & 8388608 /* JSDoc */) &&
|
|
45875
46115
|
!ts.isIdentifierName(node)) {
|
|
45876
46116
|
// strict mode identifiers
|
|
45877
46117
|
if (inStrictMode &&
|
|
@@ -46900,7 +47140,7 @@ var ts;
|
|
|
46900
47140
|
if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
|
|
46901
47141
|
return;
|
|
46902
47142
|
}
|
|
46903
|
-
if (inStrictMode && !(node.flags &
|
|
47143
|
+
if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
|
|
46904
47144
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
|
46905
47145
|
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
|
46906
47146
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
@@ -46919,7 +47159,7 @@ var ts;
|
|
|
46919
47159
|
}
|
|
46920
47160
|
}
|
|
46921
47161
|
function bindFunctionDeclaration(node) {
|
|
46922
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47162
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46923
47163
|
if (ts.isAsyncFunction(node)) {
|
|
46924
47164
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46925
47165
|
}
|
|
@@ -46934,7 +47174,7 @@ var ts;
|
|
|
46934
47174
|
}
|
|
46935
47175
|
}
|
|
46936
47176
|
function bindFunctionExpression(node) {
|
|
46937
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47177
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46938
47178
|
if (ts.isAsyncFunction(node)) {
|
|
46939
47179
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46940
47180
|
}
|
|
@@ -46947,7 +47187,7 @@ var ts;
|
|
|
46947
47187
|
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
|
|
46948
47188
|
}
|
|
46949
47189
|
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
|
|
46950
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47190
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
|
|
46951
47191
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46952
47192
|
}
|
|
46953
47193
|
if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
|
@@ -47020,7 +47260,7 @@ var ts;
|
|
|
47020
47260
|
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
|
|
47021
47261
|
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
|
|
47022
47262
|
var isError_1 = ts.unreachableCodeIsError(options) &&
|
|
47023
|
-
!(node.flags &
|
|
47263
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
47024
47264
|
(!ts.isVariableStatement(node) ||
|
|
47025
47265
|
!!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
|
|
47026
47266
|
node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
|
|
@@ -47920,7 +48160,7 @@ var ts;
|
|
|
47920
48160
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
47921
48161
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
47922
48162
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
47923
|
-
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags &
|
|
48163
|
+
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
47924
48164
|
(diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
|
|
47925
48165
|
}
|
|
47926
48166
|
});
|
|
@@ -48371,7 +48611,7 @@ var ts;
|
|
|
48371
48611
|
return diagnostic;
|
|
48372
48612
|
}
|
|
48373
48613
|
function isDeprecatedSymbol(symbol) {
|
|
48374
|
-
return !!(getDeclarationNodeFlagsFromSymbol(symbol) &
|
|
48614
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
|
|
48375
48615
|
}
|
|
48376
48616
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
48377
48617
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
@@ -48599,7 +48839,7 @@ var ts;
|
|
|
48599
48839
|
else {
|
|
48600
48840
|
// find a module that about to be augmented
|
|
48601
48841
|
// do not validate names of augmentations that are defined in ambient context
|
|
48602
|
-
var moduleNotFoundError = !(moduleName.parent.parent.flags &
|
|
48842
|
+
var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
|
|
48603
48843
|
? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
|
|
48604
48844
|
: undefined;
|
|
48605
48845
|
var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
|
|
@@ -48713,7 +48953,7 @@ var ts;
|
|
|
48713
48953
|
if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
|
|
48714
48954
|
(!ts.outFile(compilerOptions)) ||
|
|
48715
48955
|
isInTypeQuery(usage) ||
|
|
48716
|
-
declaration.flags &
|
|
48956
|
+
declaration.flags & 16777216 /* Ambient */) {
|
|
48717
48957
|
// nodes are in different files and order cannot be determined
|
|
48718
48958
|
return true;
|
|
48719
48959
|
}
|
|
@@ -48775,7 +49015,7 @@ var ts;
|
|
|
48775
49015
|
if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
|
|
48776
49016
|
return true;
|
|
48777
49017
|
}
|
|
48778
|
-
if (!!(usage.flags &
|
|
49018
|
+
if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
|
|
48779
49019
|
return true;
|
|
48780
49020
|
}
|
|
48781
49021
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
@@ -49040,7 +49280,7 @@ var ts;
|
|
|
49040
49280
|
// falls through
|
|
49041
49281
|
case 261 /* ModuleDeclaration */:
|
|
49042
49282
|
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
49043
|
-
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags &
|
|
49283
|
+
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
49044
49284
|
// It's an external module. First see if the module has an export default and if the local
|
|
49045
49285
|
// name of that export default matches.
|
|
49046
49286
|
if (result = moduleExports.get("default" /* Default */)) {
|
|
@@ -49363,7 +49603,7 @@ var ts;
|
|
|
49363
49603
|
}
|
|
49364
49604
|
}
|
|
49365
49605
|
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49366
|
-
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags &
|
|
49606
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
|
|
49367
49607
|
var merged = getMergedSymbol(result);
|
|
49368
49608
|
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49369
49609
|
errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
|
|
@@ -49618,7 +49858,7 @@ var ts;
|
|
|
49618
49858
|
var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); });
|
|
49619
49859
|
if (declaration === undefined)
|
|
49620
49860
|
return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
|
|
49621
|
-
if (!(declaration.flags &
|
|
49861
|
+
if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
|
|
49622
49862
|
var diagnosticMessage = void 0;
|
|
49623
49863
|
var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
|
|
49624
49864
|
if (result.flags & 2 /* BlockScopedVariable */) {
|
|
@@ -50129,27 +50369,27 @@ var ts;
|
|
|
50129
50369
|
function resolveAlias(symbol) {
|
|
50130
50370
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50131
50371
|
var links = getSymbolLinks(symbol);
|
|
50132
|
-
if (!links.
|
|
50133
|
-
links.
|
|
50372
|
+
if (!links.aliasTarget) {
|
|
50373
|
+
links.aliasTarget = resolvingSymbol;
|
|
50134
50374
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50135
50375
|
if (!node)
|
|
50136
50376
|
return ts.Debug.fail();
|
|
50137
50377
|
var target = getTargetOfAliasDeclaration(node);
|
|
50138
|
-
if (links.
|
|
50139
|
-
links.
|
|
50378
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50379
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50140
50380
|
}
|
|
50141
50381
|
else {
|
|
50142
50382
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50143
50383
|
}
|
|
50144
50384
|
}
|
|
50145
|
-
else if (links.
|
|
50146
|
-
links.
|
|
50385
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50386
|
+
links.aliasTarget = unknownSymbol;
|
|
50147
50387
|
}
|
|
50148
|
-
return links.
|
|
50388
|
+
return links.aliasTarget;
|
|
50149
50389
|
}
|
|
50150
50390
|
function tryResolveAlias(symbol) {
|
|
50151
50391
|
var links = getSymbolLinks(symbol);
|
|
50152
|
-
if (links.
|
|
50392
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50153
50393
|
return resolveAlias(symbol);
|
|
50154
50394
|
}
|
|
50155
50395
|
return undefined;
|
|
@@ -50391,7 +50631,7 @@ var ts;
|
|
|
50391
50631
|
}
|
|
50392
50632
|
}
|
|
50393
50633
|
function getAssignmentDeclarationLocation(node) {
|
|
50394
|
-
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags &
|
|
50634
|
+
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
|
|
50395
50635
|
if (typeAlias) {
|
|
50396
50636
|
return;
|
|
50397
50637
|
}
|
|
@@ -51859,7 +52099,20 @@ var ts;
|
|
|
51859
52099
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
51860
52100
|
if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
|
|
51861
52101
|
context.approximateLength += (ts.symbolName(type.symbol).length + 6);
|
|
51862
|
-
|
|
52102
|
+
var constraintNode = void 0;
|
|
52103
|
+
var constraint = getConstraintOfTypeParameter(type);
|
|
52104
|
+
if (constraint) {
|
|
52105
|
+
// If the infer type has a constraint that is not the same as the constraint
|
|
52106
|
+
// we would have normally inferred based on context, we emit the constraint
|
|
52107
|
+
// using `infer T extends ?`. We omit inferred constraints from type references
|
|
52108
|
+
// as they may be elided.
|
|
52109
|
+
var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
|
|
52110
|
+
if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
|
|
52111
|
+
context.approximateLength += 9;
|
|
52112
|
+
constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
52113
|
+
}
|
|
52114
|
+
}
|
|
52115
|
+
return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
|
|
51863
52116
|
}
|
|
51864
52117
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
|
|
51865
52118
|
type.flags & 262144 /* TypeParameter */ &&
|
|
@@ -51933,13 +52186,37 @@ var ts;
|
|
|
51933
52186
|
return ts.Debug.fail("Should be unreachable.");
|
|
51934
52187
|
function conditionalTypeToTypeNode(type) {
|
|
51935
52188
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52189
|
+
context.approximateLength += 15;
|
|
52190
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52191
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52192
|
+
var name = typeParameterToName(newParam, context);
|
|
52193
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52194
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52195
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52196
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52197
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52198
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52199
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52200
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52201
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52202
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52203
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52204
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52205
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52206
|
+
// this is potentially simplifiable to
|
|
52207
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52208
|
+
// but that may confuse users who read the output more.
|
|
52209
|
+
// On the other hand,
|
|
52210
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52211
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52212
|
+
return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
|
|
52213
|
+
}
|
|
51936
52214
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
51937
52215
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
51938
52216
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
51939
52217
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
51940
52218
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
51941
52219
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
51942
|
-
context.approximateLength += 15;
|
|
51943
52220
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
51944
52221
|
}
|
|
51945
52222
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -53815,7 +54092,7 @@ var ts;
|
|
|
53815
54092
|
newModifierFlags |= 1 /* Export */;
|
|
53816
54093
|
}
|
|
53817
54094
|
if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
|
|
53818
|
-
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags &
|
|
54095
|
+
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
|
|
53819
54096
|
(ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
|
|
53820
54097
|
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
|
|
53821
54098
|
newModifierFlags |= 2 /* Ambient */;
|
|
@@ -54785,7 +55062,7 @@ var ts;
|
|
|
54785
55062
|
var parent = getDeclarationContainer(node);
|
|
54786
55063
|
// If the node is not exported or it is not ambient module element (except import declaration)
|
|
54787
55064
|
if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
|
|
54788
|
-
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags &
|
|
55065
|
+
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
|
|
54789
55066
|
return isGlobalSourceFile(parent);
|
|
54790
55067
|
}
|
|
54791
55068
|
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
|
|
@@ -55125,7 +55402,7 @@ var ts;
|
|
|
55125
55402
|
}
|
|
55126
55403
|
var pattern = declaration.parent;
|
|
55127
55404
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
55128
|
-
if (strictNullChecks && declaration.flags &
|
|
55405
|
+
if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
55129
55406
|
parentType = getNonNullableType(parentType);
|
|
55130
55407
|
}
|
|
55131
55408
|
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
|
|
@@ -55241,7 +55518,7 @@ var ts;
|
|
|
55241
55518
|
}
|
|
55242
55519
|
if ((noImplicitAny || ts.isInJSFile(declaration)) &&
|
|
55243
55520
|
ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
|
|
55244
|
-
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags &
|
|
55521
|
+
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
55245
55522
|
// If --noImplicitAny is on or the declaration is in a Javascript file,
|
|
55246
55523
|
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
|
|
55247
55524
|
// initializer or a 'null' or 'undefined' initializer.
|
|
@@ -56697,7 +56974,7 @@ var ts;
|
|
|
56697
56974
|
function isLiteralEnumMember(member) {
|
|
56698
56975
|
var expr = member.initializer;
|
|
56699
56976
|
if (!expr) {
|
|
56700
|
-
return !(member.flags &
|
|
56977
|
+
return !(member.flags & 16777216 /* Ambient */);
|
|
56701
56978
|
}
|
|
56702
56979
|
switch (expr.kind) {
|
|
56703
56980
|
case 10 /* StringLiteral */:
|
|
@@ -59330,7 +59607,7 @@ var ts;
|
|
|
59330
59607
|
function getConstraintDeclaration(type) {
|
|
59331
59608
|
return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
|
|
59332
59609
|
}
|
|
59333
|
-
function getInferredTypeParameterConstraint(typeParameter) {
|
|
59610
|
+
function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
|
|
59334
59611
|
var _a;
|
|
59335
59612
|
var inferences;
|
|
59336
59613
|
if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
|
|
@@ -59342,7 +59619,7 @@ var ts;
|
|
|
59342
59619
|
// corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
|
|
59343
59620
|
// present, we form an intersection of the inferred constraint types.
|
|
59344
59621
|
var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
|
|
59345
|
-
if (grandParent.kind === 178 /* TypeReference */) {
|
|
59622
|
+
if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
|
|
59346
59623
|
var typeReference = grandParent;
|
|
59347
59624
|
var typeParameters = getTypeParametersForTypeReference(typeReference);
|
|
59348
59625
|
if (typeParameters) {
|
|
@@ -59764,7 +60041,7 @@ var ts;
|
|
|
59764
60041
|
return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
|
|
59765
60042
|
}
|
|
59766
60043
|
function isJSDocTypeReference(node) {
|
|
59767
|
-
return !!(node.flags &
|
|
60044
|
+
return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
|
|
59768
60045
|
}
|
|
59769
60046
|
function checkNoTypeArguments(node, symbol) {
|
|
59770
60047
|
if (node.typeArguments) {
|
|
@@ -61323,7 +61600,7 @@ var ts;
|
|
|
61323
61600
|
if (ts.isCallLikeExpression(parent)) {
|
|
61324
61601
|
return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
|
|
61325
61602
|
}
|
|
61326
|
-
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) &
|
|
61603
|
+
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
61327
61604
|
}
|
|
61328
61605
|
return true;
|
|
61329
61606
|
}
|
|
@@ -61764,7 +62041,11 @@ var ts;
|
|
|
61764
62041
|
return !root.isDistributive && isSingletonTupleType(root.node.checkType) && isSingletonTupleType(root.node.extendsType);
|
|
61765
62042
|
}
|
|
61766
62043
|
function isSingletonTupleType(node) {
|
|
61767
|
-
return ts.isTupleTypeNode(node) &&
|
|
62044
|
+
return ts.isTupleTypeNode(node) &&
|
|
62045
|
+
ts.length(node.elements) === 1 &&
|
|
62046
|
+
!ts.isOptionalTypeNode(node.elements[0]) &&
|
|
62047
|
+
!ts.isRestTypeNode(node.elements[0]) &&
|
|
62048
|
+
!(ts.isNamedTupleMember(node.elements[0]) && (node.elements[0].questionToken || node.elements[0].dotDotDotToken));
|
|
61768
62049
|
}
|
|
61769
62050
|
/**
|
|
61770
62051
|
* We syntactually check for common nondistributive conditional shapes and unwrap them into
|
|
@@ -62012,7 +62293,7 @@ var ts;
|
|
|
62012
62293
|
links.resolvedSymbol = unknownSymbol;
|
|
62013
62294
|
return links.resolvedType = errorType;
|
|
62014
62295
|
}
|
|
62015
|
-
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags &
|
|
62296
|
+
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
|
|
62016
62297
|
// TODO: Future work: support unions/generics/whatever via a deferred import-type
|
|
62017
62298
|
var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
|
|
62018
62299
|
if (!innerModuleSymbol) {
|
|
@@ -62348,7 +62629,7 @@ var ts;
|
|
|
62348
62629
|
}
|
|
62349
62630
|
// /** @return {this} */
|
|
62350
62631
|
// x.prototype.m = function() { ... }
|
|
62351
|
-
var host = node.flags &
|
|
62632
|
+
var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
|
|
62352
62633
|
if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
|
|
62353
62634
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
|
|
62354
62635
|
}
|
|
@@ -62423,7 +62704,7 @@ var ts;
|
|
|
62423
62704
|
case 143 /* NeverKeyword */:
|
|
62424
62705
|
return neverType;
|
|
62425
62706
|
case 148 /* ObjectKeyword */:
|
|
62426
|
-
return node.flags &
|
|
62707
|
+
return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
|
|
62427
62708
|
case 138 /* IntrinsicKeyword */:
|
|
62428
62709
|
return intrinsicMarkerType;
|
|
62429
62710
|
case 192 /* ThisType */:
|
|
@@ -66284,6 +66565,9 @@ var ts;
|
|
|
66284
66565
|
function createMarkerType(symbol, source, target) {
|
|
66285
66566
|
var mapper = makeUnaryTypeMapper(source, target);
|
|
66286
66567
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
66568
|
+
if (isErrorType(type)) {
|
|
66569
|
+
return type;
|
|
66570
|
+
}
|
|
66287
66571
|
var result = symbol.flags & 524288 /* TypeAlias */ ?
|
|
66288
66572
|
getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) :
|
|
66289
66573
|
createTypeReference(type, instantiateTypes(type.typeParameters, mapper));
|
|
@@ -67297,6 +67581,9 @@ var ts;
|
|
|
67297
67581
|
var inference = inferences[i];
|
|
67298
67582
|
if (t === inference.typeParameter) {
|
|
67299
67583
|
if (fix && !inference.isFixed) {
|
|
67584
|
+
// Before we commit to a particular inference (and thus lock out any further inferences),
|
|
67585
|
+
// we infer from any intra-expression inference sites we have collected.
|
|
67586
|
+
inferFromIntraExpressionSites(context);
|
|
67300
67587
|
clearCachedInferences(inferences);
|
|
67301
67588
|
inference.isFixed = true;
|
|
67302
67589
|
}
|
|
@@ -67313,6 +67600,37 @@ var ts;
|
|
|
67313
67600
|
}
|
|
67314
67601
|
}
|
|
67315
67602
|
}
|
|
67603
|
+
function addIntraExpressionInferenceSite(context, node, type) {
|
|
67604
|
+
var _a;
|
|
67605
|
+
((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
|
|
67606
|
+
}
|
|
67607
|
+
// We collect intra-expression inference sites within object and array literals to handle cases where
|
|
67608
|
+
// inferred types flow between context sensitive element expressions. For example:
|
|
67609
|
+
//
|
|
67610
|
+
// declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
|
|
67611
|
+
// foo([_a => 0, n => n.toFixed()]);
|
|
67612
|
+
//
|
|
67613
|
+
// Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
|
|
67614
|
+
// pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
|
|
67615
|
+
// pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
|
|
67616
|
+
// parameter in the second arrow function, but we want to first infer from the return type of the first
|
|
67617
|
+
// arrow function. This happens automatically when the arrow functions are discrete arguments (because we
|
|
67618
|
+
// infer from each argument before processing the next), but when the arrow functions are elements of an
|
|
67619
|
+
// object or array literal, we need to perform intra-expression inferences early.
|
|
67620
|
+
function inferFromIntraExpressionSites(context) {
|
|
67621
|
+
if (context.intraExpressionInferenceSites) {
|
|
67622
|
+
for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
|
|
67623
|
+
var _b = _a[_i], node = _b.node, type = _b.type;
|
|
67624
|
+
var contextualType = node.kind === 169 /* MethodDeclaration */ ?
|
|
67625
|
+
getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
|
|
67626
|
+
getContextualType(node, 2 /* NoConstraints */);
|
|
67627
|
+
if (contextualType) {
|
|
67628
|
+
inferTypes(context.inferences, type, contextualType);
|
|
67629
|
+
}
|
|
67630
|
+
}
|
|
67631
|
+
context.intraExpressionInferenceSites = undefined;
|
|
67632
|
+
}
|
|
67633
|
+
}
|
|
67316
67634
|
function createInferenceInfo(typeParameter) {
|
|
67317
67635
|
return {
|
|
67318
67636
|
typeParameter: typeParameter,
|
|
@@ -69295,7 +69613,7 @@ var ts;
|
|
|
69295
69613
|
// parameter symbols with declarations that have explicit type annotations. Such references are
|
|
69296
69614
|
// resolvable with no possibility of triggering circularities in control flow analysis.
|
|
69297
69615
|
function getTypeOfDottedName(node, diagnostic) {
|
|
69298
|
-
if (!(node.flags &
|
|
69616
|
+
if (!(node.flags & 33554432 /* InWithStatement */)) {
|
|
69299
69617
|
switch (node.kind) {
|
|
69300
69618
|
case 79 /* Identifier */:
|
|
69301
69619
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
@@ -70699,6 +71017,7 @@ var ts;
|
|
|
70699
71017
|
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
|
|
70700
71018
|
// and x are of generic types T and K, we want the resulting type to be T[K].
|
|
70701
71019
|
return parent.kind === 206 /* PropertyAccessExpression */ ||
|
|
71020
|
+
parent.kind === 161 /* QualifiedName */ ||
|
|
70702
71021
|
parent.kind === 208 /* CallExpression */ && parent.expression === node ||
|
|
70703
71022
|
parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
|
|
70704
71023
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
@@ -70992,7 +71311,7 @@ var ts;
|
|
|
70992
71311
|
isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
|
|
70993
71312
|
node.parent.kind === 230 /* NonNullExpression */ ||
|
|
70994
71313
|
declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
|
|
70995
|
-
declaration.flags &
|
|
71314
|
+
declaration.flags & 16777216 /* Ambient */;
|
|
70996
71315
|
var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
|
|
70997
71316
|
type === autoType || type === autoArrayType ? undefinedType :
|
|
70998
71317
|
getOptionalType(type);
|
|
@@ -72000,7 +72319,7 @@ var ts;
|
|
|
72000
72319
|
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
|
72001
72320
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
72002
72321
|
ts.Debug.assert(ts.isObjectLiteralMethod(node));
|
|
72003
|
-
if (node.flags &
|
|
72322
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72004
72323
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72005
72324
|
return undefined;
|
|
72006
72325
|
}
|
|
@@ -72188,7 +72507,7 @@ var ts;
|
|
|
72188
72507
|
* @returns the contextual type of an expression.
|
|
72189
72508
|
*/
|
|
72190
72509
|
function getContextualType(node, contextFlags) {
|
|
72191
|
-
if (node.flags &
|
|
72510
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72192
72511
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72193
72512
|
return undefined;
|
|
72194
72513
|
}
|
|
@@ -72606,6 +72925,11 @@ var ts;
|
|
|
72606
72925
|
var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
|
|
72607
72926
|
elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
|
|
72608
72927
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72928
|
+
if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
72929
|
+
var inferenceContext = getInferenceContext(node);
|
|
72930
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
72931
|
+
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
72932
|
+
}
|
|
72609
72933
|
}
|
|
72610
72934
|
}
|
|
72611
72935
|
if (inDestructuringPattern) {
|
|
@@ -72807,6 +73131,13 @@ var ts;
|
|
|
72807
73131
|
prop.target = member;
|
|
72808
73132
|
member = prop;
|
|
72809
73133
|
allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
73134
|
+
if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
|
|
73135
|
+
(memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
73136
|
+
var inferenceContext = getInferenceContext(node);
|
|
73137
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
73138
|
+
var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
73139
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73140
|
+
}
|
|
72810
73141
|
}
|
|
72811
73142
|
else if (memberDecl.kind === 298 /* SpreadAssignment */) {
|
|
72812
73143
|
if (languageVersion < 2 /* ES2015 */) {
|
|
@@ -73899,7 +74230,7 @@ var ts;
|
|
|
73899
74230
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73900
74231
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73901
74232
|
}
|
|
73902
|
-
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) &
|
|
74233
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
|
|
73903
74234
|
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73904
74235
|
}
|
|
73905
74236
|
}
|
|
@@ -73967,7 +74298,7 @@ var ts;
|
|
|
73967
74298
|
if (declaration && isPropertyWithoutInitializer(declaration)) {
|
|
73968
74299
|
if (!ts.isStatic(declaration)) {
|
|
73969
74300
|
var flowContainer = getControlFlowContainer(node);
|
|
73970
|
-
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags &
|
|
74301
|
+
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
73971
74302
|
assumeUninitialized = true;
|
|
73972
74303
|
}
|
|
73973
74304
|
}
|
|
@@ -74004,7 +74335,7 @@ var ts;
|
|
|
74004
74335
|
}
|
|
74005
74336
|
else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
|
|
74006
74337
|
node.parent.kind !== 178 /* TypeReference */ &&
|
|
74007
|
-
!(valueDeclaration.flags &
|
|
74338
|
+
!(valueDeclaration.flags & 16777216 /* Ambient */) &&
|
|
74008
74339
|
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74009
74340
|
diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
74010
74341
|
}
|
|
@@ -74669,34 +75000,36 @@ var ts;
|
|
|
74669
75000
|
if (node.kind !== 165 /* Decorator */) {
|
|
74670
75001
|
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
74671
75002
|
if (contextualType) {
|
|
74672
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
74673
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
74674
|
-
// inferred for any outer call expression so far.
|
|
74675
|
-
var outerContext = getInferenceContext(node);
|
|
74676
|
-
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
74677
|
-
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
74678
|
-
// If the contextual type is a generic function type with a single call signature, we
|
|
74679
|
-
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
74680
|
-
// the type parameters are not erased to type any during type inference such that they can
|
|
74681
|
-
// be inferred as actual types from the contextual type. For example:
|
|
74682
|
-
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
74683
|
-
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
74684
|
-
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
74685
|
-
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
74686
|
-
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
74687
|
-
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
74688
|
-
instantiatedType;
|
|
74689
75003
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
74690
|
-
|
|
74691
|
-
|
|
74692
|
-
|
|
74693
|
-
|
|
74694
|
-
|
|
74695
|
-
|
|
74696
|
-
|
|
74697
|
-
|
|
74698
|
-
|
|
74699
|
-
|
|
75004
|
+
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75005
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75006
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75007
|
+
// inferred for any outer call expression so far.
|
|
75008
|
+
var outerContext = getInferenceContext(node);
|
|
75009
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75010
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75011
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75012
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75013
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75014
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75015
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75016
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75017
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75018
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75019
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75020
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75021
|
+
instantiatedType;
|
|
75022
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75023
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75024
|
+
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75025
|
+
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75026
|
+
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
75027
|
+
// outer arguments), and (b) we don't want any further inferences going into this context.
|
|
75028
|
+
var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
75029
|
+
var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
75030
|
+
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
75031
|
+
context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
|
75032
|
+
}
|
|
74700
75033
|
}
|
|
74701
75034
|
}
|
|
74702
75035
|
var restType = getNonArrayRestType(signature);
|
|
@@ -74708,7 +75041,7 @@ var ts;
|
|
|
74708
75041
|
}
|
|
74709
75042
|
}
|
|
74710
75043
|
var thisType = getThisTypeOfSignature(signature);
|
|
74711
|
-
if (thisType) {
|
|
75044
|
+
if (thisType && couldContainTypeVariables(thisType)) {
|
|
74712
75045
|
var thisArgumentNode = getThisArgumentOfCall(node);
|
|
74713
75046
|
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
74714
75047
|
}
|
|
@@ -74716,11 +75049,13 @@ var ts;
|
|
|
74716
75049
|
var arg = args[i];
|
|
74717
75050
|
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74718
75051
|
var paramType = getTypeAtPosition(signature, i);
|
|
74719
|
-
|
|
74720
|
-
|
|
75052
|
+
if (couldContainTypeVariables(paramType)) {
|
|
75053
|
+
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
75054
|
+
inferTypes(context.inferences, argType, paramType);
|
|
75055
|
+
}
|
|
74721
75056
|
}
|
|
74722
75057
|
}
|
|
74723
|
-
if (restType) {
|
|
75058
|
+
if (restType && couldContainTypeVariables(restType)) {
|
|
74724
75059
|
var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
|
|
74725
75060
|
inferTypes(context.inferences, spreadType, restType);
|
|
74726
75061
|
}
|
|
@@ -76300,7 +76635,7 @@ var ts;
|
|
|
76300
76635
|
return returnType;
|
|
76301
76636
|
}
|
|
76302
76637
|
function checkDeprecatedSignature(signature, node) {
|
|
76303
|
-
if (signature.declaration && signature.declaration.flags &
|
|
76638
|
+
if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
|
|
76304
76639
|
var suggestionNode = getDeprecatedSuggestionNode(node);
|
|
76305
76640
|
var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
|
|
76306
76641
|
addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
|
|
@@ -76384,7 +76719,7 @@ var ts;
|
|
|
76384
76719
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76385
76720
|
newSymbol.parent = originalSymbol;
|
|
76386
76721
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76387
|
-
newSymbol.
|
|
76722
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76388
76723
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76389
76724
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76390
76725
|
}
|
|
@@ -76444,7 +76779,7 @@ var ts;
|
|
|
76444
76779
|
if (targetDeclarationKind !== 0 /* Unknown */) {
|
|
76445
76780
|
var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
|
|
76446
76781
|
// function/variable declaration should be ambient
|
|
76447
|
-
return !!decl && !!(decl.flags &
|
|
76782
|
+
return !!decl && !!(decl.flags & 16777216 /* Ambient */);
|
|
76448
76783
|
}
|
|
76449
76784
|
return false;
|
|
76450
76785
|
}
|
|
@@ -76639,7 +76974,7 @@ var ts;
|
|
|
76639
76974
|
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
76640
76975
|
}
|
|
76641
76976
|
var file = ts.getSourceFileOfNode(node);
|
|
76642
|
-
ts.Debug.assert(!!(file.flags &
|
|
76977
|
+
ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
76643
76978
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
76644
76979
|
}
|
|
76645
76980
|
function getTypeOfParameter(symbol) {
|
|
@@ -78653,6 +78988,11 @@ var ts;
|
|
|
78653
78988
|
context.contextualType = contextualType;
|
|
78654
78989
|
context.inferenceContext = inferenceContext;
|
|
78655
78990
|
var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
|
|
78991
|
+
// In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
|
|
78992
|
+
// parameters. This information is no longer needed after the call to checkExpression.
|
|
78993
|
+
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
78994
|
+
inferenceContext.intraExpressionInferenceSites = undefined;
|
|
78995
|
+
}
|
|
78656
78996
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
78657
78997
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
78658
78998
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
@@ -78944,7 +79284,7 @@ var ts;
|
|
|
78944
79284
|
return quickType;
|
|
78945
79285
|
}
|
|
78946
79286
|
// If a type has been cached for the node, return it.
|
|
78947
|
-
if (node.flags &
|
|
79287
|
+
if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
|
|
78948
79288
|
var cachedType = flowTypeCache[getNodeId(node)];
|
|
78949
79289
|
if (cachedType) {
|
|
78950
79290
|
return cachedType;
|
|
@@ -78956,7 +79296,7 @@ var ts;
|
|
|
78956
79296
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78957
79297
|
var cache = flowTypeCache || (flowTypeCache = []);
|
|
78958
79298
|
cache[getNodeId(node)] = type;
|
|
78959
|
-
ts.setNodeFlags(node, node.flags |
|
|
79299
|
+
ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
|
|
78960
79300
|
}
|
|
78961
79301
|
return type;
|
|
78962
79302
|
}
|
|
@@ -79042,7 +79382,7 @@ var ts;
|
|
|
79042
79382
|
if (compilerOptions.isolatedModules) {
|
|
79043
79383
|
ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
79044
79384
|
var constEnumDeclaration = type.symbol.valueDeclaration;
|
|
79045
|
-
if (constEnumDeclaration.flags &
|
|
79385
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
79046
79386
|
error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
|
|
79047
79387
|
}
|
|
79048
79388
|
}
|
|
@@ -79193,14 +79533,19 @@ var ts;
|
|
|
79193
79533
|
}
|
|
79194
79534
|
if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
|
|
79195
79535
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79196
|
-
if (modifiers
|
|
79536
|
+
if (modifiers) {
|
|
79197
79537
|
var symbol = getSymbolOfNode(node.parent);
|
|
79198
|
-
|
|
79199
|
-
|
|
79200
|
-
|
|
79201
|
-
|
|
79202
|
-
|
|
79203
|
-
|
|
79538
|
+
if (node.parent.kind === 259 /* TypeAliasDeclaration */ && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79539
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79540
|
+
}
|
|
79541
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79542
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79543
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79544
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79545
|
+
varianceTypeParameter = typeParameter;
|
|
79546
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79547
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79548
|
+
}
|
|
79204
79549
|
}
|
|
79205
79550
|
}
|
|
79206
79551
|
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
@@ -79735,7 +80080,7 @@ var ts;
|
|
|
79735
80080
|
checkDecorators(node);
|
|
79736
80081
|
checkSignatureDeclaration(node);
|
|
79737
80082
|
if (node.kind === 172 /* GetAccessor */) {
|
|
79738
|
-
if (!(node.flags &
|
|
80083
|
+
if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
|
|
79739
80084
|
if (!(node.flags & 512 /* HasExplicitReturn */)) {
|
|
79740
80085
|
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
|
|
79741
80086
|
}
|
|
@@ -79830,7 +80175,7 @@ var ts;
|
|
|
79830
80175
|
}
|
|
79831
80176
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
79832
80177
|
if (symbol) {
|
|
79833
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags &
|
|
80178
|
+
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
|
|
79834
80179
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
79835
80180
|
}
|
|
79836
80181
|
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
|
|
@@ -79990,6 +80335,23 @@ var ts;
|
|
|
79990
80335
|
grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
|
|
79991
80336
|
}
|
|
79992
80337
|
checkSourceElement(node.typeParameter);
|
|
80338
|
+
var symbol = getSymbolOfNode(node.typeParameter);
|
|
80339
|
+
if (symbol.declarations && symbol.declarations.length > 1) {
|
|
80340
|
+
var links = getSymbolLinks(symbol);
|
|
80341
|
+
if (!links.typeParametersChecked) {
|
|
80342
|
+
links.typeParametersChecked = true;
|
|
80343
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
|
|
80344
|
+
var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
|
|
80345
|
+
if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
|
|
80346
|
+
// Report an error on every conflicting declaration.
|
|
80347
|
+
var name = symbolToString(symbol);
|
|
80348
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
80349
|
+
var declaration = declarations_4[_i];
|
|
80350
|
+
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
|
|
80351
|
+
}
|
|
80352
|
+
}
|
|
80353
|
+
}
|
|
80354
|
+
}
|
|
79993
80355
|
registerForUnusedIdentifiersCheck(node);
|
|
79994
80356
|
}
|
|
79995
80357
|
function checkTemplateLiteralType(node) {
|
|
@@ -80027,7 +80389,7 @@ var ts;
|
|
|
80027
80389
|
getTypeFromTypeNode(node);
|
|
80028
80390
|
}
|
|
80029
80391
|
function isPrivateWithinAmbient(node) {
|
|
80030
|
-
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags &
|
|
80392
|
+
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
|
|
80031
80393
|
}
|
|
80032
80394
|
function getEffectiveDeclarationFlags(n, flagsToCheck) {
|
|
80033
80395
|
var flags = ts.getCombinedModifierFlags(n);
|
|
@@ -80036,7 +80398,7 @@ var ts;
|
|
|
80036
80398
|
if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
|
|
80037
80399
|
n.parent.kind !== 257 /* ClassDeclaration */ &&
|
|
80038
80400
|
n.parent.kind !== 226 /* ClassExpression */ &&
|
|
80039
|
-
n.flags &
|
|
80401
|
+
n.flags & 16777216 /* Ambient */) {
|
|
80040
80402
|
if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
|
|
80041
80403
|
// It is nested in an ambient context, which means it is automatically exported
|
|
80042
80404
|
flags |= 1 /* Export */;
|
|
@@ -80169,10 +80531,10 @@ var ts;
|
|
|
80169
80531
|
var hasNonAmbientClass = false;
|
|
80170
80532
|
var functionDeclarations = [];
|
|
80171
80533
|
if (declarations) {
|
|
80172
|
-
for (var _i = 0,
|
|
80173
|
-
var current =
|
|
80534
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
80535
|
+
var current = declarations_5[_i];
|
|
80174
80536
|
var node = current;
|
|
80175
|
-
var inAmbientContext = node.flags &
|
|
80537
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
80176
80538
|
var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
|
|
80177
80539
|
if (inAmbientContextOrInterface) {
|
|
80178
80540
|
// check if declarations are consecutive only if they are non-ambient
|
|
@@ -81024,7 +81386,7 @@ var ts;
|
|
|
81024
81386
|
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
|
|
81025
81387
|
var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
|
|
81026
81388
|
// Get first non javascript function declaration
|
|
81027
|
-
function (declaration) { return declaration.kind === node.kind && !(declaration.flags &
|
|
81389
|
+
function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
|
|
81028
81390
|
// Only type check the symbol once
|
|
81029
81391
|
if (node === firstDeclaration) {
|
|
81030
81392
|
checkFunctionOrConstructorSymbol(localSymbol);
|
|
@@ -81146,7 +81508,7 @@ var ts;
|
|
|
81146
81508
|
var symbol = getSymbolOfNode(member);
|
|
81147
81509
|
if (!symbol.isReferenced
|
|
81148
81510
|
&& (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
|
|
81149
|
-
&& !(member.flags &
|
|
81511
|
+
&& !(member.flags & 16777216 /* Ambient */)) {
|
|
81150
81512
|
addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
|
|
81151
81513
|
}
|
|
81152
81514
|
break;
|
|
@@ -81336,8 +81698,8 @@ var ts;
|
|
|
81336
81698
|
: ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
|
|
81337
81699
|
}
|
|
81338
81700
|
else {
|
|
81339
|
-
for (var _i = 0,
|
|
81340
|
-
var decl =
|
|
81701
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
81702
|
+
var decl = declarations_6[_i];
|
|
81341
81703
|
addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
|
|
81342
81704
|
}
|
|
81343
81705
|
}
|
|
@@ -81379,7 +81741,7 @@ var ts;
|
|
|
81379
81741
|
}
|
|
81380
81742
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
81381
81743
|
// no rest parameters \ declaration context \ overload - no codegen impact
|
|
81382
|
-
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags &
|
|
81744
|
+
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
|
|
81383
81745
|
return;
|
|
81384
81746
|
}
|
|
81385
81747
|
ts.forEach(node.parameters, function (p) {
|
|
@@ -81407,7 +81769,7 @@ var ts;
|
|
|
81407
81769
|
// it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
|
|
81408
81770
|
return false;
|
|
81409
81771
|
}
|
|
81410
|
-
if (node.flags &
|
|
81772
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
81411
81773
|
// ambient context - no codegen impact
|
|
81412
81774
|
return false;
|
|
81413
81775
|
}
|
|
@@ -81546,7 +81908,7 @@ var ts;
|
|
|
81546
81908
|
recordPotentialCollisionWithReflectInGeneratedCode(node, name);
|
|
81547
81909
|
if (ts.isClassLike(node)) {
|
|
81548
81910
|
checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
|
|
81549
|
-
if (!(node.flags &
|
|
81911
|
+
if (!(node.flags & 16777216 /* Ambient */)) {
|
|
81550
81912
|
checkClassNameCollisionWithObject(name);
|
|
81551
81913
|
}
|
|
81552
81914
|
}
|
|
@@ -83140,23 +83502,23 @@ var ts;
|
|
|
83140
83502
|
return;
|
|
83141
83503
|
}
|
|
83142
83504
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
83143
|
-
if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
|
|
83505
|
+
if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
|
|
83144
83506
|
// Report an error on every conflicting declaration.
|
|
83145
83507
|
var name = symbolToString(symbol);
|
|
83146
|
-
for (var _i = 0,
|
|
83147
|
-
var declaration =
|
|
83508
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
83509
|
+
var declaration = declarations_7[_i];
|
|
83148
83510
|
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
|
|
83149
83511
|
}
|
|
83150
83512
|
}
|
|
83151
83513
|
}
|
|
83152
83514
|
}
|
|
83153
|
-
function areTypeParametersIdentical(declarations, targetParameters) {
|
|
83515
|
+
function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
|
|
83154
83516
|
var maxTypeArgumentCount = ts.length(targetParameters);
|
|
83155
83517
|
var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
|
|
83156
|
-
for (var _i = 0,
|
|
83157
|
-
var declaration =
|
|
83518
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
83519
|
+
var declaration = declarations_8[_i];
|
|
83158
83520
|
// If this declaration has too few or too many type parameters, we report an error
|
|
83159
|
-
var sourceParameters =
|
|
83521
|
+
var sourceParameters = getTypeParameterDeclarations(declaration);
|
|
83160
83522
|
var numTypeParameters = sourceParameters.length;
|
|
83161
83523
|
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
|
|
83162
83524
|
return false;
|
|
@@ -83224,7 +83586,7 @@ var ts;
|
|
|
83224
83586
|
checkFunctionOrConstructorSymbol(symbol);
|
|
83225
83587
|
checkClassForDuplicateDeclarations(node);
|
|
83226
83588
|
// Only check for reserved static identifiers on non-ambient context.
|
|
83227
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83589
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83228
83590
|
if (!nodeInAmbientContext) {
|
|
83229
83591
|
checkClassForStaticPropertyNameConflicts(node);
|
|
83230
83592
|
}
|
|
@@ -83374,7 +83736,7 @@ var ts;
|
|
|
83374
83736
|
*/
|
|
83375
83737
|
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
83376
83738
|
var isJs = ts.isInJSFile(node);
|
|
83377
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83739
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83378
83740
|
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
83379
83741
|
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
83380
83742
|
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
@@ -83602,7 +83964,7 @@ var ts;
|
|
|
83602
83964
|
&& !(derived.flags & 33554432 /* Transient */)
|
|
83603
83965
|
&& !(baseDeclarationFlags & 128 /* Abstract */)
|
|
83604
83966
|
&& !(derivedDeclarationFlags & 128 /* Abstract */)
|
|
83605
|
-
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags &
|
|
83967
|
+
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
|
|
83606
83968
|
var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
|
|
83607
83969
|
var propName = uninitialized.name;
|
|
83608
83970
|
if (uninitialized.exclamationToken
|
|
@@ -83694,7 +84056,7 @@ var ts;
|
|
|
83694
84056
|
return ok;
|
|
83695
84057
|
}
|
|
83696
84058
|
function checkPropertyInitialization(node) {
|
|
83697
|
-
if (!strictNullChecks || !strictPropertyInitialization || node.flags &
|
|
84059
|
+
if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
|
|
83698
84060
|
return;
|
|
83699
84061
|
}
|
|
83700
84062
|
var constructor = findConstructorDeclaration(node);
|
|
@@ -83831,7 +84193,7 @@ var ts;
|
|
|
83831
84193
|
}
|
|
83832
84194
|
// In ambient non-const numeric enum declarations, enum members without initializers are
|
|
83833
84195
|
// considered computed members (as opposed to having auto-incremented values).
|
|
83834
|
-
if (member.parent.flags &
|
|
84196
|
+
if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
|
|
83835
84197
|
return undefined;
|
|
83836
84198
|
}
|
|
83837
84199
|
// If the member declaration specifies no value, the member is considered a constant enum member.
|
|
@@ -83863,7 +84225,7 @@ var ts;
|
|
|
83863
84225
|
else if (isConstEnum) {
|
|
83864
84226
|
error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
|
|
83865
84227
|
}
|
|
83866
|
-
else if (member.parent.flags &
|
|
84228
|
+
else if (member.parent.flags & 16777216 /* Ambient */) {
|
|
83867
84229
|
error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
|
83868
84230
|
}
|
|
83869
84231
|
else {
|
|
@@ -84031,11 +84393,11 @@ var ts;
|
|
|
84031
84393
|
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
|
|
84032
84394
|
var declarations = symbol.declarations;
|
|
84033
84395
|
if (declarations) {
|
|
84034
|
-
for (var _i = 0,
|
|
84035
|
-
var declaration =
|
|
84396
|
+
for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
|
|
84397
|
+
var declaration = declarations_9[_i];
|
|
84036
84398
|
if ((declaration.kind === 257 /* ClassDeclaration */ ||
|
|
84037
84399
|
(declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
|
|
84038
|
-
!(declaration.flags &
|
|
84400
|
+
!(declaration.flags & 16777216 /* Ambient */)) {
|
|
84039
84401
|
return declaration;
|
|
84040
84402
|
}
|
|
84041
84403
|
}
|
|
@@ -84066,7 +84428,7 @@ var ts;
|
|
|
84066
84428
|
function checkModuleDeclarationDiagnostics() {
|
|
84067
84429
|
// Grammar checking
|
|
84068
84430
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
84069
|
-
var inAmbientContext = node.flags &
|
|
84431
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
84070
84432
|
if (isGlobalAugmentation && !inAmbientContext) {
|
|
84071
84433
|
error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
|
|
84072
84434
|
}
|
|
@@ -84284,7 +84646,7 @@ var ts;
|
|
|
84284
84646
|
}
|
|
84285
84647
|
if (compilerOptions.isolatedModules
|
|
84286
84648
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
84287
|
-
&& !(node.flags &
|
|
84649
|
+
&& !(node.flags & 16777216 /* Ambient */)) {
|
|
84288
84650
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
84289
84651
|
var isType = !(target.flags & 111551 /* Value */);
|
|
84290
84652
|
if (isType || typeOnlyAlias) {
|
|
@@ -84330,7 +84692,7 @@ var ts;
|
|
|
84330
84692
|
}
|
|
84331
84693
|
}
|
|
84332
84694
|
function isDeprecatedAliasedSymbol(symbol) {
|
|
84333
|
-
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) &
|
|
84695
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
84334
84696
|
}
|
|
84335
84697
|
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
84336
84698
|
if (!(symbol.flags & 2097152 /* Alias */))
|
|
@@ -84459,7 +84821,7 @@ var ts;
|
|
|
84459
84821
|
}
|
|
84460
84822
|
}
|
|
84461
84823
|
else {
|
|
84462
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags &
|
|
84824
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
|
|
84463
84825
|
// Import equals declaration is deprecated in es6 or above
|
|
84464
84826
|
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);
|
|
84465
84827
|
}
|
|
@@ -84485,7 +84847,7 @@ var ts;
|
|
|
84485
84847
|
ts.forEach(node.exportClause.elements, checkExportSpecifier);
|
|
84486
84848
|
var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
|
|
84487
84849
|
var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
|
|
84488
|
-
!node.moduleSpecifier && node.flags &
|
|
84850
|
+
!node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
|
|
84489
84851
|
if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
|
|
84490
84852
|
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
|
|
84491
84853
|
}
|
|
@@ -84650,10 +85012,10 @@ var ts;
|
|
|
84650
85012
|
checkExpressionCached(node.expression);
|
|
84651
85013
|
}
|
|
84652
85014
|
checkExternalModuleExports(container);
|
|
84653
|
-
if ((node.flags &
|
|
85015
|
+
if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
|
|
84654
85016
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
84655
85017
|
}
|
|
84656
|
-
if (node.isExportEquals && !(node.flags &
|
|
85018
|
+
if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
|
|
84657
85019
|
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
84658
85020
|
// export assignment is not supported in es6 modules
|
|
84659
85021
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
@@ -85086,7 +85448,7 @@ var ts;
|
|
|
85086
85448
|
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
85087
85449
|
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
85088
85450
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
85089
|
-
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags &
|
|
85451
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
85090
85452
|
diagnostics.add(diag);
|
|
85091
85453
|
}
|
|
85092
85454
|
});
|
|
@@ -85186,7 +85548,7 @@ var ts;
|
|
|
85186
85548
|
}
|
|
85187
85549
|
// Language service support
|
|
85188
85550
|
function getSymbolsInScope(location, meaning) {
|
|
85189
|
-
if (location.flags &
|
|
85551
|
+
if (location.flags & 33554432 /* InWithStatement */) {
|
|
85190
85552
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85191
85553
|
return [];
|
|
85192
85554
|
}
|
|
@@ -85536,7 +85898,7 @@ var ts;
|
|
|
85536
85898
|
}
|
|
85537
85899
|
var parent = node.parent;
|
|
85538
85900
|
var grandParent = parent.parent;
|
|
85539
|
-
if (node.flags &
|
|
85901
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85540
85902
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85541
85903
|
return undefined;
|
|
85542
85904
|
}
|
|
@@ -85678,7 +86040,7 @@ var ts;
|
|
|
85678
86040
|
if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
|
|
85679
86041
|
return errorType;
|
|
85680
86042
|
}
|
|
85681
|
-
if (node.flags &
|
|
86043
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85682
86044
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85683
86045
|
return errorType;
|
|
85684
86046
|
}
|
|
@@ -85843,11 +86205,11 @@ var ts;
|
|
|
85843
86205
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
85844
86206
|
return leftSpread ? [leftSpread, rightSpread]
|
|
85845
86207
|
: syntheticOrigin ? [syntheticOrigin]
|
|
85846
|
-
: ts.singleElementArray(
|
|
86208
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
85847
86209
|
}
|
|
85848
86210
|
return undefined;
|
|
85849
86211
|
}
|
|
85850
|
-
function
|
|
86212
|
+
function tryGetTarget(symbol) {
|
|
85851
86213
|
var target;
|
|
85852
86214
|
var next = symbol;
|
|
85853
86215
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86077,7 +86439,7 @@ var ts;
|
|
|
86077
86439
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86078
86440
|
return true;
|
|
86079
86441
|
}
|
|
86080
|
-
var target = getSymbolLinks(symbol).
|
|
86442
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86081
86443
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86082
86444
|
target.flags & 111551 /* Value */ &&
|
|
86083
86445
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -86731,7 +87093,7 @@ var ts;
|
|
|
86731
87093
|
function checkExternalEmitHelpers(location, helpers) {
|
|
86732
87094
|
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
|
|
86733
87095
|
var sourceFile = ts.getSourceFileOfNode(location);
|
|
86734
|
-
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags &
|
|
87096
|
+
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
|
|
86735
87097
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
86736
87098
|
if (helpersModule !== unknownSymbol) {
|
|
86737
87099
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
@@ -86984,7 +87346,7 @@ var ts;
|
|
|
86984
87346
|
else if (node.kind === 164 /* Parameter */) {
|
|
86985
87347
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
|
|
86986
87348
|
}
|
|
86987
|
-
else if ((node.parent.flags &
|
|
87349
|
+
else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
|
|
86988
87350
|
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
|
86989
87351
|
}
|
|
86990
87352
|
else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
|
|
@@ -87030,7 +87392,7 @@ var ts;
|
|
|
87030
87392
|
if (flags & 256 /* Async */) {
|
|
87031
87393
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
|
|
87032
87394
|
}
|
|
87033
|
-
else if (flags & 2 /* Ambient */ || node.parent.flags &
|
|
87395
|
+
else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
|
|
87034
87396
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
|
87035
87397
|
}
|
|
87036
87398
|
else if (node.kind === 164 /* Parameter */) {
|
|
@@ -87176,7 +87538,7 @@ var ts;
|
|
|
87176
87538
|
if (i !== (parameterCount - 1)) {
|
|
87177
87539
|
return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
87178
87540
|
}
|
|
87179
|
-
if (!(parameter.flags &
|
|
87541
|
+
if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
|
|
87180
87542
|
checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
|
|
87181
87543
|
}
|
|
87182
87544
|
if (parameter.questionToken) {
|
|
@@ -87387,7 +87749,7 @@ var ts;
|
|
|
87387
87749
|
ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
|
|
87388
87750
|
node.kind === 213 /* FunctionExpression */ ||
|
|
87389
87751
|
node.kind === 169 /* MethodDeclaration */);
|
|
87390
|
-
if (node.flags &
|
|
87752
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87391
87753
|
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
|
|
87392
87754
|
}
|
|
87393
87755
|
if (!node.body) {
|
|
@@ -87625,7 +87987,7 @@ var ts;
|
|
|
87625
87987
|
return false;
|
|
87626
87988
|
}
|
|
87627
87989
|
function checkGrammarAccessor(accessor) {
|
|
87628
|
-
if (!(accessor.flags &
|
|
87990
|
+
if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
|
|
87629
87991
|
if (languageVersion < 1 /* ES5 */) {
|
|
87630
87992
|
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
|
87631
87993
|
}
|
|
@@ -87765,7 +88127,7 @@ var ts;
|
|
|
87765
88127
|
// However, property declarations disallow computed names in general,
|
|
87766
88128
|
// and accessors are not allowed in ambient contexts in general,
|
|
87767
88129
|
// so this error only really matters for methods.
|
|
87768
|
-
if (node.flags &
|
|
88130
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87769
88131
|
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);
|
|
87770
88132
|
}
|
|
87771
88133
|
else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
|
|
@@ -87881,7 +88243,7 @@ var ts;
|
|
|
87881
88243
|
}
|
|
87882
88244
|
function checkGrammarVariableDeclaration(node) {
|
|
87883
88245
|
if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
|
|
87884
|
-
if (node.flags &
|
|
88246
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87885
88247
|
checkAmbientInitializer(node);
|
|
87886
88248
|
}
|
|
87887
88249
|
else if (!node.initializer) {
|
|
@@ -87893,7 +88255,7 @@ var ts;
|
|
|
87893
88255
|
}
|
|
87894
88256
|
}
|
|
87895
88257
|
}
|
|
87896
|
-
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags &
|
|
88258
|
+
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
|
|
87897
88259
|
var message = node.initializer
|
|
87898
88260
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
87899
88261
|
: !node.type
|
|
@@ -87902,7 +88264,7 @@ var ts;
|
|
|
87902
88264
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
87903
88265
|
}
|
|
87904
88266
|
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
87905
|
-
!(node.parent.parent.flags &
|
|
88267
|
+
!(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
87906
88268
|
checkESModuleMarker(node.name);
|
|
87907
88269
|
}
|
|
87908
88270
|
var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
|
|
@@ -88079,11 +88441,11 @@ var ts;
|
|
|
88079
88441
|
return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
|
|
88080
88442
|
}
|
|
88081
88443
|
}
|
|
88082
|
-
if (node.flags &
|
|
88444
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88083
88445
|
checkAmbientInitializer(node);
|
|
88084
88446
|
}
|
|
88085
88447
|
if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
|
|
88086
|
-
node.flags &
|
|
88448
|
+
node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
|
|
88087
88449
|
var message = node.initializer
|
|
88088
88450
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
88089
88451
|
: !node.type
|
|
@@ -88129,10 +88491,10 @@ var ts;
|
|
|
88129
88491
|
return false;
|
|
88130
88492
|
}
|
|
88131
88493
|
function checkGrammarSourceFile(node) {
|
|
88132
|
-
return !!(node.flags &
|
|
88494
|
+
return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
|
|
88133
88495
|
}
|
|
88134
88496
|
function checkGrammarStatementInAmbientContext(node) {
|
|
88135
|
-
if (node.flags &
|
|
88497
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88136
88498
|
// Find containing block which is either Block, ModuleBlock, SourceFile
|
|
88137
88499
|
var links = getNodeLinks(node);
|
|
88138
88500
|
if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
|
|
@@ -92250,7 +92612,7 @@ var ts;
|
|
|
92250
92612
|
return !ts.nodeIsMissing(node.body);
|
|
92251
92613
|
}
|
|
92252
92614
|
function visitPropertyDeclaration(node) {
|
|
92253
|
-
if (node.flags &
|
|
92615
|
+
if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
92254
92616
|
return undefined;
|
|
92255
92617
|
}
|
|
92256
92618
|
var updated = factory.updatePropertyDeclaration(node,
|
|
@@ -99140,8 +99502,8 @@ var ts;
|
|
|
99140
99502
|
// declarations may not be sorted by position.
|
|
99141
99503
|
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
|
|
99142
99504
|
var pos = -1, end = -1;
|
|
99143
|
-
for (var _i = 0,
|
|
99144
|
-
var node =
|
|
99505
|
+
for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
|
|
99506
|
+
var node = declarations_10[_i];
|
|
99145
99507
|
pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
|
|
99146
99508
|
end = Math.max(end, node.end);
|
|
99147
99509
|
}
|
|
@@ -108073,6 +108435,10 @@ var ts;
|
|
|
108073
108435
|
return factory.updateModifiers(statement, modifiers);
|
|
108074
108436
|
}
|
|
108075
108437
|
function transformTopLevelDeclaration(input) {
|
|
108438
|
+
if (lateMarkedStatements) {
|
|
108439
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108440
|
+
;
|
|
108441
|
+
}
|
|
108076
108442
|
if (shouldStripInternal(input))
|
|
108077
108443
|
return;
|
|
108078
108444
|
switch (input.kind) {
|
|
@@ -108184,7 +108550,7 @@ var ts;
|
|
|
108184
108550
|
needsScopeFixMarker = false;
|
|
108185
108551
|
var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
|
|
108186
108552
|
var lateStatements = transformAndReplaceLatePaintedStatements(statements);
|
|
108187
|
-
if (input.flags &
|
|
108553
|
+
if (input.flags & 16777216 /* Ambient */) {
|
|
108188
108554
|
needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
|
|
108189
108555
|
}
|
|
108190
108556
|
// With the final list of statements, there are 3 possibilities:
|
|
@@ -109832,6 +110198,9 @@ var ts;
|
|
|
109832
110198
|
var currentParenthesizerRule;
|
|
109833
110199
|
var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
|
|
109834
110200
|
var parenthesizer = ts.factory.parenthesizer;
|
|
110201
|
+
var typeArgumentParenthesizerRuleSelector = {
|
|
110202
|
+
select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
|
|
110203
|
+
};
|
|
109835
110204
|
var emitBinaryExpression = createEmitBinaryExpression();
|
|
109836
110205
|
reset();
|
|
109837
110206
|
return {
|
|
@@ -111044,7 +111413,7 @@ var ts;
|
|
|
111044
111413
|
writePunctuation("}");
|
|
111045
111414
|
}
|
|
111046
111415
|
function emitArrayType(node) {
|
|
111047
|
-
emit(node.elementType, parenthesizer.
|
|
111416
|
+
emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111048
111417
|
writePunctuation("[");
|
|
111049
111418
|
writePunctuation("]");
|
|
111050
111419
|
}
|
|
@@ -111055,7 +111424,7 @@ var ts;
|
|
|
111055
111424
|
function emitTupleType(node) {
|
|
111056
111425
|
emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
|
|
111057
111426
|
var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
|
|
111058
|
-
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty
|
|
111427
|
+
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
|
|
111059
111428
|
emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
|
|
111060
111429
|
}
|
|
111061
111430
|
function emitNamedTupleMember(node) {
|
|
@@ -111067,21 +111436,21 @@ var ts;
|
|
|
111067
111436
|
emit(node.type);
|
|
111068
111437
|
}
|
|
111069
111438
|
function emitOptionalType(node) {
|
|
111070
|
-
emit(node.type, parenthesizer.
|
|
111439
|
+
emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
|
|
111071
111440
|
writePunctuation("?");
|
|
111072
111441
|
}
|
|
111073
111442
|
function emitUnionType(node) {
|
|
111074
|
-
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.
|
|
111443
|
+
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
|
|
111075
111444
|
}
|
|
111076
111445
|
function emitIntersectionType(node) {
|
|
111077
|
-
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.
|
|
111446
|
+
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
|
|
111078
111447
|
}
|
|
111079
111448
|
function emitConditionalType(node) {
|
|
111080
|
-
emit(node.checkType, parenthesizer.
|
|
111449
|
+
emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
|
|
111081
111450
|
writeSpace();
|
|
111082
111451
|
writeKeyword("extends");
|
|
111083
111452
|
writeSpace();
|
|
111084
|
-
emit(node.extendsType, parenthesizer.
|
|
111453
|
+
emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
|
|
111085
111454
|
writeSpace();
|
|
111086
111455
|
writePunctuation("?");
|
|
111087
111456
|
writeSpace();
|
|
@@ -111107,10 +111476,13 @@ var ts;
|
|
|
111107
111476
|
function emitTypeOperator(node) {
|
|
111108
111477
|
writeTokenText(node.operator, writeKeyword);
|
|
111109
111478
|
writeSpace();
|
|
111110
|
-
|
|
111479
|
+
var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
|
|
111480
|
+
parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
|
|
111481
|
+
parenthesizer.parenthesizeOperandOfTypeOperator;
|
|
111482
|
+
emit(node.type, parenthesizerRule);
|
|
111111
111483
|
}
|
|
111112
111484
|
function emitIndexedAccessType(node) {
|
|
111113
|
-
emit(node.objectType, parenthesizer.
|
|
111485
|
+
emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111114
111486
|
writePunctuation("[");
|
|
111115
111487
|
emit(node.indexType);
|
|
111116
111488
|
writePunctuation("]");
|
|
@@ -112844,7 +113216,7 @@ var ts;
|
|
|
112844
113216
|
emitList(parentNode, decorators, 2146305 /* Decorators */);
|
|
112845
113217
|
}
|
|
112846
113218
|
function emitTypeArguments(parentNode, typeArguments) {
|
|
112847
|
-
emitList(parentNode, typeArguments, 53776 /* TypeArguments */,
|
|
113219
|
+
emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
|
|
112848
113220
|
}
|
|
112849
113221
|
function emitTypeParameters(parentNode, typeParameters) {
|
|
112850
113222
|
if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
|
@@ -112963,6 +113335,7 @@ var ts;
|
|
|
112963
113335
|
if (format & 128 /* Indented */) {
|
|
112964
113336
|
increaseIndent();
|
|
112965
113337
|
}
|
|
113338
|
+
var emitListItem = getEmitListItem(emit, parenthesizerRule);
|
|
112966
113339
|
// Emit each child.
|
|
112967
113340
|
var previousSibling = void 0;
|
|
112968
113341
|
var previousSourceFileTextKind = void 0;
|
|
@@ -113013,12 +113386,7 @@ var ts;
|
|
|
113013
113386
|
shouldEmitInterveningComments = mayEmitInterveningComments;
|
|
113014
113387
|
}
|
|
113015
113388
|
nextListElementPos = child.pos;
|
|
113016
|
-
|
|
113017
|
-
emit(child);
|
|
113018
|
-
}
|
|
113019
|
-
else {
|
|
113020
|
-
emit(child, parenthesizerRule);
|
|
113021
|
-
}
|
|
113389
|
+
emitListItem(child, emit, parenthesizerRule, i);
|
|
113022
113390
|
if (shouldDecreaseIndentAfterEmit) {
|
|
113023
113391
|
decreaseIndent();
|
|
113024
113392
|
shouldDecreaseIndentAfterEmit = false;
|
|
@@ -114259,6 +114627,20 @@ var ts;
|
|
|
114259
114627
|
TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
|
|
114260
114628
|
TempFlags[TempFlags["_i"] = 268435456] = "_i";
|
|
114261
114629
|
})(TempFlags || (TempFlags = {}));
|
|
114630
|
+
function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
|
|
114631
|
+
emit(node);
|
|
114632
|
+
}
|
|
114633
|
+
function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
|
|
114634
|
+
emit(node, parenthesizerRuleSelector.select(index));
|
|
114635
|
+
}
|
|
114636
|
+
function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
|
|
114637
|
+
emit(node, parenthesizerRule);
|
|
114638
|
+
}
|
|
114639
|
+
function getEmitListItem(emit, parenthesizerRule) {
|
|
114640
|
+
return emit.length === 1 ? emitListItemNoParenthesizer :
|
|
114641
|
+
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
|
|
114642
|
+
emitListItemWithParenthesizerRule;
|
|
114643
|
+
}
|
|
114262
114644
|
})(ts || (ts = {}));
|
|
114263
114645
|
/* @internal */
|
|
114264
114646
|
var ts;
|
|
@@ -116325,7 +116707,7 @@ var ts;
|
|
|
116325
116707
|
// moduleAugmentations has changed
|
|
116326
116708
|
structureIsReused = 1 /* SafeModules */;
|
|
116327
116709
|
}
|
|
116328
|
-
if ((oldSourceFile.flags &
|
|
116710
|
+
if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
116329
116711
|
// dynamicImport has changed
|
|
116330
116712
|
structureIsReused = 1 /* SafeModules */;
|
|
116331
116713
|
}
|
|
@@ -116489,6 +116871,9 @@ var ts;
|
|
|
116489
116871
|
return !!sourceFilesFoundSearchingNodeModules.get(file.path);
|
|
116490
116872
|
}
|
|
116491
116873
|
function isSourceFileDefaultLibrary(file) {
|
|
116874
|
+
if (!file.isDeclarationFile) {
|
|
116875
|
+
return false;
|
|
116876
|
+
}
|
|
116492
116877
|
if (file.hasNoDefaultLib) {
|
|
116493
116878
|
return true;
|
|
116494
116879
|
}
|
|
@@ -117000,7 +117385,7 @@ var ts;
|
|
|
117000
117385
|
var node = _a[_i];
|
|
117001
117386
|
collectModuleReferences(node, /*inAmbientModule*/ false);
|
|
117002
117387
|
}
|
|
117003
|
-
if ((file.flags &
|
|
117388
|
+
if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
|
|
117004
117389
|
collectDynamicImportOrRequireCalls(file);
|
|
117005
117390
|
}
|
|
117006
117391
|
file.imports = imports || ts.emptyArray;
|
|
@@ -117598,7 +117983,7 @@ var ts;
|
|
|
117598
117983
|
&& index < file.imports.length
|
|
117599
117984
|
&& !elideImport
|
|
117600
117985
|
&& !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
|
|
117601
|
-
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags &
|
|
117986
|
+
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
117602
117987
|
if (elideImport) {
|
|
117603
117988
|
modulesWithElidedImports.set(file.path, true);
|
|
117604
117989
|
}
|
|
@@ -117679,21 +118064,6 @@ var ts;
|
|
|
117679
118064
|
return resolvedRef;
|
|
117680
118065
|
}
|
|
117681
118066
|
function verifyCompilerOptions() {
|
|
117682
|
-
var isNightly = ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
|
|
117683
|
-
if (!isNightly) {
|
|
117684
|
-
if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
|
|
117685
|
-
createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
|
|
117686
|
-
}
|
|
117687
|
-
else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
|
|
117688
|
-
createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
|
|
117689
|
-
}
|
|
117690
|
-
else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
|
|
117691
|
-
createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
|
|
117692
|
-
}
|
|
117693
|
-
else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
117694
|
-
createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
|
|
117695
|
-
}
|
|
117696
|
-
}
|
|
117697
118067
|
if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
|
|
117698
118068
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
|
|
117699
118069
|
}
|
|
@@ -126480,7 +126850,7 @@ var ts;
|
|
|
126480
126850
|
result.push("export" /* exportedModifier */);
|
|
126481
126851
|
if (flags & 8192 /* Deprecated */)
|
|
126482
126852
|
result.push("deprecated" /* deprecatedModifier */);
|
|
126483
|
-
if (node.flags &
|
|
126853
|
+
if (node.flags & 16777216 /* Ambient */)
|
|
126484
126854
|
result.push("declare" /* ambientModifier */);
|
|
126485
126855
|
if (node.kind === 271 /* ExportAssignment */)
|
|
126486
126856
|
result.push("export" /* exportedModifier */);
|
|
@@ -132796,7 +133166,7 @@ var ts;
|
|
|
132796
133166
|
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
|
|
132797
133167
|
// Check completions for Object property value shorthand
|
|
132798
133168
|
if (instantiatedType === undefined) {
|
|
132799
|
-
if (objectLikeContainer.flags &
|
|
133169
|
+
if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
|
|
132800
133170
|
return 2 /* Fail */;
|
|
132801
133171
|
}
|
|
132802
133172
|
isNonContextualObjectLiteral = true;
|
|
@@ -135459,17 +135829,25 @@ var ts;
|
|
|
135459
135829
|
var options = { use: 1 /* References */ };
|
|
135460
135830
|
var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
|
|
135461
135831
|
var checker = program.getTypeChecker();
|
|
135462
|
-
|
|
135832
|
+
// Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
|
|
135833
|
+
var adjustedNode = Core.getAdjustedNode(node, options);
|
|
135834
|
+
var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
|
|
135463
135835
|
return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
|
|
135464
135836
|
var definition = _a.definition, references = _a.references;
|
|
135465
135837
|
// Only include referenced symbols that have a valid definition.
|
|
135466
135838
|
return definition && {
|
|
135467
135839
|
definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
|
|
135468
|
-
references: references.map(function (r) { return
|
|
135840
|
+
references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
|
|
135469
135841
|
};
|
|
135470
135842
|
});
|
|
135471
135843
|
}
|
|
135472
135844
|
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
|
|
135845
|
+
function isDefinitionForReference(node) {
|
|
135846
|
+
return node.kind === 88 /* DefaultKeyword */
|
|
135847
|
+
|| !!ts.getDeclarationFromName(node)
|
|
135848
|
+
|| ts.isLiteralComputedPropertyDeclarationName(node)
|
|
135849
|
+
|| (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
|
|
135850
|
+
}
|
|
135473
135851
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
135474
135852
|
var node = ts.getTouchingPropertyName(sourceFile, position);
|
|
135475
135853
|
var referenceEntries;
|
|
@@ -135598,13 +135976,19 @@ var ts;
|
|
|
135598
135976
|
return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
|
|
135599
135977
|
}
|
|
135600
135978
|
FindAllReferences.toRenameLocation = toRenameLocation;
|
|
135601
|
-
function
|
|
135979
|
+
function toReferencedSymbolEntry(entry, symbol) {
|
|
135980
|
+
var referenceEntry = toReferenceEntry(entry);
|
|
135981
|
+
if (!symbol)
|
|
135982
|
+
return referenceEntry;
|
|
135983
|
+
return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
|
|
135984
|
+
}
|
|
135985
|
+
function toReferenceEntry(entry) {
|
|
135602
135986
|
var documentSpan = entryToDocumentSpan(entry);
|
|
135603
135987
|
if (entry.kind === 0 /* Span */) {
|
|
135604
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: false
|
|
135988
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: false });
|
|
135605
135989
|
}
|
|
135606
135990
|
var kind = entry.kind, node = entry.node;
|
|
135607
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node),
|
|
135991
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
|
135608
135992
|
}
|
|
135609
135993
|
FindAllReferences.toReferenceEntry = toReferenceEntry;
|
|
135610
135994
|
function entryToDocumentSpan(entry) {
|
|
@@ -135747,7 +136131,7 @@ var ts;
|
|
|
135747
136131
|
*/
|
|
135748
136132
|
function declarationIsWriteAccess(decl) {
|
|
135749
136133
|
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
|
|
135750
|
-
if (!!(decl.flags &
|
|
136134
|
+
if (!!(decl.flags & 16777216 /* Ambient */))
|
|
135751
136135
|
return true;
|
|
135752
136136
|
switch (decl.kind) {
|
|
135753
136137
|
case 221 /* BinaryExpression */:
|
|
@@ -136312,15 +136696,21 @@ var ts;
|
|
|
136312
136696
|
}
|
|
136313
136697
|
function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
|
|
136314
136698
|
var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
|
|
136315
|
-
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
|
|
136699
|
+
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
|
|
136316
136700
|
for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
|
|
136317
136701
|
var importLocation = importSearches_2[_i][0];
|
|
136318
136702
|
cb(importLocation);
|
|
136319
136703
|
}
|
|
136320
|
-
for (var _b = 0,
|
|
136321
|
-
var
|
|
136322
|
-
|
|
136323
|
-
|
|
136704
|
+
for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
|
|
136705
|
+
var singleReference = singleReferences_2[_b];
|
|
136706
|
+
if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
|
|
136707
|
+
cb(singleReference);
|
|
136708
|
+
}
|
|
136709
|
+
}
|
|
136710
|
+
for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
|
|
136711
|
+
var indirectUser = indirectUsers_2[_c];
|
|
136712
|
+
for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
|
|
136713
|
+
var node = _e[_d];
|
|
136324
136714
|
// Import specifiers should be handled by importSearches
|
|
136325
136715
|
var symbol = checker.getSymbolAtLocation(node);
|
|
136326
136716
|
var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
|
|
@@ -137322,7 +137712,7 @@ var ts;
|
|
|
137322
137712
|
}
|
|
137323
137713
|
Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
|
|
137324
137714
|
function isImplementation(node) {
|
|
137325
|
-
return !!(node.flags &
|
|
137715
|
+
return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
|
|
137326
137716
|
(ts.isVariableLike(node) ? ts.hasInitializer(node) :
|
|
137327
137717
|
ts.isFunctionLikeDeclaration(node) ? !!node.body :
|
|
137328
137718
|
ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
|
|
@@ -137700,7 +138090,7 @@ var ts;
|
|
|
137700
138090
|
function collect(node) {
|
|
137701
138091
|
if (!node)
|
|
137702
138092
|
return;
|
|
137703
|
-
if (node.flags &
|
|
138093
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
137704
138094
|
// do not descend into ambient nodes.
|
|
137705
138095
|
return;
|
|
137706
138096
|
}
|
|
@@ -137859,7 +138249,7 @@ var ts;
|
|
|
137859
138249
|
}
|
|
137860
138250
|
/** Gets the call sites that call out of the provided call hierarchy declaration. */
|
|
137861
138251
|
function getOutgoingCalls(program, declaration) {
|
|
137862
|
-
if (declaration.flags &
|
|
138252
|
+
if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
|
|
137863
138253
|
return [];
|
|
137864
138254
|
}
|
|
137865
138255
|
return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
|
|
@@ -139993,8 +140383,8 @@ var ts;
|
|
|
139993
140383
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
139994
140384
|
var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
|
|
139995
140385
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
139996
|
-
var
|
|
139997
|
-
organizeImportsWorker(
|
|
140386
|
+
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
140387
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
139998
140388
|
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
139999
140389
|
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
140000
140390
|
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
@@ -140002,8 +140392,8 @@ var ts;
|
|
|
140002
140392
|
var ambientModule = _a[_i];
|
|
140003
140393
|
if (!ambientModule.body)
|
|
140004
140394
|
continue;
|
|
140005
|
-
var
|
|
140006
|
-
organizeImportsWorker(
|
|
140395
|
+
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
140396
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140007
140397
|
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
140008
140398
|
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
140009
140399
|
}
|
|
@@ -140049,6 +140439,40 @@ var ts;
|
|
|
140049
140439
|
}
|
|
140050
140440
|
}
|
|
140051
140441
|
OrganizeImports.organizeImports = organizeImports;
|
|
140442
|
+
function groupImportsByNewlineContiguous(sourceFile, importDecls) {
|
|
140443
|
+
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
|
|
140444
|
+
var groupImports = [];
|
|
140445
|
+
var groupIndex = 0;
|
|
140446
|
+
for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
|
|
140447
|
+
var topLevelImportDecl = importDecls_1[_i];
|
|
140448
|
+
if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
|
|
140449
|
+
groupIndex++;
|
|
140450
|
+
}
|
|
140451
|
+
if (!groupImports[groupIndex]) {
|
|
140452
|
+
groupImports[groupIndex] = [];
|
|
140453
|
+
}
|
|
140454
|
+
groupImports[groupIndex].push(topLevelImportDecl);
|
|
140455
|
+
}
|
|
140456
|
+
return groupImports;
|
|
140457
|
+
}
|
|
140458
|
+
// a new group is created if an import includes at least two new line
|
|
140459
|
+
// new line from multi-line comment doesn't count
|
|
140460
|
+
function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
|
|
140461
|
+
var startPos = topLevelImportDecl.getFullStart();
|
|
140462
|
+
var endPos = topLevelImportDecl.getStart();
|
|
140463
|
+
scanner.setText(sourceFile.text, startPos, endPos - startPos);
|
|
140464
|
+
var numberOfNewLines = 0;
|
|
140465
|
+
while (scanner.getTokenPos() < endPos) {
|
|
140466
|
+
var tokenKind = scanner.scan();
|
|
140467
|
+
if (tokenKind === 4 /* NewLineTrivia */) {
|
|
140468
|
+
numberOfNewLines++;
|
|
140469
|
+
if (numberOfNewLines >= 2) {
|
|
140470
|
+
return true;
|
|
140471
|
+
}
|
|
140472
|
+
}
|
|
140473
|
+
}
|
|
140474
|
+
return false;
|
|
140475
|
+
}
|
|
140052
140476
|
function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
|
|
140053
140477
|
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
140054
140478
|
if (skipDestructiveCodeActions) {
|
|
@@ -142284,10 +142708,13 @@ var ts;
|
|
|
142284
142708
|
var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
142285
142709
|
// for optional function condition.
|
|
142286
142710
|
var nonNullableContextualType = contextualType.getNonNullableType();
|
|
142287
|
-
var
|
|
142288
|
-
if (
|
|
142711
|
+
var symbol = nonNullableContextualType.symbol;
|
|
142712
|
+
if (symbol === undefined)
|
|
142713
|
+
return undefined;
|
|
142714
|
+
var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures());
|
|
142715
|
+
if (signature === undefined)
|
|
142289
142716
|
return undefined;
|
|
142290
|
-
var invocation = { kind: 2 /* Contextual */, signature:
|
|
142717
|
+
var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
|
|
142291
142718
|
return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
|
|
142292
142719
|
}
|
|
142293
142720
|
function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
|
|
@@ -146457,9 +146884,9 @@ var ts;
|
|
|
146457
146884
|
// for block indentation, we should look for a line which contains something that's not
|
|
146458
146885
|
// whitespace.
|
|
146459
146886
|
var currentToken = ts.getTokenAtPosition(sourceFile, position);
|
|
146460
|
-
//
|
|
146461
|
-
//
|
|
146462
|
-
// the following indentation should treat { as
|
|
146887
|
+
// For object literals, we want indentation to work just like with blocks.
|
|
146888
|
+
// If the `{` starts in any position (even in the middle of a line), then
|
|
146889
|
+
// the following indentation should treat `{` as the start of that line (including leading whitespace).
|
|
146463
146890
|
// ```
|
|
146464
146891
|
// const a: { x: undefined, y: undefined } = {} // leading 4 whitespaces and { starts in the middle of line
|
|
146465
146892
|
// ->
|
|
@@ -146477,7 +146904,8 @@ var ts;
|
|
|
146477
146904
|
// y: undefined,
|
|
146478
146905
|
// }
|
|
146479
146906
|
// ```
|
|
146480
|
-
|
|
146907
|
+
var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */;
|
|
146908
|
+
if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) {
|
|
146481
146909
|
return getBlockIndent(sourceFile, position, options);
|
|
146482
146910
|
}
|
|
146483
146911
|
if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) {
|
|
@@ -146490,7 +146918,9 @@ var ts;
|
|
|
146490
146918
|
var containerList = getListByPosition(position, precedingToken.parent, sourceFile);
|
|
146491
146919
|
// use list position if the preceding token is before any list items
|
|
146492
146920
|
if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) {
|
|
146493
|
-
|
|
146921
|
+
var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1;
|
|
146922
|
+
var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize;
|
|
146923
|
+
return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217
|
|
146494
146924
|
}
|
|
146495
146925
|
return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
|
|
146496
146926
|
}
|
|
@@ -148003,8 +148433,11 @@ var ts;
|
|
|
148003
148433
|
function isTrivia(s) {
|
|
148004
148434
|
return ts.skipTrivia(s, 0) === s.length;
|
|
148005
148435
|
}
|
|
148436
|
+
// A transformation context that won't perform parenthesization, as some parenthesization rules
|
|
148437
|
+
// are more aggressive than is strictly necessary.
|
|
148438
|
+
var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
|
|
148006
148439
|
function assignPositionsToNode(node) {
|
|
148007
|
-
var visited = ts.visitEachChild(node, assignPositionsToNode,
|
|
148440
|
+
var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
|
148008
148441
|
// create proxy node for non synthesized nodes
|
|
148009
148442
|
var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
|
|
148010
148443
|
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
|
|
@@ -155969,7 +156402,7 @@ var ts;
|
|
|
155969
156402
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
155970
156403
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
155971
156404
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
155972
|
-
var ambient = !!(enclosingDeclaration.flags &
|
|
156405
|
+
var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
|
|
155973
156406
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
155974
156407
|
switch (declaration.kind) {
|
|
155975
156408
|
case 166 /* PropertySignature */:
|
|
@@ -156064,7 +156497,11 @@ var ts;
|
|
|
156064
156497
|
var program = context.program;
|
|
156065
156498
|
var checker = program.getTypeChecker();
|
|
156066
156499
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156067
|
-
var flags = 1 /* NoTruncation */
|
|
156500
|
+
var flags = 1 /* NoTruncation */
|
|
156501
|
+
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
156502
|
+
| 256 /* SuppressAnyReturnType */
|
|
156503
|
+
| 524288 /* AllowEmptyTuple */
|
|
156504
|
+
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
156068
156505
|
var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
|
|
156069
156506
|
if (!signatureDeclaration) {
|
|
156070
156507
|
return undefined;
|
|
@@ -157542,6 +157979,10 @@ var ts;
|
|
|
157542
157979
|
}
|
|
157543
157980
|
break;
|
|
157544
157981
|
}
|
|
157982
|
+
case 200 /* ImportType */:
|
|
157983
|
+
var importTypeNode = parent;
|
|
157984
|
+
changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
|
|
157985
|
+
break;
|
|
157545
157986
|
default:
|
|
157546
157987
|
ts.Debug.failBadSyntaxKind(parent);
|
|
157547
157988
|
}
|
|
@@ -158436,6 +158877,7 @@ var ts;
|
|
|
158436
158877
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
158437
158878
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
158438
158879
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
158880
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
158439
158881
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
158440
158882
|
var RangeFacts;
|
|
158441
158883
|
(function (RangeFacts) {
|
|
@@ -158444,10 +158886,11 @@ var ts;
|
|
|
158444
158886
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
158445
158887
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
158446
158888
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
158889
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
158447
158890
|
/**
|
|
158448
158891
|
* The range is in a function which needs the 'static' modifier in a class
|
|
158449
158892
|
*/
|
|
158450
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
158893
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
158451
158894
|
})(RangeFacts || (RangeFacts = {}));
|
|
158452
158895
|
/**
|
|
158453
158896
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -158478,11 +158921,12 @@ var ts;
|
|
|
158478
158921
|
// We'll modify these flags as we walk the tree to collect data
|
|
158479
158922
|
// about what things need to be done as part of the extraction.
|
|
158480
158923
|
var rangeFacts = RangeFacts.None;
|
|
158924
|
+
var thisNode;
|
|
158481
158925
|
if (!start || !end) {
|
|
158482
158926
|
// cannot find either start or end node
|
|
158483
158927
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158484
158928
|
}
|
|
158485
|
-
if (start.flags &
|
|
158929
|
+
if (start.flags & 8388608 /* JSDoc */) {
|
|
158486
158930
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
158487
158931
|
}
|
|
158488
158932
|
if (start.parent !== end.parent) {
|
|
@@ -158516,7 +158960,7 @@ var ts;
|
|
|
158516
158960
|
// the expression.
|
|
158517
158961
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158518
158962
|
}
|
|
158519
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
158963
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
158520
158964
|
}
|
|
158521
158965
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
158522
158966
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -158528,7 +158972,7 @@ var ts;
|
|
|
158528
158972
|
if (errors) {
|
|
158529
158973
|
return { errors: errors };
|
|
158530
158974
|
}
|
|
158531
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
158975
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
158532
158976
|
/**
|
|
158533
158977
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
158534
158978
|
* @param node The unrefined extraction node.
|
|
@@ -158608,7 +159052,7 @@ var ts;
|
|
|
158608
159052
|
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
158609
159053
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
158610
159054
|
}
|
|
158611
|
-
if (nodeToCheck.flags &
|
|
159055
|
+
if (nodeToCheck.flags & 16777216 /* Ambient */) {
|
|
158612
159056
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
|
|
158613
159057
|
}
|
|
158614
159058
|
// If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
|
|
@@ -158620,6 +159064,14 @@ var ts;
|
|
|
158620
159064
|
var permittedJumps = 4 /* Return */;
|
|
158621
159065
|
var seenLabels;
|
|
158622
159066
|
visit(nodeToCheck);
|
|
159067
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159068
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159069
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159070
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159071
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159072
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159073
|
+
}
|
|
159074
|
+
}
|
|
158623
159075
|
return errors;
|
|
158624
159076
|
function visit(node) {
|
|
158625
159077
|
if (errors) {
|
|
@@ -158658,6 +159110,7 @@ var ts;
|
|
|
158658
159110
|
}
|
|
158659
159111
|
else {
|
|
158660
159112
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159113
|
+
thisNode = node;
|
|
158661
159114
|
}
|
|
158662
159115
|
break;
|
|
158663
159116
|
case 214 /* ArrowFunction */:
|
|
@@ -158665,6 +159118,7 @@ var ts;
|
|
|
158665
159118
|
ts.forEachChild(node, function check(n) {
|
|
158666
159119
|
if (ts.isThis(n)) {
|
|
158667
159120
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159121
|
+
thisNode = node;
|
|
158668
159122
|
}
|
|
158669
159123
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
158670
159124
|
return false;
|
|
@@ -158721,6 +159175,7 @@ var ts;
|
|
|
158721
159175
|
case 192 /* ThisType */:
|
|
158722
159176
|
case 108 /* ThisKeyword */:
|
|
158723
159177
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159178
|
+
thisNode = node;
|
|
158724
159179
|
break;
|
|
158725
159180
|
case 250 /* LabeledStatement */: {
|
|
158726
159181
|
var label = node.label;
|
|
@@ -158798,7 +159253,8 @@ var ts;
|
|
|
158798
159253
|
return undefined;
|
|
158799
159254
|
}
|
|
158800
159255
|
function isScope(node) {
|
|
158801
|
-
return ts.
|
|
159256
|
+
return ts.isArrowFunction(node) ? ts.isFunctionBody(node.body) :
|
|
159257
|
+
ts.isFunctionLikeDeclaration(node) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node);
|
|
158802
159258
|
}
|
|
158803
159259
|
/**
|
|
158804
159260
|
* Computes possible places we could extract the function into. For example,
|
|
@@ -158807,7 +159263,7 @@ var ts;
|
|
|
158807
159263
|
*/
|
|
158808
159264
|
function collectEnclosingScopes(range) {
|
|
158809
159265
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
158810
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
159266
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
158811
159267
|
// if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
|
|
158812
159268
|
var containingClass = ts.getContainingClass(current);
|
|
158813
159269
|
if (containingClass) {
|
|
@@ -159013,6 +159469,7 @@ var ts;
|
|
|
159013
159469
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
159014
159470
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
159015
159471
|
var newFunction;
|
|
159472
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
159016
159473
|
if (ts.isClassLike(scope)) {
|
|
159017
159474
|
// always create private method in TypeScript files
|
|
159018
159475
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -159027,6 +159484,15 @@ var ts;
|
|
|
159027
159484
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
159028
159485
|
}
|
|
159029
159486
|
else {
|
|
159487
|
+
if (callThis) {
|
|
159488
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
159489
|
+
/*decorators*/ undefined,
|
|
159490
|
+
/*modifiers*/ undefined,
|
|
159491
|
+
/*dotDotDotToken*/ undefined,
|
|
159492
|
+
/*name*/ "this",
|
|
159493
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
159494
|
+
/*initializer*/ undefined));
|
|
159495
|
+
}
|
|
159030
159496
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
159031
159497
|
/*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
|
|
159032
159498
|
}
|
|
@@ -159043,7 +159509,10 @@ var ts;
|
|
|
159043
159509
|
var newNodes = [];
|
|
159044
159510
|
// replace range with function call
|
|
159045
159511
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
159046
|
-
|
|
159512
|
+
if (callThis) {
|
|
159513
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
159514
|
+
}
|
|
159515
|
+
var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
|
|
159047
159516
|
callArguments);
|
|
159048
159517
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
159049
159518
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -159654,6 +160123,9 @@ var ts;
|
|
|
159654
160123
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
159655
160124
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
159656
160125
|
}
|
|
160126
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160127
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160128
|
+
}
|
|
159657
160129
|
var hasWrite = false;
|
|
159658
160130
|
var readonlyClassPropertyWrite;
|
|
159659
160131
|
usagesPerScope[i].usages.forEach(function (value) {
|
|
@@ -160139,6 +160611,7 @@ var ts;
|
|
|
160139
160611
|
}
|
|
160140
160612
|
function doTypedefChange(changes, file, name, info) {
|
|
160141
160613
|
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
|
|
160614
|
+
ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
|
|
160142
160615
|
var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
|
|
160143
160616
|
var templates = [];
|
|
160144
160617
|
ts.forEach(typeParameters, function (typeParameter) {
|
|
@@ -162169,7 +162642,7 @@ var ts;
|
|
|
162169
162642
|
kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
|
|
162170
162643
|
new TokenObject(kind, pos, end);
|
|
162171
162644
|
node.parent = parent;
|
|
162172
|
-
node.flags = parent.flags &
|
|
162645
|
+
node.flags = parent.flags & 50720768 /* ContextFlags */;
|
|
162173
162646
|
return node;
|
|
162174
162647
|
}
|
|
162175
162648
|
var NodeObject = /** @class */ (function () {
|
|
@@ -163625,7 +164098,7 @@ var ts;
|
|
|
163625
164098
|
}
|
|
163626
164099
|
/// References and Occurrences
|
|
163627
164100
|
function getOccurrencesAtPosition(fileName, position) {
|
|
163628
|
-
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
|
|
164101
|
+
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 })); }); });
|
|
163629
164102
|
}
|
|
163630
164103
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
163631
164104
|
var normalizedFileName = ts.normalizePath(fileName);
|
|
@@ -163654,7 +164127,7 @@ var ts;
|
|
|
163654
164127
|
}
|
|
163655
164128
|
function getReferencesAtPosition(fileName, position) {
|
|
163656
164129
|
synchronizeHostData();
|
|
163657
|
-
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ },
|
|
164130
|
+
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
|
|
163658
164131
|
}
|
|
163659
164132
|
function getReferencesWorker(node, position, options, cb) {
|
|
163660
164133
|
synchronizeHostData();
|
|
@@ -163669,10 +164142,8 @@ var ts;
|
|
|
163669
164142
|
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
163670
164143
|
}
|
|
163671
164144
|
function getFileReferences(fileName) {
|
|
163672
|
-
var _a;
|
|
163673
164145
|
synchronizeHostData();
|
|
163674
|
-
|
|
163675
|
-
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
|
|
164146
|
+
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
|
|
163676
164147
|
}
|
|
163677
164148
|
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
|
|
163678
164149
|
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
|
|
@@ -164145,7 +164616,7 @@ var ts;
|
|
|
164145
164616
|
}
|
|
164146
164617
|
function isUnclosedFragment(_a) {
|
|
164147
164618
|
var closingFragment = _a.closingFragment, parent = _a.parent;
|
|
164148
|
-
return !!(closingFragment.flags &
|
|
164619
|
+
return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
|
|
164149
164620
|
}
|
|
164150
164621
|
function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
|
|
164151
164622
|
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
|
@@ -164593,7 +165064,7 @@ var ts;
|
|
|
164593
165064
|
tokenAtLocation = preceding;
|
|
164594
165065
|
}
|
|
164595
165066
|
// Cannot set breakpoint in ambient declarations
|
|
164596
|
-
if (tokenAtLocation.flags &
|
|
165067
|
+
if (tokenAtLocation.flags & 16777216 /* Ambient */) {
|
|
164597
165068
|
return undefined;
|
|
164598
165069
|
}
|
|
164599
165070
|
// Get the span in the node based on its syntax
|
|
@@ -173513,6 +173984,7 @@ var ts;
|
|
|
173513
173984
|
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
173514
173985
|
var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
|
|
173515
173986
|
if (projectOutputs) {
|
|
173987
|
+
var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
|
|
173516
173988
|
var _loop_9 = function (referencedSymbol) {
|
|
173517
173989
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
|
|
173518
173990
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -173526,6 +173998,9 @@ var ts;
|
|
|
173526
173998
|
var ref = _b[_a];
|
|
173527
173999
|
// If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
|
|
173528
174000
|
if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
|
|
174001
|
+
if (clearIsDefinition) {
|
|
174002
|
+
delete ref.isDefinition;
|
|
174003
|
+
}
|
|
173529
174004
|
symbolToAddTo.references.push(ref);
|
|
173530
174005
|
}
|
|
173531
174006
|
}
|