@typescript-deploys/pr-build 4.7.0-pr-48581-7 → 4.7.0-pr-48788-2
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/pl/diagnosticMessages.generated.json +2 -0
- package/lib/protocol.d.ts +4 -0
- 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 +297 -240
- package/lib/tsserver.js +782 -382
- package/lib/tsserverlibrary.d.ts +7 -2
- package/lib/tsserverlibrary.js +782 -382
- package/lib/typescript.d.ts +0 -1
- package/lib/typescript.js +541 -362
- package/lib/typescriptServices.d.ts +0 -1
- package/lib/typescriptServices.js +541 -362
- package/lib/typingsInstaller.js +364 -279
- 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-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220420";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4660,7 +4660,6 @@ var ts;
|
|
|
4660
4660
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4661
4661
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4662
4662
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4663
|
-
NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
|
|
4664
4663
|
// Error handling
|
|
4665
4664
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4666
4665
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -8717,6 +8716,7 @@ var ts;
|
|
|
8717
8716
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8718
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."),
|
|
8719
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."),
|
|
8720
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."),
|
|
8721
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."),
|
|
8722
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."),
|
|
@@ -14965,6 +14965,10 @@ var ts;
|
|
|
14965
14965
|
}
|
|
14966
14966
|
}
|
|
14967
14967
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
14968
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
14969
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
14970
|
+
}
|
|
14971
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
14968
14972
|
function isLateVisibilityPaintedStatement(node) {
|
|
14969
14973
|
switch (node.kind) {
|
|
14970
14974
|
case 266 /* ImportDeclaration */:
|
|
@@ -16325,17 +16329,13 @@ var ts;
|
|
|
16325
16329
|
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
|
16326
16330
|
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
|
|
16327
16331
|
}
|
|
16328
|
-
if (ts.
|
|
16332
|
+
if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
|
|
16329
16333
|
(initializer.expression.kind === 108 /* ThisKeyword */ ||
|
|
16330
16334
|
ts.isIdentifier(initializer.expression) &&
|
|
16331
16335
|
(initializer.expression.escapedText === "window" ||
|
|
16332
16336
|
initializer.expression.escapedText === "self" ||
|
|
16333
16337
|
initializer.expression.escapedText === "global"))) {
|
|
16334
|
-
|
|
16335
|
-
if (ts.isPrivateIdentifier(nameOrArgument)) {
|
|
16336
|
-
ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
|
16337
|
-
}
|
|
16338
|
-
return isSameEntityName(name, nameOrArgument);
|
|
16338
|
+
return isSameEntityName(name, getNameOrArgument(initializer));
|
|
16339
16339
|
}
|
|
16340
16340
|
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
|
16341
16341
|
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
|
@@ -16543,14 +16543,14 @@ var ts;
|
|
|
16543
16543
|
}
|
|
16544
16544
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16545
16545
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16546
|
-
var _a, _b
|
|
16546
|
+
var _a, _b;
|
|
16547
16547
|
switch (node.kind) {
|
|
16548
16548
|
case 254 /* VariableDeclaration */:
|
|
16549
|
-
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];
|
|
16550
16550
|
case 266 /* ImportDeclaration */:
|
|
16551
|
-
return
|
|
16551
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16552
16552
|
case 265 /* ImportEqualsDeclaration */:
|
|
16553
|
-
return
|
|
16553
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16554
16554
|
default:
|
|
16555
16555
|
ts.Debug.assertNever(node);
|
|
16556
16556
|
}
|
|
@@ -17065,7 +17065,10 @@ var ts;
|
|
|
17065
17065
|
return parent.propertyName === node;
|
|
17066
17066
|
case 275 /* ExportSpecifier */:
|
|
17067
17067
|
case 285 /* JsxAttribute */:
|
|
17068
|
-
|
|
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
|
|
17069
17072
|
return true;
|
|
17070
17073
|
}
|
|
17071
17074
|
return false;
|
|
@@ -17081,21 +17084,28 @@ var ts;
|
|
|
17081
17084
|
// export = <EntityNameExpression>
|
|
17082
17085
|
// export default <EntityNameExpression>
|
|
17083
17086
|
// module.exports = <EntityNameExpression>
|
|
17084
|
-
//
|
|
17085
|
-
//
|
|
17087
|
+
// module.exports.x = <EntityNameExpression>
|
|
17088
|
+
// const x = require("...")
|
|
17089
|
+
// const { x } = require("...")
|
|
17090
|
+
// const x = require("...").y
|
|
17091
|
+
// const { x } = require("...").y
|
|
17086
17092
|
function isAliasSymbolDeclaration(node) {
|
|
17087
|
-
|
|
17093
|
+
if (node.kind === 265 /* ImportEqualsDeclaration */ ||
|
|
17088
17094
|
node.kind === 264 /* NamespaceExportDeclaration */ ||
|
|
17089
17095
|
node.kind === 267 /* ImportClause */ && !!node.name ||
|
|
17090
17096
|
node.kind === 268 /* NamespaceImport */ ||
|
|
17091
17097
|
node.kind === 274 /* NamespaceExport */ ||
|
|
17092
17098
|
node.kind === 270 /* ImportSpecifier */ ||
|
|
17093
17099
|
node.kind === 275 /* ExportSpecifier */ ||
|
|
17094
|
-
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
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));
|
|
17099
17109
|
}
|
|
17100
17110
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17101
17111
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17106,6 +17116,7 @@ var ts;
|
|
|
17106
17116
|
case 275 /* ExportSpecifier */:
|
|
17107
17117
|
case 271 /* ExportAssignment */:
|
|
17108
17118
|
case 265 /* ImportEqualsDeclaration */:
|
|
17119
|
+
case 274 /* NamespaceExport */:
|
|
17109
17120
|
return node.parent;
|
|
17110
17121
|
case 161 /* QualifiedName */:
|
|
17111
17122
|
do {
|
|
@@ -18932,6 +18943,11 @@ var ts;
|
|
|
18932
18943
|
(node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
18933
18944
|
}
|
|
18934
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;
|
|
18935
18951
|
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
|
18936
18952
|
return ts.isQualifiedName(node.parent) && node.parent.right === node
|
|
18937
18953
|
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
@@ -19583,6 +19599,41 @@ var ts;
|
|
|
19583
19599
|
return expr;
|
|
19584
19600
|
}
|
|
19585
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;
|
|
19586
19637
|
function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
19587
19638
|
while (true) {
|
|
19588
19639
|
switch (node.kind) {
|
|
@@ -20530,6 +20581,7 @@ var ts;
|
|
|
20530
20581
|
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20531
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 */]];
|
|
20532
20583
|
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20584
|
+
ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
|
|
20533
20585
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20534
20586
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20535
20587
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
@@ -21218,6 +21270,11 @@ var ts;
|
|
|
21218
21270
|
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21219
21271
|
}
|
|
21220
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;
|
|
21221
21278
|
})(ts || (ts = {}));
|
|
21222
21279
|
/* @internal */
|
|
21223
21280
|
var ts;
|
|
@@ -33129,7 +33186,8 @@ var ts;
|
|
|
33129
33186
|
var pos = getNodePos();
|
|
33130
33187
|
parseExpected(112 /* TypeOfKeyword */);
|
|
33131
33188
|
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
|
33132
|
-
|
|
33189
|
+
// Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression.
|
|
33190
|
+
var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
|
|
33133
33191
|
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
33134
33192
|
}
|
|
33135
33193
|
function parseTypeParameter() {
|
|
@@ -34448,23 +34506,7 @@ var ts;
|
|
|
34448
34506
|
return undefined;
|
|
34449
34507
|
}
|
|
34450
34508
|
}
|
|
34451
|
-
|
|
34452
|
-
// x ? y => ({ y }) : z => ({ z })
|
|
34453
|
-
// We try to parse the body of the first arrow function by looking at:
|
|
34454
|
-
// ({ y }) : z => ({ z })
|
|
34455
|
-
// This is a valid arrow function with "z" as the return type.
|
|
34456
|
-
//
|
|
34457
|
-
// But, if we're in the true side of a conditional expression, this colon
|
|
34458
|
-
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34459
|
-
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34460
|
-
//
|
|
34461
|
-
// For example,
|
|
34462
|
-
// a() ? (b: number, c?: string): void => d() : e
|
|
34463
|
-
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34464
|
-
// be an arrow expression, so we allow a return type.
|
|
34465
|
-
if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) {
|
|
34466
|
-
return undefined;
|
|
34467
|
-
}
|
|
34509
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
34468
34510
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
34469
34511
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
34470
34512
|
return undefined;
|
|
@@ -34495,6 +34537,30 @@ var ts;
|
|
|
34495
34537
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
34496
34538
|
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction)
|
|
34497
34539
|
: parseIdentifier();
|
|
34540
|
+
// Given:
|
|
34541
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
34542
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
34543
|
+
// ({ y }) : z => ({ z })
|
|
34544
|
+
// This is a valid arrow function with "z" as the return type.
|
|
34545
|
+
//
|
|
34546
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
34547
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34548
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34549
|
+
//
|
|
34550
|
+
// For example,
|
|
34551
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
34552
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34553
|
+
// be an arrow expression, so we allow a return type.
|
|
34554
|
+
if (disallowReturnTypeInArrowFunction && hasReturnColon) {
|
|
34555
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
34556
|
+
// as in:
|
|
34557
|
+
// a ? (x): string => x : null
|
|
34558
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
34559
|
+
// the conditional expression.
|
|
34560
|
+
if (token() !== 58 /* ColonToken */) {
|
|
34561
|
+
return undefined;
|
|
34562
|
+
}
|
|
34563
|
+
}
|
|
34498
34564
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
34499
34565
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
34500
34566
|
}
|
|
@@ -35371,34 +35437,10 @@ var ts;
|
|
|
35371
35437
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
35372
35438
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
35373
35439
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
35374
|
-
// These tokens can't follow in a call expression, nor can they start an
|
|
35375
|
-
// expression. So, consider the type argument list part of an instantiation
|
|
35376
|
-
// expression.
|
|
35377
|
-
// falls through
|
|
35378
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
35379
|
-
case 24 /* DotToken */: // foo<x>.
|
|
35380
|
-
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
35381
|
-
case 21 /* CloseParenToken */: // foo<x>)
|
|
35382
|
-
case 23 /* CloseBracketToken */: // foo<x>]
|
|
35383
|
-
case 58 /* ColonToken */: // foo<x>:
|
|
35384
|
-
case 26 /* SemicolonToken */: // foo<x>;
|
|
35385
|
-
case 57 /* QuestionToken */: // foo<x>?
|
|
35386
|
-
case 34 /* EqualsEqualsToken */: // foo<x> ==
|
|
35387
|
-
case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
35388
|
-
case 35 /* ExclamationEqualsToken */: // foo<x> !=
|
|
35389
|
-
case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
35390
|
-
case 55 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
35391
|
-
case 56 /* BarBarToken */: // foo<x> ||
|
|
35392
|
-
case 60 /* QuestionQuestionToken */: // foo<x> ??
|
|
35393
|
-
case 52 /* CaretToken */: // foo<x> ^
|
|
35394
|
-
case 50 /* AmpersandToken */: // foo<x> &
|
|
35395
|
-
case 51 /* BarToken */: // foo<x> |
|
|
35396
|
-
case 19 /* CloseBraceToken */: // foo<x> }
|
|
35397
|
-
case 1 /* EndOfFileToken */: // foo<x>
|
|
35398
35440
|
return true;
|
|
35399
35441
|
}
|
|
35400
|
-
//
|
|
35401
|
-
return
|
|
35442
|
+
// Consider something a type argument list only if the following token can't start an expression.
|
|
35443
|
+
return !isStartOfExpression();
|
|
35402
35444
|
}
|
|
35403
35445
|
function parsePrimaryExpression() {
|
|
35404
35446
|
switch (token()) {
|
|
@@ -38616,7 +38658,7 @@ var ts;
|
|
|
38616
38658
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
38617
38659
|
/** @internal */
|
|
38618
38660
|
function isDeclarationFileName(fileName) {
|
|
38619
|
-
return ts.fileExtensionIsOneOf(fileName,
|
|
38661
|
+
return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
|
|
38620
38662
|
}
|
|
38621
38663
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38622
38664
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
@@ -42124,7 +42166,8 @@ var ts;
|
|
|
42124
42166
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42125
42167
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42126
42168
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42127
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42169
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42170
|
+
Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
|
|
42128
42171
|
})(Extensions || (Extensions = {}));
|
|
42129
42172
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42130
42173
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -43069,7 +43112,21 @@ var ts;
|
|
|
43069
43112
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43070
43113
|
}
|
|
43071
43114
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
43072
|
-
|
|
43115
|
+
var extensions;
|
|
43116
|
+
if (lookupConfig) {
|
|
43117
|
+
extensions = tsconfigExtensions;
|
|
43118
|
+
}
|
|
43119
|
+
else if (compilerOptions.noDtsResolution) {
|
|
43120
|
+
extensions = [Extensions.TsOnly];
|
|
43121
|
+
if (compilerOptions.allowJs)
|
|
43122
|
+
extensions.push(Extensions.JavaScript);
|
|
43123
|
+
if (compilerOptions.resolveJsonModule)
|
|
43124
|
+
extensions.push(Extensions.Json);
|
|
43125
|
+
}
|
|
43126
|
+
else {
|
|
43127
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
43128
|
+
}
|
|
43129
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
43073
43130
|
}
|
|
43074
43131
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
43075
43132
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -43078,6 +43135,10 @@ var ts;
|
|
|
43078
43135
|
var failedLookupLocations = [];
|
|
43079
43136
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
43080
43137
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43138
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43139
|
+
if (compilerOptions.noDtsResolution) {
|
|
43140
|
+
conditions.pop();
|
|
43141
|
+
}
|
|
43081
43142
|
var state = {
|
|
43082
43143
|
compilerOptions: compilerOptions,
|
|
43083
43144
|
host: host,
|
|
@@ -43085,7 +43146,7 @@ var ts;
|
|
|
43085
43146
|
failedLookupLocations: failedLookupLocations,
|
|
43086
43147
|
packageJsonInfoCache: cache,
|
|
43087
43148
|
features: features,
|
|
43088
|
-
conditions:
|
|
43149
|
+
conditions: conditions,
|
|
43089
43150
|
};
|
|
43090
43151
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43091
43152
|
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);
|
|
@@ -43261,9 +43322,9 @@ var ts;
|
|
|
43261
43322
|
}
|
|
43262
43323
|
}
|
|
43263
43324
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43264
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43325
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
|
|
43265
43326
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43266
|
-
return result !== undefined ? { path: candidate, ext: ts.forEach(
|
|
43327
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
43267
43328
|
}
|
|
43268
43329
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43269
43330
|
}
|
|
@@ -43293,20 +43354,22 @@ var ts;
|
|
|
43293
43354
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43294
43355
|
}
|
|
43295
43356
|
case Extensions.TypeScript:
|
|
43357
|
+
case Extensions.TsOnly:
|
|
43358
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43296
43359
|
switch (originalExtension) {
|
|
43297
43360
|
case ".mjs" /* Mjs */:
|
|
43298
43361
|
case ".mts" /* Mts */:
|
|
43299
43362
|
case ".d.mts" /* Dmts */:
|
|
43300
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43363
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43301
43364
|
case ".cjs" /* Cjs */:
|
|
43302
43365
|
case ".cts" /* Cts */:
|
|
43303
43366
|
case ".d.cts" /* Dcts */:
|
|
43304
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43367
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43305
43368
|
case ".json" /* Json */:
|
|
43306
43369
|
candidate += ".json" /* Json */;
|
|
43307
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43370
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43308
43371
|
default:
|
|
43309
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43372
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43310
43373
|
}
|
|
43311
43374
|
case Extensions.JavaScript:
|
|
43312
43375
|
switch (originalExtension) {
|
|
@@ -43533,6 +43596,7 @@ var ts;
|
|
|
43533
43596
|
switch (extensions) {
|
|
43534
43597
|
case Extensions.JavaScript:
|
|
43535
43598
|
case Extensions.Json:
|
|
43599
|
+
case Extensions.TsOnly:
|
|
43536
43600
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43537
43601
|
break;
|
|
43538
43602
|
case Extensions.TypeScript:
|
|
@@ -43605,14 +43669,16 @@ var ts;
|
|
|
43605
43669
|
function extensionIsOk(extensions, extension) {
|
|
43606
43670
|
switch (extensions) {
|
|
43607
43671
|
case Extensions.JavaScript:
|
|
43608
|
-
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
43672
|
+
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
|
|
43609
43673
|
case Extensions.TSConfig:
|
|
43610
43674
|
case Extensions.Json:
|
|
43611
43675
|
return extension === ".json" /* Json */;
|
|
43612
43676
|
case Extensions.TypeScript:
|
|
43613
|
-
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43677
|
+
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 */;
|
|
43678
|
+
case Extensions.TsOnly:
|
|
43679
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
|
|
43614
43680
|
case Extensions.DtsOnly:
|
|
43615
|
-
return extension === ".d.ts" /* Dts */;
|
|
43681
|
+
return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43616
43682
|
}
|
|
43617
43683
|
}
|
|
43618
43684
|
/* @internal */
|
|
@@ -45772,6 +45838,7 @@ var ts;
|
|
|
45772
45838
|
case 261 /* ModuleDeclaration */:
|
|
45773
45839
|
case 259 /* TypeAliasDeclaration */:
|
|
45774
45840
|
case 195 /* MappedType */:
|
|
45841
|
+
case 176 /* IndexSignature */:
|
|
45775
45842
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45776
45843
|
case 305 /* SourceFile */:
|
|
45777
45844
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45790,7 +45857,6 @@ var ts;
|
|
|
45790
45857
|
case 317 /* JSDocFunctionType */:
|
|
45791
45858
|
case 179 /* FunctionType */:
|
|
45792
45859
|
case 175 /* ConstructSignature */:
|
|
45793
|
-
case 176 /* IndexSignature */:
|
|
45794
45860
|
case 180 /* ConstructorType */:
|
|
45795
45861
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45796
45862
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -50368,27 +50434,27 @@ var ts;
|
|
|
50368
50434
|
function resolveAlias(symbol) {
|
|
50369
50435
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50370
50436
|
var links = getSymbolLinks(symbol);
|
|
50371
|
-
if (!links.
|
|
50372
|
-
links.
|
|
50437
|
+
if (!links.aliasTarget) {
|
|
50438
|
+
links.aliasTarget = resolvingSymbol;
|
|
50373
50439
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50374
50440
|
if (!node)
|
|
50375
50441
|
return ts.Debug.fail();
|
|
50376
50442
|
var target = getTargetOfAliasDeclaration(node);
|
|
50377
|
-
if (links.
|
|
50378
|
-
links.
|
|
50443
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50444
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50379
50445
|
}
|
|
50380
50446
|
else {
|
|
50381
50447
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50382
50448
|
}
|
|
50383
50449
|
}
|
|
50384
|
-
else if (links.
|
|
50385
|
-
links.
|
|
50450
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50451
|
+
links.aliasTarget = unknownSymbol;
|
|
50386
50452
|
}
|
|
50387
|
-
return links.
|
|
50453
|
+
return links.aliasTarget;
|
|
50388
50454
|
}
|
|
50389
50455
|
function tryResolveAlias(symbol) {
|
|
50390
50456
|
var links = getSymbolLinks(symbol);
|
|
50391
|
-
if (links.
|
|
50457
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50392
50458
|
return resolveAlias(symbol);
|
|
50393
50459
|
}
|
|
50394
50460
|
return undefined;
|
|
@@ -52185,13 +52251,37 @@ var ts;
|
|
|
52185
52251
|
return ts.Debug.fail("Should be unreachable.");
|
|
52186
52252
|
function conditionalTypeToTypeNode(type) {
|
|
52187
52253
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52254
|
+
context.approximateLength += 15;
|
|
52255
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52256
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52257
|
+
var name = typeParameterToName(newParam, context);
|
|
52258
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52259
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52260
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52261
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52262
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52263
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52264
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52265
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52266
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52267
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52268
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52269
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52270
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52271
|
+
// this is potentially simplifiable to
|
|
52272
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52273
|
+
// but that may confuse users who read the output more.
|
|
52274
|
+
// On the other hand,
|
|
52275
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52276
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52277
|
+
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 */));
|
|
52278
|
+
}
|
|
52188
52279
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
52189
52280
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52190
52281
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
52191
52282
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
52192
52283
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
52193
52284
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
52194
|
-
context.approximateLength += 15;
|
|
52195
52285
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
52196
52286
|
}
|
|
52197
52287
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -52305,7 +52395,7 @@ var ts;
|
|
|
52305
52395
|
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
|
|
52306
52396
|
// of types allows us to catch circular references to instantiations of the same anonymous type
|
|
52307
52397
|
if (!context.visitedTypes) {
|
|
52308
|
-
context.visitedTypes = new ts.
|
|
52398
|
+
context.visitedTypes = new ts.Set();
|
|
52309
52399
|
}
|
|
52310
52400
|
if (id && !context.symbolDepth) {
|
|
52311
52401
|
context.symbolDepth = new ts.Map();
|
|
@@ -52323,22 +52413,15 @@ var ts;
|
|
|
52323
52413
|
context.approximateLength += cachedResult.addedLength;
|
|
52324
52414
|
return deepCloneOrReuseNode(cachedResult);
|
|
52325
52415
|
}
|
|
52326
|
-
var
|
|
52327
|
-
var symbolDepth = id ? context.symbolDepth.get(id) : undefined;
|
|
52328
|
-
if (symbolDepth) {
|
|
52329
|
-
totalDepth += symbolDepth;
|
|
52330
|
-
}
|
|
52331
|
-
var visitedTypeDepth = context.visitedTypes.get(typeId);
|
|
52332
|
-
if (visitedTypeDepth) {
|
|
52333
|
-
totalDepth += visitedTypeDepth;
|
|
52334
|
-
}
|
|
52335
|
-
if (totalDepth > 10) {
|
|
52336
|
-
return createElidedInformationPlaceholder(context);
|
|
52337
|
-
}
|
|
52416
|
+
var depth;
|
|
52338
52417
|
if (id) {
|
|
52339
|
-
context.symbolDepth.
|
|
52418
|
+
depth = context.symbolDepth.get(id) || 0;
|
|
52419
|
+
if (depth > 10) {
|
|
52420
|
+
return createElidedInformationPlaceholder(context);
|
|
52421
|
+
}
|
|
52422
|
+
context.symbolDepth.set(id, depth + 1);
|
|
52340
52423
|
}
|
|
52341
|
-
context.visitedTypes.
|
|
52424
|
+
context.visitedTypes.add(typeId);
|
|
52342
52425
|
var startLength = context.approximateLength;
|
|
52343
52426
|
var result = transform(type);
|
|
52344
52427
|
var addedLength = context.approximateLength - startLength;
|
|
@@ -52349,19 +52432,9 @@ var ts;
|
|
|
52349
52432
|
result.addedLength = addedLength;
|
|
52350
52433
|
(_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result);
|
|
52351
52434
|
}
|
|
52352
|
-
|
|
52353
|
-
context.visitedTypes.set(typeId, visitedTypeDepth);
|
|
52354
|
-
}
|
|
52355
|
-
else {
|
|
52356
|
-
context.visitedTypes.delete(typeId);
|
|
52357
|
-
}
|
|
52435
|
+
context.visitedTypes.delete(typeId);
|
|
52358
52436
|
if (id) {
|
|
52359
|
-
|
|
52360
|
-
context.symbolDepth.set(id, symbolDepth);
|
|
52361
|
-
}
|
|
52362
|
-
else {
|
|
52363
|
-
context.symbolDepth.delete(id);
|
|
52364
|
-
}
|
|
52437
|
+
context.symbolDepth.set(id, depth);
|
|
52365
52438
|
}
|
|
52366
52439
|
return result;
|
|
52367
52440
|
function deepCloneOrReuseNode(node) {
|
|
@@ -52907,9 +52980,6 @@ var ts;
|
|
|
52907
52980
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
52908
52981
|
parameterType = getOptionalType(parameterType);
|
|
52909
52982
|
}
|
|
52910
|
-
if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
|
52911
|
-
parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
|
|
52912
|
-
}
|
|
52913
52983
|
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
52914
52984
|
var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
|
|
52915
52985
|
var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
@@ -53468,7 +53538,7 @@ var ts;
|
|
|
53468
53538
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
53469
53539
|
// try to reuse the existing annotation
|
|
53470
53540
|
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
53471
|
-
if (
|
|
53541
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
53472
53542
|
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
53473
53543
|
if (result_6) {
|
|
53474
53544
|
return result_6;
|
|
@@ -53485,6 +53555,16 @@ var ts;
|
|
|
53485
53555
|
context.flags = oldFlags;
|
|
53486
53556
|
return result;
|
|
53487
53557
|
}
|
|
53558
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
53559
|
+
var typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
53560
|
+
if (typeFromTypeNode === type) {
|
|
53561
|
+
return true;
|
|
53562
|
+
}
|
|
53563
|
+
if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
53564
|
+
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
53565
|
+
}
|
|
53566
|
+
return false;
|
|
53567
|
+
}
|
|
53488
53568
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
53489
53569
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
53490
53570
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
@@ -55756,7 +55836,7 @@ var ts;
|
|
|
55756
55836
|
}
|
|
55757
55837
|
}
|
|
55758
55838
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55759
|
-
type = getUnionType(sourceTypes
|
|
55839
|
+
type = getUnionType(sourceTypes);
|
|
55760
55840
|
}
|
|
55761
55841
|
}
|
|
55762
55842
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -58505,8 +58585,9 @@ var ts;
|
|
|
58505
58585
|
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
|
|
58506
58586
|
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
|
|
58507
58587
|
// nesting, so it is effectively just a safety stop.
|
|
58508
|
-
|
|
58509
|
-
|
|
58588
|
+
var identity_1 = getRecursionIdentity(t);
|
|
58589
|
+
if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
|
|
58590
|
+
stack.push(identity_1);
|
|
58510
58591
|
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
|
58511
58592
|
stack.pop();
|
|
58512
58593
|
}
|
|
@@ -61862,11 +61943,14 @@ var ts;
|
|
|
61862
61943
|
return type[cache] = elementType;
|
|
61863
61944
|
}
|
|
61864
61945
|
}
|
|
61865
|
-
// If the object type is a mapped type { [P in K]: E }, where K is generic,
|
|
61866
|
-
//
|
|
61867
|
-
// construct the type Box<T[X]>.
|
|
61868
|
-
if (isGenericMappedType(objectType)
|
|
61869
|
-
|
|
61946
|
+
// If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where
|
|
61947
|
+
// K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P.
|
|
61948
|
+
// For example, for an index access { [P in K]: Box<T[P]> }[X], we construct the type Box<T[X]>.
|
|
61949
|
+
if (isGenericMappedType(objectType)) {
|
|
61950
|
+
var nameType = getNameTypeFromMappedType(objectType);
|
|
61951
|
+
if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
|
|
61952
|
+
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
|
|
61953
|
+
}
|
|
61870
61954
|
}
|
|
61871
61955
|
return type[cache] = type;
|
|
61872
61956
|
}
|
|
@@ -66704,12 +66788,12 @@ var ts;
|
|
|
66704
66788
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
66705
66789
|
if (maxDepth === void 0) { maxDepth = 3; }
|
|
66706
66790
|
if (depth >= maxDepth) {
|
|
66707
|
-
var
|
|
66791
|
+
var identity_2 = getRecursionIdentity(type);
|
|
66708
66792
|
var count = 0;
|
|
66709
66793
|
var lastTypeId = 0;
|
|
66710
66794
|
for (var i = 0; i < depth; i++) {
|
|
66711
66795
|
var t = stack[i];
|
|
66712
|
-
if (getRecursionIdentity(t) ===
|
|
66796
|
+
if (getRecursionIdentity(t) === identity_2) {
|
|
66713
66797
|
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
66714
66798
|
// type ids are an indicator of newer instantiations caused by recursion.
|
|
66715
66799
|
if (t.id >= lastTypeId) {
|
|
@@ -74186,10 +74270,15 @@ var ts;
|
|
|
74186
74270
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
74187
74271
|
}
|
|
74188
74272
|
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
|
|
74273
|
+
// `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
|
|
74274
|
+
// here even if `Foo` is not a const enum.
|
|
74275
|
+
//
|
|
74189
74276
|
// The exceptions are:
|
|
74190
74277
|
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
|
|
74191
74278
|
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
|
|
74192
|
-
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74279
|
+
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74280
|
+
!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) ||
|
|
74281
|
+
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
|
|
74193
74282
|
markAliasReferenced(parentSymbol, node);
|
|
74194
74283
|
}
|
|
74195
74284
|
var propType;
|
|
@@ -76711,7 +76800,7 @@ var ts;
|
|
|
76711
76800
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76712
76801
|
newSymbol.parent = originalSymbol;
|
|
76713
76802
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76714
|
-
newSymbol.
|
|
76803
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76715
76804
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76716
76805
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76717
76806
|
}
|
|
@@ -79523,19 +79612,28 @@ var ts;
|
|
|
79523
79612
|
if (constraintType && defaultType) {
|
|
79524
79613
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79525
79614
|
}
|
|
79526
|
-
|
|
79615
|
+
checkNodeDeferred(node);
|
|
79616
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79617
|
+
}
|
|
79618
|
+
function checkTypeParameterDeferred(node) {
|
|
79619
|
+
if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
|
|
79620
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
|
79527
79621
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79528
|
-
if (modifiers
|
|
79622
|
+
if (modifiers) {
|
|
79529
79623
|
var symbol = getSymbolOfNode(node.parent);
|
|
79530
|
-
|
|
79531
|
-
|
|
79532
|
-
|
|
79533
|
-
|
|
79534
|
-
|
|
79535
|
-
|
|
79624
|
+
if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79625
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79626
|
+
}
|
|
79627
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79628
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79629
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79630
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79631
|
+
varianceTypeParameter = typeParameter;
|
|
79632
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79633
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79634
|
+
}
|
|
79536
79635
|
}
|
|
79537
79636
|
}
|
|
79538
|
-
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79539
79637
|
}
|
|
79540
79638
|
function checkParameter(node) {
|
|
79541
79639
|
// Grammar checking
|
|
@@ -80025,7 +80123,7 @@ var ts;
|
|
|
80025
80123
|
superCallStatement = statement;
|
|
80026
80124
|
break;
|
|
80027
80125
|
}
|
|
80028
|
-
if (
|
|
80126
|
+
if (nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
80029
80127
|
break;
|
|
80030
80128
|
}
|
|
80031
80129
|
}
|
|
@@ -85378,6 +85476,9 @@ var ts;
|
|
|
85378
85476
|
case 226 /* ClassExpression */:
|
|
85379
85477
|
checkClassExpressionDeferred(node);
|
|
85380
85478
|
break;
|
|
85479
|
+
case 163 /* TypeParameter */:
|
|
85480
|
+
checkTypeParameterDeferred(node);
|
|
85481
|
+
break;
|
|
85381
85482
|
case 279 /* JsxSelfClosingElement */:
|
|
85382
85483
|
checkJsxSelfClosingElementDeferred(node);
|
|
85383
85484
|
break;
|
|
@@ -85912,15 +86013,20 @@ var ts;
|
|
|
85912
86013
|
return propertyDeclaration;
|
|
85913
86014
|
}
|
|
85914
86015
|
}
|
|
85915
|
-
else if (ts.isMetaProperty(parent)) {
|
|
85916
|
-
|
|
85917
|
-
|
|
85918
|
-
if (propertyDeclaration) {
|
|
85919
|
-
return propertyDeclaration;
|
|
85920
|
-
}
|
|
85921
|
-
if (parent.keywordToken === 103 /* NewKeyword */) {
|
|
86016
|
+
else if (ts.isMetaProperty(parent) && parent.name === node) {
|
|
86017
|
+
if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") {
|
|
86018
|
+
// `target` in `new.target`
|
|
85922
86019
|
return checkNewTargetMetaProperty(parent).symbol;
|
|
85923
86020
|
}
|
|
86021
|
+
// The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
|
|
86022
|
+
// we have a fake expression type made for other reasons already, whose transient `meta`
|
|
86023
|
+
// member should more exactly be the kind of (declarationless) symbol we want.
|
|
86024
|
+
// (See #44364 and #45031 for relevant implementation PRs)
|
|
86025
|
+
if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") {
|
|
86026
|
+
return getGlobalImportMetaExpressionType().members.get("meta");
|
|
86027
|
+
}
|
|
86028
|
+
// no other meta properties are valid syntax, thus no others should have symbols
|
|
86029
|
+
return undefined;
|
|
85924
86030
|
}
|
|
85925
86031
|
}
|
|
85926
86032
|
switch (node.kind) {
|
|
@@ -86192,11 +86298,11 @@ var ts;
|
|
|
86192
86298
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
86193
86299
|
return leftSpread ? [leftSpread, rightSpread]
|
|
86194
86300
|
: syntheticOrigin ? [syntheticOrigin]
|
|
86195
|
-
: ts.singleElementArray(
|
|
86301
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
86196
86302
|
}
|
|
86197
86303
|
return undefined;
|
|
86198
86304
|
}
|
|
86199
|
-
function
|
|
86305
|
+
function tryGetTarget(symbol) {
|
|
86200
86306
|
var target;
|
|
86201
86307
|
var next = symbol;
|
|
86202
86308
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86426,7 +86532,7 @@ var ts;
|
|
|
86426
86532
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86427
86533
|
return true;
|
|
86428
86534
|
}
|
|
86429
|
-
var target = getSymbolLinks(symbol).
|
|
86535
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86430
86536
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86431
86537
|
target.flags & 111551 /* Value */ &&
|
|
86432
86538
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -86474,11 +86580,6 @@ var ts;
|
|
|
86474
86580
|
!parameter.initializer &&
|
|
86475
86581
|
ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
|
|
86476
86582
|
}
|
|
86477
|
-
function isOptionalUninitializedParameter(parameter) {
|
|
86478
|
-
return !!strictNullChecks &&
|
|
86479
|
-
isOptionalParameter(parameter) &&
|
|
86480
|
-
!parameter.initializer;
|
|
86481
|
-
}
|
|
86482
86583
|
function isExpandoFunctionDeclaration(node) {
|
|
86483
86584
|
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
|
|
86484
86585
|
if (!declaration) {
|
|
@@ -87395,8 +87496,7 @@ var ts;
|
|
|
87395
87496
|
case 144 /* OutKeyword */:
|
|
87396
87497
|
var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
|
|
87397
87498
|
var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
|
|
87398
|
-
if (node.kind !== 163 /* TypeParameter */ || (node.parent
|
|
87399
|
-
node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
|
|
87499
|
+
if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
|
|
87400
87500
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
|
87401
87501
|
}
|
|
87402
87502
|
if (flags & inOutFlag) {
|
|
@@ -92630,11 +92730,11 @@ var ts;
|
|
|
92630
92730
|
}
|
|
92631
92731
|
var statements = [];
|
|
92632
92732
|
resumeLexicalEnvironment();
|
|
92633
|
-
var
|
|
92634
|
-
var superStatementIndex = ts.findSuperStatementIndex(body.statements,
|
|
92733
|
+
var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92734
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
|
|
92635
92735
|
// If there was a super call, visit existing statements up to and including it
|
|
92636
92736
|
if (superStatementIndex >= 0) {
|
|
92637
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement,
|
|
92737
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
|
|
92638
92738
|
}
|
|
92639
92739
|
// Transform parameters into property assignments. Transforms this:
|
|
92640
92740
|
//
|
|
@@ -92653,12 +92753,12 @@ var ts;
|
|
|
92653
92753
|
if (superStatementIndex >= 0) {
|
|
92654
92754
|
ts.addRange(statements, parameterPropertyAssignments);
|
|
92655
92755
|
}
|
|
92656
|
-
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
92756
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
|
|
92657
92757
|
else {
|
|
92658
|
-
statements =
|
|
92758
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
92659
92759
|
}
|
|
92660
|
-
// Add remaining statements from the body, skipping the super() call if it was found
|
|
92661
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
92760
|
+
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
92761
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
|
|
92662
92762
|
// End the lexical environment.
|
|
92663
92763
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92664
92764
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -94604,7 +94704,7 @@ var ts;
|
|
|
94604
94704
|
}
|
|
94605
94705
|
resumeLexicalEnvironment();
|
|
94606
94706
|
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
94607
|
-
var
|
|
94707
|
+
var indexOfFirstStatementAfterSuperAndPrologue = 0;
|
|
94608
94708
|
var prologueStatementCount = 0;
|
|
94609
94709
|
var superStatementIndex = -1;
|
|
94610
94710
|
var statements = [];
|
|
@@ -94613,8 +94713,11 @@ var ts;
|
|
|
94613
94713
|
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
94614
94714
|
// If there was a super call, visit existing statements up to and including it
|
|
94615
94715
|
if (superStatementIndex >= 0) {
|
|
94616
|
-
|
|
94617
|
-
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount,
|
|
94716
|
+
indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
|
|
94717
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
|
|
94718
|
+
}
|
|
94719
|
+
else if (prologueStatementCount >= 0) {
|
|
94720
|
+
indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
|
|
94618
94721
|
}
|
|
94619
94722
|
}
|
|
94620
94723
|
if (needsSyntheticConstructor) {
|
|
@@ -94650,22 +94753,20 @@ var ts;
|
|
|
94650
94753
|
}
|
|
94651
94754
|
}
|
|
94652
94755
|
if (parameterPropertyDeclarationCount > 0) {
|
|
94653
|
-
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement,
|
|
94756
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
|
|
94654
94757
|
// If there was a super() call found, add parameter properties immediately after it
|
|
94655
94758
|
if (superStatementIndex >= 0) {
|
|
94656
94759
|
ts.addRange(statements, parameterProperties);
|
|
94657
94760
|
}
|
|
94658
|
-
// If a synthetic super() call was added, add them just after it
|
|
94659
|
-
else if (needsSyntheticConstructor) {
|
|
94660
|
-
statements = __spreadArray(__spreadArray([
|
|
94661
|
-
statements[0]
|
|
94662
|
-
], parameterProperties, true), statements.slice(1), true);
|
|
94663
|
-
}
|
|
94664
|
-
// Since there wasn't a super() call, add them to the top of the constructor
|
|
94665
94761
|
else {
|
|
94666
|
-
|
|
94762
|
+
// Add add parameter properties to the top of the constructor after the prologue
|
|
94763
|
+
var superAndPrologueStatementCount = prologueStatementCount;
|
|
94764
|
+
// If a synthetic super() call was added, need to account for that
|
|
94765
|
+
if (needsSyntheticConstructor)
|
|
94766
|
+
superAndPrologueStatementCount++;
|
|
94767
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
|
|
94667
94768
|
}
|
|
94668
|
-
|
|
94769
|
+
indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
|
|
94669
94770
|
}
|
|
94670
94771
|
}
|
|
94671
94772
|
}
|
|
@@ -94675,7 +94776,7 @@ var ts;
|
|
|
94675
94776
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
94676
94777
|
// Add existing statements after the initial prologues and super call
|
|
94677
94778
|
if (constructor) {
|
|
94678
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement,
|
|
94779
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
|
|
94679
94780
|
}
|
|
94680
94781
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
94681
94782
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
@@ -98716,7 +98817,7 @@ var ts;
|
|
|
98716
98817
|
// ```
|
|
98717
98818
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98718
98819
|
}
|
|
98719
|
-
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
|
|
98820
|
+
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)),
|
|
98720
98821
|
/*location*/ constructor.body.statements),
|
|
98721
98822
|
/*multiLine*/ true);
|
|
98722
98823
|
ts.setTextRange(body, constructor.body);
|
|
@@ -108422,6 +108523,10 @@ var ts;
|
|
|
108422
108523
|
return factory.updateModifiers(statement, modifiers);
|
|
108423
108524
|
}
|
|
108424
108525
|
function transformTopLevelDeclaration(input) {
|
|
108526
|
+
if (lateMarkedStatements) {
|
|
108527
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108528
|
+
;
|
|
108529
|
+
}
|
|
108425
108530
|
if (shouldStripInternal(input))
|
|
108426
108531
|
return;
|
|
108427
108532
|
switch (input.kind) {
|
|
@@ -109553,7 +109658,7 @@ var ts;
|
|
|
109553
109658
|
addOutput(buildInfoPath);
|
|
109554
109659
|
}
|
|
109555
109660
|
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
|
|
109556
|
-
if (ts.
|
|
109661
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109557
109662
|
return;
|
|
109558
109663
|
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109559
109664
|
addOutput(js);
|
|
@@ -109598,7 +109703,7 @@ var ts;
|
|
|
109598
109703
|
/*@internal*/
|
|
109599
109704
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
109600
109705
|
var options = _a.options, fileNames = _a.fileNames;
|
|
109601
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.
|
|
109706
|
+
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));
|
|
109602
109707
|
}
|
|
109603
109708
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
109604
109709
|
/*@internal*/
|
|
@@ -109640,7 +109745,7 @@ var ts;
|
|
|
109640
109745
|
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
|
|
109641
109746
|
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
|
|
109642
109747
|
var inputFileName = _b[_a];
|
|
109643
|
-
if (ts.
|
|
109748
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109644
109749
|
continue;
|
|
109645
109750
|
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109646
109751
|
if (jsFilePath)
|
|
@@ -114990,7 +115095,7 @@ var ts;
|
|
|
114990
115095
|
if (ts.outFile(options) || options.outDir)
|
|
114991
115096
|
return false;
|
|
114992
115097
|
// File if emitted next to input needs to be ignored
|
|
114993
|
-
if (ts.
|
|
115098
|
+
if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
|
|
114994
115099
|
// If its declaration directory: its not ignored if not excluded by config
|
|
114995
115100
|
if (options.declarationDir)
|
|
114996
115101
|
return false;
|
|
@@ -116163,7 +116268,7 @@ var ts;
|
|
|
116163
116268
|
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
116164
116269
|
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
|
|
116165
116270
|
var fileName = _c[_b];
|
|
116166
|
-
if (!ts.
|
|
116271
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
116167
116272
|
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
|
|
116168
116273
|
}
|
|
116169
116274
|
}
|
|
@@ -116354,7 +116459,7 @@ var ts;
|
|
|
116354
116459
|
}
|
|
116355
116460
|
function getRedirectReferenceForResolution(file) {
|
|
116356
116461
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
116357
|
-
if (redirect || !ts.
|
|
116462
|
+
if (redirect || !ts.isDeclarationFileName(file.originalFileName))
|
|
116358
116463
|
return redirect;
|
|
116359
116464
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
116360
116465
|
// 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
|
|
@@ -117745,7 +117850,7 @@ var ts;
|
|
|
117745
117850
|
}
|
|
117746
117851
|
function getProjectReferenceRedirectProject(fileName) {
|
|
117747
117852
|
// Ignore dts or any json files
|
|
117748
|
-
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.
|
|
117853
|
+
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117749
117854
|
return undefined;
|
|
117750
117855
|
}
|
|
117751
117856
|
// If this file is produced by a referenced project, we need to rewrite it to
|
|
@@ -117794,7 +117899,7 @@ var ts;
|
|
|
117794
117899
|
else {
|
|
117795
117900
|
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
117796
117901
|
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
|
|
117797
|
-
if (!ts.
|
|
117902
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117798
117903
|
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
|
|
117799
117904
|
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
|
|
117800
117905
|
}
|
|
@@ -118595,7 +118700,7 @@ var ts;
|
|
|
118595
118700
|
if (options.outDir) {
|
|
118596
118701
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
118597
118702
|
}
|
|
118598
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.
|
|
118703
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
|
|
118599
118704
|
// Otherwise just check if sourceFile with the name exists
|
|
118600
118705
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
118601
118706
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -118928,13 +119033,9 @@ var ts;
|
|
|
118928
119033
|
ts.getFileEmitOutput = getFileEmitOutput;
|
|
118929
119034
|
var BuilderState;
|
|
118930
119035
|
(function (BuilderState) {
|
|
118931
|
-
var manyToManyPathMapCount = 0;
|
|
118932
119036
|
function createManyToManyPathMap() {
|
|
118933
119037
|
function create(forward, reverse, deleted) {
|
|
118934
|
-
var version = 0;
|
|
118935
119038
|
var map = {
|
|
118936
|
-
id: manyToManyPathMapCount++,
|
|
118937
|
-
version: function () { return version; },
|
|
118938
119039
|
clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
|
|
118939
119040
|
forEach: function (fn) { return forward.forEach(fn); },
|
|
118940
119041
|
getKeys: function (v) { return reverse.get(v); },
|
|
@@ -118950,30 +119051,29 @@ var ts;
|
|
|
118950
119051
|
}
|
|
118951
119052
|
set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); });
|
|
118952
119053
|
forward.delete(k);
|
|
118953
|
-
version++;
|
|
118954
119054
|
return true;
|
|
118955
119055
|
},
|
|
118956
119056
|
set: function (k, vSet) {
|
|
118957
|
-
|
|
119057
|
+
deleted === null || deleted === void 0 ? void 0 : deleted.delete(k);
|
|
118958
119058
|
var existingVSet = forward.get(k);
|
|
118959
119059
|
forward.set(k, vSet);
|
|
118960
119060
|
existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) {
|
|
118961
119061
|
if (!vSet.has(v)) {
|
|
118962
|
-
changed = true;
|
|
118963
119062
|
deleteFromMultimap(reverse, v, k);
|
|
118964
119063
|
}
|
|
118965
119064
|
});
|
|
118966
119065
|
vSet.forEach(function (v) {
|
|
118967
119066
|
if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) {
|
|
118968
|
-
changed = true;
|
|
118969
119067
|
addToMultimap(reverse, v, k);
|
|
118970
119068
|
}
|
|
118971
119069
|
});
|
|
118972
|
-
if (changed) {
|
|
118973
|
-
version++;
|
|
118974
|
-
}
|
|
118975
119070
|
return map;
|
|
118976
119071
|
},
|
|
119072
|
+
clear: function () {
|
|
119073
|
+
forward.clear();
|
|
119074
|
+
reverse.clear();
|
|
119075
|
+
deleted === null || deleted === void 0 ? void 0 : deleted.clear();
|
|
119076
|
+
}
|
|
118977
119077
|
};
|
|
118978
119078
|
return map;
|
|
118979
119079
|
}
|
|
@@ -118988,11 +119088,10 @@ var ts;
|
|
|
118988
119088
|
}
|
|
118989
119089
|
set.add(v);
|
|
118990
119090
|
}
|
|
118991
|
-
function deleteFromMultimap(map, k, v
|
|
118992
|
-
if (removeEmpty === void 0) { removeEmpty = true; }
|
|
119091
|
+
function deleteFromMultimap(map, k, v) {
|
|
118993
119092
|
var set = map.get(k);
|
|
118994
119093
|
if (set === null || set === void 0 ? void 0 : set.delete(v)) {
|
|
118995
|
-
if (
|
|
119094
|
+
if (!set.size) {
|
|
118996
119095
|
map.delete(k);
|
|
118997
119096
|
}
|
|
118998
119097
|
return true;
|
|
@@ -119221,7 +119320,7 @@ var ts;
|
|
|
119221
119320
|
/*forceDtsEmit*/ true);
|
|
119222
119321
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
119223
119322
|
if (firstDts_1) {
|
|
119224
|
-
ts.Debug.assert(ts.
|
|
119323
|
+
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; })); });
|
|
119225
119324
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
119226
119325
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
119227
119326
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -119279,20 +119378,6 @@ var ts;
|
|
|
119279
119378
|
var _a;
|
|
119280
119379
|
if (exportedModulesMapCache) {
|
|
119281
119380
|
ts.Debug.assert(!!state.exportedModulesMap);
|
|
119282
|
-
var cacheId = exportedModulesMapCache.id;
|
|
119283
|
-
var cacheVersion = exportedModulesMapCache.version();
|
|
119284
|
-
if (state.previousCache) {
|
|
119285
|
-
if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
|
|
119286
|
-
// If this is the same cache at the same version as last time this BuilderState
|
|
119287
|
-
// was updated, there's no need to update again
|
|
119288
|
-
return;
|
|
119289
|
-
}
|
|
119290
|
-
state.previousCache.id = cacheId;
|
|
119291
|
-
state.previousCache.version = cacheVersion;
|
|
119292
|
-
}
|
|
119293
|
-
else {
|
|
119294
|
-
state.previousCache = { id: cacheId, version: cacheVersion };
|
|
119295
|
-
}
|
|
119296
119381
|
(_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
|
|
119297
119382
|
exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
|
|
119298
119383
|
}
|
|
@@ -119626,7 +119711,8 @@ var ts;
|
|
|
119626
119711
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
119627
119712
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
119628
119713
|
*/
|
|
119629
|
-
function getNextAffectedFile(state, cancellationToken, computeHash) {
|
|
119714
|
+
function getNextAffectedFile(state, cancellationToken, computeHash, host) {
|
|
119715
|
+
var _a;
|
|
119630
119716
|
while (true) {
|
|
119631
119717
|
var affectedFiles = state.affectedFiles;
|
|
119632
119718
|
if (affectedFiles) {
|
|
@@ -119637,7 +119723,7 @@ var ts;
|
|
|
119637
119723
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
119638
119724
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
119639
119725
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
119640
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
|
|
119726
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119641
119727
|
return affectedFile;
|
|
119642
119728
|
}
|
|
119643
119729
|
affectedFilesIndex++;
|
|
@@ -119649,6 +119735,7 @@ var ts;
|
|
|
119649
119735
|
ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
|
|
119650
119736
|
state.currentAffectedFilesSignatures.clear();
|
|
119651
119737
|
ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
|
|
119738
|
+
(_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
|
|
119652
119739
|
state.affectedFiles = undefined;
|
|
119653
119740
|
}
|
|
119654
119741
|
// Get next changed file
|
|
@@ -119678,6 +119765,11 @@ var ts;
|
|
|
119678
119765
|
state.seenAffectedFiles = new ts.Set();
|
|
119679
119766
|
}
|
|
119680
119767
|
}
|
|
119768
|
+
function clearAffectedFilesPendingEmit(state) {
|
|
119769
|
+
state.affectedFilesPendingEmit = undefined;
|
|
119770
|
+
state.affectedFilesPendingEmitKind = undefined;
|
|
119771
|
+
state.affectedFilesPendingEmitIndex = undefined;
|
|
119772
|
+
}
|
|
119681
119773
|
/**
|
|
119682
119774
|
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
|
119683
119775
|
*/
|
|
@@ -119697,9 +119789,7 @@ var ts;
|
|
|
119697
119789
|
}
|
|
119698
119790
|
}
|
|
119699
119791
|
}
|
|
119700
|
-
state
|
|
119701
|
-
state.affectedFilesPendingEmitKind = undefined;
|
|
119702
|
-
state.affectedFilesPendingEmitIndex = undefined;
|
|
119792
|
+
clearAffectedFilesPendingEmit(state);
|
|
119703
119793
|
}
|
|
119704
119794
|
return undefined;
|
|
119705
119795
|
}
|
|
@@ -119707,7 +119797,7 @@ var ts;
|
|
|
119707
119797
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119708
119798
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
119709
119799
|
*/
|
|
119710
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
|
|
119800
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119711
119801
|
var _a;
|
|
119712
119802
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119713
119803
|
// If affected files is everything except default library, then nothing more to do
|
|
@@ -119732,14 +119822,14 @@ var ts;
|
|
|
119732
119822
|
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);
|
|
119733
119823
|
}
|
|
119734
119824
|
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
|
|
119735
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
|
|
119825
|
+
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119736
119826
|
}
|
|
119737
119827
|
}
|
|
119738
119828
|
/**
|
|
119739
119829
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
119740
119830
|
* Also we need to make sure signature is updated for these files
|
|
119741
119831
|
*/
|
|
119742
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
|
|
119832
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
|
|
119743
119833
|
removeSemanticDiagnosticsOf(state, path);
|
|
119744
119834
|
if (!state.changedFilesSet.has(path)) {
|
|
119745
119835
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -119750,8 +119840,7 @@ var ts;
|
|
|
119750
119840
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
119751
119841
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
119752
119842
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
119753
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
|
|
119754
|
-
/* useFileVersionAsSignature */ true);
|
|
119843
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
|
|
119755
119844
|
// If not dts emit, nothing more to do
|
|
119756
119845
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
119757
119846
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -119948,13 +120037,18 @@ var ts;
|
|
|
119948
120037
|
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
|
119949
120038
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
119950
120039
|
return value.version === actualSignature ?
|
|
119951
|
-
value.affectsGlobalScope ?
|
|
119952
|
-
|
|
120040
|
+
value.affectsGlobalScope || value.impliedFormat ?
|
|
120041
|
+
// If file version is same as signature, dont serialize signature
|
|
120042
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120043
|
+
// If file info only contains version and signature and both are same we can just write string
|
|
119953
120044
|
value.version :
|
|
119954
|
-
actualSignature !== undefined ?
|
|
120045
|
+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
|
|
119955
120046
|
signature === undefined ?
|
|
120047
|
+
// If we havent computed signature, use fileInfo as is
|
|
119956
120048
|
value :
|
|
120049
|
+
// Serialize fileInfo with new updated signature
|
|
119957
120050
|
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120051
|
+
// Signature of the FileInfo is undefined, serialize it as false
|
|
119958
120052
|
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
119959
120053
|
});
|
|
119960
120054
|
var referencedMap;
|
|
@@ -120199,7 +120293,7 @@ var ts;
|
|
|
120199
120293
|
* in that order would be used to write the files
|
|
120200
120294
|
*/
|
|
120201
120295
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120202
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120296
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120203
120297
|
var emitKind = 1 /* Full */;
|
|
120204
120298
|
var isPendingEmitFile = false;
|
|
120205
120299
|
if (!affected) {
|
|
@@ -120244,54 +120338,48 @@ var ts;
|
|
|
120244
120338
|
* in that order would be used to write the files
|
|
120245
120339
|
*/
|
|
120246
120340
|
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120247
|
-
var
|
|
120248
|
-
var savedAffectedFilesPendingEmit;
|
|
120249
|
-
var savedAffectedFilesPendingEmitKind;
|
|
120250
|
-
var savedAffectedFilesPendingEmitIndex;
|
|
120251
|
-
// 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
|
|
120252
|
-
// This ensures pending files to emit is updated in tsbuildinfo
|
|
120253
|
-
// 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)
|
|
120254
|
-
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
|
|
120255
|
-
!targetSourceFile &&
|
|
120256
|
-
!ts.outFile(state.compilerOptions) &&
|
|
120257
|
-
!state.compilerOptions.noEmit &&
|
|
120258
|
-
state.compilerOptions.noEmitOnError) {
|
|
120259
|
-
restorePendingEmitOnHandlingNoEmitSuccess = true;
|
|
120260
|
-
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
|
120261
|
-
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
|
|
120262
|
-
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
|
120263
|
-
}
|
|
120341
|
+
var _a;
|
|
120264
120342
|
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120265
120343
|
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
|
|
120266
120344
|
}
|
|
120267
120345
|
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
|
|
120268
120346
|
if (result)
|
|
120269
120347
|
return result;
|
|
120270
|
-
if (restorePendingEmitOnHandlingNoEmitSuccess) {
|
|
120271
|
-
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
|
|
120272
|
-
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
|
|
120273
|
-
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
|
|
120274
|
-
}
|
|
120275
120348
|
// Emit only affected files if using builder for emit
|
|
120276
|
-
if (!targetSourceFile
|
|
120277
|
-
|
|
120278
|
-
|
|
120279
|
-
|
|
120280
|
-
|
|
120281
|
-
|
|
120282
|
-
|
|
120283
|
-
|
|
120284
|
-
|
|
120285
|
-
|
|
120286
|
-
|
|
120287
|
-
|
|
120349
|
+
if (!targetSourceFile) {
|
|
120350
|
+
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120351
|
+
// Emit and report any errors we ran into.
|
|
120352
|
+
var sourceMaps = [];
|
|
120353
|
+
var emitSkipped = false;
|
|
120354
|
+
var diagnostics = void 0;
|
|
120355
|
+
var emittedFiles = [];
|
|
120356
|
+
var affectedEmitResult = void 0;
|
|
120357
|
+
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
|
|
120358
|
+
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
|
|
120359
|
+
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
|
|
120360
|
+
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
|
|
120361
|
+
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
|
|
120362
|
+
}
|
|
120363
|
+
return {
|
|
120364
|
+
emitSkipped: emitSkipped,
|
|
120365
|
+
diagnostics: diagnostics || ts.emptyArray,
|
|
120366
|
+
emittedFiles: emittedFiles,
|
|
120367
|
+
sourceMaps: sourceMaps
|
|
120368
|
+
};
|
|
120369
|
+
}
|
|
120370
|
+
// In non Emit builder, clear affected files pending emit
|
|
120371
|
+
else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
|
|
120372
|
+
ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
|
|
120373
|
+
// State can clear affected files pending emit if
|
|
120374
|
+
if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
|
|
120375
|
+
// If every file pending emit is pending on only dts emit
|
|
120376
|
+
|| ts.every(state.affectedFilesPendingEmit, function (path, index) {
|
|
120377
|
+
return index < state.affectedFilesPendingEmitIndex ||
|
|
120378
|
+
state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
|
|
120379
|
+
})) {
|
|
120380
|
+
clearAffectedFilesPendingEmit(state);
|
|
120381
|
+
}
|
|
120288
120382
|
}
|
|
120289
|
-
return {
|
|
120290
|
-
emitSkipped: emitSkipped,
|
|
120291
|
-
diagnostics: diagnostics || ts.emptyArray,
|
|
120292
|
-
emittedFiles: emittedFiles,
|
|
120293
|
-
sourceMaps: sourceMaps
|
|
120294
|
-
};
|
|
120295
120383
|
}
|
|
120296
120384
|
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120297
120385
|
}
|
|
@@ -120301,7 +120389,7 @@ var ts;
|
|
|
120301
120389
|
*/
|
|
120302
120390
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
120303
120391
|
while (true) {
|
|
120304
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120392
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120305
120393
|
if (!affected) {
|
|
120306
120394
|
// Done
|
|
120307
120395
|
return undefined;
|
|
@@ -123421,9 +123509,6 @@ var ts;
|
|
|
123421
123509
|
function newer(date1, date2) {
|
|
123422
123510
|
return date2 > date1 ? date2 : date1;
|
|
123423
123511
|
}
|
|
123424
|
-
function isDeclarationFile(fileName) {
|
|
123425
|
-
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
123426
|
-
}
|
|
123427
123512
|
/*@internal*/
|
|
123428
123513
|
function isCircularBuildOrder(buildOrder) {
|
|
123429
123514
|
return !!buildOrder && !!buildOrder.buildOrder;
|
|
@@ -123986,7 +124071,7 @@ var ts;
|
|
|
123986
124071
|
outputFiles.forEach(function (_a) {
|
|
123987
124072
|
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
|
|
123988
124073
|
var priorChangeTime;
|
|
123989
|
-
if (!anyDtsChanged &&
|
|
124074
|
+
if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
|
|
123990
124075
|
// Check for unchanged .d.ts files
|
|
123991
124076
|
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
|
|
123992
124077
|
priorChangeTime = host.getModifiedTime(name);
|
|
@@ -124327,7 +124412,7 @@ var ts;
|
|
|
124327
124412
|
// In addition to file timestamps, we also keep track of when a .d.ts file
|
|
124328
124413
|
// had its file touched but not had its contents changed - this allows us
|
|
124329
124414
|
// to skip a downstream typecheck
|
|
124330
|
-
if (
|
|
124415
|
+
if (ts.isDeclarationFileName(output)) {
|
|
124331
124416
|
var outputModifiedTime = ts.getModifiedTime(host, output);
|
|
124332
124417
|
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
|
|
124333
124418
|
}
|
|
@@ -124481,7 +124566,7 @@ var ts;
|
|
|
124481
124566
|
reportVerbose = false;
|
|
124482
124567
|
reportStatus(state, verboseMessage, proj.options.configFilePath);
|
|
124483
124568
|
}
|
|
124484
|
-
if (
|
|
124569
|
+
if (ts.isDeclarationFileName(file)) {
|
|
124485
124570
|
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
|
|
124486
124571
|
}
|
|
124487
124572
|
host.setModifiedTime(file, now);
|
|
@@ -131376,17 +131461,13 @@ var ts;
|
|
|
131376
131461
|
}
|
|
131377
131462
|
}
|
|
131378
131463
|
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131379
|
-
|
|
131380
|
-
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
131464
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
|
|
131381
131465
|
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131382
131466
|
name = name + labelDetails.detail;
|
|
131383
131467
|
labelDetails = undefined;
|
|
131384
131468
|
}
|
|
131385
131469
|
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131386
131470
|
sortText = Completions.SortText.SortBelow(sortText);
|
|
131387
|
-
if (importAdder.hasFixes()) {
|
|
131388
|
-
hasAction = true;
|
|
131389
|
-
}
|
|
131390
131471
|
}
|
|
131391
131472
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131392
131473
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
@@ -131609,8 +131690,7 @@ var ts;
|
|
|
131609
131690
|
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131610
131691
|
var insertText = name;
|
|
131611
131692
|
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131612
|
-
var
|
|
131613
|
-
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131693
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
|
|
131614
131694
|
if (!method) {
|
|
131615
131695
|
return undefined;
|
|
131616
131696
|
}
|
|
@@ -131639,16 +131719,15 @@ var ts;
|
|
|
131639
131719
|
/*modifiers*/ undefined,
|
|
131640
131720
|
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131641
131721
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
131642
|
-
return { isSnippet: isSnippet, insertText: insertText,
|
|
131722
|
+
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
131643
131723
|
}
|
|
131644
131724
|
;
|
|
131645
|
-
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences
|
|
131725
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
131646
131726
|
var declarations = symbol.getDeclarations();
|
|
131647
131727
|
if (!(declarations && declarations.length)) {
|
|
131648
131728
|
return undefined;
|
|
131649
131729
|
}
|
|
131650
131730
|
var checker = program.getTypeChecker();
|
|
131651
|
-
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131652
131731
|
var declaration = declarations[0];
|
|
131653
131732
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131654
131733
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
@@ -131681,11 +131760,6 @@ var ts;
|
|
|
131681
131760
|
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131682
131761
|
return undefined;
|
|
131683
131762
|
}
|
|
131684
|
-
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131685
|
-
if (importableReference) {
|
|
131686
|
-
typeNode = importableReference.typeNode;
|
|
131687
|
-
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131688
|
-
}
|
|
131689
131763
|
var body = void 0;
|
|
131690
131764
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
131691
131765
|
var emptyStmt = ts.factory.createEmptyStatement();
|
|
@@ -131695,11 +131769,19 @@ var ts;
|
|
|
131695
131769
|
else {
|
|
131696
131770
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131697
131771
|
}
|
|
131772
|
+
var parameters = typeNode.parameters.map(function (typedParam) {
|
|
131773
|
+
return ts.factory.createParameterDeclaration(
|
|
131774
|
+
/*decorators*/ undefined,
|
|
131775
|
+
/*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
|
|
131776
|
+
/*type*/ undefined, typedParam.initializer);
|
|
131777
|
+
});
|
|
131698
131778
|
return ts.factory.createMethodDeclaration(
|
|
131699
131779
|
/*decorators*/ undefined,
|
|
131700
131780
|
/*modifiers*/ undefined,
|
|
131701
131781
|
/*asteriskToken*/ undefined, name,
|
|
131702
|
-
/*questionToken*/ undefined,
|
|
131782
|
+
/*questionToken*/ undefined,
|
|
131783
|
+
/*typeParameters*/ undefined, parameters,
|
|
131784
|
+
/*type*/ undefined, body);
|
|
131703
131785
|
}
|
|
131704
131786
|
default:
|
|
131705
131787
|
return undefined;
|
|
@@ -132062,20 +132144,6 @@ var ts;
|
|
|
132062
132144
|
};
|
|
132063
132145
|
}
|
|
132064
132146
|
}
|
|
132065
|
-
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132066
|
-
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132067
|
-
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132068
|
-
if (importAdder.hasFixes()) {
|
|
132069
|
-
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132070
|
-
return {
|
|
132071
|
-
sourceDisplay: undefined,
|
|
132072
|
-
codeActions: [{
|
|
132073
|
-
changes: changes,
|
|
132074
|
-
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132075
|
-
}],
|
|
132076
|
-
};
|
|
132077
|
-
}
|
|
132078
|
-
}
|
|
132079
132147
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132080
132148
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132081
132149
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -134896,7 +134964,7 @@ var ts;
|
|
|
134896
134964
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
134897
134965
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
134898
134966
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
134899
|
-
var otherBucketKey = !ts.
|
|
134967
|
+
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
134900
134968
|
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
134901
134969
|
if (otherBucketKey) {
|
|
134902
134970
|
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
@@ -136836,6 +136904,30 @@ var ts;
|
|
|
136836
136904
|
}
|
|
136837
136905
|
}
|
|
136838
136906
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
136907
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
136908
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
136909
|
+
return candidates.reduce(function (topMost, decl) {
|
|
136910
|
+
var depth = getDepth(decl);
|
|
136911
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
136912
|
+
topMost.declarationNames.push(decl);
|
|
136913
|
+
topMost.depth = depth;
|
|
136914
|
+
}
|
|
136915
|
+
else if (depth < topMost.depth) {
|
|
136916
|
+
topMost.declarationNames = [decl];
|
|
136917
|
+
topMost.depth = depth;
|
|
136918
|
+
}
|
|
136919
|
+
return topMost;
|
|
136920
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
136921
|
+
function getDepth(declaration) {
|
|
136922
|
+
var depth = 0;
|
|
136923
|
+
while (declaration) {
|
|
136924
|
+
declaration = ts.getContainerNode(declaration);
|
|
136925
|
+
depth++;
|
|
136926
|
+
}
|
|
136927
|
+
return depth;
|
|
136928
|
+
}
|
|
136929
|
+
}
|
|
136930
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
136839
136931
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
136840
136932
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
136841
136933
|
return false;
|
|
@@ -138472,7 +138564,9 @@ var ts;
|
|
|
138472
138564
|
(function (ts) {
|
|
138473
138565
|
var GoToDefinition;
|
|
138474
138566
|
(function (GoToDefinition) {
|
|
138475
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
138567
|
+
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
|
|
138568
|
+
var _a;
|
|
138569
|
+
var _b;
|
|
138476
138570
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
138477
138571
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
138478
138572
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -138495,33 +138589,63 @@ var ts;
|
|
|
138495
138589
|
}
|
|
138496
138590
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
138497
138591
|
var classDecl = node.parent.parent;
|
|
138498
|
-
var
|
|
138592
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
138499
138593
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
138500
138594
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
138501
138595
|
var sourceFile_1 = node.getSourceFile();
|
|
138502
138596
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
138503
138597
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
138504
138598
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
138505
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
138599
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
138506
138600
|
});
|
|
138507
138601
|
}
|
|
138508
|
-
var
|
|
138602
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
138603
|
+
var fallbackNode = node;
|
|
138604
|
+
if (searchOtherFilesOnly && failedAliasResolution) {
|
|
138605
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
138606
|
+
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); });
|
|
138607
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
138608
|
+
if (moduleSpecifier) {
|
|
138609
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
138610
|
+
fallbackNode = moduleSpecifier;
|
|
138611
|
+
}
|
|
138612
|
+
}
|
|
138613
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
138614
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
138615
|
+
// be that module resolution succeeded but the target was not a module.
|
|
138616
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
138617
|
+
if (ref) {
|
|
138618
|
+
return [{
|
|
138619
|
+
name: fallbackNode.text,
|
|
138620
|
+
fileName: ref.resolvedFileName,
|
|
138621
|
+
containerName: undefined,
|
|
138622
|
+
containerKind: undefined,
|
|
138623
|
+
kind: "script" /* scriptElement */,
|
|
138624
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
138625
|
+
failedAliasResolution: failedAliasResolution,
|
|
138626
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
138627
|
+
unverified: fallbackNode !== node,
|
|
138628
|
+
}];
|
|
138629
|
+
}
|
|
138630
|
+
}
|
|
138509
138631
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
138510
138632
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
138511
138633
|
if (!symbol) {
|
|
138512
138634
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
138513
138635
|
}
|
|
138636
|
+
if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
138637
|
+
return undefined;
|
|
138514
138638
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
138515
138639
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
138516
138640
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
138517
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
138641
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
138518
138642
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
138519
138643
|
// If this is the original constructor definition, parent is the class.
|
|
138520
138644
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
138521
138645
|
return [sigInfo];
|
|
138522
138646
|
}
|
|
138523
138647
|
else {
|
|
138524
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
138648
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
138525
138649
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
138526
138650
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
138527
138651
|
}
|
|
@@ -138533,7 +138657,7 @@ var ts;
|
|
|
138533
138657
|
// assignment. This case and others are handled by the following code.
|
|
138534
138658
|
if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
|
|
138535
138659
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
138536
|
-
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;
|
|
138660
|
+
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;
|
|
138537
138661
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
138538
138662
|
}
|
|
138539
138663
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -138556,7 +138680,7 @@ var ts;
|
|
|
138556
138680
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
138557
138681
|
});
|
|
138558
138682
|
}
|
|
138559
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
138683
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
138560
138684
|
}
|
|
138561
138685
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
138562
138686
|
/**
|
|
@@ -138654,24 +138778,24 @@ var ts;
|
|
|
138654
138778
|
return undefined;
|
|
138655
138779
|
}
|
|
138656
138780
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
138657
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
138781
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
138658
138782
|
}
|
|
138659
|
-
var
|
|
138783
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
138660
138784
|
if (!symbol)
|
|
138661
138785
|
return undefined;
|
|
138662
138786
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
138663
138787
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
138664
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
138788
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
138665
138789
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
138666
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
138790
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
138667
138791
|
return typeDefinitions.length ? typeDefinitions
|
|
138668
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
138792
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
138669
138793
|
: undefined;
|
|
138670
138794
|
}
|
|
138671
138795
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
138672
|
-
function definitionFromType(type, checker, node) {
|
|
138796
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
138673
138797
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
138674
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
138798
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
138675
138799
|
});
|
|
138676
138800
|
}
|
|
138677
138801
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -138713,13 +138837,17 @@ var ts;
|
|
|
138713
138837
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
138714
138838
|
// import {A, B} from "mod";
|
|
138715
138839
|
// to jump to the implementation directly.
|
|
138840
|
+
var failedAliasResolution = false;
|
|
138716
138841
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
138717
138842
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
138718
138843
|
if (aliased.declarations) {
|
|
138719
|
-
return aliased;
|
|
138844
|
+
return { symbol: aliased };
|
|
138845
|
+
}
|
|
138846
|
+
else {
|
|
138847
|
+
failedAliasResolution = true;
|
|
138720
138848
|
}
|
|
138721
138849
|
}
|
|
138722
|
-
return symbol;
|
|
138850
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
138723
138851
|
}
|
|
138724
138852
|
// Go to the original declaration for cases:
|
|
138725
138853
|
//
|
|
@@ -138733,26 +138861,45 @@ var ts;
|
|
|
138733
138861
|
if (node.parent === declaration) {
|
|
138734
138862
|
return true;
|
|
138735
138863
|
}
|
|
138736
|
-
|
|
138737
|
-
|
|
138738
|
-
case 265 /* ImportEqualsDeclaration */:
|
|
138739
|
-
return true;
|
|
138740
|
-
case 270 /* ImportSpecifier */:
|
|
138741
|
-
return declaration.parent.kind === 269 /* NamedImports */;
|
|
138742
|
-
case 203 /* BindingElement */:
|
|
138743
|
-
case 254 /* VariableDeclaration */:
|
|
138744
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
138745
|
-
default:
|
|
138746
|
-
return false;
|
|
138864
|
+
if (declaration.kind === 268 /* NamespaceImport */) {
|
|
138865
|
+
return false;
|
|
138747
138866
|
}
|
|
138867
|
+
return true;
|
|
138868
|
+
}
|
|
138869
|
+
/**
|
|
138870
|
+
* ```ts
|
|
138871
|
+
* function f() {}
|
|
138872
|
+
* f.foo = 0;
|
|
138873
|
+
* ```
|
|
138874
|
+
*
|
|
138875
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
138876
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
138877
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
138878
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
138879
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
138880
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
138881
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
138882
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
138883
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
138884
|
+
* up with a more precise definition of what counts as a definition.
|
|
138885
|
+
*/
|
|
138886
|
+
function isExpandoDeclaration(node) {
|
|
138887
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
138888
|
+
return false;
|
|
138889
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
138890
|
+
if (ts.isAssignmentExpression(p))
|
|
138891
|
+
return true;
|
|
138892
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
138893
|
+
return "quit";
|
|
138894
|
+
return false;
|
|
138895
|
+
});
|
|
138896
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
138748
138897
|
}
|
|
138749
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
138750
|
-
|
|
138751
|
-
|
|
138752
|
-
|
|
138753
|
-
|
|
138754
|
-
|| undefined;
|
|
138755
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
138898
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
138899
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
138900
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
138901
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
138902
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
|
|
138756
138903
|
function getConstructSignatureDefinition() {
|
|
138757
138904
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
138758
138905
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -138776,26 +138923,27 @@ var ts;
|
|
|
138776
138923
|
return declarations.length
|
|
138777
138924
|
? declarationsWithBody.length !== 0
|
|
138778
138925
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
138779
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
138926
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
|
|
138780
138927
|
: undefined;
|
|
138781
138928
|
}
|
|
138782
138929
|
}
|
|
138783
138930
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
138784
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
138931
|
+
function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
|
|
138785
138932
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
138786
138933
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
138787
138934
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
138788
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
138935
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
|
|
138789
138936
|
}
|
|
138937
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
138790
138938
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
138791
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
138939
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
|
|
138792
138940
|
var sourceFile = declaration.getSourceFile();
|
|
138793
138941
|
if (!textSpan) {
|
|
138794
138942
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
138795
138943
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
138796
138944
|
}
|
|
138797
138945
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
138798
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
138946
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
|
|
138799
138947
|
}
|
|
138800
138948
|
function isDefinitionVisible(checker, declaration) {
|
|
138801
138949
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -138828,8 +138976,8 @@ var ts;
|
|
|
138828
138976
|
return false;
|
|
138829
138977
|
}
|
|
138830
138978
|
}
|
|
138831
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
138832
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
138979
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
138980
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
|
138833
138981
|
}
|
|
138834
138982
|
function findReferenceInPosition(refs, pos) {
|
|
138835
138983
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -151944,9 +152092,10 @@ var ts;
|
|
|
151944
152092
|
// 2. add "member3" to the second import statement's import list
|
|
151945
152093
|
// and it is up to the user to decide which one fits best.
|
|
151946
152094
|
return ts.firstDefined(existingImports, function (_a) {
|
|
152095
|
+
var _b;
|
|
151947
152096
|
var declaration = _a.declaration;
|
|
151948
152097
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
151949
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152098
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151950
152099
|
if (namespacePrefix && moduleSpecifier) {
|
|
151951
152100
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
151952
152101
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -152122,8 +152271,9 @@ var ts;
|
|
|
152122
152271
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
152123
152272
|
}
|
|
152124
152273
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
152274
|
+
var _b;
|
|
152125
152275
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
152126
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152276
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152127
152277
|
if (moduleSpecifier) {
|
|
152128
152278
|
var addAsTypeOnly = useRequire
|
|
152129
152279
|
? 4 /* NotAllowed */
|
|
@@ -156481,7 +156631,6 @@ var ts;
|
|
|
156481
156631
|
var checker = program.getTypeChecker();
|
|
156482
156632
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156483
156633
|
var flags = 1 /* NoTruncation */
|
|
156484
|
-
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
156485
156634
|
| 256 /* SuppressAnyReturnType */
|
|
156486
156635
|
| 524288 /* AllowEmptyTuple */
|
|
156487
156636
|
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
@@ -158860,6 +159009,7 @@ var ts;
|
|
|
158860
159009
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
158861
159010
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
158862
159011
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
159012
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
158863
159013
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
158864
159014
|
var RangeFacts;
|
|
158865
159015
|
(function (RangeFacts) {
|
|
@@ -158868,10 +159018,11 @@ var ts;
|
|
|
158868
159018
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
158869
159019
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
158870
159020
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
159021
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
158871
159022
|
/**
|
|
158872
159023
|
* The range is in a function which needs the 'static' modifier in a class
|
|
158873
159024
|
*/
|
|
158874
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
159025
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
158875
159026
|
})(RangeFacts || (RangeFacts = {}));
|
|
158876
159027
|
/**
|
|
158877
159028
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -158902,6 +159053,7 @@ var ts;
|
|
|
158902
159053
|
// We'll modify these flags as we walk the tree to collect data
|
|
158903
159054
|
// about what things need to be done as part of the extraction.
|
|
158904
159055
|
var rangeFacts = RangeFacts.None;
|
|
159056
|
+
var thisNode;
|
|
158905
159057
|
if (!start || !end) {
|
|
158906
159058
|
// cannot find either start or end node
|
|
158907
159059
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
@@ -158940,7 +159092,7 @@ var ts;
|
|
|
158940
159092
|
// the expression.
|
|
158941
159093
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158942
159094
|
}
|
|
158943
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
159095
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
158944
159096
|
}
|
|
158945
159097
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
158946
159098
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -158952,7 +159104,7 @@ var ts;
|
|
|
158952
159104
|
if (errors) {
|
|
158953
159105
|
return { errors: errors };
|
|
158954
159106
|
}
|
|
158955
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
159107
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
158956
159108
|
/**
|
|
158957
159109
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
158958
159110
|
* @param node The unrefined extraction node.
|
|
@@ -159044,6 +159196,14 @@ var ts;
|
|
|
159044
159196
|
var permittedJumps = 4 /* Return */;
|
|
159045
159197
|
var seenLabels;
|
|
159046
159198
|
visit(nodeToCheck);
|
|
159199
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159200
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159201
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159202
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159203
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159204
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159205
|
+
}
|
|
159206
|
+
}
|
|
159047
159207
|
return errors;
|
|
159048
159208
|
function visit(node) {
|
|
159049
159209
|
if (errors) {
|
|
@@ -159082,6 +159242,7 @@ var ts;
|
|
|
159082
159242
|
}
|
|
159083
159243
|
else {
|
|
159084
159244
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159245
|
+
thisNode = node;
|
|
159085
159246
|
}
|
|
159086
159247
|
break;
|
|
159087
159248
|
case 214 /* ArrowFunction */:
|
|
@@ -159089,6 +159250,7 @@ var ts;
|
|
|
159089
159250
|
ts.forEachChild(node, function check(n) {
|
|
159090
159251
|
if (ts.isThis(n)) {
|
|
159091
159252
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159253
|
+
thisNode = node;
|
|
159092
159254
|
}
|
|
159093
159255
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
159094
159256
|
return false;
|
|
@@ -159145,6 +159307,7 @@ var ts;
|
|
|
159145
159307
|
case 192 /* ThisType */:
|
|
159146
159308
|
case 108 /* ThisKeyword */:
|
|
159147
159309
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159310
|
+
thisNode = node;
|
|
159148
159311
|
break;
|
|
159149
159312
|
case 250 /* LabeledStatement */: {
|
|
159150
159313
|
var label = node.label;
|
|
@@ -159232,7 +159395,7 @@ var ts;
|
|
|
159232
159395
|
*/
|
|
159233
159396
|
function collectEnclosingScopes(range) {
|
|
159234
159397
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
159235
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
159398
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
159236
159399
|
// 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
|
|
159237
159400
|
var containingClass = ts.getContainingClass(current);
|
|
159238
159401
|
if (containingClass) {
|
|
@@ -159438,6 +159601,7 @@ var ts;
|
|
|
159438
159601
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
159439
159602
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
159440
159603
|
var newFunction;
|
|
159604
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
159441
159605
|
if (ts.isClassLike(scope)) {
|
|
159442
159606
|
// always create private method in TypeScript files
|
|
159443
159607
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -159452,6 +159616,15 @@ var ts;
|
|
|
159452
159616
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
159453
159617
|
}
|
|
159454
159618
|
else {
|
|
159619
|
+
if (callThis) {
|
|
159620
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
159621
|
+
/*decorators*/ undefined,
|
|
159622
|
+
/*modifiers*/ undefined,
|
|
159623
|
+
/*dotDotDotToken*/ undefined,
|
|
159624
|
+
/*name*/ "this",
|
|
159625
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
159626
|
+
/*initializer*/ undefined));
|
|
159627
|
+
}
|
|
159455
159628
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
159456
159629
|
/*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);
|
|
159457
159630
|
}
|
|
@@ -159468,7 +159641,10 @@ var ts;
|
|
|
159468
159641
|
var newNodes = [];
|
|
159469
159642
|
// replace range with function call
|
|
159470
159643
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
159471
|
-
|
|
159644
|
+
if (callThis) {
|
|
159645
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
159646
|
+
}
|
|
159647
|
+
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
|
|
159472
159648
|
callArguments);
|
|
159473
159649
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
159474
159650
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -160079,6 +160255,9 @@ var ts;
|
|
|
160079
160255
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
160080
160256
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
160081
160257
|
}
|
|
160258
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160259
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160260
|
+
}
|
|
160082
160261
|
var hasWrite = false;
|
|
160083
160262
|
var readonlyClassPropertyWrite;
|
|
160084
160263
|
usagesPerScope[i].usages.forEach(function (value) {
|
|
@@ -164032,9 +164211,9 @@ var ts;
|
|
|
164032
164211
|
}
|
|
164033
164212
|
}
|
|
164034
164213
|
/// Goto definition
|
|
164035
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
164214
|
+
function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
|
|
164036
164215
|
synchronizeHostData();
|
|
164037
|
-
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
164216
|
+
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
|
|
164038
164217
|
}
|
|
164039
164218
|
function getDefinitionAndBoundSpan(fileName, position) {
|
|
164040
164219
|
synchronizeHostData();
|
|
@@ -166992,6 +167171,11 @@ var ts;
|
|
|
166992
167171
|
return "/dev/null/autoImportProviderProject" + counter + "*";
|
|
166993
167172
|
}
|
|
166994
167173
|
server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName;
|
|
167174
|
+
/*@internal*/
|
|
167175
|
+
function makeAuxiliaryProjectName(counter) {
|
|
167176
|
+
return "/dev/null/auxiliaryProject" + counter + "*";
|
|
167177
|
+
}
|
|
167178
|
+
server.makeAuxiliaryProjectName = makeAuxiliaryProjectName;
|
|
166995
167179
|
function createSortedArray() {
|
|
166996
167180
|
return []; // TODO: GH#19873
|
|
166997
167181
|
}
|
|
@@ -167205,6 +167389,7 @@ var ts;
|
|
|
167205
167389
|
CommandTypes["SignatureHelp"] = "signatureHelp";
|
|
167206
167390
|
/* @internal */
|
|
167207
167391
|
CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
|
|
167392
|
+
CommandTypes["FindSourceDefinition"] = "findSourceDefinition";
|
|
167208
167393
|
CommandTypes["Status"] = "status";
|
|
167209
167394
|
CommandTypes["TypeDefinition"] = "typeDefinition";
|
|
167210
167395
|
CommandTypes["ProjectInfo"] = "projectInfo";
|
|
@@ -167784,7 +167969,7 @@ var ts;
|
|
|
167784
167969
|
case 0:
|
|
167785
167970
|
return server.Errors.ThrowNoProject();
|
|
167786
167971
|
case 1:
|
|
167787
|
-
return
|
|
167972
|
+
return ensurePrimaryProjectKind(this.containingProjects[0]);
|
|
167788
167973
|
default:
|
|
167789
167974
|
// If this file belongs to multiple projects, below is the order in which default project is used
|
|
167790
167975
|
// - for open script info, its default configured project during opening is default if info is part of it
|
|
@@ -167822,7 +168007,7 @@ var ts;
|
|
|
167822
168007
|
firstInferredProject = project;
|
|
167823
168008
|
}
|
|
167824
168009
|
}
|
|
167825
|
-
return
|
|
168010
|
+
return ensurePrimaryProjectKind(defaultConfiguredProject ||
|
|
167826
168011
|
firstNonSourceOfProjectReferenceRedirect ||
|
|
167827
168012
|
firstConfiguredProject ||
|
|
167828
168013
|
firstExternalProject ||
|
|
@@ -167898,8 +168083,8 @@ var ts;
|
|
|
167898
168083
|
return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); });
|
|
167899
168084
|
};
|
|
167900
168085
|
/*@internal*/
|
|
167901
|
-
ScriptInfo.prototype.
|
|
167902
|
-
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; });
|
|
168086
|
+
ScriptInfo.prototype.isContainedByBackgroundProject = function () {
|
|
168087
|
+
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; });
|
|
167903
168088
|
};
|
|
167904
168089
|
/**
|
|
167905
168090
|
* @param line 1 based index
|
|
@@ -167933,8 +168118,13 @@ var ts;
|
|
|
167933
168118
|
return ScriptInfo;
|
|
167934
168119
|
}());
|
|
167935
168120
|
server.ScriptInfo = ScriptInfo;
|
|
167936
|
-
|
|
167937
|
-
|
|
168121
|
+
/**
|
|
168122
|
+
* Throws an error if `project` is an AutoImportProvider or AuxiliaryProject,
|
|
168123
|
+
* which are used in the background by other Projects and should never be
|
|
168124
|
+
* reported as the default project for a ScriptInfo.
|
|
168125
|
+
*/
|
|
168126
|
+
function ensurePrimaryProjectKind(project) {
|
|
168127
|
+
if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) {
|
|
167938
168128
|
return server.Errors.ThrowNoProject();
|
|
167939
168129
|
}
|
|
167940
168130
|
return project;
|
|
@@ -168074,6 +168264,7 @@ var ts;
|
|
|
168074
168264
|
ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
|
|
168075
168265
|
ProjectKind[ProjectKind["External"] = 2] = "External";
|
|
168076
168266
|
ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
|
|
168267
|
+
ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
|
|
168077
168268
|
})(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
|
|
168078
168269
|
/* @internal */
|
|
168079
168270
|
function countEachFileTypes(infos, includeSizes) {
|
|
@@ -168099,7 +168290,7 @@ var ts;
|
|
|
168099
168290
|
result.jsxSize += fileSize;
|
|
168100
168291
|
break;
|
|
168101
168292
|
case 3 /* TS */:
|
|
168102
|
-
if (ts.
|
|
168293
|
+
if (ts.isDeclarationFileName(info.fileName)) {
|
|
168103
168294
|
result.dts += 1;
|
|
168104
168295
|
result.dtsSize += fileSize;
|
|
168105
168296
|
}
|
|
@@ -168137,7 +168328,7 @@ var ts;
|
|
|
168137
168328
|
server.allFilesAreJsOrDts = allFilesAreJsOrDts;
|
|
168138
168329
|
/* @internal */
|
|
168139
168330
|
function hasNoTypeScriptSource(fileNames) {
|
|
168140
|
-
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.
|
|
168331
|
+
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
|
|
168141
168332
|
}
|
|
168142
168333
|
server.hasNoTypeScriptSource = hasNoTypeScriptSource;
|
|
168143
168334
|
function isGeneratedFileWatcher(watch) {
|
|
@@ -168541,7 +168732,7 @@ var ts;
|
|
|
168541
168732
|
}
|
|
168542
168733
|
// Update the signature
|
|
168543
168734
|
if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) {
|
|
168544
|
-
var dtsFiles = outputFiles.filter(function (f) { return ts.
|
|
168735
|
+
var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); });
|
|
168545
168736
|
if (dtsFiles.length === 1) {
|
|
168546
168737
|
var sourceFile = this.program.getSourceFile(scriptInfo.fileName);
|
|
168547
168738
|
var signature = this.projectService.host.createHash ?
|
|
@@ -168660,6 +168851,10 @@ var ts;
|
|
|
168660
168851
|
this.autoImportProviderHost.close();
|
|
168661
168852
|
}
|
|
168662
168853
|
this.autoImportProviderHost = undefined;
|
|
168854
|
+
if (this.noDtsResolutionProject) {
|
|
168855
|
+
this.noDtsResolutionProject.close();
|
|
168856
|
+
}
|
|
168857
|
+
this.noDtsResolutionProject = undefined;
|
|
168663
168858
|
// signal language service to release source files acquired from document registry
|
|
168664
168859
|
this.languageService.dispose();
|
|
168665
168860
|
this.languageService = undefined;
|
|
@@ -169182,11 +169377,13 @@ var ts;
|
|
|
169182
169377
|
}
|
|
169183
169378
|
};
|
|
169184
169379
|
Project.prototype.setCompilerOptions = function (compilerOptions) {
|
|
169380
|
+
var _a;
|
|
169185
169381
|
if (compilerOptions) {
|
|
169186
169382
|
compilerOptions.allowNonTsExtensions = true;
|
|
169187
169383
|
var oldOptions = this.compilerOptions;
|
|
169188
169384
|
this.compilerOptions = compilerOptions;
|
|
169189
169385
|
this.setInternalCompilerOptionsForEmittingJsFiles();
|
|
169386
|
+
(_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169190
169387
|
if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) {
|
|
169191
169388
|
// reset cached unresolved imports if changes in compiler options affected module resolution
|
|
169192
169389
|
this.cachedUnresolvedImportsPerFile.clear();
|
|
@@ -169526,6 +169723,31 @@ var ts;
|
|
|
169526
169723
|
Project.prototype.getIncompleteCompletionsCache = function () {
|
|
169527
169724
|
return this.projectService.getIncompleteCompletionsCache();
|
|
169528
169725
|
};
|
|
169726
|
+
/*@internal*/
|
|
169727
|
+
Project.prototype.getNoDtsResolutionProject = function (rootFileNames) {
|
|
169728
|
+
var _this = this;
|
|
169729
|
+
ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic);
|
|
169730
|
+
if (!this.noDtsResolutionProject) {
|
|
169731
|
+
this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169732
|
+
}
|
|
169733
|
+
ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) {
|
|
169734
|
+
var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost);
|
|
169735
|
+
if (info) {
|
|
169736
|
+
_this.noDtsResolutionProject.addRoot(info, pathToAdd);
|
|
169737
|
+
}
|
|
169738
|
+
}, function (pathToRemove) {
|
|
169739
|
+
// It may be preferable to remove roots only once project grows to a certain size?
|
|
169740
|
+
var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove);
|
|
169741
|
+
if (info) {
|
|
169742
|
+
_this.noDtsResolutionProject.removeRoot(info);
|
|
169743
|
+
}
|
|
169744
|
+
});
|
|
169745
|
+
return this.noDtsResolutionProject;
|
|
169746
|
+
};
|
|
169747
|
+
/*@internal*/
|
|
169748
|
+
Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () {
|
|
169749
|
+
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 });
|
|
169750
|
+
};
|
|
169529
169751
|
return Project;
|
|
169530
169752
|
}());
|
|
169531
169753
|
server.Project = Project;
|
|
@@ -169641,6 +169863,26 @@ var ts;
|
|
|
169641
169863
|
return InferredProject;
|
|
169642
169864
|
}(Project));
|
|
169643
169865
|
server.InferredProject = InferredProject;
|
|
169866
|
+
var AuxiliaryProject = /** @class */ (function (_super) {
|
|
169867
|
+
__extends(AuxiliaryProject, _super);
|
|
169868
|
+
function AuxiliaryProject(projectService, documentRegistry, compilerOptions) {
|
|
169869
|
+
return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry,
|
|
169870
|
+
/*hasExplicitListOfFiles*/ false,
|
|
169871
|
+
/*lastFileExceededProgramSize*/ undefined, compilerOptions,
|
|
169872
|
+
/*compileOnSaveEnabled*/ false,
|
|
169873
|
+
/*watchOptions*/ undefined, projectService.host,
|
|
169874
|
+
/*currentDirectory*/ undefined) || this;
|
|
169875
|
+
}
|
|
169876
|
+
AuxiliaryProject.prototype.isOrphan = function () {
|
|
169877
|
+
return true;
|
|
169878
|
+
};
|
|
169879
|
+
/*@internal*/
|
|
169880
|
+
AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
169881
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
169882
|
+
return;
|
|
169883
|
+
};
|
|
169884
|
+
return AuxiliaryProject;
|
|
169885
|
+
}(Project));
|
|
169644
169886
|
var AutoImportProviderProject = /** @class */ (function (_super) {
|
|
169645
169887
|
__extends(AutoImportProviderProject, _super);
|
|
169646
169888
|
/*@internal*/
|
|
@@ -169792,6 +170034,11 @@ var ts;
|
|
|
169792
170034
|
}
|
|
169793
170035
|
return hasSameSetOfFiles;
|
|
169794
170036
|
};
|
|
170037
|
+
/*@internal*/
|
|
170038
|
+
AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
170039
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
170040
|
+
return;
|
|
170041
|
+
};
|
|
169795
170042
|
AutoImportProviderProject.prototype.hasRoots = function () {
|
|
169796
170043
|
var _a;
|
|
169797
170044
|
return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length);
|
|
@@ -170477,6 +170724,8 @@ var ts;
|
|
|
170477
170724
|
this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName);
|
|
170478
170725
|
/*@internal*/
|
|
170479
170726
|
this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName);
|
|
170727
|
+
/*@internal*/
|
|
170728
|
+
this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName);
|
|
170480
170729
|
/**
|
|
170481
170730
|
* Open files: with value being project root path, and key being Path of the file that is open
|
|
170482
170731
|
*/
|
|
@@ -170680,13 +170929,15 @@ var ts;
|
|
|
170680
170929
|
ProjectService.prototype.delayUpdateProjectGraph = function (project) {
|
|
170681
170930
|
var _this = this;
|
|
170682
170931
|
project.markAsDirty();
|
|
170683
|
-
|
|
170684
|
-
|
|
170685
|
-
|
|
170686
|
-
|
|
170687
|
-
|
|
170688
|
-
|
|
170689
|
-
|
|
170932
|
+
if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) {
|
|
170933
|
+
var projectName_1 = project.getProjectName();
|
|
170934
|
+
this.pendingProjectUpdates.set(projectName_1, project);
|
|
170935
|
+
this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () {
|
|
170936
|
+
if (_this.pendingProjectUpdates.delete(projectName_1)) {
|
|
170937
|
+
updateProjectIfDirty(project);
|
|
170938
|
+
}
|
|
170939
|
+
});
|
|
170940
|
+
}
|
|
170690
170941
|
};
|
|
170691
170942
|
/*@internal*/
|
|
170692
170943
|
ProjectService.prototype.hasPendingProjectUpdate = function (project) {
|
|
@@ -172967,7 +173218,7 @@ var ts;
|
|
|
172967
173218
|
var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo);
|
|
172968
173219
|
this.filenameToScriptInfo.forEach(function (info) {
|
|
172969
173220
|
// If script info is open or orphan, retain it and its dependencies
|
|
172970
|
-
if (!info.isScriptOpen() && info.isOrphan() && !info.
|
|
173221
|
+
if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) {
|
|
172971
173222
|
// Otherwise if there is any source info that is alive, this alive too
|
|
172972
173223
|
if (!info.sourceMapFilePath)
|
|
172973
173224
|
return;
|
|
@@ -174263,6 +174514,9 @@ var ts;
|
|
|
174263
174514
|
_a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
|
|
174264
174515
|
return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
174265
174516
|
},
|
|
174517
|
+
_a[server.CommandNames.FindSourceDefinition] = function (request) {
|
|
174518
|
+
return _this.requiredResponse(_this.findSourceDefinition(request.arguments));
|
|
174519
|
+
},
|
|
174266
174520
|
_a[server.CommandNames.EmitOutput] = function (request) {
|
|
174267
174521
|
return _this.requiredResponse(_this.getEmitOutput(request.arguments));
|
|
174268
174522
|
},
|
|
@@ -175004,7 +175258,7 @@ var ts;
|
|
|
175004
175258
|
Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
|
|
175005
175259
|
return definitions.map(function (info) {
|
|
175006
175260
|
var newDocumentSpan = getMappedDocumentSpan(info, project);
|
|
175007
|
-
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
|
|
175261
|
+
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 });
|
|
175008
175262
|
});
|
|
175009
175263
|
};
|
|
175010
175264
|
Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
|
|
@@ -175031,6 +175285,152 @@ var ts;
|
|
|
175031
175285
|
textSpan: textSpan,
|
|
175032
175286
|
};
|
|
175033
175287
|
};
|
|
175288
|
+
Session.prototype.findSourceDefinition = function (args) {
|
|
175289
|
+
var _a;
|
|
175290
|
+
var _b = this.getFileAndProject(args), file = _b.file, project = _b.project;
|
|
175291
|
+
var position = this.getPositionInFile(args, file);
|
|
175292
|
+
var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position);
|
|
175293
|
+
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice();
|
|
175294
|
+
var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) ||
|
|
175295
|
+
ts.some(definitions, function (d) { return !!d.failedAliasResolution; }));
|
|
175296
|
+
if (needsJsResolution) {
|
|
175297
|
+
var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual);
|
|
175298
|
+
definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); });
|
|
175299
|
+
var noDtsProject = project.getNoDtsResolutionProject([file]);
|
|
175300
|
+
var ls = noDtsProject.getLanguageService();
|
|
175301
|
+
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; });
|
|
175302
|
+
if (ts.some(jsDefinitions)) {
|
|
175303
|
+
for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) {
|
|
175304
|
+
var jsDefinition = jsDefinitions_1[_i];
|
|
175305
|
+
if (jsDefinition.unverified) {
|
|
175306
|
+
var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
|
|
175307
|
+
if (ts.some(refined)) {
|
|
175308
|
+
for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) {
|
|
175309
|
+
var def = refined_1[_c];
|
|
175310
|
+
definitionSet_1.add(def);
|
|
175311
|
+
}
|
|
175312
|
+
continue;
|
|
175313
|
+
}
|
|
175314
|
+
}
|
|
175315
|
+
definitionSet_1.add(jsDefinition);
|
|
175316
|
+
}
|
|
175317
|
+
}
|
|
175318
|
+
else {
|
|
175319
|
+
var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; });
|
|
175320
|
+
for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) {
|
|
175321
|
+
var candidate = _e[_d];
|
|
175322
|
+
var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
|
|
175323
|
+
if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
|
|
175324
|
+
continue;
|
|
175325
|
+
}
|
|
175326
|
+
var noDtsProgram = ls.getProgram();
|
|
175327
|
+
var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
|
|
175328
|
+
for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) {
|
|
175329
|
+
var match = _g[_f];
|
|
175330
|
+
definitionSet_1.add(match);
|
|
175331
|
+
}
|
|
175332
|
+
}
|
|
175333
|
+
}
|
|
175334
|
+
definitions = ts.arrayFrom(definitionSet_1.values());
|
|
175335
|
+
}
|
|
175336
|
+
definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
|
|
175337
|
+
return this.mapDefinitionInfo(definitions, project);
|
|
175338
|
+
function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
|
|
175339
|
+
var _a;
|
|
175340
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
|
|
175341
|
+
if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
|
|
175342
|
+
// Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
|
|
175343
|
+
var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
|
175344
|
+
var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
|
|
175345
|
+
var compilerOptions = project.getCompilationSettings();
|
|
175346
|
+
var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
|
|
175347
|
+
if (!packageJson)
|
|
175348
|
+
return undefined;
|
|
175349
|
+
// Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext -
|
|
175350
|
+
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
|
175351
|
+
// resolved from the package root under --moduleResolution node
|
|
175352
|
+
var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache());
|
|
175353
|
+
// This substring is correct only because we checked for a single `/node_modules/` at the top.
|
|
175354
|
+
var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex);
|
|
175355
|
+
var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart));
|
|
175356
|
+
var path_1 = project.toPath(fileName);
|
|
175357
|
+
if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) {
|
|
175358
|
+
// This file was the main entrypoint of a package. Try to resolve that same package name with
|
|
175359
|
+
// the auxiliary project that only resolves to implementation files.
|
|
175360
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
|
|
175361
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175362
|
+
}
|
|
175363
|
+
else {
|
|
175364
|
+
// It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
|
|
175365
|
+
var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
|
|
175366
|
+
var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
|
|
175367
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
|
|
175368
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175369
|
+
}
|
|
175370
|
+
}
|
|
175371
|
+
// We're not in node_modules, and we only get to this function if non-dts module resolution failed.
|
|
175372
|
+
// I'm not sure what else I can do here that isn't already covered by that module resolution.
|
|
175373
|
+
return undefined;
|
|
175374
|
+
}
|
|
175375
|
+
// In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition
|
|
175376
|
+
// for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later.
|
|
175377
|
+
function getAmbientCandidatesByClimbingAccessChain() {
|
|
175378
|
+
var ls = project.getLanguageService();
|
|
175379
|
+
var program = ls.getProgram();
|
|
175380
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175381
|
+
if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) {
|
|
175382
|
+
return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) {
|
|
175383
|
+
var _a;
|
|
175384
|
+
if (nameInChain === initialNode)
|
|
175385
|
+
return undefined;
|
|
175386
|
+
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 ({
|
|
175387
|
+
fileName: d.fileName,
|
|
175388
|
+
name: ts.getTextOfIdentifierOrLiteral(initialNode)
|
|
175389
|
+
}); });
|
|
175390
|
+
if (ts.some(candidates)) {
|
|
175391
|
+
return candidates;
|
|
175392
|
+
}
|
|
175393
|
+
}) || server.emptyArray;
|
|
175394
|
+
}
|
|
175395
|
+
return server.emptyArray;
|
|
175396
|
+
}
|
|
175397
|
+
function tryRefineDefinition(definition, program, noDtsProgram) {
|
|
175398
|
+
var _a;
|
|
175399
|
+
var fileToSearch = noDtsProgram.getSourceFile(definition.fileName);
|
|
175400
|
+
if (!fileToSearch) {
|
|
175401
|
+
return undefined;
|
|
175402
|
+
}
|
|
175403
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175404
|
+
var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
|
|
175405
|
+
var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */);
|
|
175406
|
+
if (!importSpecifier)
|
|
175407
|
+
return undefined;
|
|
175408
|
+
var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text;
|
|
175409
|
+
return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram);
|
|
175410
|
+
}
|
|
175411
|
+
function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) {
|
|
175412
|
+
var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
|
|
175413
|
+
return ts.mapDefined(matches, function (match) {
|
|
175414
|
+
var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match);
|
|
175415
|
+
var decl = ts.getDeclarationFromName(match);
|
|
175416
|
+
if (symbol && decl) {
|
|
175417
|
+
// I think the last argument to this is supposed to be the start node, but it doesn't seem important.
|
|
175418
|
+
// Callers internal to GoToDefinition already get confused about this.
|
|
175419
|
+
return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true);
|
|
175420
|
+
}
|
|
175421
|
+
});
|
|
175422
|
+
}
|
|
175423
|
+
function ensureRoot(project, fileName) {
|
|
175424
|
+
var info = project.getScriptInfo(fileName);
|
|
175425
|
+
if (!info)
|
|
175426
|
+
return false;
|
|
175427
|
+
if (!project.containsScriptInfo(info)) {
|
|
175428
|
+
project.addRoot(info);
|
|
175429
|
+
project.updateGraph();
|
|
175430
|
+
}
|
|
175431
|
+
return true;
|
|
175432
|
+
}
|
|
175433
|
+
};
|
|
175034
175434
|
Session.prototype.getEmitOutput = function (args) {
|
|
175035
175435
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
175036
175436
|
if (!project.shouldEmitFile(project.getScriptInfo(file))) {
|
|
@@ -175594,7 +175994,7 @@ var ts;
|
|
|
175594
175994
|
return undefined;
|
|
175595
175995
|
}
|
|
175596
175996
|
var compilationSettings = project.getCompilationSettings();
|
|
175597
|
-
if (!!compilationSettings.noEmit || ts.
|
|
175997
|
+
if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) {
|
|
175598
175998
|
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
|
|
175599
175999
|
return undefined;
|
|
175600
176000
|
}
|
|
@@ -176074,7 +176474,7 @@ var ts;
|
|
|
176074
176474
|
else {
|
|
176075
176475
|
var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217
|
|
176076
176476
|
if (!info.isScriptOpen()) {
|
|
176077
|
-
if (ts.
|
|
176477
|
+
if (ts.isDeclarationFileName(fileNameInProject)) {
|
|
176078
176478
|
veryLowPriorityFiles.push(fileNameInProject);
|
|
176079
176479
|
}
|
|
176080
176480
|
else {
|