typescript 4.7.0-dev.20220408 → 4.7.0-dev.20220415
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +2 -0
- package/lib/de/diagnosticMessages.generated.json +2 -0
- package/lib/es/diagnosticMessages.generated.json +2 -0
- package/lib/fr/diagnosticMessages.generated.json +2 -0
- package/lib/it/diagnosticMessages.generated.json +2 -0
- package/lib/ja/diagnosticMessages.generated.json +2 -0
- package/lib/ko/diagnosticMessages.generated.json +2 -0
- package/lib/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 +198 -140
- package/lib/tsserver.js +604 -256
- package/lib/tsserverlibrary.d.ts +7 -2
- package/lib/tsserverlibrary.js +604 -256
- package/lib/typescript.d.ts +0 -1
- package/lib/typescript.js +363 -236
- package/lib/typescriptServices.d.ts +0 -1
- package/lib/typescriptServices.js +363 -236
- package/lib/typingsInstaller.js +221 -158
- 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/tsserverlibrary.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-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220415";
|
|
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";
|
|
@@ -15160,6 +15159,10 @@ var ts;
|
|
|
15160
15159
|
}
|
|
15161
15160
|
}
|
|
15162
15161
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
15162
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
15163
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
15164
|
+
}
|
|
15165
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
15163
15166
|
function isLateVisibilityPaintedStatement(node) {
|
|
15164
15167
|
switch (node.kind) {
|
|
15165
15168
|
case 266 /* ImportDeclaration */:
|
|
@@ -16520,17 +16523,13 @@ var ts;
|
|
|
16520
16523
|
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
|
16521
16524
|
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
|
|
16522
16525
|
}
|
|
16523
|
-
if (ts.
|
|
16526
|
+
if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
|
|
16524
16527
|
(initializer.expression.kind === 108 /* ThisKeyword */ ||
|
|
16525
16528
|
ts.isIdentifier(initializer.expression) &&
|
|
16526
16529
|
(initializer.expression.escapedText === "window" ||
|
|
16527
16530
|
initializer.expression.escapedText === "self" ||
|
|
16528
16531
|
initializer.expression.escapedText === "global"))) {
|
|
16529
|
-
|
|
16530
|
-
if (ts.isPrivateIdentifier(nameOrArgument)) {
|
|
16531
|
-
ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
|
16532
|
-
}
|
|
16533
|
-
return isSameEntityName(name, nameOrArgument);
|
|
16532
|
+
return isSameEntityName(name, getNameOrArgument(initializer));
|
|
16534
16533
|
}
|
|
16535
16534
|
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
|
16536
16535
|
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
|
@@ -16738,14 +16737,14 @@ var ts;
|
|
|
16738
16737
|
}
|
|
16739
16738
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16740
16739
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16741
|
-
var _a, _b
|
|
16740
|
+
var _a, _b;
|
|
16742
16741
|
switch (node.kind) {
|
|
16743
16742
|
case 254 /* VariableDeclaration */:
|
|
16744
|
-
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];
|
|
16745
16744
|
case 266 /* ImportDeclaration */:
|
|
16746
|
-
return
|
|
16745
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16747
16746
|
case 265 /* ImportEqualsDeclaration */:
|
|
16748
|
-
return
|
|
16747
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16749
16748
|
default:
|
|
16750
16749
|
ts.Debug.assertNever(node);
|
|
16751
16750
|
}
|
|
@@ -17260,7 +17259,10 @@ var ts;
|
|
|
17260
17259
|
return parent.propertyName === node;
|
|
17261
17260
|
case 275 /* ExportSpecifier */:
|
|
17262
17261
|
case 285 /* JsxAttribute */:
|
|
17263
|
-
|
|
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
|
|
17264
17266
|
return true;
|
|
17265
17267
|
}
|
|
17266
17268
|
return false;
|
|
@@ -17276,21 +17278,28 @@ var ts;
|
|
|
17276
17278
|
// export = <EntityNameExpression>
|
|
17277
17279
|
// export default <EntityNameExpression>
|
|
17278
17280
|
// module.exports = <EntityNameExpression>
|
|
17279
|
-
//
|
|
17280
|
-
//
|
|
17281
|
+
// module.exports.x = <EntityNameExpression>
|
|
17282
|
+
// const x = require("...")
|
|
17283
|
+
// const { x } = require("...")
|
|
17284
|
+
// const x = require("...").y
|
|
17285
|
+
// const { x } = require("...").y
|
|
17281
17286
|
function isAliasSymbolDeclaration(node) {
|
|
17282
|
-
|
|
17287
|
+
if (node.kind === 265 /* ImportEqualsDeclaration */ ||
|
|
17283
17288
|
node.kind === 264 /* NamespaceExportDeclaration */ ||
|
|
17284
17289
|
node.kind === 267 /* ImportClause */ && !!node.name ||
|
|
17285
17290
|
node.kind === 268 /* NamespaceImport */ ||
|
|
17286
17291
|
node.kind === 274 /* NamespaceExport */ ||
|
|
17287
17292
|
node.kind === 270 /* ImportSpecifier */ ||
|
|
17288
17293
|
node.kind === 275 /* ExportSpecifier */ ||
|
|
17289
|
-
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17293
|
-
|
|
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));
|
|
17294
17303
|
}
|
|
17295
17304
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17296
17305
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17301,6 +17310,7 @@ var ts;
|
|
|
17301
17310
|
case 275 /* ExportSpecifier */:
|
|
17302
17311
|
case 271 /* ExportAssignment */:
|
|
17303
17312
|
case 265 /* ImportEqualsDeclaration */:
|
|
17313
|
+
case 274 /* NamespaceExport */:
|
|
17304
17314
|
return node.parent;
|
|
17305
17315
|
case 161 /* QualifiedName */:
|
|
17306
17316
|
do {
|
|
@@ -19127,6 +19137,11 @@ var ts;
|
|
|
19127
19137
|
(node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
19128
19138
|
}
|
|
19129
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;
|
|
19130
19145
|
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
|
19131
19146
|
return ts.isQualifiedName(node.parent) && node.parent.right === node
|
|
19132
19147
|
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
@@ -19778,6 +19793,41 @@ var ts;
|
|
|
19778
19793
|
return expr;
|
|
19779
19794
|
}
|
|
19780
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;
|
|
19781
19831
|
function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
19782
19832
|
while (true) {
|
|
19783
19833
|
switch (node.kind) {
|
|
@@ -20725,6 +20775,7 @@ var ts;
|
|
|
20725
20775
|
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20726
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 */]];
|
|
20727
20777
|
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20778
|
+
ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
|
|
20728
20779
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20729
20780
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20730
20781
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
@@ -21413,6 +21464,11 @@ var ts;
|
|
|
21413
21464
|
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21414
21465
|
}
|
|
21415
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;
|
|
21416
21472
|
})(ts || (ts = {}));
|
|
21417
21473
|
/* @internal */
|
|
21418
21474
|
var ts;
|
|
@@ -35566,34 +35622,10 @@ var ts;
|
|
|
35566
35622
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
35567
35623
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
35568
35624
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
35569
|
-
// These tokens can't follow in a call expression, nor can they start an
|
|
35570
|
-
// expression. So, consider the type argument list part of an instantiation
|
|
35571
|
-
// expression.
|
|
35572
|
-
// falls through
|
|
35573
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
35574
|
-
case 24 /* DotToken */: // foo<x>.
|
|
35575
|
-
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
35576
|
-
case 21 /* CloseParenToken */: // foo<x>)
|
|
35577
|
-
case 23 /* CloseBracketToken */: // foo<x>]
|
|
35578
|
-
case 58 /* ColonToken */: // foo<x>:
|
|
35579
|
-
case 26 /* SemicolonToken */: // foo<x>;
|
|
35580
|
-
case 57 /* QuestionToken */: // foo<x>?
|
|
35581
|
-
case 34 /* EqualsEqualsToken */: // foo<x> ==
|
|
35582
|
-
case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
35583
|
-
case 35 /* ExclamationEqualsToken */: // foo<x> !=
|
|
35584
|
-
case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
35585
|
-
case 55 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
35586
|
-
case 56 /* BarBarToken */: // foo<x> ||
|
|
35587
|
-
case 60 /* QuestionQuestionToken */: // foo<x> ??
|
|
35588
|
-
case 52 /* CaretToken */: // foo<x> ^
|
|
35589
|
-
case 50 /* AmpersandToken */: // foo<x> &
|
|
35590
|
-
case 51 /* BarToken */: // foo<x> |
|
|
35591
|
-
case 19 /* CloseBraceToken */: // foo<x> }
|
|
35592
|
-
case 1 /* EndOfFileToken */: // foo<x>
|
|
35593
35625
|
return true;
|
|
35594
35626
|
}
|
|
35595
|
-
//
|
|
35596
|
-
return
|
|
35627
|
+
// Consider something a type argument list only if the following token can't start an expression.
|
|
35628
|
+
return !isStartOfExpression();
|
|
35597
35629
|
}
|
|
35598
35630
|
function parsePrimaryExpression() {
|
|
35599
35631
|
switch (token()) {
|
|
@@ -38811,7 +38843,7 @@ var ts;
|
|
|
38811
38843
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
38812
38844
|
/** @internal */
|
|
38813
38845
|
function isDeclarationFileName(fileName) {
|
|
38814
|
-
return ts.fileExtensionIsOneOf(fileName,
|
|
38846
|
+
return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
|
|
38815
38847
|
}
|
|
38816
38848
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38817
38849
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
@@ -42319,7 +42351,8 @@ var ts;
|
|
|
42319
42351
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42320
42352
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42321
42353
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42322
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42354
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42355
|
+
Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
|
|
42323
42356
|
})(Extensions || (Extensions = {}));
|
|
42324
42357
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42325
42358
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -43264,7 +43297,21 @@ var ts;
|
|
|
43264
43297
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43265
43298
|
}
|
|
43266
43299
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
43267
|
-
|
|
43300
|
+
var extensions;
|
|
43301
|
+
if (lookupConfig) {
|
|
43302
|
+
extensions = tsconfigExtensions;
|
|
43303
|
+
}
|
|
43304
|
+
else if (compilerOptions.noDtsResolution) {
|
|
43305
|
+
extensions = [Extensions.TsOnly];
|
|
43306
|
+
if (compilerOptions.allowJs)
|
|
43307
|
+
extensions.push(Extensions.JavaScript);
|
|
43308
|
+
if (compilerOptions.resolveJsonModule)
|
|
43309
|
+
extensions.push(Extensions.Json);
|
|
43310
|
+
}
|
|
43311
|
+
else {
|
|
43312
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
43313
|
+
}
|
|
43314
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
43268
43315
|
}
|
|
43269
43316
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
43270
43317
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -43273,6 +43320,10 @@ var ts;
|
|
|
43273
43320
|
var failedLookupLocations = [];
|
|
43274
43321
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
43275
43322
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43323
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43324
|
+
if (compilerOptions.noDtsResolution) {
|
|
43325
|
+
conditions.pop();
|
|
43326
|
+
}
|
|
43276
43327
|
var state = {
|
|
43277
43328
|
compilerOptions: compilerOptions,
|
|
43278
43329
|
host: host,
|
|
@@ -43280,7 +43331,7 @@ var ts;
|
|
|
43280
43331
|
failedLookupLocations: failedLookupLocations,
|
|
43281
43332
|
packageJsonInfoCache: cache,
|
|
43282
43333
|
features: features,
|
|
43283
|
-
conditions:
|
|
43334
|
+
conditions: conditions,
|
|
43284
43335
|
};
|
|
43285
43336
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43286
43337
|
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);
|
|
@@ -43456,9 +43507,9 @@ var ts;
|
|
|
43456
43507
|
}
|
|
43457
43508
|
}
|
|
43458
43509
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43459
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43510
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
|
|
43460
43511
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43461
|
-
return result !== undefined ? { path: candidate, ext: ts.forEach(
|
|
43512
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
43462
43513
|
}
|
|
43463
43514
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43464
43515
|
}
|
|
@@ -43488,20 +43539,22 @@ var ts;
|
|
|
43488
43539
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43489
43540
|
}
|
|
43490
43541
|
case Extensions.TypeScript:
|
|
43542
|
+
case Extensions.TsOnly:
|
|
43543
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43491
43544
|
switch (originalExtension) {
|
|
43492
43545
|
case ".mjs" /* Mjs */:
|
|
43493
43546
|
case ".mts" /* Mts */:
|
|
43494
43547
|
case ".d.mts" /* Dmts */:
|
|
43495
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43548
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43496
43549
|
case ".cjs" /* Cjs */:
|
|
43497
43550
|
case ".cts" /* Cts */:
|
|
43498
43551
|
case ".d.cts" /* Dcts */:
|
|
43499
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43552
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43500
43553
|
case ".json" /* Json */:
|
|
43501
43554
|
candidate += ".json" /* Json */;
|
|
43502
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43555
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43503
43556
|
default:
|
|
43504
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43557
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43505
43558
|
}
|
|
43506
43559
|
case Extensions.JavaScript:
|
|
43507
43560
|
switch (originalExtension) {
|
|
@@ -43728,6 +43781,7 @@ var ts;
|
|
|
43728
43781
|
switch (extensions) {
|
|
43729
43782
|
case Extensions.JavaScript:
|
|
43730
43783
|
case Extensions.Json:
|
|
43784
|
+
case Extensions.TsOnly:
|
|
43731
43785
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43732
43786
|
break;
|
|
43733
43787
|
case Extensions.TypeScript:
|
|
@@ -43800,14 +43854,16 @@ var ts;
|
|
|
43800
43854
|
function extensionIsOk(extensions, extension) {
|
|
43801
43855
|
switch (extensions) {
|
|
43802
43856
|
case Extensions.JavaScript:
|
|
43803
|
-
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
43857
|
+
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
|
|
43804
43858
|
case Extensions.TSConfig:
|
|
43805
43859
|
case Extensions.Json:
|
|
43806
43860
|
return extension === ".json" /* Json */;
|
|
43807
43861
|
case Extensions.TypeScript:
|
|
43808
|
-
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43862
|
+
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 */;
|
|
43863
|
+
case Extensions.TsOnly:
|
|
43864
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
|
|
43809
43865
|
case Extensions.DtsOnly:
|
|
43810
|
-
return extension === ".d.ts" /* Dts */;
|
|
43866
|
+
return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43811
43867
|
}
|
|
43812
43868
|
}
|
|
43813
43869
|
/* @internal */
|
|
@@ -53109,9 +53165,6 @@ var ts;
|
|
|
53109
53165
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
53110
53166
|
parameterType = getOptionalType(parameterType);
|
|
53111
53167
|
}
|
|
53112
|
-
if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
|
53113
|
-
parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
|
|
53114
|
-
}
|
|
53115
53168
|
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
53116
53169
|
var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
|
|
53117
53170
|
var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
@@ -53670,7 +53723,7 @@ var ts;
|
|
|
53670
53723
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
53671
53724
|
// try to reuse the existing annotation
|
|
53672
53725
|
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
53673
|
-
if (
|
|
53726
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
53674
53727
|
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
53675
53728
|
if (result_6) {
|
|
53676
53729
|
return result_6;
|
|
@@ -53687,6 +53740,16 @@ var ts;
|
|
|
53687
53740
|
context.flags = oldFlags;
|
|
53688
53741
|
return result;
|
|
53689
53742
|
}
|
|
53743
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
53744
|
+
var typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
53745
|
+
if (typeFromTypeNode === type) {
|
|
53746
|
+
return true;
|
|
53747
|
+
}
|
|
53748
|
+
if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
53749
|
+
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
53750
|
+
}
|
|
53751
|
+
return false;
|
|
53752
|
+
}
|
|
53690
53753
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
53691
53754
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
53692
53755
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
@@ -55958,7 +56021,7 @@ var ts;
|
|
|
55958
56021
|
}
|
|
55959
56022
|
}
|
|
55960
56023
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55961
|
-
type = getUnionType(sourceTypes
|
|
56024
|
+
type = getUnionType(sourceTypes);
|
|
55962
56025
|
}
|
|
55963
56026
|
}
|
|
55964
56027
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -58707,8 +58770,9 @@ var ts;
|
|
|
58707
58770
|
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
|
|
58708
58771
|
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
|
|
58709
58772
|
// nesting, so it is effectively just a safety stop.
|
|
58710
|
-
|
|
58711
|
-
|
|
58773
|
+
var identity_1 = getRecursionIdentity(t);
|
|
58774
|
+
if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
|
|
58775
|
+
stack.push(identity_1);
|
|
58712
58776
|
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
|
58713
58777
|
stack.pop();
|
|
58714
58778
|
}
|
|
@@ -66906,12 +66970,12 @@ var ts;
|
|
|
66906
66970
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
66907
66971
|
if (maxDepth === void 0) { maxDepth = 3; }
|
|
66908
66972
|
if (depth >= maxDepth) {
|
|
66909
|
-
var
|
|
66973
|
+
var identity_2 = getRecursionIdentity(type);
|
|
66910
66974
|
var count = 0;
|
|
66911
66975
|
var lastTypeId = 0;
|
|
66912
66976
|
for (var i = 0; i < depth; i++) {
|
|
66913
66977
|
var t = stack[i];
|
|
66914
|
-
if (getRecursionIdentity(t) ===
|
|
66978
|
+
if (getRecursionIdentity(t) === identity_2) {
|
|
66915
66979
|
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
66916
66980
|
// type ids are an indicator of newer instantiations caused by recursion.
|
|
66917
66981
|
if (t.id >= lastTypeId) {
|
|
@@ -79725,11 +79789,16 @@ var ts;
|
|
|
79725
79789
|
if (constraintType && defaultType) {
|
|
79726
79790
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79727
79791
|
}
|
|
79728
|
-
|
|
79792
|
+
checkNodeDeferred(node);
|
|
79793
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79794
|
+
}
|
|
79795
|
+
function checkTypeParameterDeferred(node) {
|
|
79796
|
+
if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
|
|
79797
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
|
79729
79798
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79730
79799
|
if (modifiers) {
|
|
79731
79800
|
var symbol = getSymbolOfNode(node.parent);
|
|
79732
|
-
if (node.parent
|
|
79801
|
+
if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79733
79802
|
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79734
79803
|
}
|
|
79735
79804
|
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
@@ -79742,7 +79811,6 @@ var ts;
|
|
|
79742
79811
|
}
|
|
79743
79812
|
}
|
|
79744
79813
|
}
|
|
79745
|
-
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79746
79814
|
}
|
|
79747
79815
|
function checkParameter(node) {
|
|
79748
79816
|
// Grammar checking
|
|
@@ -80232,7 +80300,7 @@ var ts;
|
|
|
80232
80300
|
superCallStatement = statement;
|
|
80233
80301
|
break;
|
|
80234
80302
|
}
|
|
80235
|
-
if (
|
|
80303
|
+
if (nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
80236
80304
|
break;
|
|
80237
80305
|
}
|
|
80238
80306
|
}
|
|
@@ -85585,6 +85653,9 @@ var ts;
|
|
|
85585
85653
|
case 226 /* ClassExpression */:
|
|
85586
85654
|
checkClassExpressionDeferred(node);
|
|
85587
85655
|
break;
|
|
85656
|
+
case 163 /* TypeParameter */:
|
|
85657
|
+
checkTypeParameterDeferred(node);
|
|
85658
|
+
break;
|
|
85588
85659
|
case 279 /* JsxSelfClosingElement */:
|
|
85589
85660
|
checkJsxSelfClosingElementDeferred(node);
|
|
85590
85661
|
break;
|
|
@@ -86681,11 +86752,6 @@ var ts;
|
|
|
86681
86752
|
!parameter.initializer &&
|
|
86682
86753
|
ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
|
|
86683
86754
|
}
|
|
86684
|
-
function isOptionalUninitializedParameter(parameter) {
|
|
86685
|
-
return !!strictNullChecks &&
|
|
86686
|
-
isOptionalParameter(parameter) &&
|
|
86687
|
-
!parameter.initializer;
|
|
86688
|
-
}
|
|
86689
86755
|
function isExpandoFunctionDeclaration(node) {
|
|
86690
86756
|
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
|
|
86691
86757
|
if (!declaration) {
|
|
@@ -87602,8 +87668,7 @@ var ts;
|
|
|
87602
87668
|
case 144 /* OutKeyword */:
|
|
87603
87669
|
var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
|
|
87604
87670
|
var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
|
|
87605
|
-
if (node.kind !== 163 /* TypeParameter */ || (node.parent
|
|
87606
|
-
node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
|
|
87671
|
+
if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
|
|
87607
87672
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
|
87608
87673
|
}
|
|
87609
87674
|
if (flags & inOutFlag) {
|
|
@@ -92837,11 +92902,11 @@ var ts;
|
|
|
92837
92902
|
}
|
|
92838
92903
|
var statements = [];
|
|
92839
92904
|
resumeLexicalEnvironment();
|
|
92840
|
-
var
|
|
92841
|
-
var superStatementIndex = ts.findSuperStatementIndex(body.statements,
|
|
92905
|
+
var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92906
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
|
|
92842
92907
|
// If there was a super call, visit existing statements up to and including it
|
|
92843
92908
|
if (superStatementIndex >= 0) {
|
|
92844
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement,
|
|
92909
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
|
|
92845
92910
|
}
|
|
92846
92911
|
// Transform parameters into property assignments. Transforms this:
|
|
92847
92912
|
//
|
|
@@ -92860,12 +92925,12 @@ var ts;
|
|
|
92860
92925
|
if (superStatementIndex >= 0) {
|
|
92861
92926
|
ts.addRange(statements, parameterPropertyAssignments);
|
|
92862
92927
|
}
|
|
92863
|
-
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
92928
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
|
|
92864
92929
|
else {
|
|
92865
|
-
statements =
|
|
92930
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
92866
92931
|
}
|
|
92867
|
-
// Add remaining statements from the body, skipping the super() call if it was found
|
|
92868
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
92932
|
+
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
92933
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
|
|
92869
92934
|
// End the lexical environment.
|
|
92870
92935
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92871
92936
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -109764,7 +109829,7 @@ var ts;
|
|
|
109764
109829
|
addOutput(buildInfoPath);
|
|
109765
109830
|
}
|
|
109766
109831
|
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
|
|
109767
|
-
if (ts.
|
|
109832
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109768
109833
|
return;
|
|
109769
109834
|
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109770
109835
|
addOutput(js);
|
|
@@ -109809,7 +109874,7 @@ var ts;
|
|
|
109809
109874
|
/*@internal*/
|
|
109810
109875
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
109811
109876
|
var options = _a.options, fileNames = _a.fileNames;
|
|
109812
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.
|
|
109877
|
+
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));
|
|
109813
109878
|
}
|
|
109814
109879
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
109815
109880
|
/*@internal*/
|
|
@@ -109851,7 +109916,7 @@ var ts;
|
|
|
109851
109916
|
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
|
|
109852
109917
|
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
|
|
109853
109918
|
var inputFileName = _b[_a];
|
|
109854
|
-
if (ts.
|
|
109919
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109855
109920
|
continue;
|
|
109856
109921
|
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109857
109922
|
if (jsFilePath)
|
|
@@ -115201,7 +115266,7 @@ var ts;
|
|
|
115201
115266
|
if (ts.outFile(options) || options.outDir)
|
|
115202
115267
|
return false;
|
|
115203
115268
|
// File if emitted next to input needs to be ignored
|
|
115204
|
-
if (ts.
|
|
115269
|
+
if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
|
|
115205
115270
|
// If its declaration directory: its not ignored if not excluded by config
|
|
115206
115271
|
if (options.declarationDir)
|
|
115207
115272
|
return false;
|
|
@@ -116374,7 +116439,7 @@ var ts;
|
|
|
116374
116439
|
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
116375
116440
|
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
|
|
116376
116441
|
var fileName = _c[_b];
|
|
116377
|
-
if (!ts.
|
|
116442
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
116378
116443
|
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
|
|
116379
116444
|
}
|
|
116380
116445
|
}
|
|
@@ -116565,7 +116630,7 @@ var ts;
|
|
|
116565
116630
|
}
|
|
116566
116631
|
function getRedirectReferenceForResolution(file) {
|
|
116567
116632
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
116568
|
-
if (redirect || !ts.
|
|
116633
|
+
if (redirect || !ts.isDeclarationFileName(file.originalFileName))
|
|
116569
116634
|
return redirect;
|
|
116570
116635
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
116571
116636
|
// 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
|
|
@@ -117956,7 +118021,7 @@ var ts;
|
|
|
117956
118021
|
}
|
|
117957
118022
|
function getProjectReferenceRedirectProject(fileName) {
|
|
117958
118023
|
// Ignore dts or any json files
|
|
117959
|
-
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.
|
|
118024
|
+
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117960
118025
|
return undefined;
|
|
117961
118026
|
}
|
|
117962
118027
|
// If this file is produced by a referenced project, we need to rewrite it to
|
|
@@ -118005,7 +118070,7 @@ var ts;
|
|
|
118005
118070
|
else {
|
|
118006
118071
|
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
118007
118072
|
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
|
|
118008
|
-
if (!ts.
|
|
118073
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
118009
118074
|
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
|
|
118010
118075
|
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
|
|
118011
118076
|
}
|
|
@@ -118806,7 +118871,7 @@ var ts;
|
|
|
118806
118871
|
if (options.outDir) {
|
|
118807
118872
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
118808
118873
|
}
|
|
118809
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.
|
|
118874
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
|
|
118810
118875
|
// Otherwise just check if sourceFile with the name exists
|
|
118811
118876
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
118812
118877
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -119432,7 +119497,7 @@ var ts;
|
|
|
119432
119497
|
/*forceDtsEmit*/ true);
|
|
119433
119498
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
119434
119499
|
if (firstDts_1) {
|
|
119435
|
-
ts.Debug.assert(ts.
|
|
119500
|
+
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; })); });
|
|
119436
119501
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
119437
119502
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
119438
119503
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -119837,7 +119902,7 @@ var ts;
|
|
|
119837
119902
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
119838
119903
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
119839
119904
|
*/
|
|
119840
|
-
function getNextAffectedFile(state, cancellationToken, computeHash) {
|
|
119905
|
+
function getNextAffectedFile(state, cancellationToken, computeHash, host) {
|
|
119841
119906
|
while (true) {
|
|
119842
119907
|
var affectedFiles = state.affectedFiles;
|
|
119843
119908
|
if (affectedFiles) {
|
|
@@ -119848,7 +119913,7 @@ var ts;
|
|
|
119848
119913
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
119849
119914
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
119850
119915
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
119851
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
|
|
119916
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119852
119917
|
return affectedFile;
|
|
119853
119918
|
}
|
|
119854
119919
|
affectedFilesIndex++;
|
|
@@ -119889,6 +119954,11 @@ var ts;
|
|
|
119889
119954
|
state.seenAffectedFiles = new ts.Set();
|
|
119890
119955
|
}
|
|
119891
119956
|
}
|
|
119957
|
+
function clearAffectedFilesPendingEmit(state) {
|
|
119958
|
+
state.affectedFilesPendingEmit = undefined;
|
|
119959
|
+
state.affectedFilesPendingEmitKind = undefined;
|
|
119960
|
+
state.affectedFilesPendingEmitIndex = undefined;
|
|
119961
|
+
}
|
|
119892
119962
|
/**
|
|
119893
119963
|
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
|
119894
119964
|
*/
|
|
@@ -119908,9 +119978,7 @@ var ts;
|
|
|
119908
119978
|
}
|
|
119909
119979
|
}
|
|
119910
119980
|
}
|
|
119911
|
-
state
|
|
119912
|
-
state.affectedFilesPendingEmitKind = undefined;
|
|
119913
|
-
state.affectedFilesPendingEmitIndex = undefined;
|
|
119981
|
+
clearAffectedFilesPendingEmit(state);
|
|
119914
119982
|
}
|
|
119915
119983
|
return undefined;
|
|
119916
119984
|
}
|
|
@@ -119918,7 +119986,7 @@ var ts;
|
|
|
119918
119986
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119919
119987
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
119920
119988
|
*/
|
|
119921
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
|
|
119989
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119922
119990
|
var _a;
|
|
119923
119991
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119924
119992
|
// If affected files is everything except default library, then nothing more to do
|
|
@@ -119943,14 +120011,14 @@ var ts;
|
|
|
119943
120011
|
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);
|
|
119944
120012
|
}
|
|
119945
120013
|
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
|
|
119946
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
|
|
120014
|
+
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119947
120015
|
}
|
|
119948
120016
|
}
|
|
119949
120017
|
/**
|
|
119950
120018
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
119951
120019
|
* Also we need to make sure signature is updated for these files
|
|
119952
120020
|
*/
|
|
119953
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
|
|
120021
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
|
|
119954
120022
|
removeSemanticDiagnosticsOf(state, path);
|
|
119955
120023
|
if (!state.changedFilesSet.has(path)) {
|
|
119956
120024
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -119961,8 +120029,7 @@ var ts;
|
|
|
119961
120029
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
119962
120030
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
119963
120031
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
119964
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
|
|
119965
|
-
/* useFileVersionAsSignature */ true);
|
|
120032
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
|
|
119966
120033
|
// If not dts emit, nothing more to do
|
|
119967
120034
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
119968
120035
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -120159,13 +120226,18 @@ var ts;
|
|
|
120159
120226
|
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
|
120160
120227
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
120161
120228
|
return value.version === actualSignature ?
|
|
120162
|
-
value.affectsGlobalScope ?
|
|
120163
|
-
|
|
120229
|
+
value.affectsGlobalScope || value.impliedFormat ?
|
|
120230
|
+
// If file version is same as signature, dont serialize signature
|
|
120231
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120232
|
+
// If file info only contains version and signature and both are same we can just write string
|
|
120164
120233
|
value.version :
|
|
120165
|
-
actualSignature !== undefined ?
|
|
120234
|
+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
|
|
120166
120235
|
signature === undefined ?
|
|
120236
|
+
// If we havent computed signature, use fileInfo as is
|
|
120167
120237
|
value :
|
|
120238
|
+
// Serialize fileInfo with new updated signature
|
|
120168
120239
|
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120240
|
+
// Signature of the FileInfo is undefined, serialize it as false
|
|
120169
120241
|
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
120170
120242
|
});
|
|
120171
120243
|
var referencedMap;
|
|
@@ -120410,7 +120482,7 @@ var ts;
|
|
|
120410
120482
|
* in that order would be used to write the files
|
|
120411
120483
|
*/
|
|
120412
120484
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120413
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120485
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120414
120486
|
var emitKind = 1 /* Full */;
|
|
120415
120487
|
var isPendingEmitFile = false;
|
|
120416
120488
|
if (!affected) {
|
|
@@ -120455,54 +120527,48 @@ var ts;
|
|
|
120455
120527
|
* in that order would be used to write the files
|
|
120456
120528
|
*/
|
|
120457
120529
|
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120458
|
-
var
|
|
120459
|
-
var savedAffectedFilesPendingEmit;
|
|
120460
|
-
var savedAffectedFilesPendingEmitKind;
|
|
120461
|
-
var savedAffectedFilesPendingEmitIndex;
|
|
120462
|
-
// 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
|
|
120463
|
-
// This ensures pending files to emit is updated in tsbuildinfo
|
|
120464
|
-
// 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)
|
|
120465
|
-
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
|
|
120466
|
-
!targetSourceFile &&
|
|
120467
|
-
!ts.outFile(state.compilerOptions) &&
|
|
120468
|
-
!state.compilerOptions.noEmit &&
|
|
120469
|
-
state.compilerOptions.noEmitOnError) {
|
|
120470
|
-
restorePendingEmitOnHandlingNoEmitSuccess = true;
|
|
120471
|
-
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
|
120472
|
-
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
|
|
120473
|
-
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
|
120474
|
-
}
|
|
120530
|
+
var _a;
|
|
120475
120531
|
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120476
120532
|
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
|
|
120477
120533
|
}
|
|
120478
120534
|
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
|
|
120479
120535
|
if (result)
|
|
120480
120536
|
return result;
|
|
120481
|
-
if (restorePendingEmitOnHandlingNoEmitSuccess) {
|
|
120482
|
-
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
|
|
120483
|
-
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
|
|
120484
|
-
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
|
|
120485
|
-
}
|
|
120486
120537
|
// Emit only affected files if using builder for emit
|
|
120487
|
-
if (!targetSourceFile
|
|
120488
|
-
|
|
120489
|
-
|
|
120490
|
-
|
|
120491
|
-
|
|
120492
|
-
|
|
120493
|
-
|
|
120494
|
-
|
|
120495
|
-
|
|
120496
|
-
|
|
120497
|
-
|
|
120498
|
-
|
|
120538
|
+
if (!targetSourceFile) {
|
|
120539
|
+
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120540
|
+
// Emit and report any errors we ran into.
|
|
120541
|
+
var sourceMaps = [];
|
|
120542
|
+
var emitSkipped = false;
|
|
120543
|
+
var diagnostics = void 0;
|
|
120544
|
+
var emittedFiles = [];
|
|
120545
|
+
var affectedEmitResult = void 0;
|
|
120546
|
+
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
|
|
120547
|
+
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
|
|
120548
|
+
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
|
|
120549
|
+
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
|
|
120550
|
+
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
|
|
120551
|
+
}
|
|
120552
|
+
return {
|
|
120553
|
+
emitSkipped: emitSkipped,
|
|
120554
|
+
diagnostics: diagnostics || ts.emptyArray,
|
|
120555
|
+
emittedFiles: emittedFiles,
|
|
120556
|
+
sourceMaps: sourceMaps
|
|
120557
|
+
};
|
|
120558
|
+
}
|
|
120559
|
+
// In non Emit builder, clear affected files pending emit
|
|
120560
|
+
else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
|
|
120561
|
+
ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
|
|
120562
|
+
// State can clear affected files pending emit if
|
|
120563
|
+
if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
|
|
120564
|
+
// If every file pending emit is pending on only dts emit
|
|
120565
|
+
|| ts.every(state.affectedFilesPendingEmit, function (path, index) {
|
|
120566
|
+
return index < state.affectedFilesPendingEmitIndex ||
|
|
120567
|
+
state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
|
|
120568
|
+
})) {
|
|
120569
|
+
clearAffectedFilesPendingEmit(state);
|
|
120570
|
+
}
|
|
120499
120571
|
}
|
|
120500
|
-
return {
|
|
120501
|
-
emitSkipped: emitSkipped,
|
|
120502
|
-
diagnostics: diagnostics || ts.emptyArray,
|
|
120503
|
-
emittedFiles: emittedFiles,
|
|
120504
|
-
sourceMaps: sourceMaps
|
|
120505
|
-
};
|
|
120506
120572
|
}
|
|
120507
120573
|
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120508
120574
|
}
|
|
@@ -120512,7 +120578,7 @@ var ts;
|
|
|
120512
120578
|
*/
|
|
120513
120579
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
120514
120580
|
while (true) {
|
|
120515
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120581
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120516
120582
|
if (!affected) {
|
|
120517
120583
|
// Done
|
|
120518
120584
|
return undefined;
|
|
@@ -123632,9 +123698,6 @@ var ts;
|
|
|
123632
123698
|
function newer(date1, date2) {
|
|
123633
123699
|
return date2 > date1 ? date2 : date1;
|
|
123634
123700
|
}
|
|
123635
|
-
function isDeclarationFile(fileName) {
|
|
123636
|
-
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
123637
|
-
}
|
|
123638
123701
|
/*@internal*/
|
|
123639
123702
|
function isCircularBuildOrder(buildOrder) {
|
|
123640
123703
|
return !!buildOrder && !!buildOrder.buildOrder;
|
|
@@ -124197,7 +124260,7 @@ var ts;
|
|
|
124197
124260
|
outputFiles.forEach(function (_a) {
|
|
124198
124261
|
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
|
|
124199
124262
|
var priorChangeTime;
|
|
124200
|
-
if (!anyDtsChanged &&
|
|
124263
|
+
if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
|
|
124201
124264
|
// Check for unchanged .d.ts files
|
|
124202
124265
|
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
|
|
124203
124266
|
priorChangeTime = host.getModifiedTime(name);
|
|
@@ -124538,7 +124601,7 @@ var ts;
|
|
|
124538
124601
|
// In addition to file timestamps, we also keep track of when a .d.ts file
|
|
124539
124602
|
// had its file touched but not had its contents changed - this allows us
|
|
124540
124603
|
// to skip a downstream typecheck
|
|
124541
|
-
if (
|
|
124604
|
+
if (ts.isDeclarationFileName(output)) {
|
|
124542
124605
|
var outputModifiedTime = ts.getModifiedTime(host, output);
|
|
124543
124606
|
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
|
|
124544
124607
|
}
|
|
@@ -124692,7 +124755,7 @@ var ts;
|
|
|
124692
124755
|
reportVerbose = false;
|
|
124693
124756
|
reportStatus(state, verboseMessage, proj.options.configFilePath);
|
|
124694
124757
|
}
|
|
124695
|
-
if (
|
|
124758
|
+
if (ts.isDeclarationFileName(file)) {
|
|
124696
124759
|
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
|
|
124697
124760
|
}
|
|
124698
124761
|
host.setModifiedTime(file, now);
|
|
@@ -132004,17 +132067,13 @@ var ts;
|
|
|
132004
132067
|
}
|
|
132005
132068
|
}
|
|
132006
132069
|
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
132007
|
-
|
|
132008
|
-
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
132070
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
|
|
132009
132071
|
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
132010
132072
|
name = name + labelDetails.detail;
|
|
132011
132073
|
labelDetails = undefined;
|
|
132012
132074
|
}
|
|
132013
132075
|
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
132014
132076
|
sortText = Completions.SortText.SortBelow(sortText);
|
|
132015
|
-
if (importAdder.hasFixes()) {
|
|
132016
|
-
hasAction = true;
|
|
132017
|
-
}
|
|
132018
132077
|
}
|
|
132019
132078
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
132020
132079
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
@@ -132237,8 +132296,7 @@ var ts;
|
|
|
132237
132296
|
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
132238
132297
|
var insertText = name;
|
|
132239
132298
|
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
132240
|
-
var
|
|
132241
|
-
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
132299
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
|
|
132242
132300
|
if (!method) {
|
|
132243
132301
|
return undefined;
|
|
132244
132302
|
}
|
|
@@ -132267,16 +132325,15 @@ var ts;
|
|
|
132267
132325
|
/*modifiers*/ undefined,
|
|
132268
132326
|
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
132269
132327
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
132270
|
-
return { isSnippet: isSnippet, insertText: insertText,
|
|
132328
|
+
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
132271
132329
|
}
|
|
132272
132330
|
;
|
|
132273
|
-
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences
|
|
132331
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
132274
132332
|
var declarations = symbol.getDeclarations();
|
|
132275
132333
|
if (!(declarations && declarations.length)) {
|
|
132276
132334
|
return undefined;
|
|
132277
132335
|
}
|
|
132278
132336
|
var checker = program.getTypeChecker();
|
|
132279
|
-
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
132280
132337
|
var declaration = declarations[0];
|
|
132281
132338
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
132282
132339
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
@@ -132309,11 +132366,6 @@ var ts;
|
|
|
132309
132366
|
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
132310
132367
|
return undefined;
|
|
132311
132368
|
}
|
|
132312
|
-
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
132313
|
-
if (importableReference) {
|
|
132314
|
-
typeNode = importableReference.typeNode;
|
|
132315
|
-
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
132316
|
-
}
|
|
132317
132369
|
var body = void 0;
|
|
132318
132370
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
132319
132371
|
var emptyStmt = ts.factory.createEmptyStatement();
|
|
@@ -132323,11 +132375,19 @@ var ts;
|
|
|
132323
132375
|
else {
|
|
132324
132376
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
132325
132377
|
}
|
|
132378
|
+
var parameters = typeNode.parameters.map(function (typedParam) {
|
|
132379
|
+
return ts.factory.createParameterDeclaration(
|
|
132380
|
+
/*decorators*/ undefined,
|
|
132381
|
+
/*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
|
|
132382
|
+
/*type*/ undefined, typedParam.initializer);
|
|
132383
|
+
});
|
|
132326
132384
|
return ts.factory.createMethodDeclaration(
|
|
132327
132385
|
/*decorators*/ undefined,
|
|
132328
132386
|
/*modifiers*/ undefined,
|
|
132329
132387
|
/*asteriskToken*/ undefined, name,
|
|
132330
|
-
/*questionToken*/ undefined,
|
|
132388
|
+
/*questionToken*/ undefined,
|
|
132389
|
+
/*typeParameters*/ undefined, parameters,
|
|
132390
|
+
/*type*/ undefined, body);
|
|
132331
132391
|
}
|
|
132332
132392
|
default:
|
|
132333
132393
|
return undefined;
|
|
@@ -132690,20 +132750,6 @@ var ts;
|
|
|
132690
132750
|
};
|
|
132691
132751
|
}
|
|
132692
132752
|
}
|
|
132693
|
-
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132694
|
-
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132695
|
-
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132696
|
-
if (importAdder.hasFixes()) {
|
|
132697
|
-
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132698
|
-
return {
|
|
132699
|
-
sourceDisplay: undefined,
|
|
132700
|
-
codeActions: [{
|
|
132701
|
-
changes: changes,
|
|
132702
|
-
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132703
|
-
}],
|
|
132704
|
-
};
|
|
132705
|
-
}
|
|
132706
|
-
}
|
|
132707
132753
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132708
132754
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132709
132755
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -135524,7 +135570,7 @@ var ts;
|
|
|
135524
135570
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
135525
135571
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
135526
135572
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
135527
|
-
var otherBucketKey = !ts.
|
|
135573
|
+
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
135528
135574
|
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
135529
135575
|
if (otherBucketKey) {
|
|
135530
135576
|
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
@@ -137464,6 +137510,30 @@ var ts;
|
|
|
137464
137510
|
}
|
|
137465
137511
|
}
|
|
137466
137512
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
137513
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
137514
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
137515
|
+
return candidates.reduce(function (topMost, decl) {
|
|
137516
|
+
var depth = getDepth(decl);
|
|
137517
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
137518
|
+
topMost.declarationNames.push(decl);
|
|
137519
|
+
topMost.depth = depth;
|
|
137520
|
+
}
|
|
137521
|
+
else if (depth < topMost.depth) {
|
|
137522
|
+
topMost.declarationNames = [decl];
|
|
137523
|
+
topMost.depth = depth;
|
|
137524
|
+
}
|
|
137525
|
+
return topMost;
|
|
137526
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
137527
|
+
function getDepth(declaration) {
|
|
137528
|
+
var depth = 0;
|
|
137529
|
+
while (declaration) {
|
|
137530
|
+
declaration = ts.getContainerNode(declaration);
|
|
137531
|
+
depth++;
|
|
137532
|
+
}
|
|
137533
|
+
return depth;
|
|
137534
|
+
}
|
|
137535
|
+
}
|
|
137536
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
137467
137537
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
137468
137538
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
137469
137539
|
return false;
|
|
@@ -139100,7 +139170,9 @@ var ts;
|
|
|
139100
139170
|
(function (ts) {
|
|
139101
139171
|
var GoToDefinition;
|
|
139102
139172
|
(function (GoToDefinition) {
|
|
139103
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
139173
|
+
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
|
|
139174
|
+
var _a;
|
|
139175
|
+
var _b;
|
|
139104
139176
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
139105
139177
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
139106
139178
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -139123,33 +139195,63 @@ var ts;
|
|
|
139123
139195
|
}
|
|
139124
139196
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
139125
139197
|
var classDecl = node.parent.parent;
|
|
139126
|
-
var
|
|
139198
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
139127
139199
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
139128
139200
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
139129
139201
|
var sourceFile_1 = node.getSourceFile();
|
|
139130
139202
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
139131
139203
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
139132
139204
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
139133
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
139205
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
139134
139206
|
});
|
|
139135
139207
|
}
|
|
139136
|
-
var
|
|
139208
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
139209
|
+
var fallbackNode = node;
|
|
139210
|
+
if (searchOtherFilesOnly && failedAliasResolution) {
|
|
139211
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
139212
|
+
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); });
|
|
139213
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
139214
|
+
if (moduleSpecifier) {
|
|
139215
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
139216
|
+
fallbackNode = moduleSpecifier;
|
|
139217
|
+
}
|
|
139218
|
+
}
|
|
139219
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
139220
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
139221
|
+
// be that module resolution succeeded but the target was not a module.
|
|
139222
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
139223
|
+
if (ref) {
|
|
139224
|
+
return [{
|
|
139225
|
+
name: fallbackNode.text,
|
|
139226
|
+
fileName: ref.resolvedFileName,
|
|
139227
|
+
containerName: undefined,
|
|
139228
|
+
containerKind: undefined,
|
|
139229
|
+
kind: "script" /* scriptElement */,
|
|
139230
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
139231
|
+
failedAliasResolution: failedAliasResolution,
|
|
139232
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
139233
|
+
unverified: fallbackNode !== node,
|
|
139234
|
+
}];
|
|
139235
|
+
}
|
|
139236
|
+
}
|
|
139137
139237
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
139138
139238
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
139139
139239
|
if (!symbol) {
|
|
139140
139240
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
139141
139241
|
}
|
|
139242
|
+
if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
139243
|
+
return undefined;
|
|
139142
139244
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
139143
139245
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
139144
139246
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
139145
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
139247
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
139146
139248
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
139147
139249
|
// If this is the original constructor definition, parent is the class.
|
|
139148
139250
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
139149
139251
|
return [sigInfo];
|
|
139150
139252
|
}
|
|
139151
139253
|
else {
|
|
139152
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
139254
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
139153
139255
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
139154
139256
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
139155
139257
|
}
|
|
@@ -139161,7 +139263,7 @@ var ts;
|
|
|
139161
139263
|
// assignment. This case and others are handled by the following code.
|
|
139162
139264
|
if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
|
|
139163
139265
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
139164
|
-
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;
|
|
139266
|
+
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;
|
|
139165
139267
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
139166
139268
|
}
|
|
139167
139269
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -139184,7 +139286,7 @@ var ts;
|
|
|
139184
139286
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
139185
139287
|
});
|
|
139186
139288
|
}
|
|
139187
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
139289
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
139188
139290
|
}
|
|
139189
139291
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
139190
139292
|
/**
|
|
@@ -139282,24 +139384,24 @@ var ts;
|
|
|
139282
139384
|
return undefined;
|
|
139283
139385
|
}
|
|
139284
139386
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
139285
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
139387
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
139286
139388
|
}
|
|
139287
|
-
var
|
|
139389
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
139288
139390
|
if (!symbol)
|
|
139289
139391
|
return undefined;
|
|
139290
139392
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
139291
139393
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
139292
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
139394
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
139293
139395
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
139294
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
139396
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
139295
139397
|
return typeDefinitions.length ? typeDefinitions
|
|
139296
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
139398
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
139297
139399
|
: undefined;
|
|
139298
139400
|
}
|
|
139299
139401
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
139300
|
-
function definitionFromType(type, checker, node) {
|
|
139402
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
139301
139403
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
139302
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
139404
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
139303
139405
|
});
|
|
139304
139406
|
}
|
|
139305
139407
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -139341,13 +139443,17 @@ var ts;
|
|
|
139341
139443
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
139342
139444
|
// import {A, B} from "mod";
|
|
139343
139445
|
// to jump to the implementation directly.
|
|
139446
|
+
var failedAliasResolution = false;
|
|
139344
139447
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
139345
139448
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
139346
139449
|
if (aliased.declarations) {
|
|
139347
|
-
return aliased;
|
|
139450
|
+
return { symbol: aliased };
|
|
139451
|
+
}
|
|
139452
|
+
else {
|
|
139453
|
+
failedAliasResolution = true;
|
|
139348
139454
|
}
|
|
139349
139455
|
}
|
|
139350
|
-
return symbol;
|
|
139456
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
139351
139457
|
}
|
|
139352
139458
|
// Go to the original declaration for cases:
|
|
139353
139459
|
//
|
|
@@ -139361,26 +139467,45 @@ var ts;
|
|
|
139361
139467
|
if (node.parent === declaration) {
|
|
139362
139468
|
return true;
|
|
139363
139469
|
}
|
|
139364
|
-
|
|
139365
|
-
|
|
139366
|
-
case 265 /* ImportEqualsDeclaration */:
|
|
139367
|
-
return true;
|
|
139368
|
-
case 270 /* ImportSpecifier */:
|
|
139369
|
-
return declaration.parent.kind === 269 /* NamedImports */;
|
|
139370
|
-
case 203 /* BindingElement */:
|
|
139371
|
-
case 254 /* VariableDeclaration */:
|
|
139372
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
139373
|
-
default:
|
|
139374
|
-
return false;
|
|
139470
|
+
if (declaration.kind === 268 /* NamespaceImport */) {
|
|
139471
|
+
return false;
|
|
139375
139472
|
}
|
|
139473
|
+
return true;
|
|
139474
|
+
}
|
|
139475
|
+
/**
|
|
139476
|
+
* ```ts
|
|
139477
|
+
* function f() {}
|
|
139478
|
+
* f.foo = 0;
|
|
139479
|
+
* ```
|
|
139480
|
+
*
|
|
139481
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
139482
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
139483
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
139484
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
139485
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
139486
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
139487
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
139488
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
139489
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
139490
|
+
* up with a more precise definition of what counts as a definition.
|
|
139491
|
+
*/
|
|
139492
|
+
function isExpandoDeclaration(node) {
|
|
139493
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
139494
|
+
return false;
|
|
139495
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
139496
|
+
if (ts.isAssignmentExpression(p))
|
|
139497
|
+
return true;
|
|
139498
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
139499
|
+
return "quit";
|
|
139500
|
+
return false;
|
|
139501
|
+
});
|
|
139502
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
139376
139503
|
}
|
|
139377
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
139378
|
-
|
|
139379
|
-
|
|
139380
|
-
|
|
139381
|
-
|
|
139382
|
-
|| undefined;
|
|
139383
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
139504
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
139505
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
139506
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
139507
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
139508
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
|
|
139384
139509
|
function getConstructSignatureDefinition() {
|
|
139385
139510
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
139386
139511
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -139404,26 +139529,27 @@ var ts;
|
|
|
139404
139529
|
return declarations.length
|
|
139405
139530
|
? declarationsWithBody.length !== 0
|
|
139406
139531
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
139407
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
139532
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
|
|
139408
139533
|
: undefined;
|
|
139409
139534
|
}
|
|
139410
139535
|
}
|
|
139411
139536
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
139412
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
139537
|
+
function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
|
|
139413
139538
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
139414
139539
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
139415
139540
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
139416
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
139541
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
|
|
139417
139542
|
}
|
|
139543
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
139418
139544
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
139419
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
139545
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
|
|
139420
139546
|
var sourceFile = declaration.getSourceFile();
|
|
139421
139547
|
if (!textSpan) {
|
|
139422
139548
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
139423
139549
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
139424
139550
|
}
|
|
139425
139551
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
139426
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
139552
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
|
|
139427
139553
|
}
|
|
139428
139554
|
function isDefinitionVisible(checker, declaration) {
|
|
139429
139555
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -139456,8 +139582,8 @@ var ts;
|
|
|
139456
139582
|
return false;
|
|
139457
139583
|
}
|
|
139458
139584
|
}
|
|
139459
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
139460
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
139585
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
139586
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
|
139461
139587
|
}
|
|
139462
139588
|
function findReferenceInPosition(refs, pos) {
|
|
139463
139589
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -152572,9 +152698,10 @@ var ts;
|
|
|
152572
152698
|
// 2. add "member3" to the second import statement's import list
|
|
152573
152699
|
// and it is up to the user to decide which one fits best.
|
|
152574
152700
|
return ts.firstDefined(existingImports, function (_a) {
|
|
152701
|
+
var _b;
|
|
152575
152702
|
var declaration = _a.declaration;
|
|
152576
152703
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
152577
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152704
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152578
152705
|
if (namespacePrefix && moduleSpecifier) {
|
|
152579
152706
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
152580
152707
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -152750,8 +152877,9 @@ var ts;
|
|
|
152750
152877
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
152751
152878
|
}
|
|
152752
152879
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
152880
|
+
var _b;
|
|
152753
152881
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
152754
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152882
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152755
152883
|
if (moduleSpecifier) {
|
|
152756
152884
|
var addAsTypeOnly = useRequire
|
|
152757
152885
|
? 4 /* NotAllowed */
|
|
@@ -157109,7 +157237,6 @@ var ts;
|
|
|
157109
157237
|
var checker = program.getTypeChecker();
|
|
157110
157238
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
157111
157239
|
var flags = 1 /* NoTruncation */
|
|
157112
|
-
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
157113
157240
|
| 256 /* SuppressAnyReturnType */
|
|
157114
157241
|
| 524288 /* AllowEmptyTuple */
|
|
157115
157242
|
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
@@ -164690,9 +164817,9 @@ var ts;
|
|
|
164690
164817
|
}
|
|
164691
164818
|
}
|
|
164692
164819
|
/// Goto definition
|
|
164693
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
164820
|
+
function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
|
|
164694
164821
|
synchronizeHostData();
|
|
164695
|
-
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
164822
|
+
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
|
|
164696
164823
|
}
|
|
164697
164824
|
function getDefinitionAndBoundSpan(fileName, position) {
|
|
164698
164825
|
synchronizeHostData();
|
|
@@ -167233,6 +167360,11 @@ var ts;
|
|
|
167233
167360
|
return "/dev/null/autoImportProviderProject" + counter + "*";
|
|
167234
167361
|
}
|
|
167235
167362
|
server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName;
|
|
167363
|
+
/*@internal*/
|
|
167364
|
+
function makeAuxiliaryProjectName(counter) {
|
|
167365
|
+
return "/dev/null/auxiliaryProject" + counter + "*";
|
|
167366
|
+
}
|
|
167367
|
+
server.makeAuxiliaryProjectName = makeAuxiliaryProjectName;
|
|
167236
167368
|
function createSortedArray() {
|
|
167237
167369
|
return []; // TODO: GH#19873
|
|
167238
167370
|
}
|
|
@@ -167446,6 +167578,7 @@ var ts;
|
|
|
167446
167578
|
CommandTypes["SignatureHelp"] = "signatureHelp";
|
|
167447
167579
|
/* @internal */
|
|
167448
167580
|
CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
|
|
167581
|
+
CommandTypes["FindSourceDefinition"] = "findSourceDefinition";
|
|
167449
167582
|
CommandTypes["Status"] = "status";
|
|
167450
167583
|
CommandTypes["TypeDefinition"] = "typeDefinition";
|
|
167451
167584
|
CommandTypes["ProjectInfo"] = "projectInfo";
|
|
@@ -168025,7 +168158,7 @@ var ts;
|
|
|
168025
168158
|
case 0:
|
|
168026
168159
|
return server.Errors.ThrowNoProject();
|
|
168027
168160
|
case 1:
|
|
168028
|
-
return
|
|
168161
|
+
return ensurePrimaryProjectKind(this.containingProjects[0]);
|
|
168029
168162
|
default:
|
|
168030
168163
|
// If this file belongs to multiple projects, below is the order in which default project is used
|
|
168031
168164
|
// - for open script info, its default configured project during opening is default if info is part of it
|
|
@@ -168063,7 +168196,7 @@ var ts;
|
|
|
168063
168196
|
firstInferredProject = project;
|
|
168064
168197
|
}
|
|
168065
168198
|
}
|
|
168066
|
-
return
|
|
168199
|
+
return ensurePrimaryProjectKind(defaultConfiguredProject ||
|
|
168067
168200
|
firstNonSourceOfProjectReferenceRedirect ||
|
|
168068
168201
|
firstConfiguredProject ||
|
|
168069
168202
|
firstExternalProject ||
|
|
@@ -168139,8 +168272,8 @@ var ts;
|
|
|
168139
168272
|
return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); });
|
|
168140
168273
|
};
|
|
168141
168274
|
/*@internal*/
|
|
168142
|
-
ScriptInfo.prototype.
|
|
168143
|
-
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; });
|
|
168275
|
+
ScriptInfo.prototype.isContainedByBackgroundProject = function () {
|
|
168276
|
+
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; });
|
|
168144
168277
|
};
|
|
168145
168278
|
/**
|
|
168146
168279
|
* @param line 1 based index
|
|
@@ -168174,8 +168307,13 @@ var ts;
|
|
|
168174
168307
|
return ScriptInfo;
|
|
168175
168308
|
}());
|
|
168176
168309
|
server.ScriptInfo = ScriptInfo;
|
|
168177
|
-
|
|
168178
|
-
|
|
168310
|
+
/**
|
|
168311
|
+
* Throws an error if `project` is an AutoImportProvider or AuxiliaryProject,
|
|
168312
|
+
* which are used in the background by other Projects and should never be
|
|
168313
|
+
* reported as the default project for a ScriptInfo.
|
|
168314
|
+
*/
|
|
168315
|
+
function ensurePrimaryProjectKind(project) {
|
|
168316
|
+
if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) {
|
|
168179
168317
|
return server.Errors.ThrowNoProject();
|
|
168180
168318
|
}
|
|
168181
168319
|
return project;
|
|
@@ -168315,6 +168453,7 @@ var ts;
|
|
|
168315
168453
|
ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
|
|
168316
168454
|
ProjectKind[ProjectKind["External"] = 2] = "External";
|
|
168317
168455
|
ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
|
|
168456
|
+
ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
|
|
168318
168457
|
})(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
|
|
168319
168458
|
/* @internal */
|
|
168320
168459
|
function countEachFileTypes(infos, includeSizes) {
|
|
@@ -168340,7 +168479,7 @@ var ts;
|
|
|
168340
168479
|
result.jsxSize += fileSize;
|
|
168341
168480
|
break;
|
|
168342
168481
|
case 3 /* TS */:
|
|
168343
|
-
if (ts.
|
|
168482
|
+
if (ts.isDeclarationFileName(info.fileName)) {
|
|
168344
168483
|
result.dts += 1;
|
|
168345
168484
|
result.dtsSize += fileSize;
|
|
168346
168485
|
}
|
|
@@ -168378,7 +168517,7 @@ var ts;
|
|
|
168378
168517
|
server.allFilesAreJsOrDts = allFilesAreJsOrDts;
|
|
168379
168518
|
/* @internal */
|
|
168380
168519
|
function hasNoTypeScriptSource(fileNames) {
|
|
168381
|
-
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.
|
|
168520
|
+
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
|
|
168382
168521
|
}
|
|
168383
168522
|
server.hasNoTypeScriptSource = hasNoTypeScriptSource;
|
|
168384
168523
|
function isGeneratedFileWatcher(watch) {
|
|
@@ -168782,7 +168921,7 @@ var ts;
|
|
|
168782
168921
|
}
|
|
168783
168922
|
// Update the signature
|
|
168784
168923
|
if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) {
|
|
168785
|
-
var dtsFiles = outputFiles.filter(function (f) { return ts.
|
|
168924
|
+
var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); });
|
|
168786
168925
|
if (dtsFiles.length === 1) {
|
|
168787
168926
|
var sourceFile = this.program.getSourceFile(scriptInfo.fileName);
|
|
168788
168927
|
var signature = this.projectService.host.createHash ?
|
|
@@ -168901,6 +169040,10 @@ var ts;
|
|
|
168901
169040
|
this.autoImportProviderHost.close();
|
|
168902
169041
|
}
|
|
168903
169042
|
this.autoImportProviderHost = undefined;
|
|
169043
|
+
if (this.noDtsResolutionProject) {
|
|
169044
|
+
this.noDtsResolutionProject.close();
|
|
169045
|
+
}
|
|
169046
|
+
this.noDtsResolutionProject = undefined;
|
|
168904
169047
|
// signal language service to release source files acquired from document registry
|
|
168905
169048
|
this.languageService.dispose();
|
|
168906
169049
|
this.languageService = undefined;
|
|
@@ -169423,11 +169566,13 @@ var ts;
|
|
|
169423
169566
|
}
|
|
169424
169567
|
};
|
|
169425
169568
|
Project.prototype.setCompilerOptions = function (compilerOptions) {
|
|
169569
|
+
var _a;
|
|
169426
169570
|
if (compilerOptions) {
|
|
169427
169571
|
compilerOptions.allowNonTsExtensions = true;
|
|
169428
169572
|
var oldOptions = this.compilerOptions;
|
|
169429
169573
|
this.compilerOptions = compilerOptions;
|
|
169430
169574
|
this.setInternalCompilerOptionsForEmittingJsFiles();
|
|
169575
|
+
(_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169431
169576
|
if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) {
|
|
169432
169577
|
// reset cached unresolved imports if changes in compiler options affected module resolution
|
|
169433
169578
|
this.cachedUnresolvedImportsPerFile.clear();
|
|
@@ -169767,6 +169912,31 @@ var ts;
|
|
|
169767
169912
|
Project.prototype.getIncompleteCompletionsCache = function () {
|
|
169768
169913
|
return this.projectService.getIncompleteCompletionsCache();
|
|
169769
169914
|
};
|
|
169915
|
+
/*@internal*/
|
|
169916
|
+
Project.prototype.getNoDtsResolutionProject = function (rootFileNames) {
|
|
169917
|
+
var _this = this;
|
|
169918
|
+
ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic);
|
|
169919
|
+
if (!this.noDtsResolutionProject) {
|
|
169920
|
+
this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169921
|
+
}
|
|
169922
|
+
ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) {
|
|
169923
|
+
var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost);
|
|
169924
|
+
if (info) {
|
|
169925
|
+
_this.noDtsResolutionProject.addRoot(info, pathToAdd);
|
|
169926
|
+
}
|
|
169927
|
+
}, function (pathToRemove) {
|
|
169928
|
+
// It may be preferable to remove roots only once project grows to a certain size?
|
|
169929
|
+
var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove);
|
|
169930
|
+
if (info) {
|
|
169931
|
+
_this.noDtsResolutionProject.removeRoot(info);
|
|
169932
|
+
}
|
|
169933
|
+
});
|
|
169934
|
+
return this.noDtsResolutionProject;
|
|
169935
|
+
};
|
|
169936
|
+
/*@internal*/
|
|
169937
|
+
Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () {
|
|
169938
|
+
return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
|
|
169939
|
+
};
|
|
169770
169940
|
return Project;
|
|
169771
169941
|
}());
|
|
169772
169942
|
server.Project = Project;
|
|
@@ -169882,6 +170052,26 @@ var ts;
|
|
|
169882
170052
|
return InferredProject;
|
|
169883
170053
|
}(Project));
|
|
169884
170054
|
server.InferredProject = InferredProject;
|
|
170055
|
+
var AuxiliaryProject = /** @class */ (function (_super) {
|
|
170056
|
+
__extends(AuxiliaryProject, _super);
|
|
170057
|
+
function AuxiliaryProject(projectService, documentRegistry, compilerOptions) {
|
|
170058
|
+
return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry,
|
|
170059
|
+
/*hasExplicitListOfFiles*/ false,
|
|
170060
|
+
/*lastFileExceededProgramSize*/ undefined, compilerOptions,
|
|
170061
|
+
/*compileOnSaveEnabled*/ false,
|
|
170062
|
+
/*watchOptions*/ undefined, projectService.host,
|
|
170063
|
+
/*currentDirectory*/ undefined) || this;
|
|
170064
|
+
}
|
|
170065
|
+
AuxiliaryProject.prototype.isOrphan = function () {
|
|
170066
|
+
return true;
|
|
170067
|
+
};
|
|
170068
|
+
/*@internal*/
|
|
170069
|
+
AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
170070
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
170071
|
+
return;
|
|
170072
|
+
};
|
|
170073
|
+
return AuxiliaryProject;
|
|
170074
|
+
}(Project));
|
|
169885
170075
|
var AutoImportProviderProject = /** @class */ (function (_super) {
|
|
169886
170076
|
__extends(AutoImportProviderProject, _super);
|
|
169887
170077
|
/*@internal*/
|
|
@@ -170033,6 +170223,11 @@ var ts;
|
|
|
170033
170223
|
}
|
|
170034
170224
|
return hasSameSetOfFiles;
|
|
170035
170225
|
};
|
|
170226
|
+
/*@internal*/
|
|
170227
|
+
AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
170228
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
170229
|
+
return;
|
|
170230
|
+
};
|
|
170036
170231
|
AutoImportProviderProject.prototype.hasRoots = function () {
|
|
170037
170232
|
var _a;
|
|
170038
170233
|
return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length);
|
|
@@ -170718,6 +170913,8 @@ var ts;
|
|
|
170718
170913
|
this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName);
|
|
170719
170914
|
/*@internal*/
|
|
170720
170915
|
this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName);
|
|
170916
|
+
/*@internal*/
|
|
170917
|
+
this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName);
|
|
170721
170918
|
/**
|
|
170722
170919
|
* Open files: with value being project root path, and key being Path of the file that is open
|
|
170723
170920
|
*/
|
|
@@ -170921,13 +171118,15 @@ var ts;
|
|
|
170921
171118
|
ProjectService.prototype.delayUpdateProjectGraph = function (project) {
|
|
170922
171119
|
var _this = this;
|
|
170923
171120
|
project.markAsDirty();
|
|
170924
|
-
|
|
170925
|
-
|
|
170926
|
-
|
|
170927
|
-
|
|
170928
|
-
|
|
170929
|
-
|
|
170930
|
-
|
|
171121
|
+
if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) {
|
|
171122
|
+
var projectName_1 = project.getProjectName();
|
|
171123
|
+
this.pendingProjectUpdates.set(projectName_1, project);
|
|
171124
|
+
this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () {
|
|
171125
|
+
if (_this.pendingProjectUpdates.delete(projectName_1)) {
|
|
171126
|
+
updateProjectIfDirty(project);
|
|
171127
|
+
}
|
|
171128
|
+
});
|
|
171129
|
+
}
|
|
170931
171130
|
};
|
|
170932
171131
|
/*@internal*/
|
|
170933
171132
|
ProjectService.prototype.hasPendingProjectUpdate = function (project) {
|
|
@@ -173208,7 +173407,7 @@ var ts;
|
|
|
173208
173407
|
var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo);
|
|
173209
173408
|
this.filenameToScriptInfo.forEach(function (info) {
|
|
173210
173409
|
// If script info is open or orphan, retain it and its dependencies
|
|
173211
|
-
if (!info.isScriptOpen() && info.isOrphan() && !info.
|
|
173410
|
+
if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) {
|
|
173212
173411
|
// Otherwise if there is any source info that is alive, this alive too
|
|
173213
173412
|
if (!info.sourceMapFilePath)
|
|
173214
173413
|
return;
|
|
@@ -174504,6 +174703,9 @@ var ts;
|
|
|
174504
174703
|
_a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
|
|
174505
174704
|
return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
174506
174705
|
},
|
|
174706
|
+
_a[server.CommandNames.FindSourceDefinition] = function (request) {
|
|
174707
|
+
return _this.requiredResponse(_this.findSourceDefinition(request.arguments));
|
|
174708
|
+
},
|
|
174507
174709
|
_a[server.CommandNames.EmitOutput] = function (request) {
|
|
174508
174710
|
return _this.requiredResponse(_this.getEmitOutput(request.arguments));
|
|
174509
174711
|
},
|
|
@@ -175245,7 +175447,7 @@ var ts;
|
|
|
175245
175447
|
Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
|
|
175246
175448
|
return definitions.map(function (info) {
|
|
175247
175449
|
var newDocumentSpan = getMappedDocumentSpan(info, project);
|
|
175248
|
-
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
|
|
175450
|
+
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
|
|
175249
175451
|
});
|
|
175250
175452
|
};
|
|
175251
175453
|
Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
|
|
@@ -175272,6 +175474,152 @@ var ts;
|
|
|
175272
175474
|
textSpan: textSpan,
|
|
175273
175475
|
};
|
|
175274
175476
|
};
|
|
175477
|
+
Session.prototype.findSourceDefinition = function (args) {
|
|
175478
|
+
var _a;
|
|
175479
|
+
var _b = this.getFileAndProject(args), file = _b.file, project = _b.project;
|
|
175480
|
+
var position = this.getPositionInFile(args, file);
|
|
175481
|
+
var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position);
|
|
175482
|
+
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice();
|
|
175483
|
+
var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) ||
|
|
175484
|
+
ts.some(definitions, function (d) { return !!d.failedAliasResolution; }));
|
|
175485
|
+
if (needsJsResolution) {
|
|
175486
|
+
var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual);
|
|
175487
|
+
definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); });
|
|
175488
|
+
var noDtsProject = project.getNoDtsResolutionProject([file]);
|
|
175489
|
+
var ls = noDtsProject.getLanguageService();
|
|
175490
|
+
var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; });
|
|
175491
|
+
if (ts.some(jsDefinitions)) {
|
|
175492
|
+
for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) {
|
|
175493
|
+
var jsDefinition = jsDefinitions_1[_i];
|
|
175494
|
+
if (jsDefinition.unverified) {
|
|
175495
|
+
var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
|
|
175496
|
+
if (ts.some(refined)) {
|
|
175497
|
+
for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) {
|
|
175498
|
+
var def = refined_1[_c];
|
|
175499
|
+
definitionSet_1.add(def);
|
|
175500
|
+
}
|
|
175501
|
+
continue;
|
|
175502
|
+
}
|
|
175503
|
+
}
|
|
175504
|
+
definitionSet_1.add(jsDefinition);
|
|
175505
|
+
}
|
|
175506
|
+
}
|
|
175507
|
+
else {
|
|
175508
|
+
var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; });
|
|
175509
|
+
for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) {
|
|
175510
|
+
var candidate = _e[_d];
|
|
175511
|
+
var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
|
|
175512
|
+
if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
|
|
175513
|
+
continue;
|
|
175514
|
+
}
|
|
175515
|
+
var noDtsProgram = ls.getProgram();
|
|
175516
|
+
var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
|
|
175517
|
+
for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) {
|
|
175518
|
+
var match = _g[_f];
|
|
175519
|
+
definitionSet_1.add(match);
|
|
175520
|
+
}
|
|
175521
|
+
}
|
|
175522
|
+
}
|
|
175523
|
+
definitions = ts.arrayFrom(definitionSet_1.values());
|
|
175524
|
+
}
|
|
175525
|
+
definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
|
|
175526
|
+
return this.mapDefinitionInfo(definitions, project);
|
|
175527
|
+
function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
|
|
175528
|
+
var _a;
|
|
175529
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
|
|
175530
|
+
if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
|
|
175531
|
+
// Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
|
|
175532
|
+
var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
|
175533
|
+
var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
|
|
175534
|
+
var compilerOptions = project.getCompilationSettings();
|
|
175535
|
+
var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
|
|
175536
|
+
if (!packageJson)
|
|
175537
|
+
return undefined;
|
|
175538
|
+
// Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext -
|
|
175539
|
+
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
|
175540
|
+
// resolved from the package root under --moduleResolution node
|
|
175541
|
+
var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache());
|
|
175542
|
+
// This substring is correct only because we checked for a single `/node_modules/` at the top.
|
|
175543
|
+
var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex);
|
|
175544
|
+
var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart));
|
|
175545
|
+
var path_1 = project.toPath(fileName);
|
|
175546
|
+
if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) {
|
|
175547
|
+
// This file was the main entrypoint of a package. Try to resolve that same package name with
|
|
175548
|
+
// the auxiliary project that only resolves to implementation files.
|
|
175549
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
|
|
175550
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175551
|
+
}
|
|
175552
|
+
else {
|
|
175553
|
+
// It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
|
|
175554
|
+
var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
|
|
175555
|
+
var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
|
|
175556
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
|
|
175557
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175558
|
+
}
|
|
175559
|
+
}
|
|
175560
|
+
// We're not in node_modules, and we only get to this function if non-dts module resolution failed.
|
|
175561
|
+
// I'm not sure what else I can do here that isn't already covered by that module resolution.
|
|
175562
|
+
return undefined;
|
|
175563
|
+
}
|
|
175564
|
+
// In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition
|
|
175565
|
+
// for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later.
|
|
175566
|
+
function getAmbientCandidatesByClimbingAccessChain() {
|
|
175567
|
+
var ls = project.getLanguageService();
|
|
175568
|
+
var program = ls.getProgram();
|
|
175569
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175570
|
+
if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) {
|
|
175571
|
+
return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) {
|
|
175572
|
+
var _a;
|
|
175573
|
+
if (nameInChain === initialNode)
|
|
175574
|
+
return undefined;
|
|
175575
|
+
var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({
|
|
175576
|
+
fileName: d.fileName,
|
|
175577
|
+
name: ts.getTextOfIdentifierOrLiteral(initialNode)
|
|
175578
|
+
}); });
|
|
175579
|
+
if (ts.some(candidates)) {
|
|
175580
|
+
return candidates;
|
|
175581
|
+
}
|
|
175582
|
+
}) || server.emptyArray;
|
|
175583
|
+
}
|
|
175584
|
+
return server.emptyArray;
|
|
175585
|
+
}
|
|
175586
|
+
function tryRefineDefinition(definition, program, noDtsProgram) {
|
|
175587
|
+
var _a;
|
|
175588
|
+
var fileToSearch = noDtsProgram.getSourceFile(definition.fileName);
|
|
175589
|
+
if (!fileToSearch) {
|
|
175590
|
+
return undefined;
|
|
175591
|
+
}
|
|
175592
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175593
|
+
var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
|
|
175594
|
+
var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */);
|
|
175595
|
+
if (!importSpecifier)
|
|
175596
|
+
return undefined;
|
|
175597
|
+
var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text;
|
|
175598
|
+
return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram);
|
|
175599
|
+
}
|
|
175600
|
+
function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) {
|
|
175601
|
+
var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
|
|
175602
|
+
return ts.mapDefined(matches, function (match) {
|
|
175603
|
+
var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match);
|
|
175604
|
+
var decl = ts.getDeclarationFromName(match);
|
|
175605
|
+
if (symbol && decl) {
|
|
175606
|
+
// I think the last argument to this is supposed to be the start node, but it doesn't seem important.
|
|
175607
|
+
// Callers internal to GoToDefinition already get confused about this.
|
|
175608
|
+
return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true);
|
|
175609
|
+
}
|
|
175610
|
+
});
|
|
175611
|
+
}
|
|
175612
|
+
function ensureRoot(project, fileName) {
|
|
175613
|
+
var info = project.getScriptInfo(fileName);
|
|
175614
|
+
if (!info)
|
|
175615
|
+
return false;
|
|
175616
|
+
if (!project.containsScriptInfo(info)) {
|
|
175617
|
+
project.addRoot(info);
|
|
175618
|
+
project.updateGraph();
|
|
175619
|
+
}
|
|
175620
|
+
return true;
|
|
175621
|
+
}
|
|
175622
|
+
};
|
|
175275
175623
|
Session.prototype.getEmitOutput = function (args) {
|
|
175276
175624
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
175277
175625
|
if (!project.shouldEmitFile(project.getScriptInfo(file))) {
|
|
@@ -175835,7 +176183,7 @@ var ts;
|
|
|
175835
176183
|
return undefined;
|
|
175836
176184
|
}
|
|
175837
176185
|
var compilationSettings = project.getCompilationSettings();
|
|
175838
|
-
if (!!compilationSettings.noEmit || ts.
|
|
176186
|
+
if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) {
|
|
175839
176187
|
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
|
|
175840
176188
|
return undefined;
|
|
175841
176189
|
}
|
|
@@ -176315,7 +176663,7 @@ var ts;
|
|
|
176315
176663
|
else {
|
|
176316
176664
|
var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217
|
|
176317
176665
|
if (!info.isScriptOpen()) {
|
|
176318
|
-
if (ts.
|
|
176666
|
+
if (ts.isDeclarationFileName(fileNameInProject)) {
|
|
176319
176667
|
veryLowPriorityFiles.push(fileNameInProject);
|
|
176320
176668
|
}
|
|
176321
176669
|
else {
|