typescript 4.7.0-dev.20220405 → 4.7.0-dev.20220415
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/cs/diagnosticMessages.generated.json +2 -0
- package/lib/de/diagnosticMessages.generated.json +2 -0
- package/lib/es/diagnosticMessages.generated.json +2 -0
- package/lib/fr/diagnosticMessages.generated.json +2 -0
- package/lib/it/diagnosticMessages.generated.json +2 -0
- package/lib/ja/diagnosticMessages.generated.json +2 -0
- package/lib/ko/diagnosticMessages.generated.json +2 -0
- 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/pl/diagnosticMessages.generated.json +2 -0
- package/lib/protocol.d.ts +9 -2
- package/lib/pt-br/diagnosticMessages.generated.json +2 -0
- package/lib/ru/diagnosticMessages.generated.json +2 -0
- package/lib/tr/diagnosticMessages.generated.json +2 -0
- package/lib/tsc.js +677 -387
- package/lib/tsserver.js +1369 -576
- package/lib/tsserverlibrary.d.ts +28 -15
- package/lib/tsserverlibrary.js +1369 -576
- package/lib/typescript.d.ts +16 -12
- package/lib/typescript.js +1124 -556
- package/lib/typescriptServices.d.ts +16 -12
- package/lib/typescriptServices.js +1124 -556
- package/lib/typingsInstaller.js +855 -441
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +2 -0
- 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.20220415";
|
|
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) {
|
|
@@ -4659,7 +4660,6 @@ var ts;
|
|
|
4659
4660
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4660
4661
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4661
4662
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4662
|
-
NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
|
|
4663
4663
|
// Error handling
|
|
4664
4664
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4665
4665
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -8716,6 +8716,7 @@ var ts;
|
|
|
8716
8716
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8717
8717
|
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
8718
|
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."),
|
|
8719
|
+
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
8720
|
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
8721
|
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
8722
|
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 +8889,7 @@ var ts;
|
|
|
8888
8889
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
|
|
8889
8890
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8890
8891
|
Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
|
|
8892
|
+
All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
|
|
8891
8893
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8892
8894
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8893
8895
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -14302,24 +14304,24 @@ var ts;
|
|
|
14302
14304
|
// Returns true if this node contains a parse error anywhere underneath it.
|
|
14303
14305
|
function containsParseError(node) {
|
|
14304
14306
|
aggregateChildData(node);
|
|
14305
|
-
return (node.flags &
|
|
14307
|
+
return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
|
|
14306
14308
|
}
|
|
14307
14309
|
ts.containsParseError = containsParseError;
|
|
14308
14310
|
function aggregateChildData(node) {
|
|
14309
|
-
if (!(node.flags &
|
|
14311
|
+
if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
|
|
14310
14312
|
// A node is considered to contain a parse error if:
|
|
14311
14313
|
// a) the parser explicitly marked that it had an error
|
|
14312
14314
|
// b) any of it's children reported that it had an error.
|
|
14313
|
-
var thisNodeOrAnySubNodesHasError = ((node.flags &
|
|
14315
|
+
var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
|
|
14314
14316
|
ts.forEachChild(node, containsParseError);
|
|
14315
14317
|
// If so, mark ourselves accordingly.
|
|
14316
14318
|
if (thisNodeOrAnySubNodesHasError) {
|
|
14317
|
-
node.flags |=
|
|
14319
|
+
node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
|
|
14318
14320
|
}
|
|
14319
14321
|
// Also mark that we've propagated the child information to this node. This way we can
|
|
14320
14322
|
// always consult the bit directly on this node without needing to check its children
|
|
14321
14323
|
// again.
|
|
14322
|
-
node.flags |=
|
|
14324
|
+
node.flags |= 1048576 /* HasAggregatedChildData */;
|
|
14323
14325
|
}
|
|
14324
14326
|
}
|
|
14325
14327
|
function getSourceFileOfNode(node) {
|
|
@@ -14963,6 +14965,10 @@ var ts;
|
|
|
14963
14965
|
}
|
|
14964
14966
|
}
|
|
14965
14967
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
14968
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
14969
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
14970
|
+
}
|
|
14971
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
14966
14972
|
function isLateVisibilityPaintedStatement(node) {
|
|
14967
14973
|
switch (node.kind) {
|
|
14968
14974
|
case 266 /* ImportDeclaration */:
|
|
@@ -16126,11 +16132,11 @@ var ts;
|
|
|
16126
16132
|
}
|
|
16127
16133
|
ts.isSourceFileNotJS = isSourceFileNotJS;
|
|
16128
16134
|
function isInJSFile(node) {
|
|
16129
|
-
return !!node && !!(node.flags &
|
|
16135
|
+
return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
|
|
16130
16136
|
}
|
|
16131
16137
|
ts.isInJSFile = isInJSFile;
|
|
16132
16138
|
function isInJsonFile(node) {
|
|
16133
|
-
return !!node && !!(node.flags &
|
|
16139
|
+
return !!node && !!(node.flags & 67108864 /* JsonFile */);
|
|
16134
16140
|
}
|
|
16135
16141
|
ts.isInJsonFile = isInJsonFile;
|
|
16136
16142
|
function isSourceFileNotJson(file) {
|
|
@@ -16138,7 +16144,7 @@ var ts;
|
|
|
16138
16144
|
}
|
|
16139
16145
|
ts.isSourceFileNotJson = isSourceFileNotJson;
|
|
16140
16146
|
function isInJSDoc(node) {
|
|
16141
|
-
return !!node && !!(node.flags &
|
|
16147
|
+
return !!node && !!(node.flags & 8388608 /* JSDoc */);
|
|
16142
16148
|
}
|
|
16143
16149
|
ts.isInJSDoc = isInJSDoc;
|
|
16144
16150
|
function isJSDocIndexSignature(node) {
|
|
@@ -16323,17 +16329,13 @@ var ts;
|
|
|
16323
16329
|
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
|
16324
16330
|
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
|
|
16325
16331
|
}
|
|
16326
|
-
if (ts.
|
|
16332
|
+
if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
|
|
16327
16333
|
(initializer.expression.kind === 108 /* ThisKeyword */ ||
|
|
16328
16334
|
ts.isIdentifier(initializer.expression) &&
|
|
16329
16335
|
(initializer.expression.escapedText === "window" ||
|
|
16330
16336
|
initializer.expression.escapedText === "self" ||
|
|
16331
16337
|
initializer.expression.escapedText === "global"))) {
|
|
16332
|
-
|
|
16333
|
-
if (ts.isPrivateIdentifier(nameOrArgument)) {
|
|
16334
|
-
ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
|
16335
|
-
}
|
|
16336
|
-
return isSameEntityName(name, nameOrArgument);
|
|
16338
|
+
return isSameEntityName(name, getNameOrArgument(initializer));
|
|
16337
16339
|
}
|
|
16338
16340
|
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
|
16339
16341
|
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
|
@@ -16524,7 +16526,7 @@ var ts;
|
|
|
16524
16526
|
function setValueDeclaration(symbol, node) {
|
|
16525
16527
|
var valueDeclaration = symbol.valueDeclaration;
|
|
16526
16528
|
if (!valueDeclaration ||
|
|
16527
|
-
!(node.flags &
|
|
16529
|
+
!(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
|
|
16528
16530
|
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
|
16529
16531
|
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
|
16530
16532
|
// other kinds of value declarations take precedence over modules and assignment declarations
|
|
@@ -16541,14 +16543,14 @@ var ts;
|
|
|
16541
16543
|
}
|
|
16542
16544
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16543
16545
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16544
|
-
var _a, _b
|
|
16546
|
+
var _a, _b;
|
|
16545
16547
|
switch (node.kind) {
|
|
16546
16548
|
case 254 /* VariableDeclaration */:
|
|
16547
|
-
return node.initializer.arguments[0]
|
|
16549
|
+
return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
|
|
16548
16550
|
case 266 /* ImportDeclaration */:
|
|
16549
|
-
return
|
|
16551
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16550
16552
|
case 265 /* ImportEqualsDeclaration */:
|
|
16551
|
-
return
|
|
16553
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16552
16554
|
default:
|
|
16553
16555
|
ts.Debug.assertNever(node);
|
|
16554
16556
|
}
|
|
@@ -17063,7 +17065,10 @@ var ts;
|
|
|
17063
17065
|
return parent.propertyName === node;
|
|
17064
17066
|
case 275 /* ExportSpecifier */:
|
|
17065
17067
|
case 285 /* JsxAttribute */:
|
|
17066
|
-
|
|
17068
|
+
case 279 /* JsxSelfClosingElement */:
|
|
17069
|
+
case 280 /* JsxOpeningElement */:
|
|
17070
|
+
case 281 /* JsxClosingElement */:
|
|
17071
|
+
// Any name in an export specifier or JSX Attribute or Jsx Element
|
|
17067
17072
|
return true;
|
|
17068
17073
|
}
|
|
17069
17074
|
return false;
|
|
@@ -17079,21 +17084,28 @@ var ts;
|
|
|
17079
17084
|
// export = <EntityNameExpression>
|
|
17080
17085
|
// export default <EntityNameExpression>
|
|
17081
17086
|
// module.exports = <EntityNameExpression>
|
|
17082
|
-
//
|
|
17083
|
-
//
|
|
17087
|
+
// module.exports.x = <EntityNameExpression>
|
|
17088
|
+
// const x = require("...")
|
|
17089
|
+
// const { x } = require("...")
|
|
17090
|
+
// const x = require("...").y
|
|
17091
|
+
// const { x } = require("...").y
|
|
17084
17092
|
function isAliasSymbolDeclaration(node) {
|
|
17085
|
-
|
|
17093
|
+
if (node.kind === 265 /* ImportEqualsDeclaration */ ||
|
|
17086
17094
|
node.kind === 264 /* NamespaceExportDeclaration */ ||
|
|
17087
17095
|
node.kind === 267 /* ImportClause */ && !!node.name ||
|
|
17088
17096
|
node.kind === 268 /* NamespaceImport */ ||
|
|
17089
17097
|
node.kind === 274 /* NamespaceExport */ ||
|
|
17090
17098
|
node.kind === 270 /* ImportSpecifier */ ||
|
|
17091
17099
|
node.kind === 275 /* ExportSpecifier */ ||
|
|
17092
|
-
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17100
|
+
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
|
|
17101
|
+
return true;
|
|
17102
|
+
}
|
|
17103
|
+
return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
|
|
17104
|
+
ts.isPropertyAccessExpression(node)
|
|
17105
|
+
&& ts.isBinaryExpression(node.parent)
|
|
17106
|
+
&& node.parent.left === node
|
|
17107
|
+
&& node.parent.operatorToken.kind === 63 /* EqualsToken */
|
|
17108
|
+
&& isAliasableExpression(node.parent.right));
|
|
17097
17109
|
}
|
|
17098
17110
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17099
17111
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17104,6 +17116,7 @@ var ts;
|
|
|
17104
17116
|
case 275 /* ExportSpecifier */:
|
|
17105
17117
|
case 271 /* ExportAssignment */:
|
|
17106
17118
|
case 265 /* ImportEqualsDeclaration */:
|
|
17119
|
+
case 274 /* NamespaceExport */:
|
|
17107
17120
|
return node.parent;
|
|
17108
17121
|
case 161 /* QualifiedName */:
|
|
17109
17122
|
do {
|
|
@@ -18930,6 +18943,11 @@ var ts;
|
|
|
18930
18943
|
(node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
18931
18944
|
}
|
|
18932
18945
|
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
|
|
18946
|
+
function isRightSideOfAccessExpression(node) {
|
|
18947
|
+
return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
18948
|
+
|| ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
|
|
18949
|
+
}
|
|
18950
|
+
ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
|
|
18933
18951
|
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
|
18934
18952
|
return ts.isQualifiedName(node.parent) && node.parent.right === node
|
|
18935
18953
|
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
@@ -19581,6 +19599,41 @@ var ts;
|
|
|
19581
19599
|
return expr;
|
|
19582
19600
|
}
|
|
19583
19601
|
ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
|
|
19602
|
+
function forEachNameInAccessChainWalkingLeft(name, action) {
|
|
19603
|
+
if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
|
|
19604
|
+
return walkAccessExpression(name.parent);
|
|
19605
|
+
}
|
|
19606
|
+
function walkAccessExpression(access) {
|
|
19607
|
+
if (access.kind === 206 /* PropertyAccessExpression */) {
|
|
19608
|
+
var res = action(access.name);
|
|
19609
|
+
if (res !== undefined) {
|
|
19610
|
+
return res;
|
|
19611
|
+
}
|
|
19612
|
+
}
|
|
19613
|
+
else if (access.kind === 207 /* ElementAccessExpression */) {
|
|
19614
|
+
if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
|
|
19615
|
+
var res = action(access.argumentExpression);
|
|
19616
|
+
if (res !== undefined) {
|
|
19617
|
+
return res;
|
|
19618
|
+
}
|
|
19619
|
+
}
|
|
19620
|
+
else {
|
|
19621
|
+
// Chain interrupted by non-static-name access 'x[expr()].y.z'
|
|
19622
|
+
return undefined;
|
|
19623
|
+
}
|
|
19624
|
+
}
|
|
19625
|
+
if (isAccessExpression(access.expression)) {
|
|
19626
|
+
return walkAccessExpression(access.expression);
|
|
19627
|
+
}
|
|
19628
|
+
if (ts.isIdentifier(access.expression)) {
|
|
19629
|
+
// End of chain at Identifier 'x.y.z'
|
|
19630
|
+
return action(access.expression);
|
|
19631
|
+
}
|
|
19632
|
+
// End of chain at non-Identifier 'x().y.z'
|
|
19633
|
+
return undefined;
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
|
|
19584
19637
|
function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
19585
19638
|
while (true) {
|
|
19586
19639
|
switch (node.kind) {
|
|
@@ -20528,6 +20581,7 @@ var ts;
|
|
|
20528
20581
|
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20529
20582
|
var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
|
|
20530
20583
|
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20584
|
+
ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
|
|
20531
20585
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20532
20586
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20533
20587
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
@@ -20826,7 +20880,7 @@ var ts;
|
|
|
20826
20880
|
}
|
|
20827
20881
|
ts.pseudoBigIntToString = pseudoBigIntToString;
|
|
20828
20882
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
20829
|
-
return !!(useSite.flags &
|
|
20883
|
+
return !!(useSite.flags & 16777216 /* Ambient */)
|
|
20830
20884
|
|| isPartOfTypeQuery(useSite)
|
|
20831
20885
|
|| isIdentifierInNonEmittingHeritageClause(useSite)
|
|
20832
20886
|
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
|
|
@@ -21216,6 +21270,11 @@ var ts;
|
|
|
21216
21270
|
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21217
21271
|
}
|
|
21218
21272
|
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
21273
|
+
function getParameterTypeNode(parameter) {
|
|
21274
|
+
var _a;
|
|
21275
|
+
return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21276
|
+
}
|
|
21277
|
+
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21219
21278
|
})(ts || (ts = {}));
|
|
21220
21279
|
/* @internal */
|
|
21221
21280
|
var ts;
|
|
@@ -21279,11 +21338,20 @@ var ts;
|
|
|
21279
21338
|
parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
|
|
21280
21339
|
parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
|
|
21281
21340
|
parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
|
|
21341
|
+
parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
|
|
21342
|
+
parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
|
|
21343
|
+
parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
|
|
21344
|
+
parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
|
|
21345
|
+
parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
|
|
21346
|
+
parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
|
|
21347
|
+
parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
|
|
21348
|
+
parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
|
|
21349
|
+
parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
|
|
21350
|
+
parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
|
|
21351
|
+
parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
|
|
21352
|
+
parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
|
|
21286
21353
|
parenthesizeTypeArguments: parenthesizeTypeArguments,
|
|
21354
|
+
parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
|
|
21287
21355
|
};
|
|
21288
21356
|
function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
|
|
21289
21357
|
binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
|
|
@@ -21595,33 +21663,191 @@ var ts;
|
|
|
21595
21663
|
}
|
|
21596
21664
|
return body;
|
|
21597
21665
|
}
|
|
21598
|
-
|
|
21599
|
-
|
|
21666
|
+
// Type[Extends] :
|
|
21667
|
+
// FunctionOrConstructorType
|
|
21668
|
+
// ConditionalType[?Extends]
|
|
21669
|
+
// ConditionalType[Extends] :
|
|
21670
|
+
// UnionType[?Extends]
|
|
21671
|
+
// [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
|
|
21672
|
+
//
|
|
21673
|
+
// - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
|
|
21674
|
+
// - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
|
|
21675
|
+
// - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
|
|
21676
|
+
function parenthesizeCheckTypeOfConditionalType(checkType) {
|
|
21677
|
+
switch (checkType.kind) {
|
|
21678
|
+
case 179 /* FunctionType */:
|
|
21679
|
+
case 180 /* ConstructorType */:
|
|
21680
|
+
case 189 /* ConditionalType */:
|
|
21681
|
+
return factory.createParenthesizedType(checkType);
|
|
21682
|
+
}
|
|
21683
|
+
return checkType;
|
|
21600
21684
|
}
|
|
21601
|
-
function
|
|
21602
|
-
switch (
|
|
21685
|
+
function parenthesizeExtendsTypeOfConditionalType(extendsType) {
|
|
21686
|
+
switch (extendsType.kind) {
|
|
21687
|
+
case 189 /* ConditionalType */:
|
|
21688
|
+
return factory.createParenthesizedType(extendsType);
|
|
21689
|
+
}
|
|
21690
|
+
return extendsType;
|
|
21691
|
+
}
|
|
21692
|
+
// UnionType[Extends] :
|
|
21693
|
+
// `|`? IntersectionType[?Extends]
|
|
21694
|
+
// UnionType[?Extends] `|` IntersectionType[?Extends]
|
|
21695
|
+
//
|
|
21696
|
+
// - A union type constituent has the same precedence as the check type of a conditional type
|
|
21697
|
+
function parenthesizeConstituentTypeOfUnionType(type) {
|
|
21698
|
+
switch (type.kind) {
|
|
21699
|
+
case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
|
|
21700
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21701
|
+
return factory.createParenthesizedType(type);
|
|
21702
|
+
}
|
|
21703
|
+
return parenthesizeCheckTypeOfConditionalType(type);
|
|
21704
|
+
}
|
|
21705
|
+
function parenthesizeConstituentTypesOfUnionType(members) {
|
|
21706
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
|
|
21707
|
+
}
|
|
21708
|
+
// IntersectionType[Extends] :
|
|
21709
|
+
// `&`? TypeOperator[?Extends]
|
|
21710
|
+
// IntersectionType[?Extends] `&` TypeOperator[?Extends]
|
|
21711
|
+
//
|
|
21712
|
+
// - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
|
|
21713
|
+
function parenthesizeConstituentTypeOfIntersectionType(type) {
|
|
21714
|
+
switch (type.kind) {
|
|
21603
21715
|
case 187 /* UnionType */:
|
|
21716
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
|
|
21717
|
+
return factory.createParenthesizedType(type);
|
|
21718
|
+
}
|
|
21719
|
+
return parenthesizeConstituentTypeOfUnionType(type);
|
|
21720
|
+
}
|
|
21721
|
+
function parenthesizeConstituentTypesOfIntersectionType(members) {
|
|
21722
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
|
|
21723
|
+
}
|
|
21724
|
+
// TypeOperator[Extends] :
|
|
21725
|
+
// PostfixType
|
|
21726
|
+
// InferType[?Extends]
|
|
21727
|
+
// `keyof` TypeOperator[?Extends]
|
|
21728
|
+
// `unique` TypeOperator[?Extends]
|
|
21729
|
+
// `readonly` TypeOperator[?Extends]
|
|
21730
|
+
//
|
|
21731
|
+
function parenthesizeOperandOfTypeOperator(type) {
|
|
21732
|
+
switch (type.kind) {
|
|
21604
21733
|
case 188 /* IntersectionType */:
|
|
21605
|
-
|
|
21606
|
-
case 180 /* ConstructorType */:
|
|
21607
|
-
return factory.createParenthesizedType(member);
|
|
21734
|
+
return factory.createParenthesizedType(type);
|
|
21608
21735
|
}
|
|
21609
|
-
return
|
|
21736
|
+
return parenthesizeConstituentTypeOfIntersectionType(type);
|
|
21610
21737
|
}
|
|
21611
|
-
function
|
|
21612
|
-
switch (
|
|
21613
|
-
case 181 /* TypeQuery */:
|
|
21738
|
+
function parenthesizeOperandOfReadonlyTypeOperator(type) {
|
|
21739
|
+
switch (type.kind) {
|
|
21614
21740
|
case 193 /* TypeOperator */:
|
|
21741
|
+
return factory.createParenthesizedType(type);
|
|
21742
|
+
}
|
|
21743
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21744
|
+
}
|
|
21745
|
+
// PostfixType :
|
|
21746
|
+
// NonArrayType
|
|
21747
|
+
// NonArrayType [no LineTerminator here] `!` // JSDoc
|
|
21748
|
+
// NonArrayType [no LineTerminator here] `?` // JSDoc
|
|
21749
|
+
// IndexedAccessType
|
|
21750
|
+
// ArrayType
|
|
21751
|
+
//
|
|
21752
|
+
// IndexedAccessType :
|
|
21753
|
+
// NonArrayType `[` Type[~Extends] `]`
|
|
21754
|
+
//
|
|
21755
|
+
// ArrayType :
|
|
21756
|
+
// NonArrayType `[` `]`
|
|
21757
|
+
//
|
|
21758
|
+
function parenthesizeNonArrayTypeOfPostfixType(type) {
|
|
21759
|
+
switch (type.kind) {
|
|
21615
21760
|
case 190 /* InferType */:
|
|
21616
|
-
|
|
21761
|
+
case 193 /* TypeOperator */:
|
|
21762
|
+
case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21763
|
+
return factory.createParenthesizedType(type);
|
|
21617
21764
|
}
|
|
21618
|
-
return
|
|
21765
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21766
|
+
}
|
|
21767
|
+
// TupleType :
|
|
21768
|
+
// `[` Elision? `]`
|
|
21769
|
+
// `[` NamedTupleElementTypes `]`
|
|
21770
|
+
// `[` NamedTupleElementTypes `,` Elision? `]`
|
|
21771
|
+
// `[` TupleElementTypes `]`
|
|
21772
|
+
// `[` TupleElementTypes `,` Elision? `]`
|
|
21773
|
+
//
|
|
21774
|
+
// NamedTupleElementTypes :
|
|
21775
|
+
// Elision? NamedTupleMember
|
|
21776
|
+
// NamedTupleElementTypes `,` Elision? NamedTupleMember
|
|
21777
|
+
//
|
|
21778
|
+
// NamedTupleMember :
|
|
21779
|
+
// Identifier `?`? `:` Type[~Extends]
|
|
21780
|
+
// `...` Identifier `:` Type[~Extends]
|
|
21781
|
+
//
|
|
21782
|
+
// TupleElementTypes :
|
|
21783
|
+
// Elision? TupleElementType
|
|
21784
|
+
// TupleElementTypes `,` Elision? TupleElementType
|
|
21785
|
+
//
|
|
21786
|
+
// TupleElementType :
|
|
21787
|
+
// Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21788
|
+
// OptionalType
|
|
21789
|
+
// RestType
|
|
21790
|
+
//
|
|
21791
|
+
// OptionalType :
|
|
21792
|
+
// Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21793
|
+
//
|
|
21794
|
+
// RestType :
|
|
21795
|
+
// `...` Type[~Extends]
|
|
21796
|
+
//
|
|
21797
|
+
function parenthesizeElementTypesOfTupleType(types) {
|
|
21798
|
+
return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
|
|
21799
|
+
}
|
|
21800
|
+
function parenthesizeElementTypeOfTupleType(type) {
|
|
21801
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21802
|
+
return factory.createParenthesizedType(type);
|
|
21803
|
+
return type;
|
|
21619
21804
|
}
|
|
21620
|
-
function
|
|
21621
|
-
|
|
21805
|
+
function hasJSDocPostfixQuestion(type) {
|
|
21806
|
+
if (ts.isJSDocNullableType(type))
|
|
21807
|
+
return type.postfix;
|
|
21808
|
+
if (ts.isNamedTupleMember(type))
|
|
21809
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21810
|
+
if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
|
|
21811
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21812
|
+
if (ts.isConditionalTypeNode(type))
|
|
21813
|
+
return hasJSDocPostfixQuestion(type.falseType);
|
|
21814
|
+
if (ts.isUnionTypeNode(type))
|
|
21815
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21816
|
+
if (ts.isIntersectionTypeNode(type))
|
|
21817
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21818
|
+
if (ts.isInferTypeNode(type))
|
|
21819
|
+
return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
|
|
21820
|
+
return false;
|
|
21821
|
+
}
|
|
21822
|
+
function parenthesizeTypeOfOptionalType(type) {
|
|
21823
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21824
|
+
return factory.createParenthesizedType(type);
|
|
21825
|
+
return parenthesizeNonArrayTypeOfPostfixType(type);
|
|
21826
|
+
}
|
|
21827
|
+
// function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
|
|
21828
|
+
// switch (member.kind) {
|
|
21829
|
+
// case SyntaxKind.UnionType:
|
|
21830
|
+
// case SyntaxKind.IntersectionType:
|
|
21831
|
+
// case SyntaxKind.FunctionType:
|
|
21832
|
+
// case SyntaxKind.ConstructorType:
|
|
21833
|
+
// return factory.createParenthesizedType(member);
|
|
21834
|
+
// }
|
|
21835
|
+
// return parenthesizeMemberOfConditionalType(member);
|
|
21836
|
+
// }
|
|
21837
|
+
// function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
|
|
21838
|
+
// switch (member.kind) {
|
|
21839
|
+
// case SyntaxKind.TypeQuery:
|
|
21840
|
+
// case SyntaxKind.TypeOperator:
|
|
21841
|
+
// case SyntaxKind.InferType:
|
|
21842
|
+
// return factory.createParenthesizedType(member);
|
|
21843
|
+
// }
|
|
21844
|
+
// return parenthesizeMemberOfElementType(member);
|
|
21845
|
+
// }
|
|
21846
|
+
function parenthesizeLeadingTypeArgument(node) {
|
|
21847
|
+
return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
|
|
21622
21848
|
}
|
|
21623
21849
|
function parenthesizeOrdinalTypeArgument(node, i) {
|
|
21624
|
-
return i === 0
|
|
21850
|
+
return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
|
|
21625
21851
|
}
|
|
21626
21852
|
function parenthesizeTypeArguments(typeArguments) {
|
|
21627
21853
|
if (ts.some(typeArguments)) {
|
|
@@ -21647,11 +21873,20 @@ var ts;
|
|
|
21647
21873
|
parenthesizeExpressionForDisallowedComma: ts.identity,
|
|
21648
21874
|
parenthesizeExpressionOfExpressionStatement: ts.identity,
|
|
21649
21875
|
parenthesizeConciseBodyOfArrowFunction: ts.identity,
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21653
|
-
|
|
21876
|
+
parenthesizeCheckTypeOfConditionalType: ts.identity,
|
|
21877
|
+
parenthesizeExtendsTypeOfConditionalType: ts.identity,
|
|
21878
|
+
parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21879
|
+
parenthesizeConstituentTypeOfUnionType: ts.identity,
|
|
21880
|
+
parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21881
|
+
parenthesizeConstituentTypeOfIntersectionType: ts.identity,
|
|
21882
|
+
parenthesizeOperandOfTypeOperator: ts.identity,
|
|
21883
|
+
parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
|
|
21884
|
+
parenthesizeNonArrayTypeOfPostfixType: ts.identity,
|
|
21885
|
+
parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21886
|
+
parenthesizeElementTypeOfTupleType: ts.identity,
|
|
21887
|
+
parenthesizeTypeOfOptionalType: ts.identity,
|
|
21654
21888
|
parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
|
|
21889
|
+
parenthesizeLeadingTypeArgument: ts.identity,
|
|
21655
21890
|
};
|
|
21656
21891
|
})(ts || (ts = {}));
|
|
21657
21892
|
/* @internal */
|
|
@@ -21791,6 +22026,8 @@ var ts;
|
|
|
21791
22026
|
var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
|
|
21792
22027
|
var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
|
|
21793
22028
|
var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
|
|
22029
|
+
var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
|
|
22030
|
+
var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
|
|
21794
22031
|
var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
|
|
21795
22032
|
var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
|
|
21796
22033
|
var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
|
|
@@ -21798,6 +22035,8 @@ var ts;
|
|
|
21798
22035
|
var factory = {
|
|
21799
22036
|
get parenthesizer() { return parenthesizerRules(); },
|
|
21800
22037
|
get converters() { return converters(); },
|
|
22038
|
+
baseFactory: baseFactory,
|
|
22039
|
+
flags: flags,
|
|
21801
22040
|
createNodeArray: createNodeArray,
|
|
21802
22041
|
createNumericLiteral: createNumericLiteral,
|
|
21803
22042
|
createBigIntLiteral: createBigIntLiteral,
|
|
@@ -22073,10 +22312,10 @@ var ts;
|
|
|
22073
22312
|
// lazily load factory members for JSDoc types with similar structure
|
|
22074
22313
|
get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
|
|
22075
22314
|
get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
|
|
22076
|
-
get createJSDocNonNullableType() { return
|
|
22077
|
-
get updateJSDocNonNullableType() { return
|
|
22078
|
-
get createJSDocNullableType() { return
|
|
22079
|
-
get updateJSDocNullableType() { return
|
|
22315
|
+
get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
|
|
22316
|
+
get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
|
|
22317
|
+
get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
|
|
22318
|
+
get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
|
|
22080
22319
|
get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
|
|
22081
22320
|
get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
|
|
22082
22321
|
get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
|
|
@@ -23192,7 +23431,7 @@ var ts;
|
|
|
23192
23431
|
// @api
|
|
23193
23432
|
function createArrayTypeNode(elementType) {
|
|
23194
23433
|
var node = createBaseNode(183 /* ArrayType */);
|
|
23195
|
-
node.elementType = parenthesizerRules().
|
|
23434
|
+
node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
|
|
23196
23435
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23197
23436
|
return node;
|
|
23198
23437
|
}
|
|
@@ -23205,7 +23444,7 @@ var ts;
|
|
|
23205
23444
|
// @api
|
|
23206
23445
|
function createTupleTypeNode(elements) {
|
|
23207
23446
|
var node = createBaseNode(184 /* TupleType */);
|
|
23208
|
-
node.elements = createNodeArray(elements);
|
|
23447
|
+
node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
|
|
23209
23448
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23210
23449
|
return node;
|
|
23211
23450
|
}
|
|
@@ -23237,7 +23476,7 @@ var ts;
|
|
|
23237
23476
|
// @api
|
|
23238
23477
|
function createOptionalTypeNode(type) {
|
|
23239
23478
|
var node = createBaseNode(185 /* OptionalType */);
|
|
23240
|
-
node.type = parenthesizerRules().
|
|
23479
|
+
node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
|
|
23241
23480
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23242
23481
|
return node;
|
|
23243
23482
|
}
|
|
@@ -23260,38 +23499,38 @@ var ts;
|
|
|
23260
23499
|
? update(createRestTypeNode(type), node)
|
|
23261
23500
|
: node;
|
|
23262
23501
|
}
|
|
23263
|
-
function createUnionOrIntersectionTypeNode(kind, types) {
|
|
23502
|
+
function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
|
|
23264
23503
|
var node = createBaseNode(kind);
|
|
23265
|
-
node.types =
|
|
23504
|
+
node.types = factory.createNodeArray(parenthesize(types));
|
|
23266
23505
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23267
23506
|
return node;
|
|
23268
23507
|
}
|
|
23269
|
-
function updateUnionOrIntersectionTypeNode(node, types) {
|
|
23508
|
+
function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
|
|
23270
23509
|
return node.types !== types
|
|
23271
|
-
? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
|
|
23510
|
+
? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
|
|
23272
23511
|
: node;
|
|
23273
23512
|
}
|
|
23274
23513
|
// @api
|
|
23275
23514
|
function createUnionTypeNode(types) {
|
|
23276
|
-
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
|
|
23515
|
+
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23277
23516
|
}
|
|
23278
23517
|
// @api
|
|
23279
23518
|
function updateUnionTypeNode(node, types) {
|
|
23280
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23519
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23281
23520
|
}
|
|
23282
23521
|
// @api
|
|
23283
23522
|
function createIntersectionTypeNode(types) {
|
|
23284
|
-
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
|
|
23523
|
+
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23285
23524
|
}
|
|
23286
23525
|
// @api
|
|
23287
23526
|
function updateIntersectionTypeNode(node, types) {
|
|
23288
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23527
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23289
23528
|
}
|
|
23290
23529
|
// @api
|
|
23291
23530
|
function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
|
|
23292
23531
|
var node = createBaseNode(189 /* ConditionalType */);
|
|
23293
|
-
node.checkType = parenthesizerRules().
|
|
23294
|
-
node.extendsType = parenthesizerRules().
|
|
23532
|
+
node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
|
|
23533
|
+
node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
|
|
23295
23534
|
node.trueType = trueType;
|
|
23296
23535
|
node.falseType = falseType;
|
|
23297
23536
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
@@ -23386,7 +23625,9 @@ var ts;
|
|
|
23386
23625
|
function createTypeOperatorNode(operator, type) {
|
|
23387
23626
|
var node = createBaseNode(193 /* TypeOperator */);
|
|
23388
23627
|
node.operator = operator;
|
|
23389
|
-
node.type =
|
|
23628
|
+
node.type = operator === 145 /* ReadonlyKeyword */ ?
|
|
23629
|
+
parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
|
|
23630
|
+
parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
|
|
23390
23631
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23391
23632
|
return node;
|
|
23392
23633
|
}
|
|
@@ -23399,7 +23640,7 @@ var ts;
|
|
|
23399
23640
|
// @api
|
|
23400
23641
|
function createIndexedAccessTypeNode(objectType, indexType) {
|
|
23401
23642
|
var node = createBaseNode(194 /* IndexedAccessType */);
|
|
23402
|
-
node.objectType = parenthesizerRules().
|
|
23643
|
+
node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
|
|
23403
23644
|
node.indexType = indexType;
|
|
23404
23645
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23405
23646
|
return node;
|
|
@@ -25135,8 +25376,15 @@ var ts;
|
|
|
25135
25376
|
return createBaseNode(kind);
|
|
25136
25377
|
}
|
|
25137
25378
|
// @api
|
|
25138
|
-
// createJSDocNonNullableType
|
|
25139
25379
|
// createJSDocNullableType
|
|
25380
|
+
// createJSDocNonNullableType
|
|
25381
|
+
function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
|
|
25382
|
+
if (postfix === void 0) { postfix = false; }
|
|
25383
|
+
var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
|
|
25384
|
+
node.postfix = postfix;
|
|
25385
|
+
return node;
|
|
25386
|
+
}
|
|
25387
|
+
// @api
|
|
25140
25388
|
// createJSDocOptionalType
|
|
25141
25389
|
// createJSDocVariadicType
|
|
25142
25390
|
// createJSDocNamepathType
|
|
@@ -25148,6 +25396,12 @@ var ts;
|
|
|
25148
25396
|
// @api
|
|
25149
25397
|
// updateJSDocNonNullableType
|
|
25150
25398
|
// updateJSDocNullableType
|
|
25399
|
+
function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
|
|
25400
|
+
return node.type !== type
|
|
25401
|
+
? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
|
|
25402
|
+
: node;
|
|
25403
|
+
}
|
|
25404
|
+
// @api
|
|
25151
25405
|
// updateJSDocOptionalType
|
|
25152
25406
|
// updateJSDocVariadicType
|
|
25153
25407
|
// updateJSDocNamepathType
|
|
@@ -30228,7 +30482,7 @@ var ts;
|
|
|
30228
30482
|
|| ts.isExportDeclaration(node) ? node : undefined;
|
|
30229
30483
|
}
|
|
30230
30484
|
function getImportMetaIfNecessary(sourceFile) {
|
|
30231
|
-
return sourceFile.flags &
|
|
30485
|
+
return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
|
|
30232
30486
|
walkTreeForImportMeta(sourceFile) :
|
|
30233
30487
|
undefined;
|
|
30234
30488
|
}
|
|
@@ -30883,7 +31137,7 @@ var ts;
|
|
|
30883
31137
|
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
30884
31138
|
// 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.
|
|
30885
31139
|
// We will manually port the flag to the new source file.
|
|
30886
|
-
newSourceFile.flags |= (sourceFile.flags &
|
|
31140
|
+
newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
|
|
30887
31141
|
return newSourceFile;
|
|
30888
31142
|
}
|
|
30889
31143
|
ts.updateSourceFile = updateSourceFile;
|
|
@@ -31167,10 +31421,10 @@ var ts;
|
|
|
31167
31421
|
switch (scriptKind) {
|
|
31168
31422
|
case 1 /* JS */:
|
|
31169
31423
|
case 2 /* JSX */:
|
|
31170
|
-
contextFlags =
|
|
31424
|
+
contextFlags = 262144 /* JavaScriptFile */;
|
|
31171
31425
|
break;
|
|
31172
31426
|
case 6 /* JSON */:
|
|
31173
|
-
contextFlags =
|
|
31427
|
+
contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
|
|
31174
31428
|
break;
|
|
31175
31429
|
default:
|
|
31176
31430
|
contextFlags = 0 /* None */;
|
|
@@ -31205,7 +31459,7 @@ var ts;
|
|
|
31205
31459
|
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
|
|
31206
31460
|
var isDeclarationFile = isDeclarationFileName(fileName);
|
|
31207
31461
|
if (isDeclarationFile) {
|
|
31208
|
-
contextFlags |=
|
|
31462
|
+
contextFlags |= 16777216 /* Ambient */;
|
|
31209
31463
|
}
|
|
31210
31464
|
sourceFlags = contextFlags;
|
|
31211
31465
|
// Prime the scanner.
|
|
@@ -31244,7 +31498,7 @@ var ts;
|
|
|
31244
31498
|
node.jsDoc = jsDoc;
|
|
31245
31499
|
if (hasDeprecatedTag) {
|
|
31246
31500
|
hasDeprecatedTag = false;
|
|
31247
|
-
node.flags |=
|
|
31501
|
+
node.flags |= 268435456 /* Deprecated */;
|
|
31248
31502
|
}
|
|
31249
31503
|
return node;
|
|
31250
31504
|
}
|
|
@@ -31439,6 +31693,12 @@ var ts;
|
|
|
31439
31693
|
function disallowInAnd(func) {
|
|
31440
31694
|
return doInsideOfContext(4096 /* DisallowInContext */, func);
|
|
31441
31695
|
}
|
|
31696
|
+
function allowConditionalTypesAnd(func) {
|
|
31697
|
+
return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31698
|
+
}
|
|
31699
|
+
function disallowConditionalTypesAnd(func) {
|
|
31700
|
+
return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31701
|
+
}
|
|
31442
31702
|
function doInYieldContext(func) {
|
|
31443
31703
|
return doInsideOfContext(8192 /* YieldContext */, func);
|
|
31444
31704
|
}
|
|
@@ -31466,6 +31726,9 @@ var ts;
|
|
|
31466
31726
|
function inDisallowInContext() {
|
|
31467
31727
|
return inContext(4096 /* DisallowInContext */);
|
|
31468
31728
|
}
|
|
31729
|
+
function inDisallowConditionalTypesContext() {
|
|
31730
|
+
return inContext(65536 /* DisallowConditionalTypesContext */);
|
|
31731
|
+
}
|
|
31469
31732
|
function inDecoratorContext() {
|
|
31470
31733
|
return inContext(16384 /* DecoratorContext */);
|
|
31471
31734
|
}
|
|
@@ -31850,7 +32113,7 @@ var ts;
|
|
|
31850
32113
|
// flag so that we don't mark any subsequent nodes.
|
|
31851
32114
|
if (parseErrorBeforeNextFinishedNode) {
|
|
31852
32115
|
parseErrorBeforeNextFinishedNode = false;
|
|
31853
|
-
node.flags |=
|
|
32116
|
+
node.flags |= 131072 /* ThisNodeHasError */;
|
|
31854
32117
|
}
|
|
31855
32118
|
return node;
|
|
31856
32119
|
}
|
|
@@ -32308,7 +32571,7 @@ var ts;
|
|
|
32308
32571
|
// differently depending on what mode it is in.
|
|
32309
32572
|
//
|
|
32310
32573
|
// This also applies to all our other context flags as well.
|
|
32311
|
-
var nodeContextFlags = node.flags &
|
|
32574
|
+
var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
|
|
32312
32575
|
if (nodeContextFlags !== contextFlags) {
|
|
32313
32576
|
return undefined;
|
|
32314
32577
|
}
|
|
@@ -32833,7 +33096,7 @@ var ts;
|
|
|
32833
33096
|
function parseJSDocNonNullableType() {
|
|
32834
33097
|
var pos = getNodePos();
|
|
32835
33098
|
nextToken();
|
|
32836
|
-
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
|
|
33099
|
+
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
|
|
32837
33100
|
}
|
|
32838
33101
|
function parseJSDocUnknownOrNullableType() {
|
|
32839
33102
|
var pos = getNodePos();
|
|
@@ -32857,7 +33120,7 @@ var ts;
|
|
|
32857
33120
|
return finishNode(factory.createJSDocUnknownType(), pos);
|
|
32858
33121
|
}
|
|
32859
33122
|
else {
|
|
32860
|
-
return finishNode(factory.createJSDocNullableType(parseType()), pos);
|
|
33123
|
+
return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
|
|
32861
33124
|
}
|
|
32862
33125
|
}
|
|
32863
33126
|
function parseJSDocFunctionType() {
|
|
@@ -33029,7 +33292,7 @@ var ts;
|
|
|
33029
33292
|
}
|
|
33030
33293
|
function parseReturnType(returnToken, isType) {
|
|
33031
33294
|
if (shouldParseReturnType(returnToken, isType)) {
|
|
33032
|
-
return parseTypeOrTypePredicate
|
|
33295
|
+
return allowConditionalTypesAnd(parseTypeOrTypePredicate);
|
|
33033
33296
|
}
|
|
33034
33297
|
}
|
|
33035
33298
|
function shouldParseReturnType(returnToken, isType) {
|
|
@@ -33444,7 +33707,7 @@ var ts;
|
|
|
33444
33707
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
33445
33708
|
}
|
|
33446
33709
|
function parseImportType() {
|
|
33447
|
-
sourceFlags |=
|
|
33710
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
33448
33711
|
var pos = getNodePos();
|
|
33449
33712
|
var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
|
|
33450
33713
|
parseExpected(100 /* ImportKeyword */);
|
|
@@ -33594,7 +33857,7 @@ var ts;
|
|
|
33594
33857
|
switch (token()) {
|
|
33595
33858
|
case 53 /* ExclamationToken */:
|
|
33596
33859
|
nextToken();
|
|
33597
|
-
type = finishNode(factory.createJSDocNonNullableType(type), pos);
|
|
33860
|
+
type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
|
|
33598
33861
|
break;
|
|
33599
33862
|
case 57 /* QuestionToken */:
|
|
33600
33863
|
// If next token is start of a type we have a conditional type
|
|
@@ -33602,7 +33865,7 @@ var ts;
|
|
|
33602
33865
|
return type;
|
|
33603
33866
|
}
|
|
33604
33867
|
nextToken();
|
|
33605
|
-
type = finishNode(factory.createJSDocNullableType(type), pos);
|
|
33868
|
+
type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
|
|
33606
33869
|
break;
|
|
33607
33870
|
case 22 /* OpenBracketToken */:
|
|
33608
33871
|
parseExpected(22 /* OpenBracketToken */);
|
|
@@ -33627,12 +33890,20 @@ var ts;
|
|
|
33627
33890
|
parseExpected(operator);
|
|
33628
33891
|
return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
|
|
33629
33892
|
}
|
|
33893
|
+
function tryParseConstraintOfInferType() {
|
|
33894
|
+
if (parseOptional(94 /* ExtendsKeyword */)) {
|
|
33895
|
+
var constraint = disallowConditionalTypesAnd(parseType);
|
|
33896
|
+
if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
|
|
33897
|
+
return constraint;
|
|
33898
|
+
}
|
|
33899
|
+
}
|
|
33900
|
+
}
|
|
33630
33901
|
function parseTypeParameterOfInferType() {
|
|
33631
33902
|
var pos = getNodePos();
|
|
33632
|
-
|
|
33633
|
-
|
|
33634
|
-
/*
|
|
33635
|
-
|
|
33903
|
+
var name = parseIdentifier();
|
|
33904
|
+
var constraint = tryParse(tryParseConstraintOfInferType);
|
|
33905
|
+
var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
|
|
33906
|
+
return finishNode(node, pos);
|
|
33636
33907
|
}
|
|
33637
33908
|
function parseInferType() {
|
|
33638
33909
|
var pos = getNodePos();
|
|
@@ -33649,7 +33920,7 @@ var ts;
|
|
|
33649
33920
|
case 137 /* InferKeyword */:
|
|
33650
33921
|
return parseInferType();
|
|
33651
33922
|
}
|
|
33652
|
-
return parsePostfixTypeOrHigher
|
|
33923
|
+
return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
|
|
33653
33924
|
}
|
|
33654
33925
|
function parseFunctionOrConstructorTypeToError(isInUnionType) {
|
|
33655
33926
|
// the function type and constructor type shorthand notation
|
|
@@ -33779,23 +34050,21 @@ var ts;
|
|
|
33779
34050
|
return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
|
|
33780
34051
|
}
|
|
33781
34052
|
function parseType() {
|
|
33782
|
-
|
|
33783
|
-
|
|
33784
|
-
|
|
33785
|
-
}
|
|
33786
|
-
function parseTypeWorker(noConditionalTypes) {
|
|
34053
|
+
if (contextFlags & 40960 /* TypeExcludesFlags */) {
|
|
34054
|
+
return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
|
|
34055
|
+
}
|
|
33787
34056
|
if (isStartOfFunctionTypeOrConstructorType()) {
|
|
33788
34057
|
return parseFunctionOrConstructorType();
|
|
33789
34058
|
}
|
|
33790
34059
|
var pos = getNodePos();
|
|
33791
34060
|
var type = parseUnionTypeOrHigher();
|
|
33792
|
-
if (!
|
|
34061
|
+
if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
|
|
33793
34062
|
// The type following 'extends' is not permitted to be another conditional type
|
|
33794
|
-
var extendsType =
|
|
34063
|
+
var extendsType = disallowConditionalTypesAnd(parseType);
|
|
33795
34064
|
parseExpected(57 /* QuestionToken */);
|
|
33796
|
-
var trueType =
|
|
34065
|
+
var trueType = allowConditionalTypesAnd(parseType);
|
|
33797
34066
|
parseExpected(58 /* ColonToken */);
|
|
33798
|
-
var falseType =
|
|
34067
|
+
var falseType = allowConditionalTypesAnd(parseType);
|
|
33799
34068
|
return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
|
|
33800
34069
|
}
|
|
33801
34070
|
return type;
|
|
@@ -34632,7 +34901,7 @@ var ts;
|
|
|
34632
34901
|
// var foo3 = require("subfolder
|
|
34633
34902
|
// import * as foo1 from "module-from-node
|
|
34634
34903
|
// We want this import to be a statement rather than import call expression
|
|
34635
|
-
sourceFlags |=
|
|
34904
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
34636
34905
|
expression = parseTokenNode();
|
|
34637
34906
|
}
|
|
34638
34907
|
else if (lookAhead(nextTokenIsDot)) {
|
|
@@ -34640,7 +34909,7 @@ var ts;
|
|
|
34640
34909
|
nextToken(); // advance past the 'import'
|
|
34641
34910
|
nextToken(); // advance past the dot
|
|
34642
34911
|
expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
|
|
34643
|
-
sourceFlags |=
|
|
34912
|
+
sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
|
|
34644
34913
|
}
|
|
34645
34914
|
else {
|
|
34646
34915
|
expression = parseMemberExpressionOrHigher();
|
|
@@ -34856,7 +35125,7 @@ var ts;
|
|
|
34856
35125
|
return finishNode(factory.createJsxOpeningFragment(), pos);
|
|
34857
35126
|
}
|
|
34858
35127
|
var tagName = parseJsxElementName();
|
|
34859
|
-
var typeArguments = (contextFlags &
|
|
35128
|
+
var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
|
|
34860
35129
|
var attributes = parseJsxAttributes();
|
|
34861
35130
|
var node;
|
|
34862
35131
|
if (token() === 31 /* GreaterThanToken */) {
|
|
@@ -35134,7 +35403,7 @@ var ts;
|
|
|
35134
35403
|
return result;
|
|
35135
35404
|
}
|
|
35136
35405
|
function parseTypeArgumentsInExpression() {
|
|
35137
|
-
if ((contextFlags &
|
|
35406
|
+
if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
|
|
35138
35407
|
// TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
|
|
35139
35408
|
return undefined;
|
|
35140
35409
|
}
|
|
@@ -35159,34 +35428,10 @@ var ts;
|
|
|
35159
35428
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
35160
35429
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
35161
35430
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
35162
|
-
// These tokens can't follow in a call expression, nor can they start an
|
|
35163
|
-
// expression. So, consider the type argument list part of an instantiation
|
|
35164
|
-
// expression.
|
|
35165
|
-
// falls through
|
|
35166
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
35167
|
-
case 24 /* DotToken */: // foo<x>.
|
|
35168
|
-
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
35169
|
-
case 21 /* CloseParenToken */: // foo<x>)
|
|
35170
|
-
case 23 /* CloseBracketToken */: // foo<x>]
|
|
35171
|
-
case 58 /* ColonToken */: // foo<x>:
|
|
35172
|
-
case 26 /* SemicolonToken */: // foo<x>;
|
|
35173
|
-
case 57 /* QuestionToken */: // foo<x>?
|
|
35174
|
-
case 34 /* EqualsEqualsToken */: // foo<x> ==
|
|
35175
|
-
case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
35176
|
-
case 35 /* ExclamationEqualsToken */: // foo<x> !=
|
|
35177
|
-
case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
35178
|
-
case 55 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
35179
|
-
case 56 /* BarBarToken */: // foo<x> ||
|
|
35180
|
-
case 60 /* QuestionQuestionToken */: // foo<x> ??
|
|
35181
|
-
case 52 /* CaretToken */: // foo<x> ^
|
|
35182
|
-
case 50 /* AmpersandToken */: // foo<x> &
|
|
35183
|
-
case 51 /* BarToken */: // foo<x> |
|
|
35184
|
-
case 19 /* CloseBraceToken */: // foo<x> }
|
|
35185
|
-
case 1 /* EndOfFileToken */: // foo<x>
|
|
35186
35431
|
return true;
|
|
35187
35432
|
}
|
|
35188
|
-
//
|
|
35189
|
-
return
|
|
35433
|
+
// Consider something a type argument list only if the following token can't start an expression.
|
|
35434
|
+
return !isStartOfExpression();
|
|
35190
35435
|
}
|
|
35191
35436
|
function parsePrimaryExpression() {
|
|
35192
35437
|
switch (token()) {
|
|
@@ -35530,7 +35775,7 @@ var ts;
|
|
|
35530
35775
|
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35531
35776
|
var expression = allowInAnd(parseExpression);
|
|
35532
35777
|
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35533
|
-
var statement = doInsideOfContext(
|
|
35778
|
+
var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
|
|
35534
35779
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35535
35780
|
}
|
|
35536
35781
|
function parseCaseClause() {
|
|
@@ -35905,16 +36150,16 @@ var ts;
|
|
|
35905
36150
|
if (isAmbient) {
|
|
35906
36151
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
35907
36152
|
var m = _a[_i];
|
|
35908
|
-
m.flags |=
|
|
36153
|
+
m.flags |= 16777216 /* Ambient */;
|
|
35909
36154
|
}
|
|
35910
|
-
return doInsideOfContext(
|
|
36155
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
|
|
35911
36156
|
}
|
|
35912
36157
|
else {
|
|
35913
36158
|
return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
|
|
35914
36159
|
}
|
|
35915
36160
|
}
|
|
35916
36161
|
function tryReuseAmbientDeclaration() {
|
|
35917
|
-
return doInsideOfContext(
|
|
36162
|
+
return doInsideOfContext(16777216 /* Ambient */, function () {
|
|
35918
36163
|
var node = currentNode(parsingContext);
|
|
35919
36164
|
if (node) {
|
|
35920
36165
|
return consumeNode(node);
|
|
@@ -36381,9 +36626,9 @@ var ts;
|
|
|
36381
36626
|
if (isAmbient) {
|
|
36382
36627
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
36383
36628
|
var m = _a[_i];
|
|
36384
|
-
m.flags |=
|
|
36629
|
+
m.flags |= 16777216 /* Ambient */;
|
|
36385
36630
|
}
|
|
36386
|
-
return doInsideOfContext(
|
|
36631
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
|
|
36387
36632
|
}
|
|
36388
36633
|
else {
|
|
36389
36634
|
return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -36948,7 +37193,7 @@ var ts;
|
|
|
36948
37193
|
function parseJSDocTypeExpression(mayOmitBraces) {
|
|
36949
37194
|
var pos = getNodePos();
|
|
36950
37195
|
var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
|
|
36951
|
-
var type = doInsideOfContext(
|
|
37196
|
+
var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
36952
37197
|
if (!mayOmitBraces || hasBrace) {
|
|
36953
37198
|
parseExpectedJSDoc(19 /* CloseBraceToken */);
|
|
36954
37199
|
}
|
|
@@ -36977,7 +37222,7 @@ var ts;
|
|
|
36977
37222
|
JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
|
|
36978
37223
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
36979
37224
|
initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
36980
|
-
var jsDoc = doInsideOfContext(
|
|
37225
|
+
var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36981
37226
|
var sourceFile = { languageVariant: 0 /* Standard */, text: content };
|
|
36982
37227
|
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
|
|
36983
37228
|
clearState();
|
|
@@ -36988,9 +37233,9 @@ var ts;
|
|
|
36988
37233
|
var saveToken = currentToken;
|
|
36989
37234
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
36990
37235
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
36991
|
-
var comment = doInsideOfContext(
|
|
37236
|
+
var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36992
37237
|
ts.setParent(comment, parent);
|
|
36993
|
-
if (contextFlags &
|
|
37238
|
+
if (contextFlags & 262144 /* JavaScriptFile */) {
|
|
36994
37239
|
if (!jsDocDiagnostics) {
|
|
36995
37240
|
jsDocDiagnostics = [];
|
|
36996
37241
|
}
|
|
@@ -37806,7 +38051,7 @@ var ts;
|
|
|
37806
38051
|
if (isBracketed) {
|
|
37807
38052
|
skipWhitespace();
|
|
37808
38053
|
parseExpected(63 /* EqualsToken */);
|
|
37809
|
-
defaultType = doInsideOfContext(
|
|
38054
|
+
defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
37810
38055
|
parseExpected(23 /* CloseBracketToken */);
|
|
37811
38056
|
}
|
|
37812
38057
|
if (ts.nodeIsMissing(name)) {
|
|
@@ -38404,7 +38649,7 @@ var ts;
|
|
|
38404
38649
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
38405
38650
|
/** @internal */
|
|
38406
38651
|
function isDeclarationFileName(fileName) {
|
|
38407
|
-
return ts.fileExtensionIsOneOf(fileName,
|
|
38652
|
+
return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
|
|
38408
38653
|
}
|
|
38409
38654
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38410
38655
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
@@ -41912,7 +42157,8 @@ var ts;
|
|
|
41912
42157
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
41913
42158
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
41914
42159
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
41915
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42160
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42161
|
+
Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
|
|
41916
42162
|
})(Extensions || (Extensions = {}));
|
|
41917
42163
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
41918
42164
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -42857,7 +43103,21 @@ var ts;
|
|
|
42857
43103
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
42858
43104
|
}
|
|
42859
43105
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
42860
|
-
|
|
43106
|
+
var extensions;
|
|
43107
|
+
if (lookupConfig) {
|
|
43108
|
+
extensions = tsconfigExtensions;
|
|
43109
|
+
}
|
|
43110
|
+
else if (compilerOptions.noDtsResolution) {
|
|
43111
|
+
extensions = [Extensions.TsOnly];
|
|
43112
|
+
if (compilerOptions.allowJs)
|
|
43113
|
+
extensions.push(Extensions.JavaScript);
|
|
43114
|
+
if (compilerOptions.resolveJsonModule)
|
|
43115
|
+
extensions.push(Extensions.Json);
|
|
43116
|
+
}
|
|
43117
|
+
else {
|
|
43118
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
43119
|
+
}
|
|
43120
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
42861
43121
|
}
|
|
42862
43122
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
42863
43123
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -42866,6 +43126,10 @@ var ts;
|
|
|
42866
43126
|
var failedLookupLocations = [];
|
|
42867
43127
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42868
43128
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43129
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43130
|
+
if (compilerOptions.noDtsResolution) {
|
|
43131
|
+
conditions.pop();
|
|
43132
|
+
}
|
|
42869
43133
|
var state = {
|
|
42870
43134
|
compilerOptions: compilerOptions,
|
|
42871
43135
|
host: host,
|
|
@@ -42873,7 +43137,7 @@ var ts;
|
|
|
42873
43137
|
failedLookupLocations: failedLookupLocations,
|
|
42874
43138
|
packageJsonInfoCache: cache,
|
|
42875
43139
|
features: features,
|
|
42876
|
-
conditions:
|
|
43140
|
+
conditions: conditions,
|
|
42877
43141
|
};
|
|
42878
43142
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
42879
43143
|
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
|
@@ -43049,9 +43313,9 @@ var ts;
|
|
|
43049
43313
|
}
|
|
43050
43314
|
}
|
|
43051
43315
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43052
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43316
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
|
|
43053
43317
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43054
|
-
return result !== undefined ? { path: candidate, ext: ts.forEach(
|
|
43318
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
43055
43319
|
}
|
|
43056
43320
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43057
43321
|
}
|
|
@@ -43081,20 +43345,22 @@ var ts;
|
|
|
43081
43345
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43082
43346
|
}
|
|
43083
43347
|
case Extensions.TypeScript:
|
|
43348
|
+
case Extensions.TsOnly:
|
|
43349
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43084
43350
|
switch (originalExtension) {
|
|
43085
43351
|
case ".mjs" /* Mjs */:
|
|
43086
43352
|
case ".mts" /* Mts */:
|
|
43087
43353
|
case ".d.mts" /* Dmts */:
|
|
43088
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43354
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43089
43355
|
case ".cjs" /* Cjs */:
|
|
43090
43356
|
case ".cts" /* Cts */:
|
|
43091
43357
|
case ".d.cts" /* Dcts */:
|
|
43092
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43358
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43093
43359
|
case ".json" /* Json */:
|
|
43094
43360
|
candidate += ".json" /* Json */;
|
|
43095
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43361
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43096
43362
|
default:
|
|
43097
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43363
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43098
43364
|
}
|
|
43099
43365
|
case Extensions.JavaScript:
|
|
43100
43366
|
switch (originalExtension) {
|
|
@@ -43321,6 +43587,7 @@ var ts;
|
|
|
43321
43587
|
switch (extensions) {
|
|
43322
43588
|
case Extensions.JavaScript:
|
|
43323
43589
|
case Extensions.Json:
|
|
43590
|
+
case Extensions.TsOnly:
|
|
43324
43591
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43325
43592
|
break;
|
|
43326
43593
|
case Extensions.TypeScript:
|
|
@@ -43393,14 +43660,16 @@ var ts;
|
|
|
43393
43660
|
function extensionIsOk(extensions, extension) {
|
|
43394
43661
|
switch (extensions) {
|
|
43395
43662
|
case Extensions.JavaScript:
|
|
43396
|
-
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
43663
|
+
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
|
|
43397
43664
|
case Extensions.TSConfig:
|
|
43398
43665
|
case Extensions.Json:
|
|
43399
43666
|
return extension === ".json" /* Json */;
|
|
43400
43667
|
case Extensions.TypeScript:
|
|
43401
|
-
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43668
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43669
|
+
case Extensions.TsOnly:
|
|
43670
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
|
|
43402
43671
|
case Extensions.DtsOnly:
|
|
43403
|
-
return extension === ".d.ts" /* Dts */;
|
|
43672
|
+
return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43404
43673
|
}
|
|
43405
43674
|
}
|
|
43406
43675
|
/* @internal */
|
|
@@ -45560,6 +45829,7 @@ var ts;
|
|
|
45560
45829
|
case 261 /* ModuleDeclaration */:
|
|
45561
45830
|
case 259 /* TypeAliasDeclaration */:
|
|
45562
45831
|
case 195 /* MappedType */:
|
|
45832
|
+
case 176 /* IndexSignature */:
|
|
45563
45833
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45564
45834
|
case 305 /* SourceFile */:
|
|
45565
45835
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45578,7 +45848,6 @@ var ts;
|
|
|
45578
45848
|
case 317 /* JSDocFunctionType */:
|
|
45579
45849
|
case 179 /* FunctionType */:
|
|
45580
45850
|
case 175 /* ConstructSignature */:
|
|
45581
|
-
case 176 /* IndexSignature */:
|
|
45582
45851
|
case 180 /* ConstructorType */:
|
|
45583
45852
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45584
45853
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -45694,7 +45963,7 @@ var ts;
|
|
|
45694
45963
|
function setExportContextFlag(node) {
|
|
45695
45964
|
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
|
45696
45965
|
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
|
45697
|
-
if (node.flags &
|
|
45966
|
+
if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
|
|
45698
45967
|
node.flags |= 64 /* ExportContext */;
|
|
45699
45968
|
}
|
|
45700
45969
|
else {
|
|
@@ -45897,8 +46166,8 @@ var ts;
|
|
|
45897
46166
|
function checkContextualIdentifier(node) {
|
|
45898
46167
|
// Report error only if there are no parse errors in file
|
|
45899
46168
|
if (!file.parseDiagnostics.length &&
|
|
45900
|
-
!(node.flags &
|
|
45901
|
-
!(node.flags &
|
|
46169
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
46170
|
+
!(node.flags & 8388608 /* JSDoc */) &&
|
|
45902
46171
|
!ts.isIdentifierName(node)) {
|
|
45903
46172
|
// strict mode identifiers
|
|
45904
46173
|
if (inStrictMode &&
|
|
@@ -46927,7 +47196,7 @@ var ts;
|
|
|
46927
47196
|
if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
|
|
46928
47197
|
return;
|
|
46929
47198
|
}
|
|
46930
|
-
if (inStrictMode && !(node.flags &
|
|
47199
|
+
if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
|
|
46931
47200
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
|
46932
47201
|
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
|
46933
47202
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
@@ -46946,7 +47215,7 @@ var ts;
|
|
|
46946
47215
|
}
|
|
46947
47216
|
}
|
|
46948
47217
|
function bindFunctionDeclaration(node) {
|
|
46949
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47218
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46950
47219
|
if (ts.isAsyncFunction(node)) {
|
|
46951
47220
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46952
47221
|
}
|
|
@@ -46961,7 +47230,7 @@ var ts;
|
|
|
46961
47230
|
}
|
|
46962
47231
|
}
|
|
46963
47232
|
function bindFunctionExpression(node) {
|
|
46964
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47233
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46965
47234
|
if (ts.isAsyncFunction(node)) {
|
|
46966
47235
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46967
47236
|
}
|
|
@@ -46974,7 +47243,7 @@ var ts;
|
|
|
46974
47243
|
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
|
|
46975
47244
|
}
|
|
46976
47245
|
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
|
|
46977
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47246
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
|
|
46978
47247
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46979
47248
|
}
|
|
46980
47249
|
if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
|
@@ -47047,7 +47316,7 @@ var ts;
|
|
|
47047
47316
|
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
|
|
47048
47317
|
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
|
|
47049
47318
|
var isError_1 = ts.unreachableCodeIsError(options) &&
|
|
47050
|
-
!(node.flags &
|
|
47319
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
47051
47320
|
(!ts.isVariableStatement(node) ||
|
|
47052
47321
|
!!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
|
|
47053
47322
|
node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
|
|
@@ -47947,7 +48216,7 @@ var ts;
|
|
|
47947
48216
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
47948
48217
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
47949
48218
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
47950
|
-
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags &
|
|
48219
|
+
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
47951
48220
|
(diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
|
|
47952
48221
|
}
|
|
47953
48222
|
});
|
|
@@ -48398,7 +48667,7 @@ var ts;
|
|
|
48398
48667
|
return diagnostic;
|
|
48399
48668
|
}
|
|
48400
48669
|
function isDeprecatedSymbol(symbol) {
|
|
48401
|
-
return !!(getDeclarationNodeFlagsFromSymbol(symbol) &
|
|
48670
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
|
|
48402
48671
|
}
|
|
48403
48672
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
48404
48673
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
@@ -48626,7 +48895,7 @@ var ts;
|
|
|
48626
48895
|
else {
|
|
48627
48896
|
// find a module that about to be augmented
|
|
48628
48897
|
// do not validate names of augmentations that are defined in ambient context
|
|
48629
|
-
var moduleNotFoundError = !(moduleName.parent.parent.flags &
|
|
48898
|
+
var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
|
|
48630
48899
|
? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
|
|
48631
48900
|
: undefined;
|
|
48632
48901
|
var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
|
|
@@ -48740,7 +49009,7 @@ var ts;
|
|
|
48740
49009
|
if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
|
|
48741
49010
|
(!ts.outFile(compilerOptions)) ||
|
|
48742
49011
|
isInTypeQuery(usage) ||
|
|
48743
|
-
declaration.flags &
|
|
49012
|
+
declaration.flags & 16777216 /* Ambient */) {
|
|
48744
49013
|
// nodes are in different files and order cannot be determined
|
|
48745
49014
|
return true;
|
|
48746
49015
|
}
|
|
@@ -48802,7 +49071,7 @@ var ts;
|
|
|
48802
49071
|
if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
|
|
48803
49072
|
return true;
|
|
48804
49073
|
}
|
|
48805
|
-
if (!!(usage.flags &
|
|
49074
|
+
if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
|
|
48806
49075
|
return true;
|
|
48807
49076
|
}
|
|
48808
49077
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
@@ -49067,7 +49336,7 @@ var ts;
|
|
|
49067
49336
|
// falls through
|
|
49068
49337
|
case 261 /* ModuleDeclaration */:
|
|
49069
49338
|
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
49070
|
-
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags &
|
|
49339
|
+
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
49071
49340
|
// It's an external module. First see if the module has an export default and if the local
|
|
49072
49341
|
// name of that export default matches.
|
|
49073
49342
|
if (result = moduleExports.get("default" /* Default */)) {
|
|
@@ -49390,7 +49659,7 @@ var ts;
|
|
|
49390
49659
|
}
|
|
49391
49660
|
}
|
|
49392
49661
|
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49393
|
-
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags &
|
|
49662
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
|
|
49394
49663
|
var merged = getMergedSymbol(result);
|
|
49395
49664
|
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49396
49665
|
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));
|
|
@@ -49645,7 +49914,7 @@ var ts;
|
|
|
49645
49914
|
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 */); });
|
|
49646
49915
|
if (declaration === undefined)
|
|
49647
49916
|
return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
|
|
49648
|
-
if (!(declaration.flags &
|
|
49917
|
+
if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
|
|
49649
49918
|
var diagnosticMessage = void 0;
|
|
49650
49919
|
var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
|
|
49651
49920
|
if (result.flags & 2 /* BlockScopedVariable */) {
|
|
@@ -50156,27 +50425,27 @@ var ts;
|
|
|
50156
50425
|
function resolveAlias(symbol) {
|
|
50157
50426
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50158
50427
|
var links = getSymbolLinks(symbol);
|
|
50159
|
-
if (!links.
|
|
50160
|
-
links.
|
|
50428
|
+
if (!links.aliasTarget) {
|
|
50429
|
+
links.aliasTarget = resolvingSymbol;
|
|
50161
50430
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50162
50431
|
if (!node)
|
|
50163
50432
|
return ts.Debug.fail();
|
|
50164
50433
|
var target = getTargetOfAliasDeclaration(node);
|
|
50165
|
-
if (links.
|
|
50166
|
-
links.
|
|
50434
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50435
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50167
50436
|
}
|
|
50168
50437
|
else {
|
|
50169
50438
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50170
50439
|
}
|
|
50171
50440
|
}
|
|
50172
|
-
else if (links.
|
|
50173
|
-
links.
|
|
50441
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50442
|
+
links.aliasTarget = unknownSymbol;
|
|
50174
50443
|
}
|
|
50175
|
-
return links.
|
|
50444
|
+
return links.aliasTarget;
|
|
50176
50445
|
}
|
|
50177
50446
|
function tryResolveAlias(symbol) {
|
|
50178
50447
|
var links = getSymbolLinks(symbol);
|
|
50179
|
-
if (links.
|
|
50448
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50180
50449
|
return resolveAlias(symbol);
|
|
50181
50450
|
}
|
|
50182
50451
|
return undefined;
|
|
@@ -50418,7 +50687,7 @@ var ts;
|
|
|
50418
50687
|
}
|
|
50419
50688
|
}
|
|
50420
50689
|
function getAssignmentDeclarationLocation(node) {
|
|
50421
|
-
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags &
|
|
50690
|
+
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
|
|
50422
50691
|
if (typeAlias) {
|
|
50423
50692
|
return;
|
|
50424
50693
|
}
|
|
@@ -51886,7 +52155,20 @@ var ts;
|
|
|
51886
52155
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
51887
52156
|
if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
|
|
51888
52157
|
context.approximateLength += (ts.symbolName(type.symbol).length + 6);
|
|
51889
|
-
|
|
52158
|
+
var constraintNode = void 0;
|
|
52159
|
+
var constraint = getConstraintOfTypeParameter(type);
|
|
52160
|
+
if (constraint) {
|
|
52161
|
+
// If the infer type has a constraint that is not the same as the constraint
|
|
52162
|
+
// we would have normally inferred based on context, we emit the constraint
|
|
52163
|
+
// using `infer T extends ?`. We omit inferred constraints from type references
|
|
52164
|
+
// as they may be elided.
|
|
52165
|
+
var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
|
|
52166
|
+
if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
|
|
52167
|
+
context.approximateLength += 9;
|
|
52168
|
+
constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
52169
|
+
}
|
|
52170
|
+
}
|
|
52171
|
+
return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
|
|
51890
52172
|
}
|
|
51891
52173
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
|
|
51892
52174
|
type.flags & 262144 /* TypeParameter */ &&
|
|
@@ -51960,13 +52242,37 @@ var ts;
|
|
|
51960
52242
|
return ts.Debug.fail("Should be unreachable.");
|
|
51961
52243
|
function conditionalTypeToTypeNode(type) {
|
|
51962
52244
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52245
|
+
context.approximateLength += 15;
|
|
52246
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52247
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52248
|
+
var name = typeParameterToName(newParam, context);
|
|
52249
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52250
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52251
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52252
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52253
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52254
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52255
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52256
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52257
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52258
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52259
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52260
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52261
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52262
|
+
// this is potentially simplifiable to
|
|
52263
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52264
|
+
// but that may confuse users who read the output more.
|
|
52265
|
+
// On the other hand,
|
|
52266
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52267
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52268
|
+
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 */));
|
|
52269
|
+
}
|
|
51963
52270
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
51964
52271
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
51965
52272
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
51966
52273
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
51967
52274
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
51968
52275
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
51969
|
-
context.approximateLength += 15;
|
|
51970
52276
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
51971
52277
|
}
|
|
51972
52278
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -52665,9 +52971,6 @@ var ts;
|
|
|
52665
52971
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
52666
52972
|
parameterType = getOptionalType(parameterType);
|
|
52667
52973
|
}
|
|
52668
|
-
if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
|
52669
|
-
parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
|
|
52670
|
-
}
|
|
52671
52974
|
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
52672
52975
|
var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
|
|
52673
52976
|
var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
@@ -53226,7 +53529,7 @@ var ts;
|
|
|
53226
53529
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
53227
53530
|
// try to reuse the existing annotation
|
|
53228
53531
|
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
53229
|
-
if (
|
|
53532
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
53230
53533
|
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
53231
53534
|
if (result_6) {
|
|
53232
53535
|
return result_6;
|
|
@@ -53243,6 +53546,16 @@ var ts;
|
|
|
53243
53546
|
context.flags = oldFlags;
|
|
53244
53547
|
return result;
|
|
53245
53548
|
}
|
|
53549
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
53550
|
+
var typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
53551
|
+
if (typeFromTypeNode === type) {
|
|
53552
|
+
return true;
|
|
53553
|
+
}
|
|
53554
|
+
if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
53555
|
+
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
53556
|
+
}
|
|
53557
|
+
return false;
|
|
53558
|
+
}
|
|
53246
53559
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
53247
53560
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
53248
53561
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
@@ -53842,7 +54155,7 @@ var ts;
|
|
|
53842
54155
|
newModifierFlags |= 1 /* Export */;
|
|
53843
54156
|
}
|
|
53844
54157
|
if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
|
|
53845
|
-
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags &
|
|
54158
|
+
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
|
|
53846
54159
|
(ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
|
|
53847
54160
|
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
|
|
53848
54161
|
newModifierFlags |= 2 /* Ambient */;
|
|
@@ -54812,7 +55125,7 @@ var ts;
|
|
|
54812
55125
|
var parent = getDeclarationContainer(node);
|
|
54813
55126
|
// If the node is not exported or it is not ambient module element (except import declaration)
|
|
54814
55127
|
if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
|
|
54815
|
-
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags &
|
|
55128
|
+
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
|
|
54816
55129
|
return isGlobalSourceFile(parent);
|
|
54817
55130
|
}
|
|
54818
55131
|
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
|
|
@@ -55152,7 +55465,7 @@ var ts;
|
|
|
55152
55465
|
}
|
|
55153
55466
|
var pattern = declaration.parent;
|
|
55154
55467
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
55155
|
-
if (strictNullChecks && declaration.flags &
|
|
55468
|
+
if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
55156
55469
|
parentType = getNonNullableType(parentType);
|
|
55157
55470
|
}
|
|
55158
55471
|
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
|
|
@@ -55268,7 +55581,7 @@ var ts;
|
|
|
55268
55581
|
}
|
|
55269
55582
|
if ((noImplicitAny || ts.isInJSFile(declaration)) &&
|
|
55270
55583
|
ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
|
|
55271
|
-
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags &
|
|
55584
|
+
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
55272
55585
|
// If --noImplicitAny is on or the declaration is in a Javascript file,
|
|
55273
55586
|
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
|
|
55274
55587
|
// initializer or a 'null' or 'undefined' initializer.
|
|
@@ -55514,7 +55827,7 @@ var ts;
|
|
|
55514
55827
|
}
|
|
55515
55828
|
}
|
|
55516
55829
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55517
|
-
type = getUnionType(sourceTypes
|
|
55830
|
+
type = getUnionType(sourceTypes);
|
|
55518
55831
|
}
|
|
55519
55832
|
}
|
|
55520
55833
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -56724,7 +57037,7 @@ var ts;
|
|
|
56724
57037
|
function isLiteralEnumMember(member) {
|
|
56725
57038
|
var expr = member.initializer;
|
|
56726
57039
|
if (!expr) {
|
|
56727
|
-
return !(member.flags &
|
|
57040
|
+
return !(member.flags & 16777216 /* Ambient */);
|
|
56728
57041
|
}
|
|
56729
57042
|
switch (expr.kind) {
|
|
56730
57043
|
case 10 /* StringLiteral */:
|
|
@@ -58263,8 +58576,9 @@ var ts;
|
|
|
58263
58576
|
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
|
|
58264
58577
|
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
|
|
58265
58578
|
// nesting, so it is effectively just a safety stop.
|
|
58266
|
-
|
|
58267
|
-
|
|
58579
|
+
var identity_1 = getRecursionIdentity(t);
|
|
58580
|
+
if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
|
|
58581
|
+
stack.push(identity_1);
|
|
58268
58582
|
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
|
58269
58583
|
stack.pop();
|
|
58270
58584
|
}
|
|
@@ -59357,7 +59671,7 @@ var ts;
|
|
|
59357
59671
|
function getConstraintDeclaration(type) {
|
|
59358
59672
|
return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
|
|
59359
59673
|
}
|
|
59360
|
-
function getInferredTypeParameterConstraint(typeParameter) {
|
|
59674
|
+
function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
|
|
59361
59675
|
var _a;
|
|
59362
59676
|
var inferences;
|
|
59363
59677
|
if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
|
|
@@ -59369,7 +59683,7 @@ var ts;
|
|
|
59369
59683
|
// corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
|
|
59370
59684
|
// present, we form an intersection of the inferred constraint types.
|
|
59371
59685
|
var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
|
|
59372
|
-
if (grandParent.kind === 178 /* TypeReference */) {
|
|
59686
|
+
if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
|
|
59373
59687
|
var typeReference = grandParent;
|
|
59374
59688
|
var typeParameters = getTypeParametersForTypeReference(typeReference);
|
|
59375
59689
|
if (typeParameters) {
|
|
@@ -59791,7 +60105,7 @@ var ts;
|
|
|
59791
60105
|
return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
|
|
59792
60106
|
}
|
|
59793
60107
|
function isJSDocTypeReference(node) {
|
|
59794
|
-
return !!(node.flags &
|
|
60108
|
+
return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
|
|
59795
60109
|
}
|
|
59796
60110
|
function checkNoTypeArguments(node, symbol) {
|
|
59797
60111
|
if (node.typeArguments) {
|
|
@@ -61350,7 +61664,7 @@ var ts;
|
|
|
61350
61664
|
if (ts.isCallLikeExpression(parent)) {
|
|
61351
61665
|
return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
|
|
61352
61666
|
}
|
|
61353
|
-
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) &
|
|
61667
|
+
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
61354
61668
|
}
|
|
61355
61669
|
return true;
|
|
61356
61670
|
}
|
|
@@ -62043,7 +62357,7 @@ var ts;
|
|
|
62043
62357
|
links.resolvedSymbol = unknownSymbol;
|
|
62044
62358
|
return links.resolvedType = errorType;
|
|
62045
62359
|
}
|
|
62046
|
-
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags &
|
|
62360
|
+
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
|
|
62047
62361
|
// TODO: Future work: support unions/generics/whatever via a deferred import-type
|
|
62048
62362
|
var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
|
|
62049
62363
|
if (!innerModuleSymbol) {
|
|
@@ -62379,7 +62693,7 @@ var ts;
|
|
|
62379
62693
|
}
|
|
62380
62694
|
// /** @return {this} */
|
|
62381
62695
|
// x.prototype.m = function() { ... }
|
|
62382
|
-
var host = node.flags &
|
|
62696
|
+
var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
|
|
62383
62697
|
if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
|
|
62384
62698
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
|
|
62385
62699
|
}
|
|
@@ -62454,7 +62768,7 @@ var ts;
|
|
|
62454
62768
|
case 143 /* NeverKeyword */:
|
|
62455
62769
|
return neverType;
|
|
62456
62770
|
case 148 /* ObjectKeyword */:
|
|
62457
|
-
return node.flags &
|
|
62771
|
+
return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
|
|
62458
62772
|
case 138 /* IntrinsicKeyword */:
|
|
62459
62773
|
return intrinsicMarkerType;
|
|
62460
62774
|
case 192 /* ThisType */:
|
|
@@ -66462,12 +66776,12 @@ var ts;
|
|
|
66462
66776
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
66463
66777
|
if (maxDepth === void 0) { maxDepth = 3; }
|
|
66464
66778
|
if (depth >= maxDepth) {
|
|
66465
|
-
var
|
|
66779
|
+
var identity_2 = getRecursionIdentity(type);
|
|
66466
66780
|
var count = 0;
|
|
66467
66781
|
var lastTypeId = 0;
|
|
66468
66782
|
for (var i = 0; i < depth; i++) {
|
|
66469
66783
|
var t = stack[i];
|
|
66470
|
-
if (getRecursionIdentity(t) ===
|
|
66784
|
+
if (getRecursionIdentity(t) === identity_2) {
|
|
66471
66785
|
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
66472
66786
|
// type ids are an indicator of newer instantiations caused by recursion.
|
|
66473
66787
|
if (t.id >= lastTypeId) {
|
|
@@ -67331,6 +67645,9 @@ var ts;
|
|
|
67331
67645
|
var inference = inferences[i];
|
|
67332
67646
|
if (t === inference.typeParameter) {
|
|
67333
67647
|
if (fix && !inference.isFixed) {
|
|
67648
|
+
// Before we commit to a particular inference (and thus lock out any further inferences),
|
|
67649
|
+
// we infer from any intra-expression inference sites we have collected.
|
|
67650
|
+
inferFromIntraExpressionSites(context);
|
|
67334
67651
|
clearCachedInferences(inferences);
|
|
67335
67652
|
inference.isFixed = true;
|
|
67336
67653
|
}
|
|
@@ -67347,6 +67664,37 @@ var ts;
|
|
|
67347
67664
|
}
|
|
67348
67665
|
}
|
|
67349
67666
|
}
|
|
67667
|
+
function addIntraExpressionInferenceSite(context, node, type) {
|
|
67668
|
+
var _a;
|
|
67669
|
+
((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
|
|
67670
|
+
}
|
|
67671
|
+
// We collect intra-expression inference sites within object and array literals to handle cases where
|
|
67672
|
+
// inferred types flow between context sensitive element expressions. For example:
|
|
67673
|
+
//
|
|
67674
|
+
// declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
|
|
67675
|
+
// foo([_a => 0, n => n.toFixed()]);
|
|
67676
|
+
//
|
|
67677
|
+
// Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
|
|
67678
|
+
// pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
|
|
67679
|
+
// pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
|
|
67680
|
+
// parameter in the second arrow function, but we want to first infer from the return type of the first
|
|
67681
|
+
// arrow function. This happens automatically when the arrow functions are discrete arguments (because we
|
|
67682
|
+
// infer from each argument before processing the next), but when the arrow functions are elements of an
|
|
67683
|
+
// object or array literal, we need to perform intra-expression inferences early.
|
|
67684
|
+
function inferFromIntraExpressionSites(context) {
|
|
67685
|
+
if (context.intraExpressionInferenceSites) {
|
|
67686
|
+
for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
|
|
67687
|
+
var _b = _a[_i], node = _b.node, type = _b.type;
|
|
67688
|
+
var contextualType = node.kind === 169 /* MethodDeclaration */ ?
|
|
67689
|
+
getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
|
|
67690
|
+
getContextualType(node, 2 /* NoConstraints */);
|
|
67691
|
+
if (contextualType) {
|
|
67692
|
+
inferTypes(context.inferences, type, contextualType);
|
|
67693
|
+
}
|
|
67694
|
+
}
|
|
67695
|
+
context.intraExpressionInferenceSites = undefined;
|
|
67696
|
+
}
|
|
67697
|
+
}
|
|
67350
67698
|
function createInferenceInfo(typeParameter) {
|
|
67351
67699
|
return {
|
|
67352
67700
|
typeParameter: typeParameter,
|
|
@@ -69329,7 +69677,7 @@ var ts;
|
|
|
69329
69677
|
// parameter symbols with declarations that have explicit type annotations. Such references are
|
|
69330
69678
|
// resolvable with no possibility of triggering circularities in control flow analysis.
|
|
69331
69679
|
function getTypeOfDottedName(node, diagnostic) {
|
|
69332
|
-
if (!(node.flags &
|
|
69680
|
+
if (!(node.flags & 33554432 /* InWithStatement */)) {
|
|
69333
69681
|
switch (node.kind) {
|
|
69334
69682
|
case 79 /* Identifier */:
|
|
69335
69683
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
@@ -70733,6 +71081,7 @@ var ts;
|
|
|
70733
71081
|
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
|
|
70734
71082
|
// and x are of generic types T and K, we want the resulting type to be T[K].
|
|
70735
71083
|
return parent.kind === 206 /* PropertyAccessExpression */ ||
|
|
71084
|
+
parent.kind === 161 /* QualifiedName */ ||
|
|
70736
71085
|
parent.kind === 208 /* CallExpression */ && parent.expression === node ||
|
|
70737
71086
|
parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
|
|
70738
71087
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
@@ -71026,7 +71375,7 @@ var ts;
|
|
|
71026
71375
|
isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
|
|
71027
71376
|
node.parent.kind === 230 /* NonNullExpression */ ||
|
|
71028
71377
|
declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
|
|
71029
|
-
declaration.flags &
|
|
71378
|
+
declaration.flags & 16777216 /* Ambient */;
|
|
71030
71379
|
var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
|
|
71031
71380
|
type === autoType || type === autoArrayType ? undefinedType :
|
|
71032
71381
|
getOptionalType(type);
|
|
@@ -72034,7 +72383,7 @@ var ts;
|
|
|
72034
72383
|
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
|
72035
72384
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
72036
72385
|
ts.Debug.assert(ts.isObjectLiteralMethod(node));
|
|
72037
|
-
if (node.flags &
|
|
72386
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72038
72387
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72039
72388
|
return undefined;
|
|
72040
72389
|
}
|
|
@@ -72222,7 +72571,7 @@ var ts;
|
|
|
72222
72571
|
* @returns the contextual type of an expression.
|
|
72223
72572
|
*/
|
|
72224
72573
|
function getContextualType(node, contextFlags) {
|
|
72225
|
-
if (node.flags &
|
|
72574
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72226
72575
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72227
72576
|
return undefined;
|
|
72228
72577
|
}
|
|
@@ -72640,6 +72989,11 @@ var ts;
|
|
|
72640
72989
|
var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
|
|
72641
72990
|
elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
|
|
72642
72991
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72992
|
+
if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
72993
|
+
var inferenceContext = getInferenceContext(node);
|
|
72994
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
72995
|
+
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
72996
|
+
}
|
|
72643
72997
|
}
|
|
72644
72998
|
}
|
|
72645
72999
|
if (inDestructuringPattern) {
|
|
@@ -72841,6 +73195,13 @@ var ts;
|
|
|
72841
73195
|
prop.target = member;
|
|
72842
73196
|
member = prop;
|
|
72843
73197
|
allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
73198
|
+
if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
|
|
73199
|
+
(memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
73200
|
+
var inferenceContext = getInferenceContext(node);
|
|
73201
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
73202
|
+
var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
73203
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73204
|
+
}
|
|
72844
73205
|
}
|
|
72845
73206
|
else if (memberDecl.kind === 298 /* SpreadAssignment */) {
|
|
72846
73207
|
if (languageVersion < 2 /* ES2015 */) {
|
|
@@ -73933,7 +74294,7 @@ var ts;
|
|
|
73933
74294
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73934
74295
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73935
74296
|
}
|
|
73936
|
-
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) &
|
|
74297
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
|
|
73937
74298
|
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73938
74299
|
}
|
|
73939
74300
|
}
|
|
@@ -74001,7 +74362,7 @@ var ts;
|
|
|
74001
74362
|
if (declaration && isPropertyWithoutInitializer(declaration)) {
|
|
74002
74363
|
if (!ts.isStatic(declaration)) {
|
|
74003
74364
|
var flowContainer = getControlFlowContainer(node);
|
|
74004
|
-
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags &
|
|
74365
|
+
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
74005
74366
|
assumeUninitialized = true;
|
|
74006
74367
|
}
|
|
74007
74368
|
}
|
|
@@ -74038,7 +74399,7 @@ var ts;
|
|
|
74038
74399
|
}
|
|
74039
74400
|
else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
|
|
74040
74401
|
node.parent.kind !== 178 /* TypeReference */ &&
|
|
74041
|
-
!(valueDeclaration.flags &
|
|
74402
|
+
!(valueDeclaration.flags & 16777216 /* Ambient */) &&
|
|
74042
74403
|
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74043
74404
|
diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
74044
74405
|
}
|
|
@@ -74703,34 +75064,36 @@ var ts;
|
|
|
74703
75064
|
if (node.kind !== 165 /* Decorator */) {
|
|
74704
75065
|
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
74705
75066
|
if (contextualType) {
|
|
74706
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
74707
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
74708
|
-
// inferred for any outer call expression so far.
|
|
74709
|
-
var outerContext = getInferenceContext(node);
|
|
74710
|
-
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
74711
|
-
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
74712
|
-
// If the contextual type is a generic function type with a single call signature, we
|
|
74713
|
-
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
74714
|
-
// the type parameters are not erased to type any during type inference such that they can
|
|
74715
|
-
// be inferred as actual types from the contextual type. For example:
|
|
74716
|
-
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
74717
|
-
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
74718
|
-
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
74719
|
-
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
74720
|
-
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
74721
|
-
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
74722
|
-
instantiatedType;
|
|
74723
75067
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
74724
|
-
|
|
74725
|
-
|
|
74726
|
-
|
|
74727
|
-
|
|
74728
|
-
|
|
74729
|
-
|
|
74730
|
-
|
|
74731
|
-
|
|
74732
|
-
|
|
74733
|
-
|
|
75068
|
+
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
75069
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
75070
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
75071
|
+
// inferred for any outer call expression so far.
|
|
75072
|
+
var outerContext = getInferenceContext(node);
|
|
75073
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
75074
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
75075
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
75076
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
75077
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
75078
|
+
// be inferred as actual types from the contextual type. For example:
|
|
75079
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
75080
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
75081
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
75082
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
75083
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
75084
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
75085
|
+
instantiatedType;
|
|
75086
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
75087
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
75088
|
+
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75089
|
+
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75090
|
+
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
75091
|
+
// outer arguments), and (b) we don't want any further inferences going into this context.
|
|
75092
|
+
var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
75093
|
+
var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
75094
|
+
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
75095
|
+
context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
|
75096
|
+
}
|
|
74734
75097
|
}
|
|
74735
75098
|
}
|
|
74736
75099
|
var restType = getNonArrayRestType(signature);
|
|
@@ -74742,7 +75105,7 @@ var ts;
|
|
|
74742
75105
|
}
|
|
74743
75106
|
}
|
|
74744
75107
|
var thisType = getThisTypeOfSignature(signature);
|
|
74745
|
-
if (thisType) {
|
|
75108
|
+
if (thisType && couldContainTypeVariables(thisType)) {
|
|
74746
75109
|
var thisArgumentNode = getThisArgumentOfCall(node);
|
|
74747
75110
|
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
74748
75111
|
}
|
|
@@ -74750,11 +75113,13 @@ var ts;
|
|
|
74750
75113
|
var arg = args[i];
|
|
74751
75114
|
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74752
75115
|
var paramType = getTypeAtPosition(signature, i);
|
|
74753
|
-
|
|
74754
|
-
|
|
75116
|
+
if (couldContainTypeVariables(paramType)) {
|
|
75117
|
+
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
75118
|
+
inferTypes(context.inferences, argType, paramType);
|
|
75119
|
+
}
|
|
74755
75120
|
}
|
|
74756
75121
|
}
|
|
74757
|
-
if (restType) {
|
|
75122
|
+
if (restType && couldContainTypeVariables(restType)) {
|
|
74758
75123
|
var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
|
|
74759
75124
|
inferTypes(context.inferences, spreadType, restType);
|
|
74760
75125
|
}
|
|
@@ -76334,7 +76699,7 @@ var ts;
|
|
|
76334
76699
|
return returnType;
|
|
76335
76700
|
}
|
|
76336
76701
|
function checkDeprecatedSignature(signature, node) {
|
|
76337
|
-
if (signature.declaration && signature.declaration.flags &
|
|
76702
|
+
if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
|
|
76338
76703
|
var suggestionNode = getDeprecatedSuggestionNode(node);
|
|
76339
76704
|
var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
|
|
76340
76705
|
addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
|
|
@@ -76418,7 +76783,7 @@ var ts;
|
|
|
76418
76783
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76419
76784
|
newSymbol.parent = originalSymbol;
|
|
76420
76785
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76421
|
-
newSymbol.
|
|
76786
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76422
76787
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76423
76788
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76424
76789
|
}
|
|
@@ -76478,7 +76843,7 @@ var ts;
|
|
|
76478
76843
|
if (targetDeclarationKind !== 0 /* Unknown */) {
|
|
76479
76844
|
var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
|
|
76480
76845
|
// function/variable declaration should be ambient
|
|
76481
|
-
return !!decl && !!(decl.flags &
|
|
76846
|
+
return !!decl && !!(decl.flags & 16777216 /* Ambient */);
|
|
76482
76847
|
}
|
|
76483
76848
|
return false;
|
|
76484
76849
|
}
|
|
@@ -76673,7 +77038,7 @@ var ts;
|
|
|
76673
77038
|
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
76674
77039
|
}
|
|
76675
77040
|
var file = ts.getSourceFileOfNode(node);
|
|
76676
|
-
ts.Debug.assert(!!(file.flags &
|
|
77041
|
+
ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
76677
77042
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
76678
77043
|
}
|
|
76679
77044
|
function getTypeOfParameter(symbol) {
|
|
@@ -78687,6 +79052,11 @@ var ts;
|
|
|
78687
79052
|
context.contextualType = contextualType;
|
|
78688
79053
|
context.inferenceContext = inferenceContext;
|
|
78689
79054
|
var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
|
|
79055
|
+
// In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
|
|
79056
|
+
// parameters. This information is no longer needed after the call to checkExpression.
|
|
79057
|
+
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
79058
|
+
inferenceContext.intraExpressionInferenceSites = undefined;
|
|
79059
|
+
}
|
|
78690
79060
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
78691
79061
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
78692
79062
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
@@ -78978,7 +79348,7 @@ var ts;
|
|
|
78978
79348
|
return quickType;
|
|
78979
79349
|
}
|
|
78980
79350
|
// If a type has been cached for the node, return it.
|
|
78981
|
-
if (node.flags &
|
|
79351
|
+
if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
|
|
78982
79352
|
var cachedType = flowTypeCache[getNodeId(node)];
|
|
78983
79353
|
if (cachedType) {
|
|
78984
79354
|
return cachedType;
|
|
@@ -78990,7 +79360,7 @@ var ts;
|
|
|
78990
79360
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78991
79361
|
var cache = flowTypeCache || (flowTypeCache = []);
|
|
78992
79362
|
cache[getNodeId(node)] = type;
|
|
78993
|
-
ts.setNodeFlags(node, node.flags |
|
|
79363
|
+
ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
|
|
78994
79364
|
}
|
|
78995
79365
|
return type;
|
|
78996
79366
|
}
|
|
@@ -79076,7 +79446,7 @@ var ts;
|
|
|
79076
79446
|
if (compilerOptions.isolatedModules) {
|
|
79077
79447
|
ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
79078
79448
|
var constEnumDeclaration = type.symbol.valueDeclaration;
|
|
79079
|
-
if (constEnumDeclaration.flags &
|
|
79449
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
79080
79450
|
error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
|
|
79081
79451
|
}
|
|
79082
79452
|
}
|
|
@@ -79225,19 +79595,28 @@ var ts;
|
|
|
79225
79595
|
if (constraintType && defaultType) {
|
|
79226
79596
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79227
79597
|
}
|
|
79228
|
-
|
|
79598
|
+
checkNodeDeferred(node);
|
|
79599
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79600
|
+
}
|
|
79601
|
+
function checkTypeParameterDeferred(node) {
|
|
79602
|
+
if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
|
|
79603
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
|
79229
79604
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79230
|
-
if (modifiers
|
|
79605
|
+
if (modifiers) {
|
|
79231
79606
|
var symbol = getSymbolOfNode(node.parent);
|
|
79232
|
-
|
|
79233
|
-
|
|
79234
|
-
|
|
79235
|
-
|
|
79236
|
-
|
|
79237
|
-
|
|
79607
|
+
if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79608
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79609
|
+
}
|
|
79610
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79611
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79612
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79613
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79614
|
+
varianceTypeParameter = typeParameter;
|
|
79615
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79616
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79617
|
+
}
|
|
79238
79618
|
}
|
|
79239
79619
|
}
|
|
79240
|
-
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79241
79620
|
}
|
|
79242
79621
|
function checkParameter(node) {
|
|
79243
79622
|
// Grammar checking
|
|
@@ -79727,7 +80106,7 @@ var ts;
|
|
|
79727
80106
|
superCallStatement = statement;
|
|
79728
80107
|
break;
|
|
79729
80108
|
}
|
|
79730
|
-
if (
|
|
80109
|
+
if (nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
79731
80110
|
break;
|
|
79732
80111
|
}
|
|
79733
80112
|
}
|
|
@@ -79769,7 +80148,7 @@ var ts;
|
|
|
79769
80148
|
checkDecorators(node);
|
|
79770
80149
|
checkSignatureDeclaration(node);
|
|
79771
80150
|
if (node.kind === 172 /* GetAccessor */) {
|
|
79772
|
-
if (!(node.flags &
|
|
80151
|
+
if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
|
|
79773
80152
|
if (!(node.flags & 512 /* HasExplicitReturn */)) {
|
|
79774
80153
|
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
|
|
79775
80154
|
}
|
|
@@ -79864,7 +80243,7 @@ var ts;
|
|
|
79864
80243
|
}
|
|
79865
80244
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
79866
80245
|
if (symbol) {
|
|
79867
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags &
|
|
80246
|
+
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
|
|
79868
80247
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
79869
80248
|
}
|
|
79870
80249
|
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80024,6 +80403,23 @@ var ts;
|
|
|
80024
80403
|
grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
|
|
80025
80404
|
}
|
|
80026
80405
|
checkSourceElement(node.typeParameter);
|
|
80406
|
+
var symbol = getSymbolOfNode(node.typeParameter);
|
|
80407
|
+
if (symbol.declarations && symbol.declarations.length > 1) {
|
|
80408
|
+
var links = getSymbolLinks(symbol);
|
|
80409
|
+
if (!links.typeParametersChecked) {
|
|
80410
|
+
links.typeParametersChecked = true;
|
|
80411
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
|
|
80412
|
+
var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
|
|
80413
|
+
if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
|
|
80414
|
+
// Report an error on every conflicting declaration.
|
|
80415
|
+
var name = symbolToString(symbol);
|
|
80416
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
80417
|
+
var declaration = declarations_4[_i];
|
|
80418
|
+
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
|
|
80419
|
+
}
|
|
80420
|
+
}
|
|
80421
|
+
}
|
|
80422
|
+
}
|
|
80027
80423
|
registerForUnusedIdentifiersCheck(node);
|
|
80028
80424
|
}
|
|
80029
80425
|
function checkTemplateLiteralType(node) {
|
|
@@ -80061,7 +80457,7 @@ var ts;
|
|
|
80061
80457
|
getTypeFromTypeNode(node);
|
|
80062
80458
|
}
|
|
80063
80459
|
function isPrivateWithinAmbient(node) {
|
|
80064
|
-
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags &
|
|
80460
|
+
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
|
|
80065
80461
|
}
|
|
80066
80462
|
function getEffectiveDeclarationFlags(n, flagsToCheck) {
|
|
80067
80463
|
var flags = ts.getCombinedModifierFlags(n);
|
|
@@ -80070,7 +80466,7 @@ var ts;
|
|
|
80070
80466
|
if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
|
|
80071
80467
|
n.parent.kind !== 257 /* ClassDeclaration */ &&
|
|
80072
80468
|
n.parent.kind !== 226 /* ClassExpression */ &&
|
|
80073
|
-
n.flags &
|
|
80469
|
+
n.flags & 16777216 /* Ambient */) {
|
|
80074
80470
|
if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
|
|
80075
80471
|
// It is nested in an ambient context, which means it is automatically exported
|
|
80076
80472
|
flags |= 1 /* Export */;
|
|
@@ -80203,10 +80599,10 @@ var ts;
|
|
|
80203
80599
|
var hasNonAmbientClass = false;
|
|
80204
80600
|
var functionDeclarations = [];
|
|
80205
80601
|
if (declarations) {
|
|
80206
|
-
for (var _i = 0,
|
|
80207
|
-
var current =
|
|
80602
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
80603
|
+
var current = declarations_5[_i];
|
|
80208
80604
|
var node = current;
|
|
80209
|
-
var inAmbientContext = node.flags &
|
|
80605
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
80210
80606
|
var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
|
|
80211
80607
|
if (inAmbientContextOrInterface) {
|
|
80212
80608
|
// check if declarations are consecutive only if they are non-ambient
|
|
@@ -81058,7 +81454,7 @@ var ts;
|
|
|
81058
81454
|
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
|
|
81059
81455
|
var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
|
|
81060
81456
|
// Get first non javascript function declaration
|
|
81061
|
-
function (declaration) { return declaration.kind === node.kind && !(declaration.flags &
|
|
81457
|
+
function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
|
|
81062
81458
|
// Only type check the symbol once
|
|
81063
81459
|
if (node === firstDeclaration) {
|
|
81064
81460
|
checkFunctionOrConstructorSymbol(localSymbol);
|
|
@@ -81180,7 +81576,7 @@ var ts;
|
|
|
81180
81576
|
var symbol = getSymbolOfNode(member);
|
|
81181
81577
|
if (!symbol.isReferenced
|
|
81182
81578
|
&& (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
|
|
81183
|
-
&& !(member.flags &
|
|
81579
|
+
&& !(member.flags & 16777216 /* Ambient */)) {
|
|
81184
81580
|
addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
|
|
81185
81581
|
}
|
|
81186
81582
|
break;
|
|
@@ -81370,8 +81766,8 @@ var ts;
|
|
|
81370
81766
|
: ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
|
|
81371
81767
|
}
|
|
81372
81768
|
else {
|
|
81373
|
-
for (var _i = 0,
|
|
81374
|
-
var decl =
|
|
81769
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
81770
|
+
var decl = declarations_6[_i];
|
|
81375
81771
|
addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
|
|
81376
81772
|
}
|
|
81377
81773
|
}
|
|
@@ -81413,7 +81809,7 @@ var ts;
|
|
|
81413
81809
|
}
|
|
81414
81810
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
81415
81811
|
// no rest parameters \ declaration context \ overload - no codegen impact
|
|
81416
|
-
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags &
|
|
81812
|
+
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
|
|
81417
81813
|
return;
|
|
81418
81814
|
}
|
|
81419
81815
|
ts.forEach(node.parameters, function (p) {
|
|
@@ -81441,7 +81837,7 @@ var ts;
|
|
|
81441
81837
|
// it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
|
|
81442
81838
|
return false;
|
|
81443
81839
|
}
|
|
81444
|
-
if (node.flags &
|
|
81840
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
81445
81841
|
// ambient context - no codegen impact
|
|
81446
81842
|
return false;
|
|
81447
81843
|
}
|
|
@@ -81580,7 +81976,7 @@ var ts;
|
|
|
81580
81976
|
recordPotentialCollisionWithReflectInGeneratedCode(node, name);
|
|
81581
81977
|
if (ts.isClassLike(node)) {
|
|
81582
81978
|
checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
|
|
81583
|
-
if (!(node.flags &
|
|
81979
|
+
if (!(node.flags & 16777216 /* Ambient */)) {
|
|
81584
81980
|
checkClassNameCollisionWithObject(name);
|
|
81585
81981
|
}
|
|
81586
81982
|
}
|
|
@@ -83174,23 +83570,23 @@ var ts;
|
|
|
83174
83570
|
return;
|
|
83175
83571
|
}
|
|
83176
83572
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
83177
|
-
if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
|
|
83573
|
+
if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
|
|
83178
83574
|
// Report an error on every conflicting declaration.
|
|
83179
83575
|
var name = symbolToString(symbol);
|
|
83180
|
-
for (var _i = 0,
|
|
83181
|
-
var declaration =
|
|
83576
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
83577
|
+
var declaration = declarations_7[_i];
|
|
83182
83578
|
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
|
|
83183
83579
|
}
|
|
83184
83580
|
}
|
|
83185
83581
|
}
|
|
83186
83582
|
}
|
|
83187
|
-
function areTypeParametersIdentical(declarations, targetParameters) {
|
|
83583
|
+
function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
|
|
83188
83584
|
var maxTypeArgumentCount = ts.length(targetParameters);
|
|
83189
83585
|
var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
|
|
83190
|
-
for (var _i = 0,
|
|
83191
|
-
var declaration =
|
|
83586
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
83587
|
+
var declaration = declarations_8[_i];
|
|
83192
83588
|
// If this declaration has too few or too many type parameters, we report an error
|
|
83193
|
-
var sourceParameters =
|
|
83589
|
+
var sourceParameters = getTypeParameterDeclarations(declaration);
|
|
83194
83590
|
var numTypeParameters = sourceParameters.length;
|
|
83195
83591
|
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
|
|
83196
83592
|
return false;
|
|
@@ -83258,7 +83654,7 @@ var ts;
|
|
|
83258
83654
|
checkFunctionOrConstructorSymbol(symbol);
|
|
83259
83655
|
checkClassForDuplicateDeclarations(node);
|
|
83260
83656
|
// Only check for reserved static identifiers on non-ambient context.
|
|
83261
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83657
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83262
83658
|
if (!nodeInAmbientContext) {
|
|
83263
83659
|
checkClassForStaticPropertyNameConflicts(node);
|
|
83264
83660
|
}
|
|
@@ -83408,7 +83804,7 @@ var ts;
|
|
|
83408
83804
|
*/
|
|
83409
83805
|
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
83410
83806
|
var isJs = ts.isInJSFile(node);
|
|
83411
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83807
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83412
83808
|
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
83413
83809
|
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
83414
83810
|
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
@@ -83636,7 +84032,7 @@ var ts;
|
|
|
83636
84032
|
&& !(derived.flags & 33554432 /* Transient */)
|
|
83637
84033
|
&& !(baseDeclarationFlags & 128 /* Abstract */)
|
|
83638
84034
|
&& !(derivedDeclarationFlags & 128 /* Abstract */)
|
|
83639
|
-
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags &
|
|
84035
|
+
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
|
|
83640
84036
|
var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
|
|
83641
84037
|
var propName = uninitialized.name;
|
|
83642
84038
|
if (uninitialized.exclamationToken
|
|
@@ -83728,7 +84124,7 @@ var ts;
|
|
|
83728
84124
|
return ok;
|
|
83729
84125
|
}
|
|
83730
84126
|
function checkPropertyInitialization(node) {
|
|
83731
|
-
if (!strictNullChecks || !strictPropertyInitialization || node.flags &
|
|
84127
|
+
if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
|
|
83732
84128
|
return;
|
|
83733
84129
|
}
|
|
83734
84130
|
var constructor = findConstructorDeclaration(node);
|
|
@@ -83865,7 +84261,7 @@ var ts;
|
|
|
83865
84261
|
}
|
|
83866
84262
|
// In ambient non-const numeric enum declarations, enum members without initializers are
|
|
83867
84263
|
// considered computed members (as opposed to having auto-incremented values).
|
|
83868
|
-
if (member.parent.flags &
|
|
84264
|
+
if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
|
|
83869
84265
|
return undefined;
|
|
83870
84266
|
}
|
|
83871
84267
|
// If the member declaration specifies no value, the member is considered a constant enum member.
|
|
@@ -83897,7 +84293,7 @@ var ts;
|
|
|
83897
84293
|
else if (isConstEnum) {
|
|
83898
84294
|
error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
|
|
83899
84295
|
}
|
|
83900
|
-
else if (member.parent.flags &
|
|
84296
|
+
else if (member.parent.flags & 16777216 /* Ambient */) {
|
|
83901
84297
|
error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
|
83902
84298
|
}
|
|
83903
84299
|
else {
|
|
@@ -84065,11 +84461,11 @@ var ts;
|
|
|
84065
84461
|
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
|
|
84066
84462
|
var declarations = symbol.declarations;
|
|
84067
84463
|
if (declarations) {
|
|
84068
|
-
for (var _i = 0,
|
|
84069
|
-
var declaration =
|
|
84464
|
+
for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
|
|
84465
|
+
var declaration = declarations_9[_i];
|
|
84070
84466
|
if ((declaration.kind === 257 /* ClassDeclaration */ ||
|
|
84071
84467
|
(declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
|
|
84072
|
-
!(declaration.flags &
|
|
84468
|
+
!(declaration.flags & 16777216 /* Ambient */)) {
|
|
84073
84469
|
return declaration;
|
|
84074
84470
|
}
|
|
84075
84471
|
}
|
|
@@ -84100,7 +84496,7 @@ var ts;
|
|
|
84100
84496
|
function checkModuleDeclarationDiagnostics() {
|
|
84101
84497
|
// Grammar checking
|
|
84102
84498
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
84103
|
-
var inAmbientContext = node.flags &
|
|
84499
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
84104
84500
|
if (isGlobalAugmentation && !inAmbientContext) {
|
|
84105
84501
|
error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
|
|
84106
84502
|
}
|
|
@@ -84318,7 +84714,7 @@ var ts;
|
|
|
84318
84714
|
}
|
|
84319
84715
|
if (compilerOptions.isolatedModules
|
|
84320
84716
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
84321
|
-
&& !(node.flags &
|
|
84717
|
+
&& !(node.flags & 16777216 /* Ambient */)) {
|
|
84322
84718
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
84323
84719
|
var isType = !(target.flags & 111551 /* Value */);
|
|
84324
84720
|
if (isType || typeOnlyAlias) {
|
|
@@ -84364,7 +84760,7 @@ var ts;
|
|
|
84364
84760
|
}
|
|
84365
84761
|
}
|
|
84366
84762
|
function isDeprecatedAliasedSymbol(symbol) {
|
|
84367
|
-
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) &
|
|
84763
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
84368
84764
|
}
|
|
84369
84765
|
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
84370
84766
|
if (!(symbol.flags & 2097152 /* Alias */))
|
|
@@ -84493,7 +84889,7 @@ var ts;
|
|
|
84493
84889
|
}
|
|
84494
84890
|
}
|
|
84495
84891
|
else {
|
|
84496
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags &
|
|
84892
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
|
|
84497
84893
|
// Import equals declaration is deprecated in es6 or above
|
|
84498
84894
|
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);
|
|
84499
84895
|
}
|
|
@@ -84519,7 +84915,7 @@ var ts;
|
|
|
84519
84915
|
ts.forEach(node.exportClause.elements, checkExportSpecifier);
|
|
84520
84916
|
var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
|
|
84521
84917
|
var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
|
|
84522
|
-
!node.moduleSpecifier && node.flags &
|
|
84918
|
+
!node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
|
|
84523
84919
|
if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
|
|
84524
84920
|
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
|
|
84525
84921
|
}
|
|
@@ -84684,10 +85080,10 @@ var ts;
|
|
|
84684
85080
|
checkExpressionCached(node.expression);
|
|
84685
85081
|
}
|
|
84686
85082
|
checkExternalModuleExports(container);
|
|
84687
|
-
if ((node.flags &
|
|
85083
|
+
if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
|
|
84688
85084
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
84689
85085
|
}
|
|
84690
|
-
if (node.isExportEquals && !(node.flags &
|
|
85086
|
+
if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
|
|
84691
85087
|
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
84692
85088
|
// export assignment is not supported in es6 modules
|
|
84693
85089
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
@@ -85063,6 +85459,9 @@ var ts;
|
|
|
85063
85459
|
case 226 /* ClassExpression */:
|
|
85064
85460
|
checkClassExpressionDeferred(node);
|
|
85065
85461
|
break;
|
|
85462
|
+
case 163 /* TypeParameter */:
|
|
85463
|
+
checkTypeParameterDeferred(node);
|
|
85464
|
+
break;
|
|
85066
85465
|
case 279 /* JsxSelfClosingElement */:
|
|
85067
85466
|
checkJsxSelfClosingElementDeferred(node);
|
|
85068
85467
|
break;
|
|
@@ -85120,7 +85519,7 @@ var ts;
|
|
|
85120
85519
|
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
85121
85520
|
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
85122
85521
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
85123
|
-
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags &
|
|
85522
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
85124
85523
|
diagnostics.add(diag);
|
|
85125
85524
|
}
|
|
85126
85525
|
});
|
|
@@ -85220,7 +85619,7 @@ var ts;
|
|
|
85220
85619
|
}
|
|
85221
85620
|
// Language service support
|
|
85222
85621
|
function getSymbolsInScope(location, meaning) {
|
|
85223
|
-
if (location.flags &
|
|
85622
|
+
if (location.flags & 33554432 /* InWithStatement */) {
|
|
85224
85623
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85225
85624
|
return [];
|
|
85226
85625
|
}
|
|
@@ -85570,7 +85969,7 @@ var ts;
|
|
|
85570
85969
|
}
|
|
85571
85970
|
var parent = node.parent;
|
|
85572
85971
|
var grandParent = parent.parent;
|
|
85573
|
-
if (node.flags &
|
|
85972
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85574
85973
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85575
85974
|
return undefined;
|
|
85576
85975
|
}
|
|
@@ -85712,7 +86111,7 @@ var ts;
|
|
|
85712
86111
|
if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
|
|
85713
86112
|
return errorType;
|
|
85714
86113
|
}
|
|
85715
|
-
if (node.flags &
|
|
86114
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85716
86115
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85717
86116
|
return errorType;
|
|
85718
86117
|
}
|
|
@@ -85877,11 +86276,11 @@ var ts;
|
|
|
85877
86276
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
85878
86277
|
return leftSpread ? [leftSpread, rightSpread]
|
|
85879
86278
|
: syntheticOrigin ? [syntheticOrigin]
|
|
85880
|
-
: ts.singleElementArray(
|
|
86279
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
85881
86280
|
}
|
|
85882
86281
|
return undefined;
|
|
85883
86282
|
}
|
|
85884
|
-
function
|
|
86283
|
+
function tryGetTarget(symbol) {
|
|
85885
86284
|
var target;
|
|
85886
86285
|
var next = symbol;
|
|
85887
86286
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86111,7 +86510,7 @@ var ts;
|
|
|
86111
86510
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86112
86511
|
return true;
|
|
86113
86512
|
}
|
|
86114
|
-
var target = getSymbolLinks(symbol).
|
|
86513
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86115
86514
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86116
86515
|
target.flags & 111551 /* Value */ &&
|
|
86117
86516
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -86159,11 +86558,6 @@ var ts;
|
|
|
86159
86558
|
!parameter.initializer &&
|
|
86160
86559
|
ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
|
|
86161
86560
|
}
|
|
86162
|
-
function isOptionalUninitializedParameter(parameter) {
|
|
86163
|
-
return !!strictNullChecks &&
|
|
86164
|
-
isOptionalParameter(parameter) &&
|
|
86165
|
-
!parameter.initializer;
|
|
86166
|
-
}
|
|
86167
86561
|
function isExpandoFunctionDeclaration(node) {
|
|
86168
86562
|
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
|
|
86169
86563
|
if (!declaration) {
|
|
@@ -86765,7 +87159,7 @@ var ts;
|
|
|
86765
87159
|
function checkExternalEmitHelpers(location, helpers) {
|
|
86766
87160
|
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
|
|
86767
87161
|
var sourceFile = ts.getSourceFileOfNode(location);
|
|
86768
|
-
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags &
|
|
87162
|
+
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
|
|
86769
87163
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
86770
87164
|
if (helpersModule !== unknownSymbol) {
|
|
86771
87165
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
@@ -87018,7 +87412,7 @@ var ts;
|
|
|
87018
87412
|
else if (node.kind === 164 /* Parameter */) {
|
|
87019
87413
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
|
|
87020
87414
|
}
|
|
87021
|
-
else if ((node.parent.flags &
|
|
87415
|
+
else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
|
|
87022
87416
|
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
|
87023
87417
|
}
|
|
87024
87418
|
else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
|
|
@@ -87064,7 +87458,7 @@ var ts;
|
|
|
87064
87458
|
if (flags & 256 /* Async */) {
|
|
87065
87459
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
|
|
87066
87460
|
}
|
|
87067
|
-
else if (flags & 2 /* Ambient */ || node.parent.flags &
|
|
87461
|
+
else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
|
|
87068
87462
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
|
87069
87463
|
}
|
|
87070
87464
|
else if (node.kind === 164 /* Parameter */) {
|
|
@@ -87080,8 +87474,7 @@ var ts;
|
|
|
87080
87474
|
case 144 /* OutKeyword */:
|
|
87081
87475
|
var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
|
|
87082
87476
|
var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
|
|
87083
|
-
if (node.kind !== 163 /* TypeParameter */ || (node.parent
|
|
87084
|
-
node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
|
|
87477
|
+
if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
|
|
87085
87478
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
|
87086
87479
|
}
|
|
87087
87480
|
if (flags & inOutFlag) {
|
|
@@ -87210,7 +87603,7 @@ var ts;
|
|
|
87210
87603
|
if (i !== (parameterCount - 1)) {
|
|
87211
87604
|
return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
87212
87605
|
}
|
|
87213
|
-
if (!(parameter.flags &
|
|
87606
|
+
if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
|
|
87214
87607
|
checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
|
|
87215
87608
|
}
|
|
87216
87609
|
if (parameter.questionToken) {
|
|
@@ -87421,7 +87814,7 @@ var ts;
|
|
|
87421
87814
|
ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
|
|
87422
87815
|
node.kind === 213 /* FunctionExpression */ ||
|
|
87423
87816
|
node.kind === 169 /* MethodDeclaration */);
|
|
87424
|
-
if (node.flags &
|
|
87817
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87425
87818
|
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
|
|
87426
87819
|
}
|
|
87427
87820
|
if (!node.body) {
|
|
@@ -87659,7 +88052,7 @@ var ts;
|
|
|
87659
88052
|
return false;
|
|
87660
88053
|
}
|
|
87661
88054
|
function checkGrammarAccessor(accessor) {
|
|
87662
|
-
if (!(accessor.flags &
|
|
88055
|
+
if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
|
|
87663
88056
|
if (languageVersion < 1 /* ES5 */) {
|
|
87664
88057
|
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
|
87665
88058
|
}
|
|
@@ -87799,7 +88192,7 @@ var ts;
|
|
|
87799
88192
|
// However, property declarations disallow computed names in general,
|
|
87800
88193
|
// and accessors are not allowed in ambient contexts in general,
|
|
87801
88194
|
// so this error only really matters for methods.
|
|
87802
|
-
if (node.flags &
|
|
88195
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87803
88196
|
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);
|
|
87804
88197
|
}
|
|
87805
88198
|
else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
|
|
@@ -87915,7 +88308,7 @@ var ts;
|
|
|
87915
88308
|
}
|
|
87916
88309
|
function checkGrammarVariableDeclaration(node) {
|
|
87917
88310
|
if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
|
|
87918
|
-
if (node.flags &
|
|
88311
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87919
88312
|
checkAmbientInitializer(node);
|
|
87920
88313
|
}
|
|
87921
88314
|
else if (!node.initializer) {
|
|
@@ -87927,7 +88320,7 @@ var ts;
|
|
|
87927
88320
|
}
|
|
87928
88321
|
}
|
|
87929
88322
|
}
|
|
87930
|
-
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags &
|
|
88323
|
+
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
|
|
87931
88324
|
var message = node.initializer
|
|
87932
88325
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
87933
88326
|
: !node.type
|
|
@@ -87936,7 +88329,7 @@ var ts;
|
|
|
87936
88329
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
87937
88330
|
}
|
|
87938
88331
|
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
87939
|
-
!(node.parent.parent.flags &
|
|
88332
|
+
!(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
87940
88333
|
checkESModuleMarker(node.name);
|
|
87941
88334
|
}
|
|
87942
88335
|
var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
|
|
@@ -88113,11 +88506,11 @@ var ts;
|
|
|
88113
88506
|
return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
|
|
88114
88507
|
}
|
|
88115
88508
|
}
|
|
88116
|
-
if (node.flags &
|
|
88509
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88117
88510
|
checkAmbientInitializer(node);
|
|
88118
88511
|
}
|
|
88119
88512
|
if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
|
|
88120
|
-
node.flags &
|
|
88513
|
+
node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
|
|
88121
88514
|
var message = node.initializer
|
|
88122
88515
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
88123
88516
|
: !node.type
|
|
@@ -88163,10 +88556,10 @@ var ts;
|
|
|
88163
88556
|
return false;
|
|
88164
88557
|
}
|
|
88165
88558
|
function checkGrammarSourceFile(node) {
|
|
88166
|
-
return !!(node.flags &
|
|
88559
|
+
return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
|
|
88167
88560
|
}
|
|
88168
88561
|
function checkGrammarStatementInAmbientContext(node) {
|
|
88169
|
-
if (node.flags &
|
|
88562
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88170
88563
|
// Find containing block which is either Block, ModuleBlock, SourceFile
|
|
88171
88564
|
var links = getNodeLinks(node);
|
|
88172
88565
|
if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
|
|
@@ -92284,7 +92677,7 @@ var ts;
|
|
|
92284
92677
|
return !ts.nodeIsMissing(node.body);
|
|
92285
92678
|
}
|
|
92286
92679
|
function visitPropertyDeclaration(node) {
|
|
92287
|
-
if (node.flags &
|
|
92680
|
+
if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
92288
92681
|
return undefined;
|
|
92289
92682
|
}
|
|
92290
92683
|
var updated = factory.updatePropertyDeclaration(node,
|
|
@@ -92315,11 +92708,11 @@ var ts;
|
|
|
92315
92708
|
}
|
|
92316
92709
|
var statements = [];
|
|
92317
92710
|
resumeLexicalEnvironment();
|
|
92318
|
-
var
|
|
92319
|
-
var superStatementIndex = ts.findSuperStatementIndex(body.statements,
|
|
92711
|
+
var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92712
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
|
|
92320
92713
|
// If there was a super call, visit existing statements up to and including it
|
|
92321
92714
|
if (superStatementIndex >= 0) {
|
|
92322
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement,
|
|
92715
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
|
|
92323
92716
|
}
|
|
92324
92717
|
// Transform parameters into property assignments. Transforms this:
|
|
92325
92718
|
//
|
|
@@ -92338,12 +92731,12 @@ var ts;
|
|
|
92338
92731
|
if (superStatementIndex >= 0) {
|
|
92339
92732
|
ts.addRange(statements, parameterPropertyAssignments);
|
|
92340
92733
|
}
|
|
92341
|
-
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
92734
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
|
|
92342
92735
|
else {
|
|
92343
|
-
statements =
|
|
92736
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
92344
92737
|
}
|
|
92345
|
-
// Add remaining statements from the body, skipping the super() call if it was found
|
|
92346
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
92738
|
+
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
92739
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
|
|
92347
92740
|
// End the lexical environment.
|
|
92348
92741
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92349
92742
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -99174,8 +99567,8 @@ var ts;
|
|
|
99174
99567
|
// declarations may not be sorted by position.
|
|
99175
99568
|
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
|
|
99176
99569
|
var pos = -1, end = -1;
|
|
99177
|
-
for (var _i = 0,
|
|
99178
|
-
var node =
|
|
99570
|
+
for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
|
|
99571
|
+
var node = declarations_10[_i];
|
|
99179
99572
|
pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
|
|
99180
99573
|
end = Math.max(end, node.end);
|
|
99181
99574
|
}
|
|
@@ -108107,6 +108500,10 @@ var ts;
|
|
|
108107
108500
|
return factory.updateModifiers(statement, modifiers);
|
|
108108
108501
|
}
|
|
108109
108502
|
function transformTopLevelDeclaration(input) {
|
|
108503
|
+
if (lateMarkedStatements) {
|
|
108504
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108505
|
+
;
|
|
108506
|
+
}
|
|
108110
108507
|
if (shouldStripInternal(input))
|
|
108111
108508
|
return;
|
|
108112
108509
|
switch (input.kind) {
|
|
@@ -108218,7 +108615,7 @@ var ts;
|
|
|
108218
108615
|
needsScopeFixMarker = false;
|
|
108219
108616
|
var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
|
|
108220
108617
|
var lateStatements = transformAndReplaceLatePaintedStatements(statements);
|
|
108221
|
-
if (input.flags &
|
|
108618
|
+
if (input.flags & 16777216 /* Ambient */) {
|
|
108222
108619
|
needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
|
|
108223
108620
|
}
|
|
108224
108621
|
// With the final list of statements, there are 3 possibilities:
|
|
@@ -109238,7 +109635,7 @@ var ts;
|
|
|
109238
109635
|
addOutput(buildInfoPath);
|
|
109239
109636
|
}
|
|
109240
109637
|
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
|
|
109241
|
-
if (ts.
|
|
109638
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109242
109639
|
return;
|
|
109243
109640
|
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109244
109641
|
addOutput(js);
|
|
@@ -109283,7 +109680,7 @@ var ts;
|
|
|
109283
109680
|
/*@internal*/
|
|
109284
109681
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
109285
109682
|
var options = _a.options, fileNames = _a.fileNames;
|
|
109286
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.
|
|
109683
|
+
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
|
|
109287
109684
|
}
|
|
109288
109685
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
109289
109686
|
/*@internal*/
|
|
@@ -109325,7 +109722,7 @@ var ts;
|
|
|
109325
109722
|
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
|
|
109326
109723
|
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
|
|
109327
109724
|
var inputFileName = _b[_a];
|
|
109328
|
-
if (ts.
|
|
109725
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109329
109726
|
continue;
|
|
109330
109727
|
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109331
109728
|
if (jsFilePath)
|
|
@@ -109866,6 +110263,9 @@ var ts;
|
|
|
109866
110263
|
var currentParenthesizerRule;
|
|
109867
110264
|
var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
|
|
109868
110265
|
var parenthesizer = ts.factory.parenthesizer;
|
|
110266
|
+
var typeArgumentParenthesizerRuleSelector = {
|
|
110267
|
+
select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
|
|
110268
|
+
};
|
|
109869
110269
|
var emitBinaryExpression = createEmitBinaryExpression();
|
|
109870
110270
|
reset();
|
|
109871
110271
|
return {
|
|
@@ -111078,7 +111478,7 @@ var ts;
|
|
|
111078
111478
|
writePunctuation("}");
|
|
111079
111479
|
}
|
|
111080
111480
|
function emitArrayType(node) {
|
|
111081
|
-
emit(node.elementType, parenthesizer.
|
|
111481
|
+
emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111082
111482
|
writePunctuation("[");
|
|
111083
111483
|
writePunctuation("]");
|
|
111084
111484
|
}
|
|
@@ -111089,7 +111489,7 @@ var ts;
|
|
|
111089
111489
|
function emitTupleType(node) {
|
|
111090
111490
|
emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
|
|
111091
111491
|
var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
|
|
111092
|
-
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty
|
|
111492
|
+
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
|
|
111093
111493
|
emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
|
|
111094
111494
|
}
|
|
111095
111495
|
function emitNamedTupleMember(node) {
|
|
@@ -111101,21 +111501,21 @@ var ts;
|
|
|
111101
111501
|
emit(node.type);
|
|
111102
111502
|
}
|
|
111103
111503
|
function emitOptionalType(node) {
|
|
111104
|
-
emit(node.type, parenthesizer.
|
|
111504
|
+
emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
|
|
111105
111505
|
writePunctuation("?");
|
|
111106
111506
|
}
|
|
111107
111507
|
function emitUnionType(node) {
|
|
111108
|
-
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.
|
|
111508
|
+
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
|
|
111109
111509
|
}
|
|
111110
111510
|
function emitIntersectionType(node) {
|
|
111111
|
-
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.
|
|
111511
|
+
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
|
|
111112
111512
|
}
|
|
111113
111513
|
function emitConditionalType(node) {
|
|
111114
|
-
emit(node.checkType, parenthesizer.
|
|
111514
|
+
emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
|
|
111115
111515
|
writeSpace();
|
|
111116
111516
|
writeKeyword("extends");
|
|
111117
111517
|
writeSpace();
|
|
111118
|
-
emit(node.extendsType, parenthesizer.
|
|
111518
|
+
emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
|
|
111119
111519
|
writeSpace();
|
|
111120
111520
|
writePunctuation("?");
|
|
111121
111521
|
writeSpace();
|
|
@@ -111141,10 +111541,13 @@ var ts;
|
|
|
111141
111541
|
function emitTypeOperator(node) {
|
|
111142
111542
|
writeTokenText(node.operator, writeKeyword);
|
|
111143
111543
|
writeSpace();
|
|
111144
|
-
|
|
111544
|
+
var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
|
|
111545
|
+
parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
|
|
111546
|
+
parenthesizer.parenthesizeOperandOfTypeOperator;
|
|
111547
|
+
emit(node.type, parenthesizerRule);
|
|
111145
111548
|
}
|
|
111146
111549
|
function emitIndexedAccessType(node) {
|
|
111147
|
-
emit(node.objectType, parenthesizer.
|
|
111550
|
+
emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111148
111551
|
writePunctuation("[");
|
|
111149
111552
|
emit(node.indexType);
|
|
111150
111553
|
writePunctuation("]");
|
|
@@ -112878,7 +113281,7 @@ var ts;
|
|
|
112878
113281
|
emitList(parentNode, decorators, 2146305 /* Decorators */);
|
|
112879
113282
|
}
|
|
112880
113283
|
function emitTypeArguments(parentNode, typeArguments) {
|
|
112881
|
-
emitList(parentNode, typeArguments, 53776 /* TypeArguments */,
|
|
113284
|
+
emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
|
|
112882
113285
|
}
|
|
112883
113286
|
function emitTypeParameters(parentNode, typeParameters) {
|
|
112884
113287
|
if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
|
@@ -112997,6 +113400,7 @@ var ts;
|
|
|
112997
113400
|
if (format & 128 /* Indented */) {
|
|
112998
113401
|
increaseIndent();
|
|
112999
113402
|
}
|
|
113403
|
+
var emitListItem = getEmitListItem(emit, parenthesizerRule);
|
|
113000
113404
|
// Emit each child.
|
|
113001
113405
|
var previousSibling = void 0;
|
|
113002
113406
|
var previousSourceFileTextKind = void 0;
|
|
@@ -113047,12 +113451,7 @@ var ts;
|
|
|
113047
113451
|
shouldEmitInterveningComments = mayEmitInterveningComments;
|
|
113048
113452
|
}
|
|
113049
113453
|
nextListElementPos = child.pos;
|
|
113050
|
-
|
|
113051
|
-
emit(child);
|
|
113052
|
-
}
|
|
113053
|
-
else {
|
|
113054
|
-
emit(child, parenthesizerRule);
|
|
113055
|
-
}
|
|
113454
|
+
emitListItem(child, emit, parenthesizerRule, i);
|
|
113056
113455
|
if (shouldDecreaseIndentAfterEmit) {
|
|
113057
113456
|
decreaseIndent();
|
|
113058
113457
|
shouldDecreaseIndentAfterEmit = false;
|
|
@@ -114293,6 +114692,20 @@ var ts;
|
|
|
114293
114692
|
TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
|
|
114294
114693
|
TempFlags[TempFlags["_i"] = 268435456] = "_i";
|
|
114295
114694
|
})(TempFlags || (TempFlags = {}));
|
|
114695
|
+
function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
|
|
114696
|
+
emit(node);
|
|
114697
|
+
}
|
|
114698
|
+
function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
|
|
114699
|
+
emit(node, parenthesizerRuleSelector.select(index));
|
|
114700
|
+
}
|
|
114701
|
+
function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
|
|
114702
|
+
emit(node, parenthesizerRule);
|
|
114703
|
+
}
|
|
114704
|
+
function getEmitListItem(emit, parenthesizerRule) {
|
|
114705
|
+
return emit.length === 1 ? emitListItemNoParenthesizer :
|
|
114706
|
+
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
|
|
114707
|
+
emitListItemWithParenthesizerRule;
|
|
114708
|
+
}
|
|
114296
114709
|
})(ts || (ts = {}));
|
|
114297
114710
|
/* @internal */
|
|
114298
114711
|
var ts;
|
|
@@ -114659,7 +115072,7 @@ var ts;
|
|
|
114659
115072
|
if (ts.outFile(options) || options.outDir)
|
|
114660
115073
|
return false;
|
|
114661
115074
|
// File if emitted next to input needs to be ignored
|
|
114662
|
-
if (ts.
|
|
115075
|
+
if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
|
|
114663
115076
|
// If its declaration directory: its not ignored if not excluded by config
|
|
114664
115077
|
if (options.declarationDir)
|
|
114665
115078
|
return false;
|
|
@@ -115832,7 +116245,7 @@ var ts;
|
|
|
115832
116245
|
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
115833
116246
|
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
|
|
115834
116247
|
var fileName = _c[_b];
|
|
115835
|
-
if (!ts.
|
|
116248
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
115836
116249
|
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
|
|
115837
116250
|
}
|
|
115838
116251
|
}
|
|
@@ -116023,7 +116436,7 @@ var ts;
|
|
|
116023
116436
|
}
|
|
116024
116437
|
function getRedirectReferenceForResolution(file) {
|
|
116025
116438
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
116026
|
-
if (redirect || !ts.
|
|
116439
|
+
if (redirect || !ts.isDeclarationFileName(file.originalFileName))
|
|
116027
116440
|
return redirect;
|
|
116028
116441
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
116029
116442
|
// So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
|
|
@@ -116359,7 +116772,7 @@ var ts;
|
|
|
116359
116772
|
// moduleAugmentations has changed
|
|
116360
116773
|
structureIsReused = 1 /* SafeModules */;
|
|
116361
116774
|
}
|
|
116362
|
-
if ((oldSourceFile.flags &
|
|
116775
|
+
if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
116363
116776
|
// dynamicImport has changed
|
|
116364
116777
|
structureIsReused = 1 /* SafeModules */;
|
|
116365
116778
|
}
|
|
@@ -116523,6 +116936,9 @@ var ts;
|
|
|
116523
116936
|
return !!sourceFilesFoundSearchingNodeModules.get(file.path);
|
|
116524
116937
|
}
|
|
116525
116938
|
function isSourceFileDefaultLibrary(file) {
|
|
116939
|
+
if (!file.isDeclarationFile) {
|
|
116940
|
+
return false;
|
|
116941
|
+
}
|
|
116526
116942
|
if (file.hasNoDefaultLib) {
|
|
116527
116943
|
return true;
|
|
116528
116944
|
}
|
|
@@ -117034,7 +117450,7 @@ var ts;
|
|
|
117034
117450
|
var node = _a[_i];
|
|
117035
117451
|
collectModuleReferences(node, /*inAmbientModule*/ false);
|
|
117036
117452
|
}
|
|
117037
|
-
if ((file.flags &
|
|
117453
|
+
if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
|
|
117038
117454
|
collectDynamicImportOrRequireCalls(file);
|
|
117039
117455
|
}
|
|
117040
117456
|
file.imports = imports || ts.emptyArray;
|
|
@@ -117411,7 +117827,7 @@ var ts;
|
|
|
117411
117827
|
}
|
|
117412
117828
|
function getProjectReferenceRedirectProject(fileName) {
|
|
117413
117829
|
// Ignore dts or any json files
|
|
117414
|
-
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.
|
|
117830
|
+
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117415
117831
|
return undefined;
|
|
117416
117832
|
}
|
|
117417
117833
|
// If this file is produced by a referenced project, we need to rewrite it to
|
|
@@ -117460,7 +117876,7 @@ var ts;
|
|
|
117460
117876
|
else {
|
|
117461
117877
|
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
117462
117878
|
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
|
|
117463
|
-
if (!ts.
|
|
117879
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117464
117880
|
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
|
|
117465
117881
|
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
|
|
117466
117882
|
}
|
|
@@ -117632,7 +118048,7 @@ var ts;
|
|
|
117632
118048
|
&& index < file.imports.length
|
|
117633
118049
|
&& !elideImport
|
|
117634
118050
|
&& !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
|
|
117635
|
-
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags &
|
|
118051
|
+
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
117636
118052
|
if (elideImport) {
|
|
117637
118053
|
modulesWithElidedImports.set(file.path, true);
|
|
117638
118054
|
}
|
|
@@ -118261,7 +118677,7 @@ var ts;
|
|
|
118261
118677
|
if (options.outDir) {
|
|
118262
118678
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
118263
118679
|
}
|
|
118264
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.
|
|
118680
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
|
|
118265
118681
|
// Otherwise just check if sourceFile with the name exists
|
|
118266
118682
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
118267
118683
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -118887,7 +119303,7 @@ var ts;
|
|
|
118887
119303
|
/*forceDtsEmit*/ true);
|
|
118888
119304
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
118889
119305
|
if (firstDts_1) {
|
|
118890
|
-
ts.Debug.assert(ts.
|
|
119306
|
+
ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
|
|
118891
119307
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
118892
119308
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
118893
119309
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -119292,7 +119708,7 @@ var ts;
|
|
|
119292
119708
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
119293
119709
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
119294
119710
|
*/
|
|
119295
|
-
function getNextAffectedFile(state, cancellationToken, computeHash) {
|
|
119711
|
+
function getNextAffectedFile(state, cancellationToken, computeHash, host) {
|
|
119296
119712
|
while (true) {
|
|
119297
119713
|
var affectedFiles = state.affectedFiles;
|
|
119298
119714
|
if (affectedFiles) {
|
|
@@ -119303,7 +119719,7 @@ var ts;
|
|
|
119303
119719
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
119304
119720
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
119305
119721
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
119306
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
|
|
119722
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119307
119723
|
return affectedFile;
|
|
119308
119724
|
}
|
|
119309
119725
|
affectedFilesIndex++;
|
|
@@ -119344,6 +119760,11 @@ var ts;
|
|
|
119344
119760
|
state.seenAffectedFiles = new ts.Set();
|
|
119345
119761
|
}
|
|
119346
119762
|
}
|
|
119763
|
+
function clearAffectedFilesPendingEmit(state) {
|
|
119764
|
+
state.affectedFilesPendingEmit = undefined;
|
|
119765
|
+
state.affectedFilesPendingEmitKind = undefined;
|
|
119766
|
+
state.affectedFilesPendingEmitIndex = undefined;
|
|
119767
|
+
}
|
|
119347
119768
|
/**
|
|
119348
119769
|
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
|
119349
119770
|
*/
|
|
@@ -119363,9 +119784,7 @@ var ts;
|
|
|
119363
119784
|
}
|
|
119364
119785
|
}
|
|
119365
119786
|
}
|
|
119366
|
-
state
|
|
119367
|
-
state.affectedFilesPendingEmitKind = undefined;
|
|
119368
|
-
state.affectedFilesPendingEmitIndex = undefined;
|
|
119787
|
+
clearAffectedFilesPendingEmit(state);
|
|
119369
119788
|
}
|
|
119370
119789
|
return undefined;
|
|
119371
119790
|
}
|
|
@@ -119373,7 +119792,7 @@ var ts;
|
|
|
119373
119792
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119374
119793
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
119375
119794
|
*/
|
|
119376
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
|
|
119795
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119377
119796
|
var _a;
|
|
119378
119797
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119379
119798
|
// If affected files is everything except default library, then nothing more to do
|
|
@@ -119398,14 +119817,14 @@ var ts;
|
|
|
119398
119817
|
ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
|
|
119399
119818
|
}
|
|
119400
119819
|
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
|
|
119401
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
|
|
119820
|
+
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119402
119821
|
}
|
|
119403
119822
|
}
|
|
119404
119823
|
/**
|
|
119405
119824
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
119406
119825
|
* Also we need to make sure signature is updated for these files
|
|
119407
119826
|
*/
|
|
119408
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
|
|
119827
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
|
|
119409
119828
|
removeSemanticDiagnosticsOf(state, path);
|
|
119410
119829
|
if (!state.changedFilesSet.has(path)) {
|
|
119411
119830
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -119416,8 +119835,7 @@ var ts;
|
|
|
119416
119835
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
119417
119836
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
119418
119837
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
119419
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
|
|
119420
|
-
/* useFileVersionAsSignature */ true);
|
|
119838
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
|
|
119421
119839
|
// If not dts emit, nothing more to do
|
|
119422
119840
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
119423
119841
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -119614,13 +120032,18 @@ var ts;
|
|
|
119614
120032
|
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
|
119615
120033
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
119616
120034
|
return value.version === actualSignature ?
|
|
119617
|
-
value.affectsGlobalScope ?
|
|
119618
|
-
|
|
120035
|
+
value.affectsGlobalScope || value.impliedFormat ?
|
|
120036
|
+
// If file version is same as signature, dont serialize signature
|
|
120037
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120038
|
+
// If file info only contains version and signature and both are same we can just write string
|
|
119619
120039
|
value.version :
|
|
119620
|
-
actualSignature !== undefined ?
|
|
120040
|
+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
|
|
119621
120041
|
signature === undefined ?
|
|
120042
|
+
// If we havent computed signature, use fileInfo as is
|
|
119622
120043
|
value :
|
|
120044
|
+
// Serialize fileInfo with new updated signature
|
|
119623
120045
|
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120046
|
+
// Signature of the FileInfo is undefined, serialize it as false
|
|
119624
120047
|
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
119625
120048
|
});
|
|
119626
120049
|
var referencedMap;
|
|
@@ -119865,7 +120288,7 @@ var ts;
|
|
|
119865
120288
|
* in that order would be used to write the files
|
|
119866
120289
|
*/
|
|
119867
120290
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
119868
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120291
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
119869
120292
|
var emitKind = 1 /* Full */;
|
|
119870
120293
|
var isPendingEmitFile = false;
|
|
119871
120294
|
if (!affected) {
|
|
@@ -119910,54 +120333,48 @@ var ts;
|
|
|
119910
120333
|
* in that order would be used to write the files
|
|
119911
120334
|
*/
|
|
119912
120335
|
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
119913
|
-
var
|
|
119914
|
-
var savedAffectedFilesPendingEmit;
|
|
119915
|
-
var savedAffectedFilesPendingEmitKind;
|
|
119916
|
-
var savedAffectedFilesPendingEmitIndex;
|
|
119917
|
-
// Backup and restore affected pendings emit state for non emit Builder if noEmitOnError is enabled and emitBuildInfo could be written in case there are errors
|
|
119918
|
-
// This ensures pending files to emit is updated in tsbuildinfo
|
|
119919
|
-
// Note that when there are no errors, emit proceeds as if everything is emitted as it is callers reponsibility to write the files to disk if at all (because its builder that doesnt track files to emit)
|
|
119920
|
-
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
|
|
119921
|
-
!targetSourceFile &&
|
|
119922
|
-
!ts.outFile(state.compilerOptions) &&
|
|
119923
|
-
!state.compilerOptions.noEmit &&
|
|
119924
|
-
state.compilerOptions.noEmitOnError) {
|
|
119925
|
-
restorePendingEmitOnHandlingNoEmitSuccess = true;
|
|
119926
|
-
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
|
119927
|
-
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
|
|
119928
|
-
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
|
119929
|
-
}
|
|
120336
|
+
var _a;
|
|
119930
120337
|
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
119931
120338
|
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
|
|
119932
120339
|
}
|
|
119933
120340
|
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
|
|
119934
120341
|
if (result)
|
|
119935
120342
|
return result;
|
|
119936
|
-
if (restorePendingEmitOnHandlingNoEmitSuccess) {
|
|
119937
|
-
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
|
|
119938
|
-
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
|
|
119939
|
-
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
|
|
119940
|
-
}
|
|
119941
120343
|
// Emit only affected files if using builder for emit
|
|
119942
|
-
if (!targetSourceFile
|
|
119943
|
-
|
|
119944
|
-
|
|
119945
|
-
|
|
119946
|
-
|
|
119947
|
-
|
|
119948
|
-
|
|
119949
|
-
|
|
119950
|
-
|
|
119951
|
-
|
|
119952
|
-
|
|
119953
|
-
|
|
120344
|
+
if (!targetSourceFile) {
|
|
120345
|
+
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120346
|
+
// Emit and report any errors we ran into.
|
|
120347
|
+
var sourceMaps = [];
|
|
120348
|
+
var emitSkipped = false;
|
|
120349
|
+
var diagnostics = void 0;
|
|
120350
|
+
var emittedFiles = [];
|
|
120351
|
+
var affectedEmitResult = void 0;
|
|
120352
|
+
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
|
|
120353
|
+
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
|
|
120354
|
+
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
|
|
120355
|
+
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
|
|
120356
|
+
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
|
|
120357
|
+
}
|
|
120358
|
+
return {
|
|
120359
|
+
emitSkipped: emitSkipped,
|
|
120360
|
+
diagnostics: diagnostics || ts.emptyArray,
|
|
120361
|
+
emittedFiles: emittedFiles,
|
|
120362
|
+
sourceMaps: sourceMaps
|
|
120363
|
+
};
|
|
120364
|
+
}
|
|
120365
|
+
// In non Emit builder, clear affected files pending emit
|
|
120366
|
+
else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
|
|
120367
|
+
ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
|
|
120368
|
+
// State can clear affected files pending emit if
|
|
120369
|
+
if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
|
|
120370
|
+
// If every file pending emit is pending on only dts emit
|
|
120371
|
+
|| ts.every(state.affectedFilesPendingEmit, function (path, index) {
|
|
120372
|
+
return index < state.affectedFilesPendingEmitIndex ||
|
|
120373
|
+
state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
|
|
120374
|
+
})) {
|
|
120375
|
+
clearAffectedFilesPendingEmit(state);
|
|
120376
|
+
}
|
|
119954
120377
|
}
|
|
119955
|
-
return {
|
|
119956
|
-
emitSkipped: emitSkipped,
|
|
119957
|
-
diagnostics: diagnostics || ts.emptyArray,
|
|
119958
|
-
emittedFiles: emittedFiles,
|
|
119959
|
-
sourceMaps: sourceMaps
|
|
119960
|
-
};
|
|
119961
120378
|
}
|
|
119962
120379
|
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
119963
120380
|
}
|
|
@@ -119967,7 +120384,7 @@ var ts;
|
|
|
119967
120384
|
*/
|
|
119968
120385
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
119969
120386
|
while (true) {
|
|
119970
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120387
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
119971
120388
|
if (!affected) {
|
|
119972
120389
|
// Done
|
|
119973
120390
|
return undefined;
|
|
@@ -123087,9 +123504,6 @@ var ts;
|
|
|
123087
123504
|
function newer(date1, date2) {
|
|
123088
123505
|
return date2 > date1 ? date2 : date1;
|
|
123089
123506
|
}
|
|
123090
|
-
function isDeclarationFile(fileName) {
|
|
123091
|
-
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
123092
|
-
}
|
|
123093
123507
|
/*@internal*/
|
|
123094
123508
|
function isCircularBuildOrder(buildOrder) {
|
|
123095
123509
|
return !!buildOrder && !!buildOrder.buildOrder;
|
|
@@ -123652,7 +124066,7 @@ var ts;
|
|
|
123652
124066
|
outputFiles.forEach(function (_a) {
|
|
123653
124067
|
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
|
|
123654
124068
|
var priorChangeTime;
|
|
123655
|
-
if (!anyDtsChanged &&
|
|
124069
|
+
if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
|
|
123656
124070
|
// Check for unchanged .d.ts files
|
|
123657
124071
|
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
|
|
123658
124072
|
priorChangeTime = host.getModifiedTime(name);
|
|
@@ -123993,7 +124407,7 @@ var ts;
|
|
|
123993
124407
|
// In addition to file timestamps, we also keep track of when a .d.ts file
|
|
123994
124408
|
// had its file touched but not had its contents changed - this allows us
|
|
123995
124409
|
// to skip a downstream typecheck
|
|
123996
|
-
if (
|
|
124410
|
+
if (ts.isDeclarationFileName(output)) {
|
|
123997
124411
|
var outputModifiedTime = ts.getModifiedTime(host, output);
|
|
123998
124412
|
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
|
|
123999
124413
|
}
|
|
@@ -124147,7 +124561,7 @@ var ts;
|
|
|
124147
124561
|
reportVerbose = false;
|
|
124148
124562
|
reportStatus(state, verboseMessage, proj.options.configFilePath);
|
|
124149
124563
|
}
|
|
124150
|
-
if (
|
|
124564
|
+
if (ts.isDeclarationFileName(file)) {
|
|
124151
124565
|
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
|
|
124152
124566
|
}
|
|
124153
124567
|
host.setModifiedTime(file, now);
|
|
@@ -126499,7 +126913,7 @@ var ts;
|
|
|
126499
126913
|
result.push("export" /* exportedModifier */);
|
|
126500
126914
|
if (flags & 8192 /* Deprecated */)
|
|
126501
126915
|
result.push("deprecated" /* deprecatedModifier */);
|
|
126502
|
-
if (node.flags &
|
|
126916
|
+
if (node.flags & 16777216 /* Ambient */)
|
|
126503
126917
|
result.push("declare" /* ambientModifier */);
|
|
126504
126918
|
if (node.kind === 271 /* ExportAssignment */)
|
|
126505
126919
|
result.push("export" /* exportedModifier */);
|
|
@@ -131042,17 +131456,13 @@ var ts;
|
|
|
131042
131456
|
}
|
|
131043
131457
|
}
|
|
131044
131458
|
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131045
|
-
|
|
131046
|
-
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
131459
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
|
|
131047
131460
|
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131048
131461
|
name = name + labelDetails.detail;
|
|
131049
131462
|
labelDetails = undefined;
|
|
131050
131463
|
}
|
|
131051
131464
|
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131052
131465
|
sortText = Completions.SortText.SortBelow(sortText);
|
|
131053
|
-
if (importAdder.hasFixes()) {
|
|
131054
|
-
hasAction = true;
|
|
131055
|
-
}
|
|
131056
131466
|
}
|
|
131057
131467
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131058
131468
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
@@ -131275,8 +131685,7 @@ var ts;
|
|
|
131275
131685
|
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131276
131686
|
var insertText = name;
|
|
131277
131687
|
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131278
|
-
var
|
|
131279
|
-
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131688
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
|
|
131280
131689
|
if (!method) {
|
|
131281
131690
|
return undefined;
|
|
131282
131691
|
}
|
|
@@ -131305,16 +131714,15 @@ var ts;
|
|
|
131305
131714
|
/*modifiers*/ undefined,
|
|
131306
131715
|
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131307
131716
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
131308
|
-
return { isSnippet: isSnippet, insertText: insertText,
|
|
131717
|
+
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
131309
131718
|
}
|
|
131310
131719
|
;
|
|
131311
|
-
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences
|
|
131720
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
131312
131721
|
var declarations = symbol.getDeclarations();
|
|
131313
131722
|
if (!(declarations && declarations.length)) {
|
|
131314
131723
|
return undefined;
|
|
131315
131724
|
}
|
|
131316
131725
|
var checker = program.getTypeChecker();
|
|
131317
|
-
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131318
131726
|
var declaration = declarations[0];
|
|
131319
131727
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131320
131728
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
@@ -131347,11 +131755,6 @@ var ts;
|
|
|
131347
131755
|
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131348
131756
|
return undefined;
|
|
131349
131757
|
}
|
|
131350
|
-
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131351
|
-
if (importableReference) {
|
|
131352
|
-
typeNode = importableReference.typeNode;
|
|
131353
|
-
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131354
|
-
}
|
|
131355
131758
|
var body = void 0;
|
|
131356
131759
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
131357
131760
|
var emptyStmt = ts.factory.createEmptyStatement();
|
|
@@ -131361,11 +131764,19 @@ var ts;
|
|
|
131361
131764
|
else {
|
|
131362
131765
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131363
131766
|
}
|
|
131767
|
+
var parameters = typeNode.parameters.map(function (typedParam) {
|
|
131768
|
+
return ts.factory.createParameterDeclaration(
|
|
131769
|
+
/*decorators*/ undefined,
|
|
131770
|
+
/*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
|
|
131771
|
+
/*type*/ undefined, typedParam.initializer);
|
|
131772
|
+
});
|
|
131364
131773
|
return ts.factory.createMethodDeclaration(
|
|
131365
131774
|
/*decorators*/ undefined,
|
|
131366
131775
|
/*modifiers*/ undefined,
|
|
131367
131776
|
/*asteriskToken*/ undefined, name,
|
|
131368
|
-
/*questionToken*/ undefined,
|
|
131777
|
+
/*questionToken*/ undefined,
|
|
131778
|
+
/*typeParameters*/ undefined, parameters,
|
|
131779
|
+
/*type*/ undefined, body);
|
|
131369
131780
|
}
|
|
131370
131781
|
default:
|
|
131371
131782
|
return undefined;
|
|
@@ -131728,20 +132139,6 @@ var ts;
|
|
|
131728
132139
|
};
|
|
131729
132140
|
}
|
|
131730
132141
|
}
|
|
131731
|
-
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
131732
|
-
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
131733
|
-
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
131734
|
-
if (importAdder.hasFixes()) {
|
|
131735
|
-
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
131736
|
-
return {
|
|
131737
|
-
sourceDisplay: undefined,
|
|
131738
|
-
codeActions: [{
|
|
131739
|
-
changes: changes,
|
|
131740
|
-
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
131741
|
-
}],
|
|
131742
|
-
};
|
|
131743
|
-
}
|
|
131744
|
-
}
|
|
131745
132142
|
if (originIsTypeOnlyAlias(origin)) {
|
|
131746
132143
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
131747
132144
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -132815,7 +133212,7 @@ var ts;
|
|
|
132815
133212
|
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
|
|
132816
133213
|
// Check completions for Object property value shorthand
|
|
132817
133214
|
if (instantiatedType === undefined) {
|
|
132818
|
-
if (objectLikeContainer.flags &
|
|
133215
|
+
if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
|
|
132819
133216
|
return 2 /* Fail */;
|
|
132820
133217
|
}
|
|
132821
133218
|
isNonContextualObjectLiteral = true;
|
|
@@ -134562,7 +134959,7 @@ var ts;
|
|
|
134562
134959
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
134563
134960
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
134564
134961
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
134565
|
-
var otherBucketKey = !ts.
|
|
134962
|
+
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
134566
134963
|
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
134567
134964
|
if (otherBucketKey) {
|
|
134568
134965
|
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
@@ -135478,17 +135875,25 @@ var ts;
|
|
|
135478
135875
|
var options = { use: 1 /* References */ };
|
|
135479
135876
|
var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
|
|
135480
135877
|
var checker = program.getTypeChecker();
|
|
135481
|
-
|
|
135878
|
+
// Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
|
|
135879
|
+
var adjustedNode = Core.getAdjustedNode(node, options);
|
|
135880
|
+
var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
|
|
135482
135881
|
return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
|
|
135483
135882
|
var definition = _a.definition, references = _a.references;
|
|
135484
135883
|
// Only include referenced symbols that have a valid definition.
|
|
135485
135884
|
return definition && {
|
|
135486
135885
|
definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
|
|
135487
|
-
references: references.map(function (r) { return
|
|
135886
|
+
references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
|
|
135488
135887
|
};
|
|
135489
135888
|
});
|
|
135490
135889
|
}
|
|
135491
135890
|
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
|
|
135891
|
+
function isDefinitionForReference(node) {
|
|
135892
|
+
return node.kind === 88 /* DefaultKeyword */
|
|
135893
|
+
|| !!ts.getDeclarationFromName(node)
|
|
135894
|
+
|| ts.isLiteralComputedPropertyDeclarationName(node)
|
|
135895
|
+
|| (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
|
|
135896
|
+
}
|
|
135492
135897
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
135493
135898
|
var node = ts.getTouchingPropertyName(sourceFile, position);
|
|
135494
135899
|
var referenceEntries;
|
|
@@ -135617,13 +136022,19 @@ var ts;
|
|
|
135617
136022
|
return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
|
|
135618
136023
|
}
|
|
135619
136024
|
FindAllReferences.toRenameLocation = toRenameLocation;
|
|
135620
|
-
function
|
|
136025
|
+
function toReferencedSymbolEntry(entry, symbol) {
|
|
136026
|
+
var referenceEntry = toReferenceEntry(entry);
|
|
136027
|
+
if (!symbol)
|
|
136028
|
+
return referenceEntry;
|
|
136029
|
+
return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
|
|
136030
|
+
}
|
|
136031
|
+
function toReferenceEntry(entry) {
|
|
135621
136032
|
var documentSpan = entryToDocumentSpan(entry);
|
|
135622
136033
|
if (entry.kind === 0 /* Span */) {
|
|
135623
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: false
|
|
136034
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: false });
|
|
135624
136035
|
}
|
|
135625
136036
|
var kind = entry.kind, node = entry.node;
|
|
135626
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node),
|
|
136037
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
|
135627
136038
|
}
|
|
135628
136039
|
FindAllReferences.toReferenceEntry = toReferenceEntry;
|
|
135629
136040
|
function entryToDocumentSpan(entry) {
|
|
@@ -135766,7 +136177,7 @@ var ts;
|
|
|
135766
136177
|
*/
|
|
135767
136178
|
function declarationIsWriteAccess(decl) {
|
|
135768
136179
|
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
|
|
135769
|
-
if (!!(decl.flags &
|
|
136180
|
+
if (!!(decl.flags & 16777216 /* Ambient */))
|
|
135770
136181
|
return true;
|
|
135771
136182
|
switch (decl.kind) {
|
|
135772
136183
|
case 221 /* BinaryExpression */:
|
|
@@ -136331,15 +136742,21 @@ var ts;
|
|
|
136331
136742
|
}
|
|
136332
136743
|
function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
|
|
136333
136744
|
var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
|
|
136334
|
-
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
|
|
136745
|
+
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
|
|
136335
136746
|
for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
|
|
136336
136747
|
var importLocation = importSearches_2[_i][0];
|
|
136337
136748
|
cb(importLocation);
|
|
136338
136749
|
}
|
|
136339
|
-
for (var _b = 0,
|
|
136340
|
-
var
|
|
136341
|
-
|
|
136342
|
-
|
|
136750
|
+
for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
|
|
136751
|
+
var singleReference = singleReferences_2[_b];
|
|
136752
|
+
if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
|
|
136753
|
+
cb(singleReference);
|
|
136754
|
+
}
|
|
136755
|
+
}
|
|
136756
|
+
for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
|
|
136757
|
+
var indirectUser = indirectUsers_2[_c];
|
|
136758
|
+
for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
|
|
136759
|
+
var node = _e[_d];
|
|
136343
136760
|
// Import specifiers should be handled by importSearches
|
|
136344
136761
|
var symbol = checker.getSymbolAtLocation(node);
|
|
136345
136762
|
var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
|
|
@@ -136482,6 +136899,30 @@ var ts;
|
|
|
136482
136899
|
}
|
|
136483
136900
|
}
|
|
136484
136901
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
136902
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
136903
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
136904
|
+
return candidates.reduce(function (topMost, decl) {
|
|
136905
|
+
var depth = getDepth(decl);
|
|
136906
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
136907
|
+
topMost.declarationNames.push(decl);
|
|
136908
|
+
topMost.depth = depth;
|
|
136909
|
+
}
|
|
136910
|
+
else if (depth < topMost.depth) {
|
|
136911
|
+
topMost.declarationNames = [decl];
|
|
136912
|
+
topMost.depth = depth;
|
|
136913
|
+
}
|
|
136914
|
+
return topMost;
|
|
136915
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
136916
|
+
function getDepth(declaration) {
|
|
136917
|
+
var depth = 0;
|
|
136918
|
+
while (declaration) {
|
|
136919
|
+
declaration = ts.getContainerNode(declaration);
|
|
136920
|
+
depth++;
|
|
136921
|
+
}
|
|
136922
|
+
return depth;
|
|
136923
|
+
}
|
|
136924
|
+
}
|
|
136925
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
136485
136926
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
136486
136927
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
136487
136928
|
return false;
|
|
@@ -137341,7 +137782,7 @@ var ts;
|
|
|
137341
137782
|
}
|
|
137342
137783
|
Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
|
|
137343
137784
|
function isImplementation(node) {
|
|
137344
|
-
return !!(node.flags &
|
|
137785
|
+
return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
|
|
137345
137786
|
(ts.isVariableLike(node) ? ts.hasInitializer(node) :
|
|
137346
137787
|
ts.isFunctionLikeDeclaration(node) ? !!node.body :
|
|
137347
137788
|
ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
|
|
@@ -137719,7 +138160,7 @@ var ts;
|
|
|
137719
138160
|
function collect(node) {
|
|
137720
138161
|
if (!node)
|
|
137721
138162
|
return;
|
|
137722
|
-
if (node.flags &
|
|
138163
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
137723
138164
|
// do not descend into ambient nodes.
|
|
137724
138165
|
return;
|
|
137725
138166
|
}
|
|
@@ -137878,7 +138319,7 @@ var ts;
|
|
|
137878
138319
|
}
|
|
137879
138320
|
/** Gets the call sites that call out of the provided call hierarchy declaration. */
|
|
137880
138321
|
function getOutgoingCalls(program, declaration) {
|
|
137881
|
-
if (declaration.flags &
|
|
138322
|
+
if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
|
|
137882
138323
|
return [];
|
|
137883
138324
|
}
|
|
137884
138325
|
return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
|
|
@@ -138118,7 +138559,9 @@ var ts;
|
|
|
138118
138559
|
(function (ts) {
|
|
138119
138560
|
var GoToDefinition;
|
|
138120
138561
|
(function (GoToDefinition) {
|
|
138121
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
138562
|
+
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
|
|
138563
|
+
var _a;
|
|
138564
|
+
var _b;
|
|
138122
138565
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
138123
138566
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
138124
138567
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -138141,33 +138584,63 @@ var ts;
|
|
|
138141
138584
|
}
|
|
138142
138585
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
138143
138586
|
var classDecl = node.parent.parent;
|
|
138144
|
-
var
|
|
138587
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
138145
138588
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
138146
138589
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
138147
138590
|
var sourceFile_1 = node.getSourceFile();
|
|
138148
138591
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
138149
138592
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
138150
138593
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
138151
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
138594
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
138152
138595
|
});
|
|
138153
138596
|
}
|
|
138154
|
-
var
|
|
138597
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
138598
|
+
var fallbackNode = node;
|
|
138599
|
+
if (searchOtherFilesOnly && failedAliasResolution) {
|
|
138600
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
138601
|
+
var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); });
|
|
138602
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
138603
|
+
if (moduleSpecifier) {
|
|
138604
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
138605
|
+
fallbackNode = moduleSpecifier;
|
|
138606
|
+
}
|
|
138607
|
+
}
|
|
138608
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
138609
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
138610
|
+
// be that module resolution succeeded but the target was not a module.
|
|
138611
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
138612
|
+
if (ref) {
|
|
138613
|
+
return [{
|
|
138614
|
+
name: fallbackNode.text,
|
|
138615
|
+
fileName: ref.resolvedFileName,
|
|
138616
|
+
containerName: undefined,
|
|
138617
|
+
containerKind: undefined,
|
|
138618
|
+
kind: "script" /* scriptElement */,
|
|
138619
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
138620
|
+
failedAliasResolution: failedAliasResolution,
|
|
138621
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
138622
|
+
unverified: fallbackNode !== node,
|
|
138623
|
+
}];
|
|
138624
|
+
}
|
|
138625
|
+
}
|
|
138155
138626
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
138156
138627
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
138157
138628
|
if (!symbol) {
|
|
138158
138629
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
138159
138630
|
}
|
|
138631
|
+
if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
138632
|
+
return undefined;
|
|
138160
138633
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
138161
138634
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
138162
138635
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
138163
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
138636
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
138164
138637
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
138165
138638
|
// If this is the original constructor definition, parent is the class.
|
|
138166
138639
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
138167
138640
|
return [sigInfo];
|
|
138168
138641
|
}
|
|
138169
138642
|
else {
|
|
138170
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
138643
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
138171
138644
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
138172
138645
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
138173
138646
|
}
|
|
@@ -138179,7 +138652,7 @@ var ts;
|
|
|
138179
138652
|
// assignment. This case and others are handled by the following code.
|
|
138180
138653
|
if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
|
|
138181
138654
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
138182
|
-
var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
|
|
138655
|
+
var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
|
|
138183
138656
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
138184
138657
|
}
|
|
138185
138658
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -138202,7 +138675,7 @@ var ts;
|
|
|
138202
138675
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
138203
138676
|
});
|
|
138204
138677
|
}
|
|
138205
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
138678
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
138206
138679
|
}
|
|
138207
138680
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
138208
138681
|
/**
|
|
@@ -138300,24 +138773,24 @@ var ts;
|
|
|
138300
138773
|
return undefined;
|
|
138301
138774
|
}
|
|
138302
138775
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
138303
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
138776
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
138304
138777
|
}
|
|
138305
|
-
var
|
|
138778
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
138306
138779
|
if (!symbol)
|
|
138307
138780
|
return undefined;
|
|
138308
138781
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
138309
138782
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
138310
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
138783
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
138311
138784
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
138312
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
138785
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
138313
138786
|
return typeDefinitions.length ? typeDefinitions
|
|
138314
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
138787
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
138315
138788
|
: undefined;
|
|
138316
138789
|
}
|
|
138317
138790
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
138318
|
-
function definitionFromType(type, checker, node) {
|
|
138791
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
138319
138792
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
138320
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
138793
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
138321
138794
|
});
|
|
138322
138795
|
}
|
|
138323
138796
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -138359,13 +138832,17 @@ var ts;
|
|
|
138359
138832
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
138360
138833
|
// import {A, B} from "mod";
|
|
138361
138834
|
// to jump to the implementation directly.
|
|
138835
|
+
var failedAliasResolution = false;
|
|
138362
138836
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
138363
138837
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
138364
138838
|
if (aliased.declarations) {
|
|
138365
|
-
return aliased;
|
|
138839
|
+
return { symbol: aliased };
|
|
138840
|
+
}
|
|
138841
|
+
else {
|
|
138842
|
+
failedAliasResolution = true;
|
|
138366
138843
|
}
|
|
138367
138844
|
}
|
|
138368
|
-
return symbol;
|
|
138845
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
138369
138846
|
}
|
|
138370
138847
|
// Go to the original declaration for cases:
|
|
138371
138848
|
//
|
|
@@ -138379,26 +138856,45 @@ var ts;
|
|
|
138379
138856
|
if (node.parent === declaration) {
|
|
138380
138857
|
return true;
|
|
138381
138858
|
}
|
|
138382
|
-
|
|
138383
|
-
|
|
138384
|
-
case 265 /* ImportEqualsDeclaration */:
|
|
138385
|
-
return true;
|
|
138386
|
-
case 270 /* ImportSpecifier */:
|
|
138387
|
-
return declaration.parent.kind === 269 /* NamedImports */;
|
|
138388
|
-
case 203 /* BindingElement */:
|
|
138389
|
-
case 254 /* VariableDeclaration */:
|
|
138390
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
138391
|
-
default:
|
|
138392
|
-
return false;
|
|
138859
|
+
if (declaration.kind === 268 /* NamespaceImport */) {
|
|
138860
|
+
return false;
|
|
138393
138861
|
}
|
|
138862
|
+
return true;
|
|
138863
|
+
}
|
|
138864
|
+
/**
|
|
138865
|
+
* ```ts
|
|
138866
|
+
* function f() {}
|
|
138867
|
+
* f.foo = 0;
|
|
138868
|
+
* ```
|
|
138869
|
+
*
|
|
138870
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
138871
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
138872
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
138873
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
138874
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
138875
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
138876
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
138877
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
138878
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
138879
|
+
* up with a more precise definition of what counts as a definition.
|
|
138880
|
+
*/
|
|
138881
|
+
function isExpandoDeclaration(node) {
|
|
138882
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
138883
|
+
return false;
|
|
138884
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
138885
|
+
if (ts.isAssignmentExpression(p))
|
|
138886
|
+
return true;
|
|
138887
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
138888
|
+
return "quit";
|
|
138889
|
+
return false;
|
|
138890
|
+
});
|
|
138891
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
138394
138892
|
}
|
|
138395
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
138396
|
-
|
|
138397
|
-
|
|
138398
|
-
|
|
138399
|
-
|
|
138400
|
-
|| undefined;
|
|
138401
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
138893
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
138894
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
138895
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
138896
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
138897
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
|
|
138402
138898
|
function getConstructSignatureDefinition() {
|
|
138403
138899
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
138404
138900
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -138422,26 +138918,27 @@ var ts;
|
|
|
138422
138918
|
return declarations.length
|
|
138423
138919
|
? declarationsWithBody.length !== 0
|
|
138424
138920
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
138425
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
138921
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
|
|
138426
138922
|
: undefined;
|
|
138427
138923
|
}
|
|
138428
138924
|
}
|
|
138429
138925
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
138430
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
138926
|
+
function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
|
|
138431
138927
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
138432
138928
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
138433
138929
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
138434
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
138930
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
|
|
138435
138931
|
}
|
|
138932
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
138436
138933
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
138437
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
138934
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
|
|
138438
138935
|
var sourceFile = declaration.getSourceFile();
|
|
138439
138936
|
if (!textSpan) {
|
|
138440
138937
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
138441
138938
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
138442
138939
|
}
|
|
138443
138940
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
138444
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
138941
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
|
|
138445
138942
|
}
|
|
138446
138943
|
function isDefinitionVisible(checker, declaration) {
|
|
138447
138944
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -138474,8 +138971,8 @@ var ts;
|
|
|
138474
138971
|
return false;
|
|
138475
138972
|
}
|
|
138476
138973
|
}
|
|
138477
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
138478
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
138974
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
138975
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
|
138479
138976
|
}
|
|
138480
138977
|
function findReferenceInPosition(refs, pos) {
|
|
138481
138978
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -140012,8 +140509,8 @@ var ts;
|
|
|
140012
140509
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
140013
140510
|
var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
|
|
140014
140511
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
140015
|
-
var
|
|
140016
|
-
organizeImportsWorker(
|
|
140512
|
+
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
140513
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140017
140514
|
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
140018
140515
|
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
140019
140516
|
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
@@ -140021,8 +140518,8 @@ var ts;
|
|
|
140021
140518
|
var ambientModule = _a[_i];
|
|
140022
140519
|
if (!ambientModule.body)
|
|
140023
140520
|
continue;
|
|
140024
|
-
var
|
|
140025
|
-
organizeImportsWorker(
|
|
140521
|
+
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
140522
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140026
140523
|
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
140027
140524
|
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
140028
140525
|
}
|
|
@@ -140068,6 +140565,40 @@ var ts;
|
|
|
140068
140565
|
}
|
|
140069
140566
|
}
|
|
140070
140567
|
OrganizeImports.organizeImports = organizeImports;
|
|
140568
|
+
function groupImportsByNewlineContiguous(sourceFile, importDecls) {
|
|
140569
|
+
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
|
|
140570
|
+
var groupImports = [];
|
|
140571
|
+
var groupIndex = 0;
|
|
140572
|
+
for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
|
|
140573
|
+
var topLevelImportDecl = importDecls_1[_i];
|
|
140574
|
+
if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
|
|
140575
|
+
groupIndex++;
|
|
140576
|
+
}
|
|
140577
|
+
if (!groupImports[groupIndex]) {
|
|
140578
|
+
groupImports[groupIndex] = [];
|
|
140579
|
+
}
|
|
140580
|
+
groupImports[groupIndex].push(topLevelImportDecl);
|
|
140581
|
+
}
|
|
140582
|
+
return groupImports;
|
|
140583
|
+
}
|
|
140584
|
+
// a new group is created if an import includes at least two new line
|
|
140585
|
+
// new line from multi-line comment doesn't count
|
|
140586
|
+
function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
|
|
140587
|
+
var startPos = topLevelImportDecl.getFullStart();
|
|
140588
|
+
var endPos = topLevelImportDecl.getStart();
|
|
140589
|
+
scanner.setText(sourceFile.text, startPos, endPos - startPos);
|
|
140590
|
+
var numberOfNewLines = 0;
|
|
140591
|
+
while (scanner.getTokenPos() < endPos) {
|
|
140592
|
+
var tokenKind = scanner.scan();
|
|
140593
|
+
if (tokenKind === 4 /* NewLineTrivia */) {
|
|
140594
|
+
numberOfNewLines++;
|
|
140595
|
+
if (numberOfNewLines >= 2) {
|
|
140596
|
+
return true;
|
|
140597
|
+
}
|
|
140598
|
+
}
|
|
140599
|
+
}
|
|
140600
|
+
return false;
|
|
140601
|
+
}
|
|
140071
140602
|
function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
|
|
140072
140603
|
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
140073
140604
|
if (skipDestructiveCodeActions) {
|
|
@@ -148028,8 +148559,11 @@ var ts;
|
|
|
148028
148559
|
function isTrivia(s) {
|
|
148029
148560
|
return ts.skipTrivia(s, 0) === s.length;
|
|
148030
148561
|
}
|
|
148562
|
+
// A transformation context that won't perform parenthesization, as some parenthesization rules
|
|
148563
|
+
// are more aggressive than is strictly necessary.
|
|
148564
|
+
var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
|
|
148031
148565
|
function assignPositionsToNode(node) {
|
|
148032
|
-
var visited = ts.visitEachChild(node, assignPositionsToNode,
|
|
148566
|
+
var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
|
148033
148567
|
// create proxy node for non synthesized nodes
|
|
148034
148568
|
var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
|
|
148035
148569
|
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
|
|
@@ -151553,9 +152087,10 @@ var ts;
|
|
|
151553
152087
|
// 2. add "member3" to the second import statement's import list
|
|
151554
152088
|
// and it is up to the user to decide which one fits best.
|
|
151555
152089
|
return ts.firstDefined(existingImports, function (_a) {
|
|
152090
|
+
var _b;
|
|
151556
152091
|
var declaration = _a.declaration;
|
|
151557
152092
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
151558
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152093
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151559
152094
|
if (namespacePrefix && moduleSpecifier) {
|
|
151560
152095
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
151561
152096
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -151731,8 +152266,9 @@ var ts;
|
|
|
151731
152266
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
151732
152267
|
}
|
|
151733
152268
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
152269
|
+
var _b;
|
|
151734
152270
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
151735
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152271
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151736
152272
|
if (moduleSpecifier) {
|
|
151737
152273
|
var addAsTypeOnly = useRequire
|
|
151738
152274
|
? 4 /* NotAllowed */
|
|
@@ -155994,7 +156530,7 @@ var ts;
|
|
|
155994
156530
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
155995
156531
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
155996
156532
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
155997
|
-
var ambient = !!(enclosingDeclaration.flags &
|
|
156533
|
+
var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
|
|
155998
156534
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
155999
156535
|
switch (declaration.kind) {
|
|
156000
156536
|
case 166 /* PropertySignature */:
|
|
@@ -156090,7 +156626,6 @@ var ts;
|
|
|
156090
156626
|
var checker = program.getTypeChecker();
|
|
156091
156627
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156092
156628
|
var flags = 1 /* NoTruncation */
|
|
156093
|
-
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
156094
156629
|
| 256 /* SuppressAnyReturnType */
|
|
156095
156630
|
| 524288 /* AllowEmptyTuple */
|
|
156096
156631
|
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
@@ -157571,6 +158106,10 @@ var ts;
|
|
|
157571
158106
|
}
|
|
157572
158107
|
break;
|
|
157573
158108
|
}
|
|
158109
|
+
case 200 /* ImportType */:
|
|
158110
|
+
var importTypeNode = parent;
|
|
158111
|
+
changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
|
|
158112
|
+
break;
|
|
157574
158113
|
default:
|
|
157575
158114
|
ts.Debug.failBadSyntaxKind(parent);
|
|
157576
158115
|
}
|
|
@@ -158465,6 +159004,7 @@ var ts;
|
|
|
158465
159004
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
158466
159005
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
158467
159006
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
159007
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
158468
159008
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
158469
159009
|
var RangeFacts;
|
|
158470
159010
|
(function (RangeFacts) {
|
|
@@ -158473,10 +159013,11 @@ var ts;
|
|
|
158473
159013
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
158474
159014
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
158475
159015
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
159016
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
158476
159017
|
/**
|
|
158477
159018
|
* The range is in a function which needs the 'static' modifier in a class
|
|
158478
159019
|
*/
|
|
158479
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
159020
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
158480
159021
|
})(RangeFacts || (RangeFacts = {}));
|
|
158481
159022
|
/**
|
|
158482
159023
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -158507,11 +159048,12 @@ var ts;
|
|
|
158507
159048
|
// We'll modify these flags as we walk the tree to collect data
|
|
158508
159049
|
// about what things need to be done as part of the extraction.
|
|
158509
159050
|
var rangeFacts = RangeFacts.None;
|
|
159051
|
+
var thisNode;
|
|
158510
159052
|
if (!start || !end) {
|
|
158511
159053
|
// cannot find either start or end node
|
|
158512
159054
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158513
159055
|
}
|
|
158514
|
-
if (start.flags &
|
|
159056
|
+
if (start.flags & 8388608 /* JSDoc */) {
|
|
158515
159057
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
158516
159058
|
}
|
|
158517
159059
|
if (start.parent !== end.parent) {
|
|
@@ -158545,7 +159087,7 @@ var ts;
|
|
|
158545
159087
|
// the expression.
|
|
158546
159088
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158547
159089
|
}
|
|
158548
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
159090
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
158549
159091
|
}
|
|
158550
159092
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
158551
159093
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -158557,7 +159099,7 @@ var ts;
|
|
|
158557
159099
|
if (errors) {
|
|
158558
159100
|
return { errors: errors };
|
|
158559
159101
|
}
|
|
158560
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
159102
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
158561
159103
|
/**
|
|
158562
159104
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
158563
159105
|
* @param node The unrefined extraction node.
|
|
@@ -158637,7 +159179,7 @@ var ts;
|
|
|
158637
159179
|
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
158638
159180
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
158639
159181
|
}
|
|
158640
|
-
if (nodeToCheck.flags &
|
|
159182
|
+
if (nodeToCheck.flags & 16777216 /* Ambient */) {
|
|
158641
159183
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
|
|
158642
159184
|
}
|
|
158643
159185
|
// If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
|
|
@@ -158649,6 +159191,14 @@ var ts;
|
|
|
158649
159191
|
var permittedJumps = 4 /* Return */;
|
|
158650
159192
|
var seenLabels;
|
|
158651
159193
|
visit(nodeToCheck);
|
|
159194
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159195
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159196
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159197
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159198
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159199
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159200
|
+
}
|
|
159201
|
+
}
|
|
158652
159202
|
return errors;
|
|
158653
159203
|
function visit(node) {
|
|
158654
159204
|
if (errors) {
|
|
@@ -158687,6 +159237,7 @@ var ts;
|
|
|
158687
159237
|
}
|
|
158688
159238
|
else {
|
|
158689
159239
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159240
|
+
thisNode = node;
|
|
158690
159241
|
}
|
|
158691
159242
|
break;
|
|
158692
159243
|
case 214 /* ArrowFunction */:
|
|
@@ -158694,6 +159245,7 @@ var ts;
|
|
|
158694
159245
|
ts.forEachChild(node, function check(n) {
|
|
158695
159246
|
if (ts.isThis(n)) {
|
|
158696
159247
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159248
|
+
thisNode = node;
|
|
158697
159249
|
}
|
|
158698
159250
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
158699
159251
|
return false;
|
|
@@ -158750,6 +159302,7 @@ var ts;
|
|
|
158750
159302
|
case 192 /* ThisType */:
|
|
158751
159303
|
case 108 /* ThisKeyword */:
|
|
158752
159304
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159305
|
+
thisNode = node;
|
|
158753
159306
|
break;
|
|
158754
159307
|
case 250 /* LabeledStatement */: {
|
|
158755
159308
|
var label = node.label;
|
|
@@ -158837,7 +159390,7 @@ var ts;
|
|
|
158837
159390
|
*/
|
|
158838
159391
|
function collectEnclosingScopes(range) {
|
|
158839
159392
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
158840
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
159393
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
158841
159394
|
// 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
|
|
158842
159395
|
var containingClass = ts.getContainingClass(current);
|
|
158843
159396
|
if (containingClass) {
|
|
@@ -159043,6 +159596,7 @@ var ts;
|
|
|
159043
159596
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
159044
159597
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
159045
159598
|
var newFunction;
|
|
159599
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
159046
159600
|
if (ts.isClassLike(scope)) {
|
|
159047
159601
|
// always create private method in TypeScript files
|
|
159048
159602
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -159057,6 +159611,15 @@ var ts;
|
|
|
159057
159611
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
159058
159612
|
}
|
|
159059
159613
|
else {
|
|
159614
|
+
if (callThis) {
|
|
159615
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
159616
|
+
/*decorators*/ undefined,
|
|
159617
|
+
/*modifiers*/ undefined,
|
|
159618
|
+
/*dotDotDotToken*/ undefined,
|
|
159619
|
+
/*name*/ "this",
|
|
159620
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
159621
|
+
/*initializer*/ undefined));
|
|
159622
|
+
}
|
|
159060
159623
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
159061
159624
|
/*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);
|
|
159062
159625
|
}
|
|
@@ -159073,7 +159636,10 @@ var ts;
|
|
|
159073
159636
|
var newNodes = [];
|
|
159074
159637
|
// replace range with function call
|
|
159075
159638
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
159076
|
-
|
|
159639
|
+
if (callThis) {
|
|
159640
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
159641
|
+
}
|
|
159642
|
+
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
|
|
159077
159643
|
callArguments);
|
|
159078
159644
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
159079
159645
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -159684,6 +160250,9 @@ var ts;
|
|
|
159684
160250
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
159685
160251
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
159686
160252
|
}
|
|
160253
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160254
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160255
|
+
}
|
|
159687
160256
|
var hasWrite = false;
|
|
159688
160257
|
var readonlyClassPropertyWrite;
|
|
159689
160258
|
usagesPerScope[i].usages.forEach(function (value) {
|
|
@@ -160169,6 +160738,7 @@ var ts;
|
|
|
160169
160738
|
}
|
|
160170
160739
|
function doTypedefChange(changes, file, name, info) {
|
|
160171
160740
|
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
|
|
160741
|
+
ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
|
|
160172
160742
|
var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
|
|
160173
160743
|
var templates = [];
|
|
160174
160744
|
ts.forEach(typeParameters, function (typeParameter) {
|
|
@@ -162199,7 +162769,7 @@ var ts;
|
|
|
162199
162769
|
kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
|
|
162200
162770
|
new TokenObject(kind, pos, end);
|
|
162201
162771
|
node.parent = parent;
|
|
162202
|
-
node.flags = parent.flags &
|
|
162772
|
+
node.flags = parent.flags & 50720768 /* ContextFlags */;
|
|
162203
162773
|
return node;
|
|
162204
162774
|
}
|
|
162205
162775
|
var NodeObject = /** @class */ (function () {
|
|
@@ -163636,9 +164206,9 @@ var ts;
|
|
|
163636
164206
|
}
|
|
163637
164207
|
}
|
|
163638
164208
|
/// Goto definition
|
|
163639
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
164209
|
+
function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
|
|
163640
164210
|
synchronizeHostData();
|
|
163641
|
-
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
164211
|
+
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
|
|
163642
164212
|
}
|
|
163643
164213
|
function getDefinitionAndBoundSpan(fileName, position) {
|
|
163644
164214
|
synchronizeHostData();
|
|
@@ -163655,7 +164225,7 @@ var ts;
|
|
|
163655
164225
|
}
|
|
163656
164226
|
/// References and Occurrences
|
|
163657
164227
|
function getOccurrencesAtPosition(fileName, position) {
|
|
163658
|
-
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
|
|
164228
|
+
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 })); }); });
|
|
163659
164229
|
}
|
|
163660
164230
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
163661
164231
|
var normalizedFileName = ts.normalizePath(fileName);
|
|
@@ -163684,7 +164254,7 @@ var ts;
|
|
|
163684
164254
|
}
|
|
163685
164255
|
function getReferencesAtPosition(fileName, position) {
|
|
163686
164256
|
synchronizeHostData();
|
|
163687
|
-
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ },
|
|
164257
|
+
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
|
|
163688
164258
|
}
|
|
163689
164259
|
function getReferencesWorker(node, position, options, cb) {
|
|
163690
164260
|
synchronizeHostData();
|
|
@@ -163699,10 +164269,8 @@ var ts;
|
|
|
163699
164269
|
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
163700
164270
|
}
|
|
163701
164271
|
function getFileReferences(fileName) {
|
|
163702
|
-
var _a;
|
|
163703
164272
|
synchronizeHostData();
|
|
163704
|
-
|
|
163705
|
-
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
|
|
164273
|
+
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
|
|
163706
164274
|
}
|
|
163707
164275
|
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
|
|
163708
164276
|
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
|
|
@@ -164175,7 +164743,7 @@ var ts;
|
|
|
164175
164743
|
}
|
|
164176
164744
|
function isUnclosedFragment(_a) {
|
|
164177
164745
|
var closingFragment = _a.closingFragment, parent = _a.parent;
|
|
164178
|
-
return !!(closingFragment.flags &
|
|
164746
|
+
return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
|
|
164179
164747
|
}
|
|
164180
164748
|
function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
|
|
164181
164749
|
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
|
@@ -164623,7 +165191,7 @@ var ts;
|
|
|
164623
165191
|
tokenAtLocation = preceding;
|
|
164624
165192
|
}
|
|
164625
165193
|
// Cannot set breakpoint in ambient declarations
|
|
164626
|
-
if (tokenAtLocation.flags &
|
|
165194
|
+
if (tokenAtLocation.flags & 16777216 /* Ambient */) {
|
|
164627
165195
|
return undefined;
|
|
164628
165196
|
}
|
|
164629
165197
|
// Get the span in the node based on its syntax
|
|
@@ -166598,6 +167166,11 @@ var ts;
|
|
|
166598
167166
|
return "/dev/null/autoImportProviderProject" + counter + "*";
|
|
166599
167167
|
}
|
|
166600
167168
|
server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName;
|
|
167169
|
+
/*@internal*/
|
|
167170
|
+
function makeAuxiliaryProjectName(counter) {
|
|
167171
|
+
return "/dev/null/auxiliaryProject" + counter + "*";
|
|
167172
|
+
}
|
|
167173
|
+
server.makeAuxiliaryProjectName = makeAuxiliaryProjectName;
|
|
166601
167174
|
function createSortedArray() {
|
|
166602
167175
|
return []; // TODO: GH#19873
|
|
166603
167176
|
}
|
|
@@ -166811,6 +167384,7 @@ var ts;
|
|
|
166811
167384
|
CommandTypes["SignatureHelp"] = "signatureHelp";
|
|
166812
167385
|
/* @internal */
|
|
166813
167386
|
CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
|
|
167387
|
+
CommandTypes["FindSourceDefinition"] = "findSourceDefinition";
|
|
166814
167388
|
CommandTypes["Status"] = "status";
|
|
166815
167389
|
CommandTypes["TypeDefinition"] = "typeDefinition";
|
|
166816
167390
|
CommandTypes["ProjectInfo"] = "projectInfo";
|
|
@@ -167390,7 +167964,7 @@ var ts;
|
|
|
167390
167964
|
case 0:
|
|
167391
167965
|
return server.Errors.ThrowNoProject();
|
|
167392
167966
|
case 1:
|
|
167393
|
-
return
|
|
167967
|
+
return ensurePrimaryProjectKind(this.containingProjects[0]);
|
|
167394
167968
|
default:
|
|
167395
167969
|
// If this file belongs to multiple projects, below is the order in which default project is used
|
|
167396
167970
|
// - for open script info, its default configured project during opening is default if info is part of it
|
|
@@ -167428,7 +168002,7 @@ var ts;
|
|
|
167428
168002
|
firstInferredProject = project;
|
|
167429
168003
|
}
|
|
167430
168004
|
}
|
|
167431
|
-
return
|
|
168005
|
+
return ensurePrimaryProjectKind(defaultConfiguredProject ||
|
|
167432
168006
|
firstNonSourceOfProjectReferenceRedirect ||
|
|
167433
168007
|
firstConfiguredProject ||
|
|
167434
168008
|
firstExternalProject ||
|
|
@@ -167504,8 +168078,8 @@ var ts;
|
|
|
167504
168078
|
return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); });
|
|
167505
168079
|
};
|
|
167506
168080
|
/*@internal*/
|
|
167507
|
-
ScriptInfo.prototype.
|
|
167508
|
-
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; });
|
|
168081
|
+
ScriptInfo.prototype.isContainedByBackgroundProject = function () {
|
|
168082
|
+
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; });
|
|
167509
168083
|
};
|
|
167510
168084
|
/**
|
|
167511
168085
|
* @param line 1 based index
|
|
@@ -167539,8 +168113,13 @@ var ts;
|
|
|
167539
168113
|
return ScriptInfo;
|
|
167540
168114
|
}());
|
|
167541
168115
|
server.ScriptInfo = ScriptInfo;
|
|
167542
|
-
|
|
167543
|
-
|
|
168116
|
+
/**
|
|
168117
|
+
* Throws an error if `project` is an AutoImportProvider or AuxiliaryProject,
|
|
168118
|
+
* which are used in the background by other Projects and should never be
|
|
168119
|
+
* reported as the default project for a ScriptInfo.
|
|
168120
|
+
*/
|
|
168121
|
+
function ensurePrimaryProjectKind(project) {
|
|
168122
|
+
if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) {
|
|
167544
168123
|
return server.Errors.ThrowNoProject();
|
|
167545
168124
|
}
|
|
167546
168125
|
return project;
|
|
@@ -167680,6 +168259,7 @@ var ts;
|
|
|
167680
168259
|
ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
|
|
167681
168260
|
ProjectKind[ProjectKind["External"] = 2] = "External";
|
|
167682
168261
|
ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
|
|
168262
|
+
ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
|
|
167683
168263
|
})(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
|
|
167684
168264
|
/* @internal */
|
|
167685
168265
|
function countEachFileTypes(infos, includeSizes) {
|
|
@@ -167705,7 +168285,7 @@ var ts;
|
|
|
167705
168285
|
result.jsxSize += fileSize;
|
|
167706
168286
|
break;
|
|
167707
168287
|
case 3 /* TS */:
|
|
167708
|
-
if (ts.
|
|
168288
|
+
if (ts.isDeclarationFileName(info.fileName)) {
|
|
167709
168289
|
result.dts += 1;
|
|
167710
168290
|
result.dtsSize += fileSize;
|
|
167711
168291
|
}
|
|
@@ -167743,7 +168323,7 @@ var ts;
|
|
|
167743
168323
|
server.allFilesAreJsOrDts = allFilesAreJsOrDts;
|
|
167744
168324
|
/* @internal */
|
|
167745
168325
|
function hasNoTypeScriptSource(fileNames) {
|
|
167746
|
-
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.
|
|
168326
|
+
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
|
|
167747
168327
|
}
|
|
167748
168328
|
server.hasNoTypeScriptSource = hasNoTypeScriptSource;
|
|
167749
168329
|
function isGeneratedFileWatcher(watch) {
|
|
@@ -168147,7 +168727,7 @@ var ts;
|
|
|
168147
168727
|
}
|
|
168148
168728
|
// Update the signature
|
|
168149
168729
|
if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) {
|
|
168150
|
-
var dtsFiles = outputFiles.filter(function (f) { return ts.
|
|
168730
|
+
var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); });
|
|
168151
168731
|
if (dtsFiles.length === 1) {
|
|
168152
168732
|
var sourceFile = this.program.getSourceFile(scriptInfo.fileName);
|
|
168153
168733
|
var signature = this.projectService.host.createHash ?
|
|
@@ -168266,6 +168846,10 @@ var ts;
|
|
|
168266
168846
|
this.autoImportProviderHost.close();
|
|
168267
168847
|
}
|
|
168268
168848
|
this.autoImportProviderHost = undefined;
|
|
168849
|
+
if (this.noDtsResolutionProject) {
|
|
168850
|
+
this.noDtsResolutionProject.close();
|
|
168851
|
+
}
|
|
168852
|
+
this.noDtsResolutionProject = undefined;
|
|
168269
168853
|
// signal language service to release source files acquired from document registry
|
|
168270
168854
|
this.languageService.dispose();
|
|
168271
168855
|
this.languageService = undefined;
|
|
@@ -168788,11 +169372,13 @@ var ts;
|
|
|
168788
169372
|
}
|
|
168789
169373
|
};
|
|
168790
169374
|
Project.prototype.setCompilerOptions = function (compilerOptions) {
|
|
169375
|
+
var _a;
|
|
168791
169376
|
if (compilerOptions) {
|
|
168792
169377
|
compilerOptions.allowNonTsExtensions = true;
|
|
168793
169378
|
var oldOptions = this.compilerOptions;
|
|
168794
169379
|
this.compilerOptions = compilerOptions;
|
|
168795
169380
|
this.setInternalCompilerOptionsForEmittingJsFiles();
|
|
169381
|
+
(_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject());
|
|
168796
169382
|
if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) {
|
|
168797
169383
|
// reset cached unresolved imports if changes in compiler options affected module resolution
|
|
168798
169384
|
this.cachedUnresolvedImportsPerFile.clear();
|
|
@@ -169132,6 +169718,31 @@ var ts;
|
|
|
169132
169718
|
Project.prototype.getIncompleteCompletionsCache = function () {
|
|
169133
169719
|
return this.projectService.getIncompleteCompletionsCache();
|
|
169134
169720
|
};
|
|
169721
|
+
/*@internal*/
|
|
169722
|
+
Project.prototype.getNoDtsResolutionProject = function (rootFileNames) {
|
|
169723
|
+
var _this = this;
|
|
169724
|
+
ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic);
|
|
169725
|
+
if (!this.noDtsResolutionProject) {
|
|
169726
|
+
this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169727
|
+
}
|
|
169728
|
+
ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) {
|
|
169729
|
+
var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost);
|
|
169730
|
+
if (info) {
|
|
169731
|
+
_this.noDtsResolutionProject.addRoot(info, pathToAdd);
|
|
169732
|
+
}
|
|
169733
|
+
}, function (pathToRemove) {
|
|
169734
|
+
// It may be preferable to remove roots only once project grows to a certain size?
|
|
169735
|
+
var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove);
|
|
169736
|
+
if (info) {
|
|
169737
|
+
_this.noDtsResolutionProject.removeRoot(info);
|
|
169738
|
+
}
|
|
169739
|
+
});
|
|
169740
|
+
return this.noDtsResolutionProject;
|
|
169741
|
+
};
|
|
169742
|
+
/*@internal*/
|
|
169743
|
+
Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () {
|
|
169744
|
+
return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
|
|
169745
|
+
};
|
|
169135
169746
|
return Project;
|
|
169136
169747
|
}());
|
|
169137
169748
|
server.Project = Project;
|
|
@@ -169247,6 +169858,26 @@ var ts;
|
|
|
169247
169858
|
return InferredProject;
|
|
169248
169859
|
}(Project));
|
|
169249
169860
|
server.InferredProject = InferredProject;
|
|
169861
|
+
var AuxiliaryProject = /** @class */ (function (_super) {
|
|
169862
|
+
__extends(AuxiliaryProject, _super);
|
|
169863
|
+
function AuxiliaryProject(projectService, documentRegistry, compilerOptions) {
|
|
169864
|
+
return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry,
|
|
169865
|
+
/*hasExplicitListOfFiles*/ false,
|
|
169866
|
+
/*lastFileExceededProgramSize*/ undefined, compilerOptions,
|
|
169867
|
+
/*compileOnSaveEnabled*/ false,
|
|
169868
|
+
/*watchOptions*/ undefined, projectService.host,
|
|
169869
|
+
/*currentDirectory*/ undefined) || this;
|
|
169870
|
+
}
|
|
169871
|
+
AuxiliaryProject.prototype.isOrphan = function () {
|
|
169872
|
+
return true;
|
|
169873
|
+
};
|
|
169874
|
+
/*@internal*/
|
|
169875
|
+
AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
169876
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
169877
|
+
return;
|
|
169878
|
+
};
|
|
169879
|
+
return AuxiliaryProject;
|
|
169880
|
+
}(Project));
|
|
169250
169881
|
var AutoImportProviderProject = /** @class */ (function (_super) {
|
|
169251
169882
|
__extends(AutoImportProviderProject, _super);
|
|
169252
169883
|
/*@internal*/
|
|
@@ -169398,6 +170029,11 @@ var ts;
|
|
|
169398
170029
|
}
|
|
169399
170030
|
return hasSameSetOfFiles;
|
|
169400
170031
|
};
|
|
170032
|
+
/*@internal*/
|
|
170033
|
+
AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
170034
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
170035
|
+
return;
|
|
170036
|
+
};
|
|
169401
170037
|
AutoImportProviderProject.prototype.hasRoots = function () {
|
|
169402
170038
|
var _a;
|
|
169403
170039
|
return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length);
|
|
@@ -170083,6 +170719,8 @@ var ts;
|
|
|
170083
170719
|
this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName);
|
|
170084
170720
|
/*@internal*/
|
|
170085
170721
|
this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName);
|
|
170722
|
+
/*@internal*/
|
|
170723
|
+
this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName);
|
|
170086
170724
|
/**
|
|
170087
170725
|
* Open files: with value being project root path, and key being Path of the file that is open
|
|
170088
170726
|
*/
|
|
@@ -170286,13 +170924,15 @@ var ts;
|
|
|
170286
170924
|
ProjectService.prototype.delayUpdateProjectGraph = function (project) {
|
|
170287
170925
|
var _this = this;
|
|
170288
170926
|
project.markAsDirty();
|
|
170289
|
-
|
|
170290
|
-
|
|
170291
|
-
|
|
170292
|
-
|
|
170293
|
-
|
|
170294
|
-
|
|
170295
|
-
|
|
170927
|
+
if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) {
|
|
170928
|
+
var projectName_1 = project.getProjectName();
|
|
170929
|
+
this.pendingProjectUpdates.set(projectName_1, project);
|
|
170930
|
+
this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () {
|
|
170931
|
+
if (_this.pendingProjectUpdates.delete(projectName_1)) {
|
|
170932
|
+
updateProjectIfDirty(project);
|
|
170933
|
+
}
|
|
170934
|
+
});
|
|
170935
|
+
}
|
|
170296
170936
|
};
|
|
170297
170937
|
/*@internal*/
|
|
170298
170938
|
ProjectService.prototype.hasPendingProjectUpdate = function (project) {
|
|
@@ -172573,7 +173213,7 @@ var ts;
|
|
|
172573
173213
|
var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo);
|
|
172574
173214
|
this.filenameToScriptInfo.forEach(function (info) {
|
|
172575
173215
|
// If script info is open or orphan, retain it and its dependencies
|
|
172576
|
-
if (!info.isScriptOpen() && info.isOrphan() && !info.
|
|
173216
|
+
if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) {
|
|
172577
173217
|
// Otherwise if there is any source info that is alive, this alive too
|
|
172578
173218
|
if (!info.sourceMapFilePath)
|
|
172579
173219
|
return;
|
|
@@ -173543,6 +174183,7 @@ var ts;
|
|
|
173543
174183
|
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
173544
174184
|
var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
|
|
173545
174185
|
if (projectOutputs) {
|
|
174186
|
+
var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
|
|
173546
174187
|
var _loop_9 = function (referencedSymbol) {
|
|
173547
174188
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
|
|
173548
174189
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -173556,6 +174197,9 @@ var ts;
|
|
|
173556
174197
|
var ref = _b[_a];
|
|
173557
174198
|
// If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
|
|
173558
174199
|
if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
|
|
174200
|
+
if (clearIsDefinition) {
|
|
174201
|
+
delete ref.isDefinition;
|
|
174202
|
+
}
|
|
173559
174203
|
symbolToAddTo.references.push(ref);
|
|
173560
174204
|
}
|
|
173561
174205
|
}
|
|
@@ -173865,6 +174509,9 @@ var ts;
|
|
|
173865
174509
|
_a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
|
|
173866
174510
|
return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
173867
174511
|
},
|
|
174512
|
+
_a[server.CommandNames.FindSourceDefinition] = function (request) {
|
|
174513
|
+
return _this.requiredResponse(_this.findSourceDefinition(request.arguments));
|
|
174514
|
+
},
|
|
173868
174515
|
_a[server.CommandNames.EmitOutput] = function (request) {
|
|
173869
174516
|
return _this.requiredResponse(_this.getEmitOutput(request.arguments));
|
|
173870
174517
|
},
|
|
@@ -174606,7 +175253,7 @@ var ts;
|
|
|
174606
175253
|
Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
|
|
174607
175254
|
return definitions.map(function (info) {
|
|
174608
175255
|
var newDocumentSpan = getMappedDocumentSpan(info, project);
|
|
174609
|
-
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
|
|
175256
|
+
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
|
|
174610
175257
|
});
|
|
174611
175258
|
};
|
|
174612
175259
|
Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
|
|
@@ -174633,6 +175280,152 @@ var ts;
|
|
|
174633
175280
|
textSpan: textSpan,
|
|
174634
175281
|
};
|
|
174635
175282
|
};
|
|
175283
|
+
Session.prototype.findSourceDefinition = function (args) {
|
|
175284
|
+
var _a;
|
|
175285
|
+
var _b = this.getFileAndProject(args), file = _b.file, project = _b.project;
|
|
175286
|
+
var position = this.getPositionInFile(args, file);
|
|
175287
|
+
var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position);
|
|
175288
|
+
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice();
|
|
175289
|
+
var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) ||
|
|
175290
|
+
ts.some(definitions, function (d) { return !!d.failedAliasResolution; }));
|
|
175291
|
+
if (needsJsResolution) {
|
|
175292
|
+
var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual);
|
|
175293
|
+
definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); });
|
|
175294
|
+
var noDtsProject = project.getNoDtsResolutionProject([file]);
|
|
175295
|
+
var ls = noDtsProject.getLanguageService();
|
|
175296
|
+
var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; });
|
|
175297
|
+
if (ts.some(jsDefinitions)) {
|
|
175298
|
+
for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) {
|
|
175299
|
+
var jsDefinition = jsDefinitions_1[_i];
|
|
175300
|
+
if (jsDefinition.unverified) {
|
|
175301
|
+
var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
|
|
175302
|
+
if (ts.some(refined)) {
|
|
175303
|
+
for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) {
|
|
175304
|
+
var def = refined_1[_c];
|
|
175305
|
+
definitionSet_1.add(def);
|
|
175306
|
+
}
|
|
175307
|
+
continue;
|
|
175308
|
+
}
|
|
175309
|
+
}
|
|
175310
|
+
definitionSet_1.add(jsDefinition);
|
|
175311
|
+
}
|
|
175312
|
+
}
|
|
175313
|
+
else {
|
|
175314
|
+
var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; });
|
|
175315
|
+
for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) {
|
|
175316
|
+
var candidate = _e[_d];
|
|
175317
|
+
var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
|
|
175318
|
+
if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
|
|
175319
|
+
continue;
|
|
175320
|
+
}
|
|
175321
|
+
var noDtsProgram = ls.getProgram();
|
|
175322
|
+
var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
|
|
175323
|
+
for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) {
|
|
175324
|
+
var match = _g[_f];
|
|
175325
|
+
definitionSet_1.add(match);
|
|
175326
|
+
}
|
|
175327
|
+
}
|
|
175328
|
+
}
|
|
175329
|
+
definitions = ts.arrayFrom(definitionSet_1.values());
|
|
175330
|
+
}
|
|
175331
|
+
definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
|
|
175332
|
+
return this.mapDefinitionInfo(definitions, project);
|
|
175333
|
+
function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
|
|
175334
|
+
var _a;
|
|
175335
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
|
|
175336
|
+
if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
|
|
175337
|
+
// Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
|
|
175338
|
+
var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
|
175339
|
+
var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
|
|
175340
|
+
var compilerOptions = project.getCompilationSettings();
|
|
175341
|
+
var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
|
|
175342
|
+
if (!packageJson)
|
|
175343
|
+
return undefined;
|
|
175344
|
+
// Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext -
|
|
175345
|
+
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
|
175346
|
+
// resolved from the package root under --moduleResolution node
|
|
175347
|
+
var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache());
|
|
175348
|
+
// This substring is correct only because we checked for a single `/node_modules/` at the top.
|
|
175349
|
+
var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex);
|
|
175350
|
+
var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart));
|
|
175351
|
+
var path_1 = project.toPath(fileName);
|
|
175352
|
+
if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) {
|
|
175353
|
+
// This file was the main entrypoint of a package. Try to resolve that same package name with
|
|
175354
|
+
// the auxiliary project that only resolves to implementation files.
|
|
175355
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
|
|
175356
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175357
|
+
}
|
|
175358
|
+
else {
|
|
175359
|
+
// It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
|
|
175360
|
+
var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
|
|
175361
|
+
var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
|
|
175362
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
|
|
175363
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175364
|
+
}
|
|
175365
|
+
}
|
|
175366
|
+
// We're not in node_modules, and we only get to this function if non-dts module resolution failed.
|
|
175367
|
+
// I'm not sure what else I can do here that isn't already covered by that module resolution.
|
|
175368
|
+
return undefined;
|
|
175369
|
+
}
|
|
175370
|
+
// In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition
|
|
175371
|
+
// for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later.
|
|
175372
|
+
function getAmbientCandidatesByClimbingAccessChain() {
|
|
175373
|
+
var ls = project.getLanguageService();
|
|
175374
|
+
var program = ls.getProgram();
|
|
175375
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175376
|
+
if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) {
|
|
175377
|
+
return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) {
|
|
175378
|
+
var _a;
|
|
175379
|
+
if (nameInChain === initialNode)
|
|
175380
|
+
return undefined;
|
|
175381
|
+
var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({
|
|
175382
|
+
fileName: d.fileName,
|
|
175383
|
+
name: ts.getTextOfIdentifierOrLiteral(initialNode)
|
|
175384
|
+
}); });
|
|
175385
|
+
if (ts.some(candidates)) {
|
|
175386
|
+
return candidates;
|
|
175387
|
+
}
|
|
175388
|
+
}) || server.emptyArray;
|
|
175389
|
+
}
|
|
175390
|
+
return server.emptyArray;
|
|
175391
|
+
}
|
|
175392
|
+
function tryRefineDefinition(definition, program, noDtsProgram) {
|
|
175393
|
+
var _a;
|
|
175394
|
+
var fileToSearch = noDtsProgram.getSourceFile(definition.fileName);
|
|
175395
|
+
if (!fileToSearch) {
|
|
175396
|
+
return undefined;
|
|
175397
|
+
}
|
|
175398
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175399
|
+
var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
|
|
175400
|
+
var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */);
|
|
175401
|
+
if (!importSpecifier)
|
|
175402
|
+
return undefined;
|
|
175403
|
+
var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text;
|
|
175404
|
+
return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram);
|
|
175405
|
+
}
|
|
175406
|
+
function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) {
|
|
175407
|
+
var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
|
|
175408
|
+
return ts.mapDefined(matches, function (match) {
|
|
175409
|
+
var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match);
|
|
175410
|
+
var decl = ts.getDeclarationFromName(match);
|
|
175411
|
+
if (symbol && decl) {
|
|
175412
|
+
// I think the last argument to this is supposed to be the start node, but it doesn't seem important.
|
|
175413
|
+
// Callers internal to GoToDefinition already get confused about this.
|
|
175414
|
+
return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true);
|
|
175415
|
+
}
|
|
175416
|
+
});
|
|
175417
|
+
}
|
|
175418
|
+
function ensureRoot(project, fileName) {
|
|
175419
|
+
var info = project.getScriptInfo(fileName);
|
|
175420
|
+
if (!info)
|
|
175421
|
+
return false;
|
|
175422
|
+
if (!project.containsScriptInfo(info)) {
|
|
175423
|
+
project.addRoot(info);
|
|
175424
|
+
project.updateGraph();
|
|
175425
|
+
}
|
|
175426
|
+
return true;
|
|
175427
|
+
}
|
|
175428
|
+
};
|
|
174636
175429
|
Session.prototype.getEmitOutput = function (args) {
|
|
174637
175430
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
174638
175431
|
if (!project.shouldEmitFile(project.getScriptInfo(file))) {
|
|
@@ -175196,7 +175989,7 @@ var ts;
|
|
|
175196
175989
|
return undefined;
|
|
175197
175990
|
}
|
|
175198
175991
|
var compilationSettings = project.getCompilationSettings();
|
|
175199
|
-
if (!!compilationSettings.noEmit || ts.
|
|
175992
|
+
if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) {
|
|
175200
175993
|
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
|
|
175201
175994
|
return undefined;
|
|
175202
175995
|
}
|
|
@@ -175676,7 +176469,7 @@ var ts;
|
|
|
175676
176469
|
else {
|
|
175677
176470
|
var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217
|
|
175678
176471
|
if (!info.isScriptOpen()) {
|
|
175679
|
-
if (ts.
|
|
176472
|
+
if (ts.isDeclarationFileName(fileNameInProject)) {
|
|
175680
176473
|
veryLowPriorityFiles.push(fileNameInProject);
|
|
175681
176474
|
}
|
|
175682
176475
|
else {
|