@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/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220420";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -4854,7 +4854,6 @@ var ts;
|
|
|
4854
4854
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4855
4855
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4856
4856
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4857
|
-
NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
|
|
4858
4857
|
// Error handling
|
|
4859
4858
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4860
4859
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -8911,6 +8910,7 @@ var ts;
|
|
|
8911
8910
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8912
8911
|
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."),
|
|
8913
8912
|
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."),
|
|
8913
|
+
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."),
|
|
8914
8914
|
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."),
|
|
8915
8915
|
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."),
|
|
8916
8916
|
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."),
|
|
@@ -15159,6 +15159,10 @@ var ts;
|
|
|
15159
15159
|
}
|
|
15160
15160
|
}
|
|
15161
15161
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
15162
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
15163
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
15164
|
+
}
|
|
15165
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
15162
15166
|
function isLateVisibilityPaintedStatement(node) {
|
|
15163
15167
|
switch (node.kind) {
|
|
15164
15168
|
case 266 /* ImportDeclaration */:
|
|
@@ -16519,17 +16523,13 @@ var ts;
|
|
|
16519
16523
|
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
|
16520
16524
|
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
|
|
16521
16525
|
}
|
|
16522
|
-
if (ts.
|
|
16526
|
+
if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
|
|
16523
16527
|
(initializer.expression.kind === 108 /* ThisKeyword */ ||
|
|
16524
16528
|
ts.isIdentifier(initializer.expression) &&
|
|
16525
16529
|
(initializer.expression.escapedText === "window" ||
|
|
16526
16530
|
initializer.expression.escapedText === "self" ||
|
|
16527
16531
|
initializer.expression.escapedText === "global"))) {
|
|
16528
|
-
|
|
16529
|
-
if (ts.isPrivateIdentifier(nameOrArgument)) {
|
|
16530
|
-
ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
|
16531
|
-
}
|
|
16532
|
-
return isSameEntityName(name, nameOrArgument);
|
|
16532
|
+
return isSameEntityName(name, getNameOrArgument(initializer));
|
|
16533
16533
|
}
|
|
16534
16534
|
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
|
16535
16535
|
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
|
@@ -16737,14 +16737,14 @@ var ts;
|
|
|
16737
16737
|
}
|
|
16738
16738
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16739
16739
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16740
|
-
var _a, _b
|
|
16740
|
+
var _a, _b;
|
|
16741
16741
|
switch (node.kind) {
|
|
16742
16742
|
case 254 /* VariableDeclaration */:
|
|
16743
|
-
return node.initializer.arguments[0]
|
|
16743
|
+
return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
|
|
16744
16744
|
case 266 /* ImportDeclaration */:
|
|
16745
|
-
return
|
|
16745
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16746
16746
|
case 265 /* ImportEqualsDeclaration */:
|
|
16747
|
-
return
|
|
16747
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16748
16748
|
default:
|
|
16749
16749
|
ts.Debug.assertNever(node);
|
|
16750
16750
|
}
|
|
@@ -17259,7 +17259,10 @@ var ts;
|
|
|
17259
17259
|
return parent.propertyName === node;
|
|
17260
17260
|
case 275 /* ExportSpecifier */:
|
|
17261
17261
|
case 285 /* JsxAttribute */:
|
|
17262
|
-
|
|
17262
|
+
case 279 /* JsxSelfClosingElement */:
|
|
17263
|
+
case 280 /* JsxOpeningElement */:
|
|
17264
|
+
case 281 /* JsxClosingElement */:
|
|
17265
|
+
// Any name in an export specifier or JSX Attribute or Jsx Element
|
|
17263
17266
|
return true;
|
|
17264
17267
|
}
|
|
17265
17268
|
return false;
|
|
@@ -17275,21 +17278,28 @@ var ts;
|
|
|
17275
17278
|
// export = <EntityNameExpression>
|
|
17276
17279
|
// export default <EntityNameExpression>
|
|
17277
17280
|
// module.exports = <EntityNameExpression>
|
|
17278
|
-
//
|
|
17279
|
-
//
|
|
17281
|
+
// module.exports.x = <EntityNameExpression>
|
|
17282
|
+
// const x = require("...")
|
|
17283
|
+
// const { x } = require("...")
|
|
17284
|
+
// const x = require("...").y
|
|
17285
|
+
// const { x } = require("...").y
|
|
17280
17286
|
function isAliasSymbolDeclaration(node) {
|
|
17281
|
-
|
|
17287
|
+
if (node.kind === 265 /* ImportEqualsDeclaration */ ||
|
|
17282
17288
|
node.kind === 264 /* NamespaceExportDeclaration */ ||
|
|
17283
17289
|
node.kind === 267 /* ImportClause */ && !!node.name ||
|
|
17284
17290
|
node.kind === 268 /* NamespaceImport */ ||
|
|
17285
17291
|
node.kind === 274 /* NamespaceExport */ ||
|
|
17286
17292
|
node.kind === 270 /* ImportSpecifier */ ||
|
|
17287
17293
|
node.kind === 275 /* ExportSpecifier */ ||
|
|
17288
|
-
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17294
|
+
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
|
|
17295
|
+
return true;
|
|
17296
|
+
}
|
|
17297
|
+
return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
|
|
17298
|
+
ts.isPropertyAccessExpression(node)
|
|
17299
|
+
&& ts.isBinaryExpression(node.parent)
|
|
17300
|
+
&& node.parent.left === node
|
|
17301
|
+
&& node.parent.operatorToken.kind === 63 /* EqualsToken */
|
|
17302
|
+
&& isAliasableExpression(node.parent.right));
|
|
17293
17303
|
}
|
|
17294
17304
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17295
17305
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17300,6 +17310,7 @@ var ts;
|
|
|
17300
17310
|
case 275 /* ExportSpecifier */:
|
|
17301
17311
|
case 271 /* ExportAssignment */:
|
|
17302
17312
|
case 265 /* ImportEqualsDeclaration */:
|
|
17313
|
+
case 274 /* NamespaceExport */:
|
|
17303
17314
|
return node.parent;
|
|
17304
17315
|
case 161 /* QualifiedName */:
|
|
17305
17316
|
do {
|
|
@@ -19126,6 +19137,11 @@ var ts;
|
|
|
19126
19137
|
(node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
19127
19138
|
}
|
|
19128
19139
|
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
|
|
19140
|
+
function isRightSideOfAccessExpression(node) {
|
|
19141
|
+
return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
19142
|
+
|| ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
|
|
19143
|
+
}
|
|
19144
|
+
ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
|
|
19129
19145
|
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
|
19130
19146
|
return ts.isQualifiedName(node.parent) && node.parent.right === node
|
|
19131
19147
|
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
@@ -19777,6 +19793,41 @@ var ts;
|
|
|
19777
19793
|
return expr;
|
|
19778
19794
|
}
|
|
19779
19795
|
ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
|
|
19796
|
+
function forEachNameInAccessChainWalkingLeft(name, action) {
|
|
19797
|
+
if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
|
|
19798
|
+
return walkAccessExpression(name.parent);
|
|
19799
|
+
}
|
|
19800
|
+
function walkAccessExpression(access) {
|
|
19801
|
+
if (access.kind === 206 /* PropertyAccessExpression */) {
|
|
19802
|
+
var res = action(access.name);
|
|
19803
|
+
if (res !== undefined) {
|
|
19804
|
+
return res;
|
|
19805
|
+
}
|
|
19806
|
+
}
|
|
19807
|
+
else if (access.kind === 207 /* ElementAccessExpression */) {
|
|
19808
|
+
if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
|
|
19809
|
+
var res = action(access.argumentExpression);
|
|
19810
|
+
if (res !== undefined) {
|
|
19811
|
+
return res;
|
|
19812
|
+
}
|
|
19813
|
+
}
|
|
19814
|
+
else {
|
|
19815
|
+
// Chain interrupted by non-static-name access 'x[expr()].y.z'
|
|
19816
|
+
return undefined;
|
|
19817
|
+
}
|
|
19818
|
+
}
|
|
19819
|
+
if (isAccessExpression(access.expression)) {
|
|
19820
|
+
return walkAccessExpression(access.expression);
|
|
19821
|
+
}
|
|
19822
|
+
if (ts.isIdentifier(access.expression)) {
|
|
19823
|
+
// End of chain at Identifier 'x.y.z'
|
|
19824
|
+
return action(access.expression);
|
|
19825
|
+
}
|
|
19826
|
+
// End of chain at non-Identifier 'x().y.z'
|
|
19827
|
+
return undefined;
|
|
19828
|
+
}
|
|
19829
|
+
}
|
|
19830
|
+
ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
|
|
19780
19831
|
function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
19781
19832
|
while (true) {
|
|
19782
19833
|
switch (node.kind) {
|
|
@@ -20724,6 +20775,7 @@ var ts;
|
|
|
20724
20775
|
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20725
20776
|
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 */]];
|
|
20726
20777
|
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20778
|
+
ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
|
|
20727
20779
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20728
20780
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20729
20781
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
@@ -21412,6 +21464,11 @@ var ts;
|
|
|
21412
21464
|
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21413
21465
|
}
|
|
21414
21466
|
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
21467
|
+
function getParameterTypeNode(parameter) {
|
|
21468
|
+
var _a;
|
|
21469
|
+
return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21470
|
+
}
|
|
21471
|
+
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21415
21472
|
})(ts || (ts = {}));
|
|
21416
21473
|
/* @internal */
|
|
21417
21474
|
var ts;
|
|
@@ -33323,7 +33380,8 @@ var ts;
|
|
|
33323
33380
|
var pos = getNodePos();
|
|
33324
33381
|
parseExpected(112 /* TypeOfKeyword */);
|
|
33325
33382
|
var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
|
33326
|
-
|
|
33383
|
+
// Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression.
|
|
33384
|
+
var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
|
|
33327
33385
|
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
33328
33386
|
}
|
|
33329
33387
|
function parseTypeParameter() {
|
|
@@ -34642,23 +34700,7 @@ var ts;
|
|
|
34642
34700
|
return undefined;
|
|
34643
34701
|
}
|
|
34644
34702
|
}
|
|
34645
|
-
|
|
34646
|
-
// x ? y => ({ y }) : z => ({ z })
|
|
34647
|
-
// We try to parse the body of the first arrow function by looking at:
|
|
34648
|
-
// ({ y }) : z => ({ z })
|
|
34649
|
-
// This is a valid arrow function with "z" as the return type.
|
|
34650
|
-
//
|
|
34651
|
-
// But, if we're in the true side of a conditional expression, this colon
|
|
34652
|
-
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34653
|
-
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34654
|
-
//
|
|
34655
|
-
// For example,
|
|
34656
|
-
// a() ? (b: number, c?: string): void => d() : e
|
|
34657
|
-
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34658
|
-
// be an arrow expression, so we allow a return type.
|
|
34659
|
-
if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) {
|
|
34660
|
-
return undefined;
|
|
34661
|
-
}
|
|
34703
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
34662
34704
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
34663
34705
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
34664
34706
|
return undefined;
|
|
@@ -34689,6 +34731,30 @@ var ts;
|
|
|
34689
34731
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
34690
34732
|
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), disallowReturnTypeInArrowFunction)
|
|
34691
34733
|
: parseIdentifier();
|
|
34734
|
+
// Given:
|
|
34735
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
34736
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
34737
|
+
// ({ y }) : z => ({ z })
|
|
34738
|
+
// This is a valid arrow function with "z" as the return type.
|
|
34739
|
+
//
|
|
34740
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
34741
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34742
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34743
|
+
//
|
|
34744
|
+
// For example,
|
|
34745
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
34746
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34747
|
+
// be an arrow expression, so we allow a return type.
|
|
34748
|
+
if (disallowReturnTypeInArrowFunction && hasReturnColon) {
|
|
34749
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
34750
|
+
// as in:
|
|
34751
|
+
// a ? (x): string => x : null
|
|
34752
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
34753
|
+
// the conditional expression.
|
|
34754
|
+
if (token() !== 58 /* ColonToken */) {
|
|
34755
|
+
return undefined;
|
|
34756
|
+
}
|
|
34757
|
+
}
|
|
34692
34758
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
34693
34759
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
34694
34760
|
}
|
|
@@ -35565,34 +35631,10 @@ var ts;
|
|
|
35565
35631
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
35566
35632
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
35567
35633
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
35568
|
-
// These tokens can't follow in a call expression, nor can they start an
|
|
35569
|
-
// expression. So, consider the type argument list part of an instantiation
|
|
35570
|
-
// expression.
|
|
35571
|
-
// falls through
|
|
35572
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
35573
|
-
case 24 /* DotToken */: // foo<x>.
|
|
35574
|
-
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
35575
|
-
case 21 /* CloseParenToken */: // foo<x>)
|
|
35576
|
-
case 23 /* CloseBracketToken */: // foo<x>]
|
|
35577
|
-
case 58 /* ColonToken */: // foo<x>:
|
|
35578
|
-
case 26 /* SemicolonToken */: // foo<x>;
|
|
35579
|
-
case 57 /* QuestionToken */: // foo<x>?
|
|
35580
|
-
case 34 /* EqualsEqualsToken */: // foo<x> ==
|
|
35581
|
-
case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
35582
|
-
case 35 /* ExclamationEqualsToken */: // foo<x> !=
|
|
35583
|
-
case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
35584
|
-
case 55 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
35585
|
-
case 56 /* BarBarToken */: // foo<x> ||
|
|
35586
|
-
case 60 /* QuestionQuestionToken */: // foo<x> ??
|
|
35587
|
-
case 52 /* CaretToken */: // foo<x> ^
|
|
35588
|
-
case 50 /* AmpersandToken */: // foo<x> &
|
|
35589
|
-
case 51 /* BarToken */: // foo<x> |
|
|
35590
|
-
case 19 /* CloseBraceToken */: // foo<x> }
|
|
35591
|
-
case 1 /* EndOfFileToken */: // foo<x>
|
|
35592
35634
|
return true;
|
|
35593
35635
|
}
|
|
35594
|
-
//
|
|
35595
|
-
return
|
|
35636
|
+
// Consider something a type argument list only if the following token can't start an expression.
|
|
35637
|
+
return !isStartOfExpression();
|
|
35596
35638
|
}
|
|
35597
35639
|
function parsePrimaryExpression() {
|
|
35598
35640
|
switch (token()) {
|
|
@@ -38810,7 +38852,7 @@ var ts;
|
|
|
38810
38852
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
38811
38853
|
/** @internal */
|
|
38812
38854
|
function isDeclarationFileName(fileName) {
|
|
38813
|
-
return ts.fileExtensionIsOneOf(fileName,
|
|
38855
|
+
return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
|
|
38814
38856
|
}
|
|
38815
38857
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38816
38858
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
@@ -42318,7 +42360,8 @@ var ts;
|
|
|
42318
42360
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42319
42361
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42320
42362
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42321
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42363
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42364
|
+
Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
|
|
42322
42365
|
})(Extensions || (Extensions = {}));
|
|
42323
42366
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42324
42367
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -43263,7 +43306,21 @@ var ts;
|
|
|
43263
43306
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43264
43307
|
}
|
|
43265
43308
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
43266
|
-
|
|
43309
|
+
var extensions;
|
|
43310
|
+
if (lookupConfig) {
|
|
43311
|
+
extensions = tsconfigExtensions;
|
|
43312
|
+
}
|
|
43313
|
+
else if (compilerOptions.noDtsResolution) {
|
|
43314
|
+
extensions = [Extensions.TsOnly];
|
|
43315
|
+
if (compilerOptions.allowJs)
|
|
43316
|
+
extensions.push(Extensions.JavaScript);
|
|
43317
|
+
if (compilerOptions.resolveJsonModule)
|
|
43318
|
+
extensions.push(Extensions.Json);
|
|
43319
|
+
}
|
|
43320
|
+
else {
|
|
43321
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
43322
|
+
}
|
|
43323
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
43267
43324
|
}
|
|
43268
43325
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
43269
43326
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -43272,6 +43329,10 @@ var ts;
|
|
|
43272
43329
|
var failedLookupLocations = [];
|
|
43273
43330
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
43274
43331
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43332
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43333
|
+
if (compilerOptions.noDtsResolution) {
|
|
43334
|
+
conditions.pop();
|
|
43335
|
+
}
|
|
43275
43336
|
var state = {
|
|
43276
43337
|
compilerOptions: compilerOptions,
|
|
43277
43338
|
host: host,
|
|
@@ -43279,7 +43340,7 @@ var ts;
|
|
|
43279
43340
|
failedLookupLocations: failedLookupLocations,
|
|
43280
43341
|
packageJsonInfoCache: cache,
|
|
43281
43342
|
features: features,
|
|
43282
|
-
conditions:
|
|
43343
|
+
conditions: conditions,
|
|
43283
43344
|
};
|
|
43284
43345
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43285
43346
|
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);
|
|
@@ -43455,9 +43516,9 @@ var ts;
|
|
|
43455
43516
|
}
|
|
43456
43517
|
}
|
|
43457
43518
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43458
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43519
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
|
|
43459
43520
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43460
|
-
return result !== undefined ? { path: candidate, ext: ts.forEach(
|
|
43521
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
43461
43522
|
}
|
|
43462
43523
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43463
43524
|
}
|
|
@@ -43487,20 +43548,22 @@ var ts;
|
|
|
43487
43548
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43488
43549
|
}
|
|
43489
43550
|
case Extensions.TypeScript:
|
|
43551
|
+
case Extensions.TsOnly:
|
|
43552
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43490
43553
|
switch (originalExtension) {
|
|
43491
43554
|
case ".mjs" /* Mjs */:
|
|
43492
43555
|
case ".mts" /* Mts */:
|
|
43493
43556
|
case ".d.mts" /* Dmts */:
|
|
43494
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43557
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43495
43558
|
case ".cjs" /* Cjs */:
|
|
43496
43559
|
case ".cts" /* Cts */:
|
|
43497
43560
|
case ".d.cts" /* Dcts */:
|
|
43498
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43561
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43499
43562
|
case ".json" /* Json */:
|
|
43500
43563
|
candidate += ".json" /* Json */;
|
|
43501
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43564
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43502
43565
|
default:
|
|
43503
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43566
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43504
43567
|
}
|
|
43505
43568
|
case Extensions.JavaScript:
|
|
43506
43569
|
switch (originalExtension) {
|
|
@@ -43727,6 +43790,7 @@ var ts;
|
|
|
43727
43790
|
switch (extensions) {
|
|
43728
43791
|
case Extensions.JavaScript:
|
|
43729
43792
|
case Extensions.Json:
|
|
43793
|
+
case Extensions.TsOnly:
|
|
43730
43794
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43731
43795
|
break;
|
|
43732
43796
|
case Extensions.TypeScript:
|
|
@@ -43799,14 +43863,16 @@ var ts;
|
|
|
43799
43863
|
function extensionIsOk(extensions, extension) {
|
|
43800
43864
|
switch (extensions) {
|
|
43801
43865
|
case Extensions.JavaScript:
|
|
43802
|
-
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
43866
|
+
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
|
|
43803
43867
|
case Extensions.TSConfig:
|
|
43804
43868
|
case Extensions.Json:
|
|
43805
43869
|
return extension === ".json" /* Json */;
|
|
43806
43870
|
case Extensions.TypeScript:
|
|
43807
|
-
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43871
|
+
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 */;
|
|
43872
|
+
case Extensions.TsOnly:
|
|
43873
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
|
|
43808
43874
|
case Extensions.DtsOnly:
|
|
43809
|
-
return extension === ".d.ts" /* Dts */;
|
|
43875
|
+
return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43810
43876
|
}
|
|
43811
43877
|
}
|
|
43812
43878
|
/* @internal */
|
|
@@ -45966,6 +46032,7 @@ var ts;
|
|
|
45966
46032
|
case 261 /* ModuleDeclaration */:
|
|
45967
46033
|
case 259 /* TypeAliasDeclaration */:
|
|
45968
46034
|
case 195 /* MappedType */:
|
|
46035
|
+
case 176 /* IndexSignature */:
|
|
45969
46036
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45970
46037
|
case 305 /* SourceFile */:
|
|
45971
46038
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45984,7 +46051,6 @@ var ts;
|
|
|
45984
46051
|
case 317 /* JSDocFunctionType */:
|
|
45985
46052
|
case 179 /* FunctionType */:
|
|
45986
46053
|
case 175 /* ConstructSignature */:
|
|
45987
|
-
case 176 /* IndexSignature */:
|
|
45988
46054
|
case 180 /* ConstructorType */:
|
|
45989
46055
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45990
46056
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -50562,27 +50628,27 @@ var ts;
|
|
|
50562
50628
|
function resolveAlias(symbol) {
|
|
50563
50629
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50564
50630
|
var links = getSymbolLinks(symbol);
|
|
50565
|
-
if (!links.
|
|
50566
|
-
links.
|
|
50631
|
+
if (!links.aliasTarget) {
|
|
50632
|
+
links.aliasTarget = resolvingSymbol;
|
|
50567
50633
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50568
50634
|
if (!node)
|
|
50569
50635
|
return ts.Debug.fail();
|
|
50570
50636
|
var target = getTargetOfAliasDeclaration(node);
|
|
50571
|
-
if (links.
|
|
50572
|
-
links.
|
|
50637
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50638
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50573
50639
|
}
|
|
50574
50640
|
else {
|
|
50575
50641
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50576
50642
|
}
|
|
50577
50643
|
}
|
|
50578
|
-
else if (links.
|
|
50579
|
-
links.
|
|
50644
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50645
|
+
links.aliasTarget = unknownSymbol;
|
|
50580
50646
|
}
|
|
50581
|
-
return links.
|
|
50647
|
+
return links.aliasTarget;
|
|
50582
50648
|
}
|
|
50583
50649
|
function tryResolveAlias(symbol) {
|
|
50584
50650
|
var links = getSymbolLinks(symbol);
|
|
50585
|
-
if (links.
|
|
50651
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50586
50652
|
return resolveAlias(symbol);
|
|
50587
50653
|
}
|
|
50588
50654
|
return undefined;
|
|
@@ -52379,13 +52445,37 @@ var ts;
|
|
|
52379
52445
|
return ts.Debug.fail("Should be unreachable.");
|
|
52380
52446
|
function conditionalTypeToTypeNode(type) {
|
|
52381
52447
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52448
|
+
context.approximateLength += 15;
|
|
52449
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52450
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52451
|
+
var name = typeParameterToName(newParam, context);
|
|
52452
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52453
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52454
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52455
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52456
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52457
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52458
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52459
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52460
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52461
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52462
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52463
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52464
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52465
|
+
// this is potentially simplifiable to
|
|
52466
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52467
|
+
// but that may confuse users who read the output more.
|
|
52468
|
+
// On the other hand,
|
|
52469
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52470
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52471
|
+
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 */));
|
|
52472
|
+
}
|
|
52382
52473
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
52383
52474
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52384
52475
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
52385
52476
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
52386
52477
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
52387
52478
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
52388
|
-
context.approximateLength += 15;
|
|
52389
52479
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
52390
52480
|
}
|
|
52391
52481
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -52499,7 +52589,7 @@ var ts;
|
|
|
52499
52589
|
// Since instantiations of the same anonymous type have the same symbol, tracking symbols instead
|
|
52500
52590
|
// of types allows us to catch circular references to instantiations of the same anonymous type
|
|
52501
52591
|
if (!context.visitedTypes) {
|
|
52502
|
-
context.visitedTypes = new ts.
|
|
52592
|
+
context.visitedTypes = new ts.Set();
|
|
52503
52593
|
}
|
|
52504
52594
|
if (id && !context.symbolDepth) {
|
|
52505
52595
|
context.symbolDepth = new ts.Map();
|
|
@@ -52517,22 +52607,15 @@ var ts;
|
|
|
52517
52607
|
context.approximateLength += cachedResult.addedLength;
|
|
52518
52608
|
return deepCloneOrReuseNode(cachedResult);
|
|
52519
52609
|
}
|
|
52520
|
-
var
|
|
52521
|
-
var symbolDepth = id ? context.symbolDepth.get(id) : undefined;
|
|
52522
|
-
if (symbolDepth) {
|
|
52523
|
-
totalDepth += symbolDepth;
|
|
52524
|
-
}
|
|
52525
|
-
var visitedTypeDepth = context.visitedTypes.get(typeId);
|
|
52526
|
-
if (visitedTypeDepth) {
|
|
52527
|
-
totalDepth += visitedTypeDepth;
|
|
52528
|
-
}
|
|
52529
|
-
if (totalDepth > 10) {
|
|
52530
|
-
return createElidedInformationPlaceholder(context);
|
|
52531
|
-
}
|
|
52610
|
+
var depth;
|
|
52532
52611
|
if (id) {
|
|
52533
|
-
context.symbolDepth.
|
|
52612
|
+
depth = context.symbolDepth.get(id) || 0;
|
|
52613
|
+
if (depth > 10) {
|
|
52614
|
+
return createElidedInformationPlaceholder(context);
|
|
52615
|
+
}
|
|
52616
|
+
context.symbolDepth.set(id, depth + 1);
|
|
52534
52617
|
}
|
|
52535
|
-
context.visitedTypes.
|
|
52618
|
+
context.visitedTypes.add(typeId);
|
|
52536
52619
|
var startLength = context.approximateLength;
|
|
52537
52620
|
var result = transform(type);
|
|
52538
52621
|
var addedLength = context.approximateLength - startLength;
|
|
@@ -52543,19 +52626,9 @@ var ts;
|
|
|
52543
52626
|
result.addedLength = addedLength;
|
|
52544
52627
|
(_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result);
|
|
52545
52628
|
}
|
|
52546
|
-
|
|
52547
|
-
context.visitedTypes.set(typeId, visitedTypeDepth);
|
|
52548
|
-
}
|
|
52549
|
-
else {
|
|
52550
|
-
context.visitedTypes.delete(typeId);
|
|
52551
|
-
}
|
|
52629
|
+
context.visitedTypes.delete(typeId);
|
|
52552
52630
|
if (id) {
|
|
52553
|
-
|
|
52554
|
-
context.symbolDepth.set(id, symbolDepth);
|
|
52555
|
-
}
|
|
52556
|
-
else {
|
|
52557
|
-
context.symbolDepth.delete(id);
|
|
52558
|
-
}
|
|
52631
|
+
context.symbolDepth.set(id, depth);
|
|
52559
52632
|
}
|
|
52560
52633
|
return result;
|
|
52561
52634
|
function deepCloneOrReuseNode(node) {
|
|
@@ -53101,9 +53174,6 @@ var ts;
|
|
|
53101
53174
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
53102
53175
|
parameterType = getOptionalType(parameterType);
|
|
53103
53176
|
}
|
|
53104
|
-
if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
|
53105
|
-
parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
|
|
53106
|
-
}
|
|
53107
53177
|
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
53108
53178
|
var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
|
|
53109
53179
|
var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
@@ -53662,7 +53732,7 @@ var ts;
|
|
|
53662
53732
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
53663
53733
|
// try to reuse the existing annotation
|
|
53664
53734
|
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
53665
|
-
if (
|
|
53735
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
53666
53736
|
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
53667
53737
|
if (result_6) {
|
|
53668
53738
|
return result_6;
|
|
@@ -53679,6 +53749,16 @@ var ts;
|
|
|
53679
53749
|
context.flags = oldFlags;
|
|
53680
53750
|
return result;
|
|
53681
53751
|
}
|
|
53752
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
53753
|
+
var typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
53754
|
+
if (typeFromTypeNode === type) {
|
|
53755
|
+
return true;
|
|
53756
|
+
}
|
|
53757
|
+
if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
53758
|
+
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
53759
|
+
}
|
|
53760
|
+
return false;
|
|
53761
|
+
}
|
|
53682
53762
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
53683
53763
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
53684
53764
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
@@ -55950,7 +56030,7 @@ var ts;
|
|
|
55950
56030
|
}
|
|
55951
56031
|
}
|
|
55952
56032
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55953
|
-
type = getUnionType(sourceTypes
|
|
56033
|
+
type = getUnionType(sourceTypes);
|
|
55954
56034
|
}
|
|
55955
56035
|
}
|
|
55956
56036
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -58699,8 +58779,9 @@ var ts;
|
|
|
58699
58779
|
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
|
|
58700
58780
|
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
|
|
58701
58781
|
// nesting, so it is effectively just a safety stop.
|
|
58702
|
-
|
|
58703
|
-
|
|
58782
|
+
var identity_1 = getRecursionIdentity(t);
|
|
58783
|
+
if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
|
|
58784
|
+
stack.push(identity_1);
|
|
58704
58785
|
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
|
58705
58786
|
stack.pop();
|
|
58706
58787
|
}
|
|
@@ -62056,11 +62137,14 @@ var ts;
|
|
|
62056
62137
|
return type[cache] = elementType;
|
|
62057
62138
|
}
|
|
62058
62139
|
}
|
|
62059
|
-
// If the object type is a mapped type { [P in K]: E }, where K is generic,
|
|
62060
|
-
//
|
|
62061
|
-
// construct the type Box<T[X]>.
|
|
62062
|
-
if (isGenericMappedType(objectType)
|
|
62063
|
-
|
|
62140
|
+
// If the object type is a mapped type { [P in K]: E }, where K is generic, or { [P in K as N]: E }, where
|
|
62141
|
+
// K is generic and N is assignable to P, instantiate E using a mapper that substitutes the index type for P.
|
|
62142
|
+
// For example, for an index access { [P in K]: Box<T[P]> }[X], we construct the type Box<T[X]>.
|
|
62143
|
+
if (isGenericMappedType(objectType)) {
|
|
62144
|
+
var nameType = getNameTypeFromMappedType(objectType);
|
|
62145
|
+
if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) {
|
|
62146
|
+
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
|
|
62147
|
+
}
|
|
62064
62148
|
}
|
|
62065
62149
|
return type[cache] = type;
|
|
62066
62150
|
}
|
|
@@ -66898,12 +66982,12 @@ var ts;
|
|
|
66898
66982
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
66899
66983
|
if (maxDepth === void 0) { maxDepth = 3; }
|
|
66900
66984
|
if (depth >= maxDepth) {
|
|
66901
|
-
var
|
|
66985
|
+
var identity_2 = getRecursionIdentity(type);
|
|
66902
66986
|
var count = 0;
|
|
66903
66987
|
var lastTypeId = 0;
|
|
66904
66988
|
for (var i = 0; i < depth; i++) {
|
|
66905
66989
|
var t = stack[i];
|
|
66906
|
-
if (getRecursionIdentity(t) ===
|
|
66990
|
+
if (getRecursionIdentity(t) === identity_2) {
|
|
66907
66991
|
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
66908
66992
|
// type ids are an indicator of newer instantiations caused by recursion.
|
|
66909
66993
|
if (t.id >= lastTypeId) {
|
|
@@ -74380,10 +74464,15 @@ var ts;
|
|
|
74380
74464
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
74381
74465
|
}
|
|
74382
74466
|
// In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
|
|
74467
|
+
// `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
|
|
74468
|
+
// here even if `Foo` is not a const enum.
|
|
74469
|
+
//
|
|
74383
74470
|
// The exceptions are:
|
|
74384
74471
|
// 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
|
|
74385
74472
|
// 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
|
|
74386
|
-
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74473
|
+
if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
|
|
74474
|
+
!(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) ||
|
|
74475
|
+
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
|
|
74387
74476
|
markAliasReferenced(parentSymbol, node);
|
|
74388
74477
|
}
|
|
74389
74478
|
var propType;
|
|
@@ -76905,7 +76994,7 @@ var ts;
|
|
|
76905
76994
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76906
76995
|
newSymbol.parent = originalSymbol;
|
|
76907
76996
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76908
|
-
newSymbol.
|
|
76997
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76909
76998
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76910
76999
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76911
77000
|
}
|
|
@@ -79717,19 +79806,28 @@ var ts;
|
|
|
79717
79806
|
if (constraintType && defaultType) {
|
|
79718
79807
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79719
79808
|
}
|
|
79720
|
-
|
|
79809
|
+
checkNodeDeferred(node);
|
|
79810
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79811
|
+
}
|
|
79812
|
+
function checkTypeParameterDeferred(node) {
|
|
79813
|
+
if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
|
|
79814
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
|
79721
79815
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79722
|
-
if (modifiers
|
|
79816
|
+
if (modifiers) {
|
|
79723
79817
|
var symbol = getSymbolOfNode(node.parent);
|
|
79724
|
-
|
|
79725
|
-
|
|
79726
|
-
|
|
79727
|
-
|
|
79728
|
-
|
|
79729
|
-
|
|
79818
|
+
if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79819
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79820
|
+
}
|
|
79821
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79822
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79823
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79824
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79825
|
+
varianceTypeParameter = typeParameter;
|
|
79826
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79827
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79828
|
+
}
|
|
79730
79829
|
}
|
|
79731
79830
|
}
|
|
79732
|
-
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79733
79831
|
}
|
|
79734
79832
|
function checkParameter(node) {
|
|
79735
79833
|
// Grammar checking
|
|
@@ -80219,7 +80317,7 @@ var ts;
|
|
|
80219
80317
|
superCallStatement = statement;
|
|
80220
80318
|
break;
|
|
80221
80319
|
}
|
|
80222
|
-
if (
|
|
80320
|
+
if (nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
80223
80321
|
break;
|
|
80224
80322
|
}
|
|
80225
80323
|
}
|
|
@@ -85572,6 +85670,9 @@ var ts;
|
|
|
85572
85670
|
case 226 /* ClassExpression */:
|
|
85573
85671
|
checkClassExpressionDeferred(node);
|
|
85574
85672
|
break;
|
|
85673
|
+
case 163 /* TypeParameter */:
|
|
85674
|
+
checkTypeParameterDeferred(node);
|
|
85675
|
+
break;
|
|
85575
85676
|
case 279 /* JsxSelfClosingElement */:
|
|
85576
85677
|
checkJsxSelfClosingElementDeferred(node);
|
|
85577
85678
|
break;
|
|
@@ -86106,15 +86207,20 @@ var ts;
|
|
|
86106
86207
|
return propertyDeclaration;
|
|
86107
86208
|
}
|
|
86108
86209
|
}
|
|
86109
|
-
else if (ts.isMetaProperty(parent)) {
|
|
86110
|
-
|
|
86111
|
-
|
|
86112
|
-
if (propertyDeclaration) {
|
|
86113
|
-
return propertyDeclaration;
|
|
86114
|
-
}
|
|
86115
|
-
if (parent.keywordToken === 103 /* NewKeyword */) {
|
|
86210
|
+
else if (ts.isMetaProperty(parent) && parent.name === node) {
|
|
86211
|
+
if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") {
|
|
86212
|
+
// `target` in `new.target`
|
|
86116
86213
|
return checkNewTargetMetaProperty(parent).symbol;
|
|
86117
86214
|
}
|
|
86215
|
+
// The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
|
|
86216
|
+
// we have a fake expression type made for other reasons already, whose transient `meta`
|
|
86217
|
+
// member should more exactly be the kind of (declarationless) symbol we want.
|
|
86218
|
+
// (See #44364 and #45031 for relevant implementation PRs)
|
|
86219
|
+
if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") {
|
|
86220
|
+
return getGlobalImportMetaExpressionType().members.get("meta");
|
|
86221
|
+
}
|
|
86222
|
+
// no other meta properties are valid syntax, thus no others should have symbols
|
|
86223
|
+
return undefined;
|
|
86118
86224
|
}
|
|
86119
86225
|
}
|
|
86120
86226
|
switch (node.kind) {
|
|
@@ -86386,11 +86492,11 @@ var ts;
|
|
|
86386
86492
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
86387
86493
|
return leftSpread ? [leftSpread, rightSpread]
|
|
86388
86494
|
: syntheticOrigin ? [syntheticOrigin]
|
|
86389
|
-
: ts.singleElementArray(
|
|
86495
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
86390
86496
|
}
|
|
86391
86497
|
return undefined;
|
|
86392
86498
|
}
|
|
86393
|
-
function
|
|
86499
|
+
function tryGetTarget(symbol) {
|
|
86394
86500
|
var target;
|
|
86395
86501
|
var next = symbol;
|
|
86396
86502
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86620,7 +86726,7 @@ var ts;
|
|
|
86620
86726
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86621
86727
|
return true;
|
|
86622
86728
|
}
|
|
86623
|
-
var target = getSymbolLinks(symbol).
|
|
86729
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86624
86730
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86625
86731
|
target.flags & 111551 /* Value */ &&
|
|
86626
86732
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -86668,11 +86774,6 @@ var ts;
|
|
|
86668
86774
|
!parameter.initializer &&
|
|
86669
86775
|
ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
|
|
86670
86776
|
}
|
|
86671
|
-
function isOptionalUninitializedParameter(parameter) {
|
|
86672
|
-
return !!strictNullChecks &&
|
|
86673
|
-
isOptionalParameter(parameter) &&
|
|
86674
|
-
!parameter.initializer;
|
|
86675
|
-
}
|
|
86676
86777
|
function isExpandoFunctionDeclaration(node) {
|
|
86677
86778
|
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
|
|
86678
86779
|
if (!declaration) {
|
|
@@ -87589,8 +87690,7 @@ var ts;
|
|
|
87589
87690
|
case 144 /* OutKeyword */:
|
|
87590
87691
|
var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
|
|
87591
87692
|
var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
|
|
87592
|
-
if (node.kind !== 163 /* TypeParameter */ || (node.parent
|
|
87593
|
-
node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
|
|
87693
|
+
if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
|
|
87594
87694
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
|
87595
87695
|
}
|
|
87596
87696
|
if (flags & inOutFlag) {
|
|
@@ -92824,11 +92924,11 @@ var ts;
|
|
|
92824
92924
|
}
|
|
92825
92925
|
var statements = [];
|
|
92826
92926
|
resumeLexicalEnvironment();
|
|
92827
|
-
var
|
|
92828
|
-
var superStatementIndex = ts.findSuperStatementIndex(body.statements,
|
|
92927
|
+
var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92928
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
|
|
92829
92929
|
// If there was a super call, visit existing statements up to and including it
|
|
92830
92930
|
if (superStatementIndex >= 0) {
|
|
92831
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement,
|
|
92931
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
|
|
92832
92932
|
}
|
|
92833
92933
|
// Transform parameters into property assignments. Transforms this:
|
|
92834
92934
|
//
|
|
@@ -92847,12 +92947,12 @@ var ts;
|
|
|
92847
92947
|
if (superStatementIndex >= 0) {
|
|
92848
92948
|
ts.addRange(statements, parameterPropertyAssignments);
|
|
92849
92949
|
}
|
|
92850
|
-
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
92950
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
|
|
92851
92951
|
else {
|
|
92852
|
-
statements =
|
|
92952
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
92853
92953
|
}
|
|
92854
|
-
// Add remaining statements from the body, skipping the super() call if it was found
|
|
92855
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
92954
|
+
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
92955
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
|
|
92856
92956
|
// End the lexical environment.
|
|
92857
92957
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92858
92958
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -94798,7 +94898,7 @@ var ts;
|
|
|
94798
94898
|
}
|
|
94799
94899
|
resumeLexicalEnvironment();
|
|
94800
94900
|
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
94801
|
-
var
|
|
94901
|
+
var indexOfFirstStatementAfterSuperAndPrologue = 0;
|
|
94802
94902
|
var prologueStatementCount = 0;
|
|
94803
94903
|
var superStatementIndex = -1;
|
|
94804
94904
|
var statements = [];
|
|
@@ -94807,8 +94907,11 @@ var ts;
|
|
|
94807
94907
|
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
94808
94908
|
// If there was a super call, visit existing statements up to and including it
|
|
94809
94909
|
if (superStatementIndex >= 0) {
|
|
94810
|
-
|
|
94811
|
-
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount,
|
|
94910
|
+
indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
|
|
94911
|
+
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);
|
|
94912
|
+
}
|
|
94913
|
+
else if (prologueStatementCount >= 0) {
|
|
94914
|
+
indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
|
|
94812
94915
|
}
|
|
94813
94916
|
}
|
|
94814
94917
|
if (needsSyntheticConstructor) {
|
|
@@ -94844,22 +94947,20 @@ var ts;
|
|
|
94844
94947
|
}
|
|
94845
94948
|
}
|
|
94846
94949
|
if (parameterPropertyDeclarationCount > 0) {
|
|
94847
|
-
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement,
|
|
94950
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
|
|
94848
94951
|
// If there was a super() call found, add parameter properties immediately after it
|
|
94849
94952
|
if (superStatementIndex >= 0) {
|
|
94850
94953
|
ts.addRange(statements, parameterProperties);
|
|
94851
94954
|
}
|
|
94852
|
-
// If a synthetic super() call was added, add them just after it
|
|
94853
|
-
else if (needsSyntheticConstructor) {
|
|
94854
|
-
statements = __spreadArray(__spreadArray([
|
|
94855
|
-
statements[0]
|
|
94856
|
-
], parameterProperties, true), statements.slice(1), true);
|
|
94857
|
-
}
|
|
94858
|
-
// Since there wasn't a super() call, add them to the top of the constructor
|
|
94859
94955
|
else {
|
|
94860
|
-
|
|
94956
|
+
// Add add parameter properties to the top of the constructor after the prologue
|
|
94957
|
+
var superAndPrologueStatementCount = prologueStatementCount;
|
|
94958
|
+
// If a synthetic super() call was added, need to account for that
|
|
94959
|
+
if (needsSyntheticConstructor)
|
|
94960
|
+
superAndPrologueStatementCount++;
|
|
94961
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
|
|
94861
94962
|
}
|
|
94862
|
-
|
|
94963
|
+
indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
|
|
94863
94964
|
}
|
|
94864
94965
|
}
|
|
94865
94966
|
}
|
|
@@ -94869,7 +94970,7 @@ var ts;
|
|
|
94869
94970
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
94870
94971
|
// Add existing statements after the initial prologues and super call
|
|
94871
94972
|
if (constructor) {
|
|
94872
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement,
|
|
94973
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
|
|
94873
94974
|
}
|
|
94874
94975
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
94875
94976
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
@@ -98910,7 +99011,7 @@ var ts;
|
|
|
98910
99011
|
// ```
|
|
98911
99012
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
98912
99013
|
}
|
|
98913
|
-
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)),
|
|
99014
|
+
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)),
|
|
98914
99015
|
/*location*/ constructor.body.statements),
|
|
98915
99016
|
/*multiLine*/ true);
|
|
98916
99017
|
ts.setTextRange(body, constructor.body);
|
|
@@ -108616,6 +108717,10 @@ var ts;
|
|
|
108616
108717
|
return factory.updateModifiers(statement, modifiers);
|
|
108617
108718
|
}
|
|
108618
108719
|
function transformTopLevelDeclaration(input) {
|
|
108720
|
+
if (lateMarkedStatements) {
|
|
108721
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108722
|
+
;
|
|
108723
|
+
}
|
|
108619
108724
|
if (shouldStripInternal(input))
|
|
108620
108725
|
return;
|
|
108621
108726
|
switch (input.kind) {
|
|
@@ -109747,7 +109852,7 @@ var ts;
|
|
|
109747
109852
|
addOutput(buildInfoPath);
|
|
109748
109853
|
}
|
|
109749
109854
|
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
|
|
109750
|
-
if (ts.
|
|
109855
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109751
109856
|
return;
|
|
109752
109857
|
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109753
109858
|
addOutput(js);
|
|
@@ -109792,7 +109897,7 @@ var ts;
|
|
|
109792
109897
|
/*@internal*/
|
|
109793
109898
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
109794
109899
|
var options = _a.options, fileNames = _a.fileNames;
|
|
109795
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.
|
|
109900
|
+
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));
|
|
109796
109901
|
}
|
|
109797
109902
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
109798
109903
|
/*@internal*/
|
|
@@ -109834,7 +109939,7 @@ var ts;
|
|
|
109834
109939
|
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
|
|
109835
109940
|
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
|
|
109836
109941
|
var inputFileName = _b[_a];
|
|
109837
|
-
if (ts.
|
|
109942
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109838
109943
|
continue;
|
|
109839
109944
|
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109840
109945
|
if (jsFilePath)
|
|
@@ -115184,7 +115289,7 @@ var ts;
|
|
|
115184
115289
|
if (ts.outFile(options) || options.outDir)
|
|
115185
115290
|
return false;
|
|
115186
115291
|
// File if emitted next to input needs to be ignored
|
|
115187
|
-
if (ts.
|
|
115292
|
+
if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
|
|
115188
115293
|
// If its declaration directory: its not ignored if not excluded by config
|
|
115189
115294
|
if (options.declarationDir)
|
|
115190
115295
|
return false;
|
|
@@ -116357,7 +116462,7 @@ var ts;
|
|
|
116357
116462
|
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
116358
116463
|
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
|
|
116359
116464
|
var fileName = _c[_b];
|
|
116360
|
-
if (!ts.
|
|
116465
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
116361
116466
|
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
|
|
116362
116467
|
}
|
|
116363
116468
|
}
|
|
@@ -116548,7 +116653,7 @@ var ts;
|
|
|
116548
116653
|
}
|
|
116549
116654
|
function getRedirectReferenceForResolution(file) {
|
|
116550
116655
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
116551
|
-
if (redirect || !ts.
|
|
116656
|
+
if (redirect || !ts.isDeclarationFileName(file.originalFileName))
|
|
116552
116657
|
return redirect;
|
|
116553
116658
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
116554
116659
|
// 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
|
|
@@ -117939,7 +118044,7 @@ var ts;
|
|
|
117939
118044
|
}
|
|
117940
118045
|
function getProjectReferenceRedirectProject(fileName) {
|
|
117941
118046
|
// Ignore dts or any json files
|
|
117942
|
-
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.
|
|
118047
|
+
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117943
118048
|
return undefined;
|
|
117944
118049
|
}
|
|
117945
118050
|
// If this file is produced by a referenced project, we need to rewrite it to
|
|
@@ -117988,7 +118093,7 @@ var ts;
|
|
|
117988
118093
|
else {
|
|
117989
118094
|
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
117990
118095
|
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
|
|
117991
|
-
if (!ts.
|
|
118096
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117992
118097
|
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
|
|
117993
118098
|
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
|
|
117994
118099
|
}
|
|
@@ -118789,7 +118894,7 @@ var ts;
|
|
|
118789
118894
|
if (options.outDir) {
|
|
118790
118895
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
118791
118896
|
}
|
|
118792
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.
|
|
118897
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
|
|
118793
118898
|
// Otherwise just check if sourceFile with the name exists
|
|
118794
118899
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
118795
118900
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -119122,13 +119227,9 @@ var ts;
|
|
|
119122
119227
|
ts.getFileEmitOutput = getFileEmitOutput;
|
|
119123
119228
|
var BuilderState;
|
|
119124
119229
|
(function (BuilderState) {
|
|
119125
|
-
var manyToManyPathMapCount = 0;
|
|
119126
119230
|
function createManyToManyPathMap() {
|
|
119127
119231
|
function create(forward, reverse, deleted) {
|
|
119128
|
-
var version = 0;
|
|
119129
119232
|
var map = {
|
|
119130
|
-
id: manyToManyPathMapCount++,
|
|
119131
|
-
version: function () { return version; },
|
|
119132
119233
|
clone: function () { return create(new ts.Map(forward), new ts.Map(reverse), deleted && new ts.Set(deleted)); },
|
|
119133
119234
|
forEach: function (fn) { return forward.forEach(fn); },
|
|
119134
119235
|
getKeys: function (v) { return reverse.get(v); },
|
|
@@ -119144,30 +119245,29 @@ var ts;
|
|
|
119144
119245
|
}
|
|
119145
119246
|
set.forEach(function (v) { return deleteFromMultimap(reverse, v, k); });
|
|
119146
119247
|
forward.delete(k);
|
|
119147
|
-
version++;
|
|
119148
119248
|
return true;
|
|
119149
119249
|
},
|
|
119150
119250
|
set: function (k, vSet) {
|
|
119151
|
-
|
|
119251
|
+
deleted === null || deleted === void 0 ? void 0 : deleted.delete(k);
|
|
119152
119252
|
var existingVSet = forward.get(k);
|
|
119153
119253
|
forward.set(k, vSet);
|
|
119154
119254
|
existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.forEach(function (v) {
|
|
119155
119255
|
if (!vSet.has(v)) {
|
|
119156
|
-
changed = true;
|
|
119157
119256
|
deleteFromMultimap(reverse, v, k);
|
|
119158
119257
|
}
|
|
119159
119258
|
});
|
|
119160
119259
|
vSet.forEach(function (v) {
|
|
119161
119260
|
if (!(existingVSet === null || existingVSet === void 0 ? void 0 : existingVSet.has(v))) {
|
|
119162
|
-
changed = true;
|
|
119163
119261
|
addToMultimap(reverse, v, k);
|
|
119164
119262
|
}
|
|
119165
119263
|
});
|
|
119166
|
-
if (changed) {
|
|
119167
|
-
version++;
|
|
119168
|
-
}
|
|
119169
119264
|
return map;
|
|
119170
119265
|
},
|
|
119266
|
+
clear: function () {
|
|
119267
|
+
forward.clear();
|
|
119268
|
+
reverse.clear();
|
|
119269
|
+
deleted === null || deleted === void 0 ? void 0 : deleted.clear();
|
|
119270
|
+
}
|
|
119171
119271
|
};
|
|
119172
119272
|
return map;
|
|
119173
119273
|
}
|
|
@@ -119182,11 +119282,10 @@ var ts;
|
|
|
119182
119282
|
}
|
|
119183
119283
|
set.add(v);
|
|
119184
119284
|
}
|
|
119185
|
-
function deleteFromMultimap(map, k, v
|
|
119186
|
-
if (removeEmpty === void 0) { removeEmpty = true; }
|
|
119285
|
+
function deleteFromMultimap(map, k, v) {
|
|
119187
119286
|
var set = map.get(k);
|
|
119188
119287
|
if (set === null || set === void 0 ? void 0 : set.delete(v)) {
|
|
119189
|
-
if (
|
|
119288
|
+
if (!set.size) {
|
|
119190
119289
|
map.delete(k);
|
|
119191
119290
|
}
|
|
119192
119291
|
return true;
|
|
@@ -119415,7 +119514,7 @@ var ts;
|
|
|
119415
119514
|
/*forceDtsEmit*/ true);
|
|
119416
119515
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
119417
119516
|
if (firstDts_1) {
|
|
119418
|
-
ts.Debug.assert(ts.
|
|
119517
|
+
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; })); });
|
|
119419
119518
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
119420
119519
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
119421
119520
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -119473,20 +119572,6 @@ var ts;
|
|
|
119473
119572
|
var _a;
|
|
119474
119573
|
if (exportedModulesMapCache) {
|
|
119475
119574
|
ts.Debug.assert(!!state.exportedModulesMap);
|
|
119476
|
-
var cacheId = exportedModulesMapCache.id;
|
|
119477
|
-
var cacheVersion = exportedModulesMapCache.version();
|
|
119478
|
-
if (state.previousCache) {
|
|
119479
|
-
if (state.previousCache.id === cacheId && state.previousCache.version === cacheVersion) {
|
|
119480
|
-
// If this is the same cache at the same version as last time this BuilderState
|
|
119481
|
-
// was updated, there's no need to update again
|
|
119482
|
-
return;
|
|
119483
|
-
}
|
|
119484
|
-
state.previousCache.id = cacheId;
|
|
119485
|
-
state.previousCache.version = cacheVersion;
|
|
119486
|
-
}
|
|
119487
|
-
else {
|
|
119488
|
-
state.previousCache = { id: cacheId, version: cacheVersion };
|
|
119489
|
-
}
|
|
119490
119575
|
(_a = exportedModulesMapCache.deletedKeys()) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return state.exportedModulesMap.deleteKey(path); });
|
|
119491
119576
|
exportedModulesMapCache.forEach(function (exportedModules, path) { return state.exportedModulesMap.set(path, exportedModules); });
|
|
119492
119577
|
}
|
|
@@ -119820,7 +119905,8 @@ var ts;
|
|
|
119820
119905
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
119821
119906
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
119822
119907
|
*/
|
|
119823
|
-
function getNextAffectedFile(state, cancellationToken, computeHash) {
|
|
119908
|
+
function getNextAffectedFile(state, cancellationToken, computeHash, host) {
|
|
119909
|
+
var _a;
|
|
119824
119910
|
while (true) {
|
|
119825
119911
|
var affectedFiles = state.affectedFiles;
|
|
119826
119912
|
if (affectedFiles) {
|
|
@@ -119831,7 +119917,7 @@ var ts;
|
|
|
119831
119917
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
119832
119918
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
119833
119919
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
119834
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
|
|
119920
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119835
119921
|
return affectedFile;
|
|
119836
119922
|
}
|
|
119837
119923
|
affectedFilesIndex++;
|
|
@@ -119843,6 +119929,7 @@ var ts;
|
|
|
119843
119929
|
ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
|
|
119844
119930
|
state.currentAffectedFilesSignatures.clear();
|
|
119845
119931
|
ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
|
|
119932
|
+
(_a = state.currentAffectedFilesExportedModulesMap) === null || _a === void 0 ? void 0 : _a.clear();
|
|
119846
119933
|
state.affectedFiles = undefined;
|
|
119847
119934
|
}
|
|
119848
119935
|
// Get next changed file
|
|
@@ -119872,6 +119959,11 @@ var ts;
|
|
|
119872
119959
|
state.seenAffectedFiles = new ts.Set();
|
|
119873
119960
|
}
|
|
119874
119961
|
}
|
|
119962
|
+
function clearAffectedFilesPendingEmit(state) {
|
|
119963
|
+
state.affectedFilesPendingEmit = undefined;
|
|
119964
|
+
state.affectedFilesPendingEmitKind = undefined;
|
|
119965
|
+
state.affectedFilesPendingEmitIndex = undefined;
|
|
119966
|
+
}
|
|
119875
119967
|
/**
|
|
119876
119968
|
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
|
119877
119969
|
*/
|
|
@@ -119891,9 +119983,7 @@ var ts;
|
|
|
119891
119983
|
}
|
|
119892
119984
|
}
|
|
119893
119985
|
}
|
|
119894
|
-
state
|
|
119895
|
-
state.affectedFilesPendingEmitKind = undefined;
|
|
119896
|
-
state.affectedFilesPendingEmitIndex = undefined;
|
|
119986
|
+
clearAffectedFilesPendingEmit(state);
|
|
119897
119987
|
}
|
|
119898
119988
|
return undefined;
|
|
119899
119989
|
}
|
|
@@ -119901,7 +119991,7 @@ var ts;
|
|
|
119901
119991
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119902
119992
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
119903
119993
|
*/
|
|
119904
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
|
|
119994
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119905
119995
|
var _a;
|
|
119906
119996
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119907
119997
|
// If affected files is everything except default library, then nothing more to do
|
|
@@ -119926,14 +120016,14 @@ var ts;
|
|
|
119926
120016
|
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);
|
|
119927
120017
|
}
|
|
119928
120018
|
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
|
|
119929
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
|
|
120019
|
+
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119930
120020
|
}
|
|
119931
120021
|
}
|
|
119932
120022
|
/**
|
|
119933
120023
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
119934
120024
|
* Also we need to make sure signature is updated for these files
|
|
119935
120025
|
*/
|
|
119936
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
|
|
120026
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
|
|
119937
120027
|
removeSemanticDiagnosticsOf(state, path);
|
|
119938
120028
|
if (!state.changedFilesSet.has(path)) {
|
|
119939
120029
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -119944,8 +120034,7 @@ var ts;
|
|
|
119944
120034
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
119945
120035
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
119946
120036
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
119947
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
|
|
119948
|
-
/* useFileVersionAsSignature */ true);
|
|
120037
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
|
|
119949
120038
|
// If not dts emit, nothing more to do
|
|
119950
120039
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
119951
120040
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -120142,13 +120231,18 @@ var ts;
|
|
|
120142
120231
|
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
|
120143
120232
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
120144
120233
|
return value.version === actualSignature ?
|
|
120145
|
-
value.affectsGlobalScope ?
|
|
120146
|
-
|
|
120234
|
+
value.affectsGlobalScope || value.impliedFormat ?
|
|
120235
|
+
// If file version is same as signature, dont serialize signature
|
|
120236
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120237
|
+
// If file info only contains version and signature and both are same we can just write string
|
|
120147
120238
|
value.version :
|
|
120148
|
-
actualSignature !== undefined ?
|
|
120239
|
+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
|
|
120149
120240
|
signature === undefined ?
|
|
120241
|
+
// If we havent computed signature, use fileInfo as is
|
|
120150
120242
|
value :
|
|
120243
|
+
// Serialize fileInfo with new updated signature
|
|
120151
120244
|
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120245
|
+
// Signature of the FileInfo is undefined, serialize it as false
|
|
120152
120246
|
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
120153
120247
|
});
|
|
120154
120248
|
var referencedMap;
|
|
@@ -120393,7 +120487,7 @@ var ts;
|
|
|
120393
120487
|
* in that order would be used to write the files
|
|
120394
120488
|
*/
|
|
120395
120489
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120396
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120490
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120397
120491
|
var emitKind = 1 /* Full */;
|
|
120398
120492
|
var isPendingEmitFile = false;
|
|
120399
120493
|
if (!affected) {
|
|
@@ -120438,54 +120532,48 @@ var ts;
|
|
|
120438
120532
|
* in that order would be used to write the files
|
|
120439
120533
|
*/
|
|
120440
120534
|
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120441
|
-
var
|
|
120442
|
-
var savedAffectedFilesPendingEmit;
|
|
120443
|
-
var savedAffectedFilesPendingEmitKind;
|
|
120444
|
-
var savedAffectedFilesPendingEmitIndex;
|
|
120445
|
-
// 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
|
|
120446
|
-
// This ensures pending files to emit is updated in tsbuildinfo
|
|
120447
|
-
// 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)
|
|
120448
|
-
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
|
|
120449
|
-
!targetSourceFile &&
|
|
120450
|
-
!ts.outFile(state.compilerOptions) &&
|
|
120451
|
-
!state.compilerOptions.noEmit &&
|
|
120452
|
-
state.compilerOptions.noEmitOnError) {
|
|
120453
|
-
restorePendingEmitOnHandlingNoEmitSuccess = true;
|
|
120454
|
-
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
|
120455
|
-
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
|
|
120456
|
-
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
|
120457
|
-
}
|
|
120535
|
+
var _a;
|
|
120458
120536
|
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120459
120537
|
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
|
|
120460
120538
|
}
|
|
120461
120539
|
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
|
|
120462
120540
|
if (result)
|
|
120463
120541
|
return result;
|
|
120464
|
-
if (restorePendingEmitOnHandlingNoEmitSuccess) {
|
|
120465
|
-
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
|
|
120466
|
-
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
|
|
120467
|
-
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
|
|
120468
|
-
}
|
|
120469
120542
|
// Emit only affected files if using builder for emit
|
|
120470
|
-
if (!targetSourceFile
|
|
120471
|
-
|
|
120472
|
-
|
|
120473
|
-
|
|
120474
|
-
|
|
120475
|
-
|
|
120476
|
-
|
|
120477
|
-
|
|
120478
|
-
|
|
120479
|
-
|
|
120480
|
-
|
|
120481
|
-
|
|
120543
|
+
if (!targetSourceFile) {
|
|
120544
|
+
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120545
|
+
// Emit and report any errors we ran into.
|
|
120546
|
+
var sourceMaps = [];
|
|
120547
|
+
var emitSkipped = false;
|
|
120548
|
+
var diagnostics = void 0;
|
|
120549
|
+
var emittedFiles = [];
|
|
120550
|
+
var affectedEmitResult = void 0;
|
|
120551
|
+
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
|
|
120552
|
+
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
|
|
120553
|
+
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
|
|
120554
|
+
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
|
|
120555
|
+
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
|
|
120556
|
+
}
|
|
120557
|
+
return {
|
|
120558
|
+
emitSkipped: emitSkipped,
|
|
120559
|
+
diagnostics: diagnostics || ts.emptyArray,
|
|
120560
|
+
emittedFiles: emittedFiles,
|
|
120561
|
+
sourceMaps: sourceMaps
|
|
120562
|
+
};
|
|
120563
|
+
}
|
|
120564
|
+
// In non Emit builder, clear affected files pending emit
|
|
120565
|
+
else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
|
|
120566
|
+
ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
|
|
120567
|
+
// State can clear affected files pending emit if
|
|
120568
|
+
if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
|
|
120569
|
+
// If every file pending emit is pending on only dts emit
|
|
120570
|
+
|| ts.every(state.affectedFilesPendingEmit, function (path, index) {
|
|
120571
|
+
return index < state.affectedFilesPendingEmitIndex ||
|
|
120572
|
+
state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
|
|
120573
|
+
})) {
|
|
120574
|
+
clearAffectedFilesPendingEmit(state);
|
|
120575
|
+
}
|
|
120482
120576
|
}
|
|
120483
|
-
return {
|
|
120484
|
-
emitSkipped: emitSkipped,
|
|
120485
|
-
diagnostics: diagnostics || ts.emptyArray,
|
|
120486
|
-
emittedFiles: emittedFiles,
|
|
120487
|
-
sourceMaps: sourceMaps
|
|
120488
|
-
};
|
|
120489
120577
|
}
|
|
120490
120578
|
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120491
120579
|
}
|
|
@@ -120495,7 +120583,7 @@ var ts;
|
|
|
120495
120583
|
*/
|
|
120496
120584
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
120497
120585
|
while (true) {
|
|
120498
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120586
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120499
120587
|
if (!affected) {
|
|
120500
120588
|
// Done
|
|
120501
120589
|
return undefined;
|
|
@@ -123615,9 +123703,6 @@ var ts;
|
|
|
123615
123703
|
function newer(date1, date2) {
|
|
123616
123704
|
return date2 > date1 ? date2 : date1;
|
|
123617
123705
|
}
|
|
123618
|
-
function isDeclarationFile(fileName) {
|
|
123619
|
-
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
123620
|
-
}
|
|
123621
123706
|
/*@internal*/
|
|
123622
123707
|
function isCircularBuildOrder(buildOrder) {
|
|
123623
123708
|
return !!buildOrder && !!buildOrder.buildOrder;
|
|
@@ -124180,7 +124265,7 @@ var ts;
|
|
|
124180
124265
|
outputFiles.forEach(function (_a) {
|
|
124181
124266
|
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
|
|
124182
124267
|
var priorChangeTime;
|
|
124183
|
-
if (!anyDtsChanged &&
|
|
124268
|
+
if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
|
|
124184
124269
|
// Check for unchanged .d.ts files
|
|
124185
124270
|
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
|
|
124186
124271
|
priorChangeTime = host.getModifiedTime(name);
|
|
@@ -124521,7 +124606,7 @@ var ts;
|
|
|
124521
124606
|
// In addition to file timestamps, we also keep track of when a .d.ts file
|
|
124522
124607
|
// had its file touched but not had its contents changed - this allows us
|
|
124523
124608
|
// to skip a downstream typecheck
|
|
124524
|
-
if (
|
|
124609
|
+
if (ts.isDeclarationFileName(output)) {
|
|
124525
124610
|
var outputModifiedTime = ts.getModifiedTime(host, output);
|
|
124526
124611
|
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
|
|
124527
124612
|
}
|
|
@@ -124675,7 +124760,7 @@ var ts;
|
|
|
124675
124760
|
reportVerbose = false;
|
|
124676
124761
|
reportStatus(state, verboseMessage, proj.options.configFilePath);
|
|
124677
124762
|
}
|
|
124678
|
-
if (
|
|
124763
|
+
if (ts.isDeclarationFileName(file)) {
|
|
124679
124764
|
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
|
|
124680
124765
|
}
|
|
124681
124766
|
host.setModifiedTime(file, now);
|
|
@@ -131987,17 +132072,13 @@ var ts;
|
|
|
131987
132072
|
}
|
|
131988
132073
|
}
|
|
131989
132074
|
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131990
|
-
|
|
131991
|
-
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
132075
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
|
|
131992
132076
|
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131993
132077
|
name = name + labelDetails.detail;
|
|
131994
132078
|
labelDetails = undefined;
|
|
131995
132079
|
}
|
|
131996
132080
|
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131997
132081
|
sortText = Completions.SortText.SortBelow(sortText);
|
|
131998
|
-
if (importAdder.hasFixes()) {
|
|
131999
|
-
hasAction = true;
|
|
132000
|
-
}
|
|
132001
132082
|
}
|
|
132002
132083
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
132003
132084
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
@@ -132220,8 +132301,7 @@ var ts;
|
|
|
132220
132301
|
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
132221
132302
|
var insertText = name;
|
|
132222
132303
|
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
132223
|
-
var
|
|
132224
|
-
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
132304
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
|
|
132225
132305
|
if (!method) {
|
|
132226
132306
|
return undefined;
|
|
132227
132307
|
}
|
|
@@ -132250,16 +132330,15 @@ var ts;
|
|
|
132250
132330
|
/*modifiers*/ undefined,
|
|
132251
132331
|
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
132252
132332
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
132253
|
-
return { isSnippet: isSnippet, insertText: insertText,
|
|
132333
|
+
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
132254
132334
|
}
|
|
132255
132335
|
;
|
|
132256
|
-
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences
|
|
132336
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
132257
132337
|
var declarations = symbol.getDeclarations();
|
|
132258
132338
|
if (!(declarations && declarations.length)) {
|
|
132259
132339
|
return undefined;
|
|
132260
132340
|
}
|
|
132261
132341
|
var checker = program.getTypeChecker();
|
|
132262
|
-
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
132263
132342
|
var declaration = declarations[0];
|
|
132264
132343
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
132265
132344
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
@@ -132292,11 +132371,6 @@ var ts;
|
|
|
132292
132371
|
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
132293
132372
|
return undefined;
|
|
132294
132373
|
}
|
|
132295
|
-
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
132296
|
-
if (importableReference) {
|
|
132297
|
-
typeNode = importableReference.typeNode;
|
|
132298
|
-
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
132299
|
-
}
|
|
132300
132374
|
var body = void 0;
|
|
132301
132375
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
132302
132376
|
var emptyStmt = ts.factory.createEmptyStatement();
|
|
@@ -132306,11 +132380,19 @@ var ts;
|
|
|
132306
132380
|
else {
|
|
132307
132381
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
132308
132382
|
}
|
|
132383
|
+
var parameters = typeNode.parameters.map(function (typedParam) {
|
|
132384
|
+
return ts.factory.createParameterDeclaration(
|
|
132385
|
+
/*decorators*/ undefined,
|
|
132386
|
+
/*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
|
|
132387
|
+
/*type*/ undefined, typedParam.initializer);
|
|
132388
|
+
});
|
|
132309
132389
|
return ts.factory.createMethodDeclaration(
|
|
132310
132390
|
/*decorators*/ undefined,
|
|
132311
132391
|
/*modifiers*/ undefined,
|
|
132312
132392
|
/*asteriskToken*/ undefined, name,
|
|
132313
|
-
/*questionToken*/ undefined,
|
|
132393
|
+
/*questionToken*/ undefined,
|
|
132394
|
+
/*typeParameters*/ undefined, parameters,
|
|
132395
|
+
/*type*/ undefined, body);
|
|
132314
132396
|
}
|
|
132315
132397
|
default:
|
|
132316
132398
|
return undefined;
|
|
@@ -132673,20 +132755,6 @@ var ts;
|
|
|
132673
132755
|
};
|
|
132674
132756
|
}
|
|
132675
132757
|
}
|
|
132676
|
-
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132677
|
-
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132678
|
-
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132679
|
-
if (importAdder.hasFixes()) {
|
|
132680
|
-
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132681
|
-
return {
|
|
132682
|
-
sourceDisplay: undefined,
|
|
132683
|
-
codeActions: [{
|
|
132684
|
-
changes: changes,
|
|
132685
|
-
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132686
|
-
}],
|
|
132687
|
-
};
|
|
132688
|
-
}
|
|
132689
|
-
}
|
|
132690
132758
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132691
132759
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132692
132760
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -135507,7 +135575,7 @@ var ts;
|
|
|
135507
135575
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
135508
135576
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
135509
135577
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
135510
|
-
var otherBucketKey = !ts.
|
|
135578
|
+
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
135511
135579
|
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
135512
135580
|
if (otherBucketKey) {
|
|
135513
135581
|
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
@@ -137447,6 +137515,30 @@ var ts;
|
|
|
137447
137515
|
}
|
|
137448
137516
|
}
|
|
137449
137517
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
137518
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
137519
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
137520
|
+
return candidates.reduce(function (topMost, decl) {
|
|
137521
|
+
var depth = getDepth(decl);
|
|
137522
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
137523
|
+
topMost.declarationNames.push(decl);
|
|
137524
|
+
topMost.depth = depth;
|
|
137525
|
+
}
|
|
137526
|
+
else if (depth < topMost.depth) {
|
|
137527
|
+
topMost.declarationNames = [decl];
|
|
137528
|
+
topMost.depth = depth;
|
|
137529
|
+
}
|
|
137530
|
+
return topMost;
|
|
137531
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
137532
|
+
function getDepth(declaration) {
|
|
137533
|
+
var depth = 0;
|
|
137534
|
+
while (declaration) {
|
|
137535
|
+
declaration = ts.getContainerNode(declaration);
|
|
137536
|
+
depth++;
|
|
137537
|
+
}
|
|
137538
|
+
return depth;
|
|
137539
|
+
}
|
|
137540
|
+
}
|
|
137541
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
137450
137542
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
137451
137543
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
137452
137544
|
return false;
|
|
@@ -139083,7 +139175,9 @@ var ts;
|
|
|
139083
139175
|
(function (ts) {
|
|
139084
139176
|
var GoToDefinition;
|
|
139085
139177
|
(function (GoToDefinition) {
|
|
139086
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
139178
|
+
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
|
|
139179
|
+
var _a;
|
|
139180
|
+
var _b;
|
|
139087
139181
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
139088
139182
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
139089
139183
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -139106,33 +139200,63 @@ var ts;
|
|
|
139106
139200
|
}
|
|
139107
139201
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
139108
139202
|
var classDecl = node.parent.parent;
|
|
139109
|
-
var
|
|
139203
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
139110
139204
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
139111
139205
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
139112
139206
|
var sourceFile_1 = node.getSourceFile();
|
|
139113
139207
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
139114
139208
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
139115
139209
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
139116
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
139210
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
139117
139211
|
});
|
|
139118
139212
|
}
|
|
139119
|
-
var
|
|
139213
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
139214
|
+
var fallbackNode = node;
|
|
139215
|
+
if (searchOtherFilesOnly && failedAliasResolution) {
|
|
139216
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
139217
|
+
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); });
|
|
139218
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
139219
|
+
if (moduleSpecifier) {
|
|
139220
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
139221
|
+
fallbackNode = moduleSpecifier;
|
|
139222
|
+
}
|
|
139223
|
+
}
|
|
139224
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
139225
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
139226
|
+
// be that module resolution succeeded but the target was not a module.
|
|
139227
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
139228
|
+
if (ref) {
|
|
139229
|
+
return [{
|
|
139230
|
+
name: fallbackNode.text,
|
|
139231
|
+
fileName: ref.resolvedFileName,
|
|
139232
|
+
containerName: undefined,
|
|
139233
|
+
containerKind: undefined,
|
|
139234
|
+
kind: "script" /* scriptElement */,
|
|
139235
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
139236
|
+
failedAliasResolution: failedAliasResolution,
|
|
139237
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
139238
|
+
unverified: fallbackNode !== node,
|
|
139239
|
+
}];
|
|
139240
|
+
}
|
|
139241
|
+
}
|
|
139120
139242
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
139121
139243
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
139122
139244
|
if (!symbol) {
|
|
139123
139245
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
139124
139246
|
}
|
|
139247
|
+
if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
139248
|
+
return undefined;
|
|
139125
139249
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
139126
139250
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
139127
139251
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
139128
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
139252
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
139129
139253
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
139130
139254
|
// If this is the original constructor definition, parent is the class.
|
|
139131
139255
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
139132
139256
|
return [sigInfo];
|
|
139133
139257
|
}
|
|
139134
139258
|
else {
|
|
139135
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
139259
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
139136
139260
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
139137
139261
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
139138
139262
|
}
|
|
@@ -139144,7 +139268,7 @@ var ts;
|
|
|
139144
139268
|
// assignment. This case and others are handled by the following code.
|
|
139145
139269
|
if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
|
|
139146
139270
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
139147
|
-
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;
|
|
139271
|
+
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;
|
|
139148
139272
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
139149
139273
|
}
|
|
139150
139274
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -139167,7 +139291,7 @@ var ts;
|
|
|
139167
139291
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
139168
139292
|
});
|
|
139169
139293
|
}
|
|
139170
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
139294
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
139171
139295
|
}
|
|
139172
139296
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
139173
139297
|
/**
|
|
@@ -139265,24 +139389,24 @@ var ts;
|
|
|
139265
139389
|
return undefined;
|
|
139266
139390
|
}
|
|
139267
139391
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
139268
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
139392
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
139269
139393
|
}
|
|
139270
|
-
var
|
|
139394
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
139271
139395
|
if (!symbol)
|
|
139272
139396
|
return undefined;
|
|
139273
139397
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
139274
139398
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
139275
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
139399
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
139276
139400
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
139277
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
139401
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
139278
139402
|
return typeDefinitions.length ? typeDefinitions
|
|
139279
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
139403
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
139280
139404
|
: undefined;
|
|
139281
139405
|
}
|
|
139282
139406
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
139283
|
-
function definitionFromType(type, checker, node) {
|
|
139407
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
139284
139408
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
139285
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
139409
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
139286
139410
|
});
|
|
139287
139411
|
}
|
|
139288
139412
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -139324,13 +139448,17 @@ var ts;
|
|
|
139324
139448
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
139325
139449
|
// import {A, B} from "mod";
|
|
139326
139450
|
// to jump to the implementation directly.
|
|
139451
|
+
var failedAliasResolution = false;
|
|
139327
139452
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
139328
139453
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
139329
139454
|
if (aliased.declarations) {
|
|
139330
|
-
return aliased;
|
|
139455
|
+
return { symbol: aliased };
|
|
139456
|
+
}
|
|
139457
|
+
else {
|
|
139458
|
+
failedAliasResolution = true;
|
|
139331
139459
|
}
|
|
139332
139460
|
}
|
|
139333
|
-
return symbol;
|
|
139461
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
139334
139462
|
}
|
|
139335
139463
|
// Go to the original declaration for cases:
|
|
139336
139464
|
//
|
|
@@ -139344,26 +139472,45 @@ var ts;
|
|
|
139344
139472
|
if (node.parent === declaration) {
|
|
139345
139473
|
return true;
|
|
139346
139474
|
}
|
|
139347
|
-
|
|
139348
|
-
|
|
139349
|
-
case 265 /* ImportEqualsDeclaration */:
|
|
139350
|
-
return true;
|
|
139351
|
-
case 270 /* ImportSpecifier */:
|
|
139352
|
-
return declaration.parent.kind === 269 /* NamedImports */;
|
|
139353
|
-
case 203 /* BindingElement */:
|
|
139354
|
-
case 254 /* VariableDeclaration */:
|
|
139355
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
139356
|
-
default:
|
|
139357
|
-
return false;
|
|
139475
|
+
if (declaration.kind === 268 /* NamespaceImport */) {
|
|
139476
|
+
return false;
|
|
139358
139477
|
}
|
|
139478
|
+
return true;
|
|
139479
|
+
}
|
|
139480
|
+
/**
|
|
139481
|
+
* ```ts
|
|
139482
|
+
* function f() {}
|
|
139483
|
+
* f.foo = 0;
|
|
139484
|
+
* ```
|
|
139485
|
+
*
|
|
139486
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
139487
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
139488
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
139489
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
139490
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
139491
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
139492
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
139493
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
139494
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
139495
|
+
* up with a more precise definition of what counts as a definition.
|
|
139496
|
+
*/
|
|
139497
|
+
function isExpandoDeclaration(node) {
|
|
139498
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
139499
|
+
return false;
|
|
139500
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
139501
|
+
if (ts.isAssignmentExpression(p))
|
|
139502
|
+
return true;
|
|
139503
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
139504
|
+
return "quit";
|
|
139505
|
+
return false;
|
|
139506
|
+
});
|
|
139507
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
139359
139508
|
}
|
|
139360
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
139361
|
-
|
|
139362
|
-
|
|
139363
|
-
|
|
139364
|
-
|
|
139365
|
-
|| undefined;
|
|
139366
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
139509
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
139510
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
139511
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
139512
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
139513
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
|
|
139367
139514
|
function getConstructSignatureDefinition() {
|
|
139368
139515
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
139369
139516
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -139387,26 +139534,27 @@ var ts;
|
|
|
139387
139534
|
return declarations.length
|
|
139388
139535
|
? declarationsWithBody.length !== 0
|
|
139389
139536
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
139390
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
139537
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
|
|
139391
139538
|
: undefined;
|
|
139392
139539
|
}
|
|
139393
139540
|
}
|
|
139394
139541
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
139395
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
139542
|
+
function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
|
|
139396
139543
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
139397
139544
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
139398
139545
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
139399
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
139546
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
|
|
139400
139547
|
}
|
|
139548
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
139401
139549
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
139402
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
139550
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
|
|
139403
139551
|
var sourceFile = declaration.getSourceFile();
|
|
139404
139552
|
if (!textSpan) {
|
|
139405
139553
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
139406
139554
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
139407
139555
|
}
|
|
139408
139556
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
139409
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
139557
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
|
|
139410
139558
|
}
|
|
139411
139559
|
function isDefinitionVisible(checker, declaration) {
|
|
139412
139560
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -139439,8 +139587,8 @@ var ts;
|
|
|
139439
139587
|
return false;
|
|
139440
139588
|
}
|
|
139441
139589
|
}
|
|
139442
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
139443
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
139590
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
139591
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
|
139444
139592
|
}
|
|
139445
139593
|
function findReferenceInPosition(refs, pos) {
|
|
139446
139594
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -152555,9 +152703,10 @@ var ts;
|
|
|
152555
152703
|
// 2. add "member3" to the second import statement's import list
|
|
152556
152704
|
// and it is up to the user to decide which one fits best.
|
|
152557
152705
|
return ts.firstDefined(existingImports, function (_a) {
|
|
152706
|
+
var _b;
|
|
152558
152707
|
var declaration = _a.declaration;
|
|
152559
152708
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
152560
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152709
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152561
152710
|
if (namespacePrefix && moduleSpecifier) {
|
|
152562
152711
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
152563
152712
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -152733,8 +152882,9 @@ var ts;
|
|
|
152733
152882
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
152734
152883
|
}
|
|
152735
152884
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
152885
|
+
var _b;
|
|
152736
152886
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
152737
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152887
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152738
152888
|
if (moduleSpecifier) {
|
|
152739
152889
|
var addAsTypeOnly = useRequire
|
|
152740
152890
|
? 4 /* NotAllowed */
|
|
@@ -157092,7 +157242,6 @@ var ts;
|
|
|
157092
157242
|
var checker = program.getTypeChecker();
|
|
157093
157243
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
157094
157244
|
var flags = 1 /* NoTruncation */
|
|
157095
|
-
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
157096
157245
|
| 256 /* SuppressAnyReturnType */
|
|
157097
157246
|
| 524288 /* AllowEmptyTuple */
|
|
157098
157247
|
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
@@ -159471,6 +159620,7 @@ var ts;
|
|
|
159471
159620
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
159472
159621
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
159473
159622
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
159623
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
159474
159624
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
159475
159625
|
var RangeFacts;
|
|
159476
159626
|
(function (RangeFacts) {
|
|
@@ -159479,10 +159629,11 @@ var ts;
|
|
|
159479
159629
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
159480
159630
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
159481
159631
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
159632
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
159482
159633
|
/**
|
|
159483
159634
|
* The range is in a function which needs the 'static' modifier in a class
|
|
159484
159635
|
*/
|
|
159485
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
159636
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
159486
159637
|
})(RangeFacts || (RangeFacts = {}));
|
|
159487
159638
|
/**
|
|
159488
159639
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -159513,6 +159664,7 @@ var ts;
|
|
|
159513
159664
|
// We'll modify these flags as we walk the tree to collect data
|
|
159514
159665
|
// about what things need to be done as part of the extraction.
|
|
159515
159666
|
var rangeFacts = RangeFacts.None;
|
|
159667
|
+
var thisNode;
|
|
159516
159668
|
if (!start || !end) {
|
|
159517
159669
|
// cannot find either start or end node
|
|
159518
159670
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
@@ -159551,7 +159703,7 @@ var ts;
|
|
|
159551
159703
|
// the expression.
|
|
159552
159704
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
159553
159705
|
}
|
|
159554
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
159706
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
159555
159707
|
}
|
|
159556
159708
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
159557
159709
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -159563,7 +159715,7 @@ var ts;
|
|
|
159563
159715
|
if (errors) {
|
|
159564
159716
|
return { errors: errors };
|
|
159565
159717
|
}
|
|
159566
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
159718
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
159567
159719
|
/**
|
|
159568
159720
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
159569
159721
|
* @param node The unrefined extraction node.
|
|
@@ -159655,6 +159807,14 @@ var ts;
|
|
|
159655
159807
|
var permittedJumps = 4 /* Return */;
|
|
159656
159808
|
var seenLabels;
|
|
159657
159809
|
visit(nodeToCheck);
|
|
159810
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159811
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159812
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159813
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159814
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159815
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159816
|
+
}
|
|
159817
|
+
}
|
|
159658
159818
|
return errors;
|
|
159659
159819
|
function visit(node) {
|
|
159660
159820
|
if (errors) {
|
|
@@ -159693,6 +159853,7 @@ var ts;
|
|
|
159693
159853
|
}
|
|
159694
159854
|
else {
|
|
159695
159855
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159856
|
+
thisNode = node;
|
|
159696
159857
|
}
|
|
159697
159858
|
break;
|
|
159698
159859
|
case 214 /* ArrowFunction */:
|
|
@@ -159700,6 +159861,7 @@ var ts;
|
|
|
159700
159861
|
ts.forEachChild(node, function check(n) {
|
|
159701
159862
|
if (ts.isThis(n)) {
|
|
159702
159863
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159864
|
+
thisNode = node;
|
|
159703
159865
|
}
|
|
159704
159866
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
159705
159867
|
return false;
|
|
@@ -159756,6 +159918,7 @@ var ts;
|
|
|
159756
159918
|
case 192 /* ThisType */:
|
|
159757
159919
|
case 108 /* ThisKeyword */:
|
|
159758
159920
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159921
|
+
thisNode = node;
|
|
159759
159922
|
break;
|
|
159760
159923
|
case 250 /* LabeledStatement */: {
|
|
159761
159924
|
var label = node.label;
|
|
@@ -159843,7 +160006,7 @@ var ts;
|
|
|
159843
160006
|
*/
|
|
159844
160007
|
function collectEnclosingScopes(range) {
|
|
159845
160008
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
159846
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
160009
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
159847
160010
|
// 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
|
|
159848
160011
|
var containingClass = ts.getContainingClass(current);
|
|
159849
160012
|
if (containingClass) {
|
|
@@ -160049,6 +160212,7 @@ var ts;
|
|
|
160049
160212
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
160050
160213
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
160051
160214
|
var newFunction;
|
|
160215
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
160052
160216
|
if (ts.isClassLike(scope)) {
|
|
160053
160217
|
// always create private method in TypeScript files
|
|
160054
160218
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -160063,6 +160227,15 @@ var ts;
|
|
|
160063
160227
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
160064
160228
|
}
|
|
160065
160229
|
else {
|
|
160230
|
+
if (callThis) {
|
|
160231
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
160232
|
+
/*decorators*/ undefined,
|
|
160233
|
+
/*modifiers*/ undefined,
|
|
160234
|
+
/*dotDotDotToken*/ undefined,
|
|
160235
|
+
/*name*/ "this",
|
|
160236
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
160237
|
+
/*initializer*/ undefined));
|
|
160238
|
+
}
|
|
160066
160239
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
160067
160240
|
/*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);
|
|
160068
160241
|
}
|
|
@@ -160079,7 +160252,10 @@ var ts;
|
|
|
160079
160252
|
var newNodes = [];
|
|
160080
160253
|
// replace range with function call
|
|
160081
160254
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
160082
|
-
|
|
160255
|
+
if (callThis) {
|
|
160256
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
160257
|
+
}
|
|
160258
|
+
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
|
|
160083
160259
|
callArguments);
|
|
160084
160260
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
160085
160261
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -160690,6 +160866,9 @@ var ts;
|
|
|
160690
160866
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
160691
160867
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
160692
160868
|
}
|
|
160869
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160870
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160871
|
+
}
|
|
160693
160872
|
var hasWrite = false;
|
|
160694
160873
|
var readonlyClassPropertyWrite;
|
|
160695
160874
|
usagesPerScope[i].usages.forEach(function (value) {
|
|
@@ -164643,9 +164822,9 @@ var ts;
|
|
|
164643
164822
|
}
|
|
164644
164823
|
}
|
|
164645
164824
|
/// Goto definition
|
|
164646
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
164825
|
+
function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
|
|
164647
164826
|
synchronizeHostData();
|
|
164648
|
-
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
164827
|
+
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
|
|
164649
164828
|
}
|
|
164650
164829
|
function getDefinitionAndBoundSpan(fileName, position) {
|
|
164651
164830
|
synchronizeHostData();
|