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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220415";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4660,7 +4660,6 @@ var ts;
|
|
|
4660
4660
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4661
4661
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4662
4662
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4663
|
-
NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType";
|
|
4664
4663
|
// Error handling
|
|
4665
4664
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4666
4665
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -14966,6 +14965,10 @@ var ts;
|
|
|
14966
14965
|
}
|
|
14967
14966
|
}
|
|
14968
14967
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
14968
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
14969
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
14970
|
+
}
|
|
14971
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
14969
14972
|
function isLateVisibilityPaintedStatement(node) {
|
|
14970
14973
|
switch (node.kind) {
|
|
14971
14974
|
case 266 /* ImportDeclaration */:
|
|
@@ -16326,17 +16329,13 @@ var ts;
|
|
|
16326
16329
|
if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
|
|
16327
16330
|
return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
|
|
16328
16331
|
}
|
|
16329
|
-
if (ts.
|
|
16332
|
+
if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) &&
|
|
16330
16333
|
(initializer.expression.kind === 108 /* ThisKeyword */ ||
|
|
16331
16334
|
ts.isIdentifier(initializer.expression) &&
|
|
16332
16335
|
(initializer.expression.escapedText === "window" ||
|
|
16333
16336
|
initializer.expression.escapedText === "self" ||
|
|
16334
16337
|
initializer.expression.escapedText === "global"))) {
|
|
16335
|
-
|
|
16336
|
-
if (ts.isPrivateIdentifier(nameOrArgument)) {
|
|
16337
|
-
ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
|
|
16338
|
-
}
|
|
16339
|
-
return isSameEntityName(name, nameOrArgument);
|
|
16338
|
+
return isSameEntityName(name, getNameOrArgument(initializer));
|
|
16340
16339
|
}
|
|
16341
16340
|
if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
|
|
16342
16341
|
return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
|
|
@@ -16544,14 +16543,14 @@ var ts;
|
|
|
16544
16543
|
}
|
|
16545
16544
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16546
16545
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16547
|
-
var _a, _b
|
|
16546
|
+
var _a, _b;
|
|
16548
16547
|
switch (node.kind) {
|
|
16549
16548
|
case 254 /* VariableDeclaration */:
|
|
16550
|
-
return node.initializer.arguments[0]
|
|
16549
|
+
return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
|
|
16551
16550
|
case 266 /* ImportDeclaration */:
|
|
16552
|
-
return
|
|
16551
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16553
16552
|
case 265 /* ImportEqualsDeclaration */:
|
|
16554
|
-
return
|
|
16553
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16555
16554
|
default:
|
|
16556
16555
|
ts.Debug.assertNever(node);
|
|
16557
16556
|
}
|
|
@@ -17066,7 +17065,10 @@ var ts;
|
|
|
17066
17065
|
return parent.propertyName === node;
|
|
17067
17066
|
case 275 /* ExportSpecifier */:
|
|
17068
17067
|
case 285 /* JsxAttribute */:
|
|
17069
|
-
|
|
17068
|
+
case 279 /* JsxSelfClosingElement */:
|
|
17069
|
+
case 280 /* JsxOpeningElement */:
|
|
17070
|
+
case 281 /* JsxClosingElement */:
|
|
17071
|
+
// Any name in an export specifier or JSX Attribute or Jsx Element
|
|
17070
17072
|
return true;
|
|
17071
17073
|
}
|
|
17072
17074
|
return false;
|
|
@@ -17082,21 +17084,28 @@ var ts;
|
|
|
17082
17084
|
// export = <EntityNameExpression>
|
|
17083
17085
|
// export default <EntityNameExpression>
|
|
17084
17086
|
// module.exports = <EntityNameExpression>
|
|
17085
|
-
//
|
|
17086
|
-
//
|
|
17087
|
+
// module.exports.x = <EntityNameExpression>
|
|
17088
|
+
// const x = require("...")
|
|
17089
|
+
// const { x } = require("...")
|
|
17090
|
+
// const x = require("...").y
|
|
17091
|
+
// const { x } = require("...").y
|
|
17087
17092
|
function isAliasSymbolDeclaration(node) {
|
|
17088
|
-
|
|
17093
|
+
if (node.kind === 265 /* ImportEqualsDeclaration */ ||
|
|
17089
17094
|
node.kind === 264 /* NamespaceExportDeclaration */ ||
|
|
17090
17095
|
node.kind === 267 /* ImportClause */ && !!node.name ||
|
|
17091
17096
|
node.kind === 268 /* NamespaceImport */ ||
|
|
17092
17097
|
node.kind === 274 /* NamespaceExport */ ||
|
|
17093
17098
|
node.kind === 270 /* ImportSpecifier */ ||
|
|
17094
17099
|
node.kind === 275 /* ExportSpecifier */ ||
|
|
17095
|
-
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
+
node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
|
|
17101
|
+
return true;
|
|
17102
|
+
}
|
|
17103
|
+
return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
|
|
17104
|
+
ts.isPropertyAccessExpression(node)
|
|
17105
|
+
&& ts.isBinaryExpression(node.parent)
|
|
17106
|
+
&& node.parent.left === node
|
|
17107
|
+
&& node.parent.operatorToken.kind === 63 /* EqualsToken */
|
|
17108
|
+
&& isAliasableExpression(node.parent.right));
|
|
17100
17109
|
}
|
|
17101
17110
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17102
17111
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17107,6 +17116,7 @@ var ts;
|
|
|
17107
17116
|
case 275 /* ExportSpecifier */:
|
|
17108
17117
|
case 271 /* ExportAssignment */:
|
|
17109
17118
|
case 265 /* ImportEqualsDeclaration */:
|
|
17119
|
+
case 274 /* NamespaceExport */:
|
|
17110
17120
|
return node.parent;
|
|
17111
17121
|
case 161 /* QualifiedName */:
|
|
17112
17122
|
do {
|
|
@@ -18933,6 +18943,11 @@ var ts;
|
|
|
18933
18943
|
(node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node);
|
|
18934
18944
|
}
|
|
18935
18945
|
ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
|
|
18946
|
+
function isRightSideOfAccessExpression(node) {
|
|
18947
|
+
return ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
18948
|
+
|| ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
|
|
18949
|
+
}
|
|
18950
|
+
ts.isRightSideOfAccessExpression = isRightSideOfAccessExpression;
|
|
18936
18951
|
function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) {
|
|
18937
18952
|
return ts.isQualifiedName(node.parent) && node.parent.right === node
|
|
18938
18953
|
|| ts.isPropertyAccessExpression(node.parent) && node.parent.name === node
|
|
@@ -19584,6 +19599,41 @@ var ts;
|
|
|
19584
19599
|
return expr;
|
|
19585
19600
|
}
|
|
19586
19601
|
ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
|
|
19602
|
+
function forEachNameInAccessChainWalkingLeft(name, action) {
|
|
19603
|
+
if (isAccessExpression(name.parent) && isRightSideOfAccessExpression(name)) {
|
|
19604
|
+
return walkAccessExpression(name.parent);
|
|
19605
|
+
}
|
|
19606
|
+
function walkAccessExpression(access) {
|
|
19607
|
+
if (access.kind === 206 /* PropertyAccessExpression */) {
|
|
19608
|
+
var res = action(access.name);
|
|
19609
|
+
if (res !== undefined) {
|
|
19610
|
+
return res;
|
|
19611
|
+
}
|
|
19612
|
+
}
|
|
19613
|
+
else if (access.kind === 207 /* ElementAccessExpression */) {
|
|
19614
|
+
if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) {
|
|
19615
|
+
var res = action(access.argumentExpression);
|
|
19616
|
+
if (res !== undefined) {
|
|
19617
|
+
return res;
|
|
19618
|
+
}
|
|
19619
|
+
}
|
|
19620
|
+
else {
|
|
19621
|
+
// Chain interrupted by non-static-name access 'x[expr()].y.z'
|
|
19622
|
+
return undefined;
|
|
19623
|
+
}
|
|
19624
|
+
}
|
|
19625
|
+
if (isAccessExpression(access.expression)) {
|
|
19626
|
+
return walkAccessExpression(access.expression);
|
|
19627
|
+
}
|
|
19628
|
+
if (ts.isIdentifier(access.expression)) {
|
|
19629
|
+
// End of chain at Identifier 'x.y.z'
|
|
19630
|
+
return action(access.expression);
|
|
19631
|
+
}
|
|
19632
|
+
// End of chain at non-Identifier 'x().y.z'
|
|
19633
|
+
return undefined;
|
|
19634
|
+
}
|
|
19635
|
+
}
|
|
19636
|
+
ts.forEachNameInAccessChainWalkingLeft = forEachNameInAccessChainWalkingLeft;
|
|
19587
19637
|
function getLeftmostExpression(node, stopAtCallExpressions) {
|
|
19588
19638
|
while (true) {
|
|
19589
19639
|
switch (node.kind) {
|
|
@@ -20531,6 +20581,7 @@ var ts;
|
|
|
20531
20581
|
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20532
20582
|
var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
|
|
20533
20583
|
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20584
|
+
ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
|
|
20534
20585
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20535
20586
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20536
20587
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
@@ -21219,6 +21270,11 @@ var ts;
|
|
|
21219
21270
|
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
21220
21271
|
}
|
|
21221
21272
|
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
21273
|
+
function getParameterTypeNode(parameter) {
|
|
21274
|
+
var _a;
|
|
21275
|
+
return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21276
|
+
}
|
|
21277
|
+
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21222
21278
|
})(ts || (ts = {}));
|
|
21223
21279
|
/* @internal */
|
|
21224
21280
|
var ts;
|
|
@@ -35372,34 +35428,10 @@ var ts;
|
|
|
35372
35428
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
35373
35429
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
35374
35430
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
35375
|
-
// These tokens can't follow in a call expression, nor can they start an
|
|
35376
|
-
// expression. So, consider the type argument list part of an instantiation
|
|
35377
|
-
// expression.
|
|
35378
|
-
// falls through
|
|
35379
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
35380
|
-
case 24 /* DotToken */: // foo<x>.
|
|
35381
|
-
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
35382
|
-
case 21 /* CloseParenToken */: // foo<x>)
|
|
35383
|
-
case 23 /* CloseBracketToken */: // foo<x>]
|
|
35384
|
-
case 58 /* ColonToken */: // foo<x>:
|
|
35385
|
-
case 26 /* SemicolonToken */: // foo<x>;
|
|
35386
|
-
case 57 /* QuestionToken */: // foo<x>?
|
|
35387
|
-
case 34 /* EqualsEqualsToken */: // foo<x> ==
|
|
35388
|
-
case 36 /* EqualsEqualsEqualsToken */: // foo<x> ===
|
|
35389
|
-
case 35 /* ExclamationEqualsToken */: // foo<x> !=
|
|
35390
|
-
case 37 /* ExclamationEqualsEqualsToken */: // foo<x> !==
|
|
35391
|
-
case 55 /* AmpersandAmpersandToken */: // foo<x> &&
|
|
35392
|
-
case 56 /* BarBarToken */: // foo<x> ||
|
|
35393
|
-
case 60 /* QuestionQuestionToken */: // foo<x> ??
|
|
35394
|
-
case 52 /* CaretToken */: // foo<x> ^
|
|
35395
|
-
case 50 /* AmpersandToken */: // foo<x> &
|
|
35396
|
-
case 51 /* BarToken */: // foo<x> |
|
|
35397
|
-
case 19 /* CloseBraceToken */: // foo<x> }
|
|
35398
|
-
case 1 /* EndOfFileToken */: // foo<x>
|
|
35399
35431
|
return true;
|
|
35400
35432
|
}
|
|
35401
|
-
//
|
|
35402
|
-
return
|
|
35433
|
+
// Consider something a type argument list only if the following token can't start an expression.
|
|
35434
|
+
return !isStartOfExpression();
|
|
35403
35435
|
}
|
|
35404
35436
|
function parsePrimaryExpression() {
|
|
35405
35437
|
switch (token()) {
|
|
@@ -38617,7 +38649,7 @@ var ts;
|
|
|
38617
38649
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
38618
38650
|
/** @internal */
|
|
38619
38651
|
function isDeclarationFileName(fileName) {
|
|
38620
|
-
return ts.fileExtensionIsOneOf(fileName,
|
|
38652
|
+
return ts.fileExtensionIsOneOf(fileName, ts.supportedDeclarationExtensions);
|
|
38621
38653
|
}
|
|
38622
38654
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
38623
38655
|
function parseResolutionMode(mode, pos, end, reportDiagnostic) {
|
|
@@ -42125,7 +42157,8 @@ var ts;
|
|
|
42125
42157
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42126
42158
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42127
42159
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42128
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42160
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42161
|
+
Extensions[Extensions["TsOnly"] = 5] = "TsOnly";
|
|
42129
42162
|
})(Extensions || (Extensions = {}));
|
|
42130
42163
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42131
42164
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -43070,7 +43103,21 @@ var ts;
|
|
|
43070
43103
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
43071
43104
|
}
|
|
43072
43105
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
43073
|
-
|
|
43106
|
+
var extensions;
|
|
43107
|
+
if (lookupConfig) {
|
|
43108
|
+
extensions = tsconfigExtensions;
|
|
43109
|
+
}
|
|
43110
|
+
else if (compilerOptions.noDtsResolution) {
|
|
43111
|
+
extensions = [Extensions.TsOnly];
|
|
43112
|
+
if (compilerOptions.allowJs)
|
|
43113
|
+
extensions.push(Extensions.JavaScript);
|
|
43114
|
+
if (compilerOptions.resolveJsonModule)
|
|
43115
|
+
extensions.push(Extensions.Json);
|
|
43116
|
+
}
|
|
43117
|
+
else {
|
|
43118
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
43119
|
+
}
|
|
43120
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
43074
43121
|
}
|
|
43075
43122
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
43076
43123
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -43079,6 +43126,10 @@ var ts;
|
|
|
43079
43126
|
var failedLookupLocations = [];
|
|
43080
43127
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
43081
43128
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43129
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43130
|
+
if (compilerOptions.noDtsResolution) {
|
|
43131
|
+
conditions.pop();
|
|
43132
|
+
}
|
|
43082
43133
|
var state = {
|
|
43083
43134
|
compilerOptions: compilerOptions,
|
|
43084
43135
|
host: host,
|
|
@@ -43086,7 +43137,7 @@ var ts;
|
|
|
43086
43137
|
failedLookupLocations: failedLookupLocations,
|
|
43087
43138
|
packageJsonInfoCache: cache,
|
|
43088
43139
|
features: features,
|
|
43089
|
-
conditions:
|
|
43140
|
+
conditions: conditions,
|
|
43090
43141
|
};
|
|
43091
43142
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43092
43143
|
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
|
@@ -43262,9 +43313,9 @@ var ts;
|
|
|
43262
43313
|
}
|
|
43263
43314
|
}
|
|
43264
43315
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43265
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43316
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
|
|
43266
43317
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43267
|
-
return result !== undefined ? { path: candidate, ext: ts.forEach(
|
|
43318
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
43268
43319
|
}
|
|
43269
43320
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43270
43321
|
}
|
|
@@ -43294,20 +43345,22 @@ var ts;
|
|
|
43294
43345
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43295
43346
|
}
|
|
43296
43347
|
case Extensions.TypeScript:
|
|
43348
|
+
case Extensions.TsOnly:
|
|
43349
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43297
43350
|
switch (originalExtension) {
|
|
43298
43351
|
case ".mjs" /* Mjs */:
|
|
43299
43352
|
case ".mts" /* Mts */:
|
|
43300
43353
|
case ".d.mts" /* Dmts */:
|
|
43301
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43354
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43302
43355
|
case ".cjs" /* Cjs */:
|
|
43303
43356
|
case ".cts" /* Cts */:
|
|
43304
43357
|
case ".d.cts" /* Dcts */:
|
|
43305
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43358
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43306
43359
|
case ".json" /* Json */:
|
|
43307
43360
|
candidate += ".json" /* Json */;
|
|
43308
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43361
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43309
43362
|
default:
|
|
43310
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43363
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43311
43364
|
}
|
|
43312
43365
|
case Extensions.JavaScript:
|
|
43313
43366
|
switch (originalExtension) {
|
|
@@ -43534,6 +43587,7 @@ var ts;
|
|
|
43534
43587
|
switch (extensions) {
|
|
43535
43588
|
case Extensions.JavaScript:
|
|
43536
43589
|
case Extensions.Json:
|
|
43590
|
+
case Extensions.TsOnly:
|
|
43537
43591
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43538
43592
|
break;
|
|
43539
43593
|
case Extensions.TypeScript:
|
|
@@ -43606,14 +43660,16 @@ var ts;
|
|
|
43606
43660
|
function extensionIsOk(extensions, extension) {
|
|
43607
43661
|
switch (extensions) {
|
|
43608
43662
|
case Extensions.JavaScript:
|
|
43609
|
-
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */;
|
|
43663
|
+
return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
|
|
43610
43664
|
case Extensions.TSConfig:
|
|
43611
43665
|
case Extensions.Json:
|
|
43612
43666
|
return extension === ".json" /* Json */;
|
|
43613
43667
|
case Extensions.TypeScript:
|
|
43614
|
-
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43668
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43669
|
+
case Extensions.TsOnly:
|
|
43670
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
|
|
43615
43671
|
case Extensions.DtsOnly:
|
|
43616
|
-
return extension === ".d.ts" /* Dts */;
|
|
43672
|
+
return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
|
|
43617
43673
|
}
|
|
43618
43674
|
}
|
|
43619
43675
|
/* @internal */
|
|
@@ -52915,9 +52971,6 @@ var ts;
|
|
|
52915
52971
|
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
52916
52972
|
parameterType = getOptionalType(parameterType);
|
|
52917
52973
|
}
|
|
52918
|
-
if ((context.flags & 1073741824 /* NoUndefinedOptionalParameterType */) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
|
52919
|
-
parameterType = getTypeWithFacts(parameterType, 524288 /* NEUndefined */);
|
|
52920
|
-
}
|
|
52921
52974
|
var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
52922
52975
|
var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
|
|
52923
52976
|
var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
@@ -53476,7 +53529,7 @@ var ts;
|
|
|
53476
53529
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
53477
53530
|
// try to reuse the existing annotation
|
|
53478
53531
|
var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
53479
|
-
if (
|
|
53532
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
53480
53533
|
var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
53481
53534
|
if (result_6) {
|
|
53482
53535
|
return result_6;
|
|
@@ -53493,6 +53546,16 @@ var ts;
|
|
|
53493
53546
|
context.flags = oldFlags;
|
|
53494
53547
|
return result;
|
|
53495
53548
|
}
|
|
53549
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
53550
|
+
var typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
53551
|
+
if (typeFromTypeNode === type) {
|
|
53552
|
+
return true;
|
|
53553
|
+
}
|
|
53554
|
+
if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
53555
|
+
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
53556
|
+
}
|
|
53557
|
+
return false;
|
|
53558
|
+
}
|
|
53496
53559
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
53497
53560
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
53498
53561
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
@@ -55764,7 +55827,7 @@ var ts;
|
|
|
55764
55827
|
}
|
|
55765
55828
|
}
|
|
55766
55829
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55767
|
-
type = getUnionType(sourceTypes
|
|
55830
|
+
type = getUnionType(sourceTypes);
|
|
55768
55831
|
}
|
|
55769
55832
|
}
|
|
55770
55833
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -58513,8 +58576,9 @@ var ts;
|
|
|
58513
58576
|
// levels of nesting, we are presumably exploring a repeating pattern with a long cycle that hasn't
|
|
58514
58577
|
// yet triggered the deeply nested limiter. We have no test cases that actually get to 50 levels of
|
|
58515
58578
|
// nesting, so it is effectively just a safety stop.
|
|
58516
|
-
|
|
58517
|
-
|
|
58579
|
+
var identity_1 = getRecursionIdentity(t);
|
|
58580
|
+
if (stack.length < 10 || stack.length < 50 && !ts.contains(stack, identity_1)) {
|
|
58581
|
+
stack.push(identity_1);
|
|
58518
58582
|
result = computeBaseConstraint(getSimplifiedType(t, /*writing*/ false));
|
|
58519
58583
|
stack.pop();
|
|
58520
58584
|
}
|
|
@@ -66712,12 +66776,12 @@ var ts;
|
|
|
66712
66776
|
function isDeeplyNestedType(type, stack, depth, maxDepth) {
|
|
66713
66777
|
if (maxDepth === void 0) { maxDepth = 3; }
|
|
66714
66778
|
if (depth >= maxDepth) {
|
|
66715
|
-
var
|
|
66779
|
+
var identity_2 = getRecursionIdentity(type);
|
|
66716
66780
|
var count = 0;
|
|
66717
66781
|
var lastTypeId = 0;
|
|
66718
66782
|
for (var i = 0; i < depth; i++) {
|
|
66719
66783
|
var t = stack[i];
|
|
66720
|
-
if (getRecursionIdentity(t) ===
|
|
66784
|
+
if (getRecursionIdentity(t) === identity_2) {
|
|
66721
66785
|
// We only count occurrences with a higher type id than the previous occurrence, since higher
|
|
66722
66786
|
// type ids are an indicator of newer instantiations caused by recursion.
|
|
66723
66787
|
if (t.id >= lastTypeId) {
|
|
@@ -79531,11 +79595,16 @@ var ts;
|
|
|
79531
79595
|
if (constraintType && defaultType) {
|
|
79532
79596
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79533
79597
|
}
|
|
79534
|
-
|
|
79598
|
+
checkNodeDeferred(node);
|
|
79599
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79600
|
+
}
|
|
79601
|
+
function checkTypeParameterDeferred(node) {
|
|
79602
|
+
if (ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent)) {
|
|
79603
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
|
|
79535
79604
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79536
79605
|
if (modifiers) {
|
|
79537
79606
|
var symbol = getSymbolOfNode(node.parent);
|
|
79538
|
-
if (node.parent
|
|
79607
|
+
if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79539
79608
|
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79540
79609
|
}
|
|
79541
79610
|
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
@@ -79548,7 +79617,6 @@ var ts;
|
|
|
79548
79617
|
}
|
|
79549
79618
|
}
|
|
79550
79619
|
}
|
|
79551
|
-
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79552
79620
|
}
|
|
79553
79621
|
function checkParameter(node) {
|
|
79554
79622
|
// Grammar checking
|
|
@@ -80038,7 +80106,7 @@ var ts;
|
|
|
80038
80106
|
superCallStatement = statement;
|
|
80039
80107
|
break;
|
|
80040
80108
|
}
|
|
80041
|
-
if (
|
|
80109
|
+
if (nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
80042
80110
|
break;
|
|
80043
80111
|
}
|
|
80044
80112
|
}
|
|
@@ -85391,6 +85459,9 @@ var ts;
|
|
|
85391
85459
|
case 226 /* ClassExpression */:
|
|
85392
85460
|
checkClassExpressionDeferred(node);
|
|
85393
85461
|
break;
|
|
85462
|
+
case 163 /* TypeParameter */:
|
|
85463
|
+
checkTypeParameterDeferred(node);
|
|
85464
|
+
break;
|
|
85394
85465
|
case 279 /* JsxSelfClosingElement */:
|
|
85395
85466
|
checkJsxSelfClosingElementDeferred(node);
|
|
85396
85467
|
break;
|
|
@@ -86487,11 +86558,6 @@ var ts;
|
|
|
86487
86558
|
!parameter.initializer &&
|
|
86488
86559
|
ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */);
|
|
86489
86560
|
}
|
|
86490
|
-
function isOptionalUninitializedParameter(parameter) {
|
|
86491
|
-
return !!strictNullChecks &&
|
|
86492
|
-
isOptionalParameter(parameter) &&
|
|
86493
|
-
!parameter.initializer;
|
|
86494
|
-
}
|
|
86495
86561
|
function isExpandoFunctionDeclaration(node) {
|
|
86496
86562
|
var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
|
|
86497
86563
|
if (!declaration) {
|
|
@@ -87408,8 +87474,7 @@ var ts;
|
|
|
87408
87474
|
case 144 /* OutKeyword */:
|
|
87409
87475
|
var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */;
|
|
87410
87476
|
var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out";
|
|
87411
|
-
if (node.kind !== 163 /* TypeParameter */ || (node.parent
|
|
87412
|
-
node.parent.kind !== 257 /* ClassDeclaration */ && node.parent.kind !== 259 /* TypeAliasDeclaration */)) {
|
|
87477
|
+
if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) {
|
|
87413
87478
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
|
87414
87479
|
}
|
|
87415
87480
|
if (flags & inOutFlag) {
|
|
@@ -92643,11 +92708,11 @@ var ts;
|
|
|
92643
92708
|
}
|
|
92644
92709
|
var statements = [];
|
|
92645
92710
|
resumeLexicalEnvironment();
|
|
92646
|
-
var
|
|
92647
|
-
var superStatementIndex = ts.findSuperStatementIndex(body.statements,
|
|
92711
|
+
var prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92712
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, prologueStatementCount);
|
|
92648
92713
|
// If there was a super call, visit existing statements up to and including it
|
|
92649
92714
|
if (superStatementIndex >= 0) {
|
|
92650
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement,
|
|
92715
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount));
|
|
92651
92716
|
}
|
|
92652
92717
|
// Transform parameters into property assignments. Transforms this:
|
|
92653
92718
|
//
|
|
@@ -92666,12 +92731,12 @@ var ts;
|
|
|
92666
92731
|
if (superStatementIndex >= 0) {
|
|
92667
92732
|
ts.addRange(statements, parameterPropertyAssignments);
|
|
92668
92733
|
}
|
|
92669
|
-
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
92734
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements
|
|
92670
92735
|
else {
|
|
92671
|
-
statements =
|
|
92736
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
92672
92737
|
}
|
|
92673
|
-
// Add remaining statements from the body, skipping the super() call if it was found
|
|
92674
|
-
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
92738
|
+
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
92739
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount));
|
|
92675
92740
|
// End the lexical environment.
|
|
92676
92741
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92677
92742
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -109570,7 +109635,7 @@ var ts;
|
|
|
109570
109635
|
addOutput(buildInfoPath);
|
|
109571
109636
|
}
|
|
109572
109637
|
function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
|
|
109573
|
-
if (ts.
|
|
109638
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109574
109639
|
return;
|
|
109575
109640
|
var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109576
109641
|
addOutput(js);
|
|
@@ -109615,7 +109680,7 @@ var ts;
|
|
|
109615
109680
|
/*@internal*/
|
|
109616
109681
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
109617
109682
|
var options = _a.options, fileNames = _a.fileNames;
|
|
109618
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.
|
|
109683
|
+
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.isDeclarationFileName(file); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
|
|
109619
109684
|
}
|
|
109620
109685
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
109621
109686
|
/*@internal*/
|
|
@@ -109657,7 +109722,7 @@ var ts;
|
|
|
109657
109722
|
var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
|
|
109658
109723
|
for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
|
|
109659
109724
|
var inputFileName = _b[_a];
|
|
109660
|
-
if (ts.
|
|
109725
|
+
if (ts.isDeclarationFileName(inputFileName))
|
|
109661
109726
|
continue;
|
|
109662
109727
|
var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
|
|
109663
109728
|
if (jsFilePath)
|
|
@@ -115007,7 +115072,7 @@ var ts;
|
|
|
115007
115072
|
if (ts.outFile(options) || options.outDir)
|
|
115008
115073
|
return false;
|
|
115009
115074
|
// File if emitted next to input needs to be ignored
|
|
115010
|
-
if (ts.
|
|
115075
|
+
if (ts.isDeclarationFileName(fileOrDirectoryPath)) {
|
|
115011
115076
|
// If its declaration directory: its not ignored if not excluded by config
|
|
115012
115077
|
if (options.declarationDir)
|
|
115013
115078
|
return false;
|
|
@@ -116180,7 +116245,7 @@ var ts;
|
|
|
116180
116245
|
var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
116181
116246
|
for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
|
|
116182
116247
|
var fileName = _c[_b];
|
|
116183
|
-
if (!ts.
|
|
116248
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
116184
116249
|
processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
|
|
116185
116250
|
}
|
|
116186
116251
|
}
|
|
@@ -116371,7 +116436,7 @@ var ts;
|
|
|
116371
116436
|
}
|
|
116372
116437
|
function getRedirectReferenceForResolution(file) {
|
|
116373
116438
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
116374
|
-
if (redirect || !ts.
|
|
116439
|
+
if (redirect || !ts.isDeclarationFileName(file.originalFileName))
|
|
116375
116440
|
return redirect;
|
|
116376
116441
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
116377
116442
|
// So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
|
|
@@ -117762,7 +117827,7 @@ var ts;
|
|
|
117762
117827
|
}
|
|
117763
117828
|
function getProjectReferenceRedirectProject(fileName) {
|
|
117764
117829
|
// Ignore dts or any json files
|
|
117765
|
-
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.
|
|
117830
|
+
if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117766
117831
|
return undefined;
|
|
117767
117832
|
}
|
|
117768
117833
|
// If this file is produced by a referenced project, we need to rewrite it to
|
|
@@ -117811,7 +117876,7 @@ var ts;
|
|
|
117811
117876
|
else {
|
|
117812
117877
|
var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
|
|
117813
117878
|
ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
|
|
117814
|
-
if (!ts.
|
|
117879
|
+
if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) {
|
|
117815
117880
|
var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
|
|
117816
117881
|
mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
|
|
117817
117882
|
}
|
|
@@ -118612,7 +118677,7 @@ var ts;
|
|
|
118612
118677
|
if (options.outDir) {
|
|
118613
118678
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
118614
118679
|
}
|
|
118615
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.
|
|
118680
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) {
|
|
118616
118681
|
// Otherwise just check if sourceFile with the name exists
|
|
118617
118682
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
118618
118683
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -119238,7 +119303,7 @@ var ts;
|
|
|
119238
119303
|
/*forceDtsEmit*/ true);
|
|
119239
119304
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
119240
119305
|
if (firstDts_1) {
|
|
119241
|
-
ts.Debug.assert(ts.
|
|
119306
|
+
ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
|
|
119242
119307
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
119243
119308
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
119244
119309
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -119643,7 +119708,7 @@ var ts;
|
|
|
119643
119708
|
* This is to allow the callers to be able to actually remove affected file only when the operation is complete
|
|
119644
119709
|
* eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
|
|
119645
119710
|
*/
|
|
119646
|
-
function getNextAffectedFile(state, cancellationToken, computeHash) {
|
|
119711
|
+
function getNextAffectedFile(state, cancellationToken, computeHash, host) {
|
|
119647
119712
|
while (true) {
|
|
119648
119713
|
var affectedFiles = state.affectedFiles;
|
|
119649
119714
|
if (affectedFiles) {
|
|
@@ -119654,7 +119719,7 @@ var ts;
|
|
|
119654
119719
|
if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
|
|
119655
119720
|
// Set the next affected file as seen and remove the cached semantic diagnostics
|
|
119656
119721
|
state.affectedFilesIndex = affectedFilesIndex;
|
|
119657
|
-
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
|
|
119722
|
+
handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
|
|
119658
119723
|
return affectedFile;
|
|
119659
119724
|
}
|
|
119660
119725
|
affectedFilesIndex++;
|
|
@@ -119695,6 +119760,11 @@ var ts;
|
|
|
119695
119760
|
state.seenAffectedFiles = new ts.Set();
|
|
119696
119761
|
}
|
|
119697
119762
|
}
|
|
119763
|
+
function clearAffectedFilesPendingEmit(state) {
|
|
119764
|
+
state.affectedFilesPendingEmit = undefined;
|
|
119765
|
+
state.affectedFilesPendingEmitKind = undefined;
|
|
119766
|
+
state.affectedFilesPendingEmitIndex = undefined;
|
|
119767
|
+
}
|
|
119698
119768
|
/**
|
|
119699
119769
|
* Returns next file to be emitted from files that retrieved semantic diagnostics but did not emit yet
|
|
119700
119770
|
*/
|
|
@@ -119714,9 +119784,7 @@ var ts;
|
|
|
119714
119784
|
}
|
|
119715
119785
|
}
|
|
119716
119786
|
}
|
|
119717
|
-
state
|
|
119718
|
-
state.affectedFilesPendingEmitKind = undefined;
|
|
119719
|
-
state.affectedFilesPendingEmitIndex = undefined;
|
|
119787
|
+
clearAffectedFilesPendingEmit(state);
|
|
119720
119788
|
}
|
|
119721
119789
|
return undefined;
|
|
119722
119790
|
}
|
|
@@ -119724,7 +119792,7 @@ var ts;
|
|
|
119724
119792
|
* Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
|
|
119725
119793
|
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
|
|
119726
119794
|
*/
|
|
119727
|
-
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
|
|
119795
|
+
function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
|
|
119728
119796
|
var _a;
|
|
119729
119797
|
removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
|
|
119730
119798
|
// If affected files is everything except default library, then nothing more to do
|
|
@@ -119749,14 +119817,14 @@ var ts;
|
|
|
119749
119817
|
ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
|
|
119750
119818
|
}
|
|
119751
119819
|
if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
|
|
119752
|
-
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
|
|
119820
|
+
forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
|
|
119753
119821
|
}
|
|
119754
119822
|
}
|
|
119755
119823
|
/**
|
|
119756
119824
|
* Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
|
|
119757
119825
|
* Also we need to make sure signature is updated for these files
|
|
119758
119826
|
*/
|
|
119759
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
|
|
119827
|
+
function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
|
|
119760
119828
|
removeSemanticDiagnosticsOf(state, path);
|
|
119761
119829
|
if (!state.changedFilesSet.has(path)) {
|
|
119762
119830
|
var program = ts.Debug.checkDefined(state.program);
|
|
@@ -119767,8 +119835,7 @@ var ts;
|
|
|
119767
119835
|
// This ensures that we dont later during incremental builds considering wrong signature.
|
|
119768
119836
|
// Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
|
|
119769
119837
|
// But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
|
|
119770
|
-
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap,
|
|
119771
|
-
/* useFileVersionAsSignature */ true);
|
|
119838
|
+
ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap, !host.disableUseFileVersionAsSignature);
|
|
119772
119839
|
// If not dts emit, nothing more to do
|
|
119773
119840
|
if (ts.getEmitDeclarations(state.compilerOptions)) {
|
|
119774
119841
|
addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
|
|
@@ -119965,13 +120032,18 @@ var ts;
|
|
|
119965
120032
|
var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
|
|
119966
120033
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
119967
120034
|
return value.version === actualSignature ?
|
|
119968
|
-
value.affectsGlobalScope ?
|
|
119969
|
-
|
|
120035
|
+
value.affectsGlobalScope || value.impliedFormat ?
|
|
120036
|
+
// If file version is same as signature, dont serialize signature
|
|
120037
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120038
|
+
// If file info only contains version and signature and both are same we can just write string
|
|
119970
120039
|
value.version :
|
|
119971
|
-
actualSignature !== undefined ?
|
|
120040
|
+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
|
|
119972
120041
|
signature === undefined ?
|
|
120042
|
+
// If we havent computed signature, use fileInfo as is
|
|
119973
120043
|
value :
|
|
120044
|
+
// Serialize fileInfo with new updated signature
|
|
119974
120045
|
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
120046
|
+
// Signature of the FileInfo is undefined, serialize it as false
|
|
119975
120047
|
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
119976
120048
|
});
|
|
119977
120049
|
var referencedMap;
|
|
@@ -120216,7 +120288,7 @@ var ts;
|
|
|
120216
120288
|
* in that order would be used to write the files
|
|
120217
120289
|
*/
|
|
120218
120290
|
function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120219
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120291
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120220
120292
|
var emitKind = 1 /* Full */;
|
|
120221
120293
|
var isPendingEmitFile = false;
|
|
120222
120294
|
if (!affected) {
|
|
@@ -120261,54 +120333,48 @@ var ts;
|
|
|
120261
120333
|
* in that order would be used to write the files
|
|
120262
120334
|
*/
|
|
120263
120335
|
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
120264
|
-
var
|
|
120265
|
-
var savedAffectedFilesPendingEmit;
|
|
120266
|
-
var savedAffectedFilesPendingEmitKind;
|
|
120267
|
-
var savedAffectedFilesPendingEmitIndex;
|
|
120268
|
-
// 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
|
|
120269
|
-
// This ensures pending files to emit is updated in tsbuildinfo
|
|
120270
|
-
// 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)
|
|
120271
|
-
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
|
|
120272
|
-
!targetSourceFile &&
|
|
120273
|
-
!ts.outFile(state.compilerOptions) &&
|
|
120274
|
-
!state.compilerOptions.noEmit &&
|
|
120275
|
-
state.compilerOptions.noEmitOnError) {
|
|
120276
|
-
restorePendingEmitOnHandlingNoEmitSuccess = true;
|
|
120277
|
-
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
|
|
120278
|
-
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
|
|
120279
|
-
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
|
|
120280
|
-
}
|
|
120336
|
+
var _a;
|
|
120281
120337
|
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120282
120338
|
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
|
|
120283
120339
|
}
|
|
120284
120340
|
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
|
|
120285
120341
|
if (result)
|
|
120286
120342
|
return result;
|
|
120287
|
-
if (restorePendingEmitOnHandlingNoEmitSuccess) {
|
|
120288
|
-
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
|
|
120289
|
-
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
|
|
120290
|
-
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
|
|
120291
|
-
}
|
|
120292
120343
|
// Emit only affected files if using builder for emit
|
|
120293
|
-
if (!targetSourceFile
|
|
120294
|
-
|
|
120295
|
-
|
|
120296
|
-
|
|
120297
|
-
|
|
120298
|
-
|
|
120299
|
-
|
|
120300
|
-
|
|
120301
|
-
|
|
120302
|
-
|
|
120303
|
-
|
|
120304
|
-
|
|
120344
|
+
if (!targetSourceFile) {
|
|
120345
|
+
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
|
|
120346
|
+
// Emit and report any errors we ran into.
|
|
120347
|
+
var sourceMaps = [];
|
|
120348
|
+
var emitSkipped = false;
|
|
120349
|
+
var diagnostics = void 0;
|
|
120350
|
+
var emittedFiles = [];
|
|
120351
|
+
var affectedEmitResult = void 0;
|
|
120352
|
+
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
|
|
120353
|
+
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
|
|
120354
|
+
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
|
|
120355
|
+
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
|
|
120356
|
+
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
|
|
120357
|
+
}
|
|
120358
|
+
return {
|
|
120359
|
+
emitSkipped: emitSkipped,
|
|
120360
|
+
diagnostics: diagnostics || ts.emptyArray,
|
|
120361
|
+
emittedFiles: emittedFiles,
|
|
120362
|
+
sourceMaps: sourceMaps
|
|
120363
|
+
};
|
|
120364
|
+
}
|
|
120365
|
+
// In non Emit builder, clear affected files pending emit
|
|
120366
|
+
else if ((_a = state.affectedFilesPendingEmitKind) === null || _a === void 0 ? void 0 : _a.size) {
|
|
120367
|
+
ts.Debug.assert(kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram);
|
|
120368
|
+
// State can clear affected files pending emit if
|
|
120369
|
+
if (!emitOnlyDtsFiles // If we are doing complete emit, affected files pending emit can be cleared
|
|
120370
|
+
// If every file pending emit is pending on only dts emit
|
|
120371
|
+
|| ts.every(state.affectedFilesPendingEmit, function (path, index) {
|
|
120372
|
+
return index < state.affectedFilesPendingEmitIndex ||
|
|
120373
|
+
state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */;
|
|
120374
|
+
})) {
|
|
120375
|
+
clearAffectedFilesPendingEmit(state);
|
|
120376
|
+
}
|
|
120305
120377
|
}
|
|
120306
|
-
return {
|
|
120307
|
-
emitSkipped: emitSkipped,
|
|
120308
|
-
diagnostics: diagnostics || ts.emptyArray,
|
|
120309
|
-
emittedFiles: emittedFiles,
|
|
120310
|
-
sourceMaps: sourceMaps
|
|
120311
|
-
};
|
|
120312
120378
|
}
|
|
120313
120379
|
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
120314
120380
|
}
|
|
@@ -120318,7 +120384,7 @@ var ts;
|
|
|
120318
120384
|
*/
|
|
120319
120385
|
function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
|
|
120320
120386
|
while (true) {
|
|
120321
|
-
var affected = getNextAffectedFile(state, cancellationToken, computeHash);
|
|
120387
|
+
var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
|
|
120322
120388
|
if (!affected) {
|
|
120323
120389
|
// Done
|
|
120324
120390
|
return undefined;
|
|
@@ -123438,9 +123504,6 @@ var ts;
|
|
|
123438
123504
|
function newer(date1, date2) {
|
|
123439
123505
|
return date2 > date1 ? date2 : date1;
|
|
123440
123506
|
}
|
|
123441
|
-
function isDeclarationFile(fileName) {
|
|
123442
|
-
return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */);
|
|
123443
|
-
}
|
|
123444
123507
|
/*@internal*/
|
|
123445
123508
|
function isCircularBuildOrder(buildOrder) {
|
|
123446
123509
|
return !!buildOrder && !!buildOrder.buildOrder;
|
|
@@ -124003,7 +124066,7 @@ var ts;
|
|
|
124003
124066
|
outputFiles.forEach(function (_a) {
|
|
124004
124067
|
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
|
|
124005
124068
|
var priorChangeTime;
|
|
124006
|
-
if (!anyDtsChanged &&
|
|
124069
|
+
if (!anyDtsChanged && ts.isDeclarationFileName(name)) {
|
|
124007
124070
|
// Check for unchanged .d.ts files
|
|
124008
124071
|
if (host.fileExists(name) && state.readFileWithCache(name) === text) {
|
|
124009
124072
|
priorChangeTime = host.getModifiedTime(name);
|
|
@@ -124344,7 +124407,7 @@ var ts;
|
|
|
124344
124407
|
// In addition to file timestamps, we also keep track of when a .d.ts file
|
|
124345
124408
|
// had its file touched but not had its contents changed - this allows us
|
|
124346
124409
|
// to skip a downstream typecheck
|
|
124347
|
-
if (
|
|
124410
|
+
if (ts.isDeclarationFileName(output)) {
|
|
124348
124411
|
var outputModifiedTime = ts.getModifiedTime(host, output);
|
|
124349
124412
|
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
|
|
124350
124413
|
}
|
|
@@ -124498,7 +124561,7 @@ var ts;
|
|
|
124498
124561
|
reportVerbose = false;
|
|
124499
124562
|
reportStatus(state, verboseMessage, proj.options.configFilePath);
|
|
124500
124563
|
}
|
|
124501
|
-
if (
|
|
124564
|
+
if (ts.isDeclarationFileName(file)) {
|
|
124502
124565
|
priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file));
|
|
124503
124566
|
}
|
|
124504
124567
|
host.setModifiedTime(file, now);
|
|
@@ -131393,17 +131456,13 @@ var ts;
|
|
|
131393
131456
|
}
|
|
131394
131457
|
}
|
|
131395
131458
|
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131396
|
-
|
|
131397
|
-
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
131459
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, labelDetails = origin.labelDetails);
|
|
131398
131460
|
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131399
131461
|
name = name + labelDetails.detail;
|
|
131400
131462
|
labelDetails = undefined;
|
|
131401
131463
|
}
|
|
131402
131464
|
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131403
131465
|
sortText = Completions.SortText.SortBelow(sortText);
|
|
131404
|
-
if (importAdder.hasFixes()) {
|
|
131405
|
-
hasAction = true;
|
|
131406
|
-
}
|
|
131407
131466
|
}
|
|
131408
131467
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131409
131468
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
@@ -131626,8 +131685,7 @@ var ts;
|
|
|
131626
131685
|
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131627
131686
|
var insertText = name;
|
|
131628
131687
|
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131629
|
-
var
|
|
131630
|
-
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131688
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences);
|
|
131631
131689
|
if (!method) {
|
|
131632
131690
|
return undefined;
|
|
131633
131691
|
}
|
|
@@ -131656,16 +131714,15 @@ var ts;
|
|
|
131656
131714
|
/*modifiers*/ undefined,
|
|
131657
131715
|
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131658
131716
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
131659
|
-
return { isSnippet: isSnippet, insertText: insertText,
|
|
131717
|
+
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
131660
131718
|
}
|
|
131661
131719
|
;
|
|
131662
|
-
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences
|
|
131720
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
131663
131721
|
var declarations = symbol.getDeclarations();
|
|
131664
131722
|
if (!(declarations && declarations.length)) {
|
|
131665
131723
|
return undefined;
|
|
131666
131724
|
}
|
|
131667
131725
|
var checker = program.getTypeChecker();
|
|
131668
|
-
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131669
131726
|
var declaration = declarations[0];
|
|
131670
131727
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131671
131728
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
@@ -131698,11 +131755,6 @@ var ts;
|
|
|
131698
131755
|
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131699
131756
|
return undefined;
|
|
131700
131757
|
}
|
|
131701
|
-
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131702
|
-
if (importableReference) {
|
|
131703
|
-
typeNode = importableReference.typeNode;
|
|
131704
|
-
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131705
|
-
}
|
|
131706
131758
|
var body = void 0;
|
|
131707
131759
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
131708
131760
|
var emptyStmt = ts.factory.createEmptyStatement();
|
|
@@ -131712,11 +131764,19 @@ var ts;
|
|
|
131712
131764
|
else {
|
|
131713
131765
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131714
131766
|
}
|
|
131767
|
+
var parameters = typeNode.parameters.map(function (typedParam) {
|
|
131768
|
+
return ts.factory.createParameterDeclaration(
|
|
131769
|
+
/*decorators*/ undefined,
|
|
131770
|
+
/*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, typedParam.questionToken,
|
|
131771
|
+
/*type*/ undefined, typedParam.initializer);
|
|
131772
|
+
});
|
|
131715
131773
|
return ts.factory.createMethodDeclaration(
|
|
131716
131774
|
/*decorators*/ undefined,
|
|
131717
131775
|
/*modifiers*/ undefined,
|
|
131718
131776
|
/*asteriskToken*/ undefined, name,
|
|
131719
|
-
/*questionToken*/ undefined,
|
|
131777
|
+
/*questionToken*/ undefined,
|
|
131778
|
+
/*typeParameters*/ undefined, parameters,
|
|
131779
|
+
/*type*/ undefined, body);
|
|
131720
131780
|
}
|
|
131721
131781
|
default:
|
|
131722
131782
|
return undefined;
|
|
@@ -132079,20 +132139,6 @@ var ts;
|
|
|
132079
132139
|
};
|
|
132080
132140
|
}
|
|
132081
132141
|
}
|
|
132082
|
-
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132083
|
-
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132084
|
-
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132085
|
-
if (importAdder.hasFixes()) {
|
|
132086
|
-
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132087
|
-
return {
|
|
132088
|
-
sourceDisplay: undefined,
|
|
132089
|
-
codeActions: [{
|
|
132090
|
-
changes: changes,
|
|
132091
|
-
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132092
|
-
}],
|
|
132093
|
-
};
|
|
132094
|
-
}
|
|
132095
|
-
}
|
|
132096
132142
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132097
132143
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132098
132144
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -134913,7 +134959,7 @@ var ts;
|
|
|
134913
134959
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
134914
134960
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
134915
134961
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
134916
|
-
var otherBucketKey = !ts.
|
|
134962
|
+
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
134917
134963
|
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
134918
134964
|
if (otherBucketKey) {
|
|
134919
134965
|
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
@@ -136853,6 +136899,30 @@ var ts;
|
|
|
136853
136899
|
}
|
|
136854
136900
|
}
|
|
136855
136901
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
136902
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
136903
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
136904
|
+
return candidates.reduce(function (topMost, decl) {
|
|
136905
|
+
var depth = getDepth(decl);
|
|
136906
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
136907
|
+
topMost.declarationNames.push(decl);
|
|
136908
|
+
topMost.depth = depth;
|
|
136909
|
+
}
|
|
136910
|
+
else if (depth < topMost.depth) {
|
|
136911
|
+
topMost.declarationNames = [decl];
|
|
136912
|
+
topMost.depth = depth;
|
|
136913
|
+
}
|
|
136914
|
+
return topMost;
|
|
136915
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
136916
|
+
function getDepth(declaration) {
|
|
136917
|
+
var depth = 0;
|
|
136918
|
+
while (declaration) {
|
|
136919
|
+
declaration = ts.getContainerNode(declaration);
|
|
136920
|
+
depth++;
|
|
136921
|
+
}
|
|
136922
|
+
return depth;
|
|
136923
|
+
}
|
|
136924
|
+
}
|
|
136925
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
136856
136926
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
136857
136927
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
136858
136928
|
return false;
|
|
@@ -138489,7 +138559,9 @@ var ts;
|
|
|
138489
138559
|
(function (ts) {
|
|
138490
138560
|
var GoToDefinition;
|
|
138491
138561
|
(function (GoToDefinition) {
|
|
138492
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
138562
|
+
function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly) {
|
|
138563
|
+
var _a;
|
|
138564
|
+
var _b;
|
|
138493
138565
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
138494
138566
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
138495
138567
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -138512,33 +138584,63 @@ var ts;
|
|
|
138512
138584
|
}
|
|
138513
138585
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
138514
138586
|
var classDecl = node.parent.parent;
|
|
138515
|
-
var
|
|
138587
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
138516
138588
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
138517
138589
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
138518
138590
|
var sourceFile_1 = node.getSourceFile();
|
|
138519
138591
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
138520
138592
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
138521
138593
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
138522
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
138594
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
138523
138595
|
});
|
|
138524
138596
|
}
|
|
138525
|
-
var
|
|
138597
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
138598
|
+
var fallbackNode = node;
|
|
138599
|
+
if (searchOtherFilesOnly && failedAliasResolution) {
|
|
138600
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
138601
|
+
var importDeclaration = ts.forEach(__spreadArray([node], (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, true), function (n) { return ts.findAncestor(n, ts.isAnyImportOrBareOrAccessedRequire); });
|
|
138602
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
138603
|
+
if (moduleSpecifier) {
|
|
138604
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
138605
|
+
fallbackNode = moduleSpecifier;
|
|
138606
|
+
}
|
|
138607
|
+
}
|
|
138608
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
138609
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
138610
|
+
// be that module resolution succeeded but the target was not a module.
|
|
138611
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
138612
|
+
if (ref) {
|
|
138613
|
+
return [{
|
|
138614
|
+
name: fallbackNode.text,
|
|
138615
|
+
fileName: ref.resolvedFileName,
|
|
138616
|
+
containerName: undefined,
|
|
138617
|
+
containerKind: undefined,
|
|
138618
|
+
kind: "script" /* scriptElement */,
|
|
138619
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
138620
|
+
failedAliasResolution: failedAliasResolution,
|
|
138621
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
138622
|
+
unverified: fallbackNode !== node,
|
|
138623
|
+
}];
|
|
138624
|
+
}
|
|
138625
|
+
}
|
|
138526
138626
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
138527
138627
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
138528
138628
|
if (!symbol) {
|
|
138529
138629
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
138530
138630
|
}
|
|
138631
|
+
if (searchOtherFilesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
138632
|
+
return undefined;
|
|
138531
138633
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
138532
138634
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
138533
138635
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
138534
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
138636
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
138535
138637
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
138536
138638
|
// If this is the original constructor definition, parent is the class.
|
|
138537
138639
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
138538
138640
|
return [sigInfo];
|
|
138539
138641
|
}
|
|
138540
138642
|
else {
|
|
138541
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
138643
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
138542
138644
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
138543
138645
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
138544
138646
|
}
|
|
@@ -138550,7 +138652,7 @@ var ts;
|
|
|
138550
138652
|
// assignment. This case and others are handled by the following code.
|
|
138551
138653
|
if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) {
|
|
138552
138654
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
138553
|
-
var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : ts.emptyArray;
|
|
138655
|
+
var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray;
|
|
138554
138656
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
138555
138657
|
}
|
|
138556
138658
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -138573,7 +138675,7 @@ var ts;
|
|
|
138573
138675
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
138574
138676
|
});
|
|
138575
138677
|
}
|
|
138576
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
138678
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
138577
138679
|
}
|
|
138578
138680
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
138579
138681
|
/**
|
|
@@ -138671,24 +138773,24 @@ var ts;
|
|
|
138671
138773
|
return undefined;
|
|
138672
138774
|
}
|
|
138673
138775
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
138674
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
138776
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
138675
138777
|
}
|
|
138676
|
-
var
|
|
138778
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
138677
138779
|
if (!symbol)
|
|
138678
138780
|
return undefined;
|
|
138679
138781
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
138680
138782
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
138681
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
138783
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
138682
138784
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
138683
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
138785
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
138684
138786
|
return typeDefinitions.length ? typeDefinitions
|
|
138685
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
138787
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
138686
138788
|
: undefined;
|
|
138687
138789
|
}
|
|
138688
138790
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
138689
|
-
function definitionFromType(type, checker, node) {
|
|
138791
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
138690
138792
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
138691
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
138793
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
138692
138794
|
});
|
|
138693
138795
|
}
|
|
138694
138796
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -138730,13 +138832,17 @@ var ts;
|
|
|
138730
138832
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
138731
138833
|
// import {A, B} from "mod";
|
|
138732
138834
|
// to jump to the implementation directly.
|
|
138835
|
+
var failedAliasResolution = false;
|
|
138733
138836
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
138734
138837
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
138735
138838
|
if (aliased.declarations) {
|
|
138736
|
-
return aliased;
|
|
138839
|
+
return { symbol: aliased };
|
|
138840
|
+
}
|
|
138841
|
+
else {
|
|
138842
|
+
failedAliasResolution = true;
|
|
138737
138843
|
}
|
|
138738
138844
|
}
|
|
138739
|
-
return symbol;
|
|
138845
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
138740
138846
|
}
|
|
138741
138847
|
// Go to the original declaration for cases:
|
|
138742
138848
|
//
|
|
@@ -138750,26 +138856,45 @@ var ts;
|
|
|
138750
138856
|
if (node.parent === declaration) {
|
|
138751
138857
|
return true;
|
|
138752
138858
|
}
|
|
138753
|
-
|
|
138754
|
-
|
|
138755
|
-
case 265 /* ImportEqualsDeclaration */:
|
|
138756
|
-
return true;
|
|
138757
|
-
case 270 /* ImportSpecifier */:
|
|
138758
|
-
return declaration.parent.kind === 269 /* NamedImports */;
|
|
138759
|
-
case 203 /* BindingElement */:
|
|
138760
|
-
case 254 /* VariableDeclaration */:
|
|
138761
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
138762
|
-
default:
|
|
138763
|
-
return false;
|
|
138859
|
+
if (declaration.kind === 268 /* NamespaceImport */) {
|
|
138860
|
+
return false;
|
|
138764
138861
|
}
|
|
138862
|
+
return true;
|
|
138863
|
+
}
|
|
138864
|
+
/**
|
|
138865
|
+
* ```ts
|
|
138866
|
+
* function f() {}
|
|
138867
|
+
* f.foo = 0;
|
|
138868
|
+
* ```
|
|
138869
|
+
*
|
|
138870
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
138871
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
138872
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
138873
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
138874
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
138875
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
138876
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
138877
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
138878
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
138879
|
+
* up with a more precise definition of what counts as a definition.
|
|
138880
|
+
*/
|
|
138881
|
+
function isExpandoDeclaration(node) {
|
|
138882
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
138883
|
+
return false;
|
|
138884
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
138885
|
+
if (ts.isAssignmentExpression(p))
|
|
138886
|
+
return true;
|
|
138887
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
138888
|
+
return "quit";
|
|
138889
|
+
return false;
|
|
138890
|
+
});
|
|
138891
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
138765
138892
|
}
|
|
138766
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
138767
|
-
|
|
138768
|
-
|
|
138769
|
-
|
|
138770
|
-
|
|
138771
|
-
|| undefined;
|
|
138772
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
138893
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
138894
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
138895
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
138896
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
138897
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution); });
|
|
138773
138898
|
function getConstructSignatureDefinition() {
|
|
138774
138899
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
138775
138900
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -138793,26 +138918,27 @@ var ts;
|
|
|
138793
138918
|
return declarations.length
|
|
138794
138919
|
? declarationsWithBody.length !== 0
|
|
138795
138920
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
138796
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
138921
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, /*unverified*/ false, failedAliasResolution)]
|
|
138797
138922
|
: undefined;
|
|
138798
138923
|
}
|
|
138799
138924
|
}
|
|
138800
138925
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
138801
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
138926
|
+
function createDefinitionInfo(declaration, checker, symbol, node, unverified, failedAliasResolution) {
|
|
138802
138927
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
138803
138928
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
138804
138929
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
138805
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
138930
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution);
|
|
138806
138931
|
}
|
|
138932
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
138807
138933
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
138808
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
138934
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, unverified, failedAliasResolution, textSpan) {
|
|
138809
138935
|
var sourceFile = declaration.getSourceFile();
|
|
138810
138936
|
if (!textSpan) {
|
|
138811
138937
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
138812
138938
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
138813
138939
|
}
|
|
138814
138940
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
138815
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
138941
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution });
|
|
138816
138942
|
}
|
|
138817
138943
|
function isDefinitionVisible(checker, declaration) {
|
|
138818
138944
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -138845,8 +138971,8 @@ var ts;
|
|
|
138845
138971
|
return false;
|
|
138846
138972
|
}
|
|
138847
138973
|
}
|
|
138848
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
138849
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
138974
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
138975
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
|
138850
138976
|
}
|
|
138851
138977
|
function findReferenceInPosition(refs, pos) {
|
|
138852
138978
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -151961,9 +152087,10 @@ var ts;
|
|
|
151961
152087
|
// 2. add "member3" to the second import statement's import list
|
|
151962
152088
|
// and it is up to the user to decide which one fits best.
|
|
151963
152089
|
return ts.firstDefined(existingImports, function (_a) {
|
|
152090
|
+
var _b;
|
|
151964
152091
|
var declaration = _a.declaration;
|
|
151965
152092
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
151966
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152093
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151967
152094
|
if (namespacePrefix && moduleSpecifier) {
|
|
151968
152095
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
151969
152096
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -152139,8 +152266,9 @@ var ts;
|
|
|
152139
152266
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
152140
152267
|
}
|
|
152141
152268
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
152269
|
+
var _b;
|
|
152142
152270
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
152143
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
152271
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
152144
152272
|
if (moduleSpecifier) {
|
|
152145
152273
|
var addAsTypeOnly = useRequire
|
|
152146
152274
|
? 4 /* NotAllowed */
|
|
@@ -156498,7 +156626,6 @@ var ts;
|
|
|
156498
156626
|
var checker = program.getTypeChecker();
|
|
156499
156627
|
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156500
156628
|
var flags = 1 /* NoTruncation */
|
|
156501
|
-
| 1073741824 /* NoUndefinedOptionalParameterType */
|
|
156502
156629
|
| 256 /* SuppressAnyReturnType */
|
|
156503
156630
|
| 524288 /* AllowEmptyTuple */
|
|
156504
156631
|
| (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
@@ -164079,9 +164206,9 @@ var ts;
|
|
|
164079
164206
|
}
|
|
164080
164207
|
}
|
|
164081
164208
|
/// Goto definition
|
|
164082
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
164209
|
+
function getDefinitionAtPosition(fileName, position, searchOtherFilesOnly) {
|
|
164083
164210
|
synchronizeHostData();
|
|
164084
|
-
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
164211
|
+
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly);
|
|
164085
164212
|
}
|
|
164086
164213
|
function getDefinitionAndBoundSpan(fileName, position) {
|
|
164087
164214
|
synchronizeHostData();
|
|
@@ -167039,6 +167166,11 @@ var ts;
|
|
|
167039
167166
|
return "/dev/null/autoImportProviderProject" + counter + "*";
|
|
167040
167167
|
}
|
|
167041
167168
|
server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName;
|
|
167169
|
+
/*@internal*/
|
|
167170
|
+
function makeAuxiliaryProjectName(counter) {
|
|
167171
|
+
return "/dev/null/auxiliaryProject" + counter + "*";
|
|
167172
|
+
}
|
|
167173
|
+
server.makeAuxiliaryProjectName = makeAuxiliaryProjectName;
|
|
167042
167174
|
function createSortedArray() {
|
|
167043
167175
|
return []; // TODO: GH#19873
|
|
167044
167176
|
}
|
|
@@ -167252,6 +167384,7 @@ var ts;
|
|
|
167252
167384
|
CommandTypes["SignatureHelp"] = "signatureHelp";
|
|
167253
167385
|
/* @internal */
|
|
167254
167386
|
CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
|
|
167387
|
+
CommandTypes["FindSourceDefinition"] = "findSourceDefinition";
|
|
167255
167388
|
CommandTypes["Status"] = "status";
|
|
167256
167389
|
CommandTypes["TypeDefinition"] = "typeDefinition";
|
|
167257
167390
|
CommandTypes["ProjectInfo"] = "projectInfo";
|
|
@@ -167831,7 +167964,7 @@ var ts;
|
|
|
167831
167964
|
case 0:
|
|
167832
167965
|
return server.Errors.ThrowNoProject();
|
|
167833
167966
|
case 1:
|
|
167834
|
-
return
|
|
167967
|
+
return ensurePrimaryProjectKind(this.containingProjects[0]);
|
|
167835
167968
|
default:
|
|
167836
167969
|
// If this file belongs to multiple projects, below is the order in which default project is used
|
|
167837
167970
|
// - for open script info, its default configured project during opening is default if info is part of it
|
|
@@ -167869,7 +168002,7 @@ var ts;
|
|
|
167869
168002
|
firstInferredProject = project;
|
|
167870
168003
|
}
|
|
167871
168004
|
}
|
|
167872
|
-
return
|
|
168005
|
+
return ensurePrimaryProjectKind(defaultConfiguredProject ||
|
|
167873
168006
|
firstNonSourceOfProjectReferenceRedirect ||
|
|
167874
168007
|
firstConfiguredProject ||
|
|
167875
168008
|
firstExternalProject ||
|
|
@@ -167945,8 +168078,8 @@ var ts;
|
|
|
167945
168078
|
return !ts.forEach(this.containingProjects, function (p) { return !p.isOrphan(); });
|
|
167946
168079
|
};
|
|
167947
168080
|
/*@internal*/
|
|
167948
|
-
ScriptInfo.prototype.
|
|
167949
|
-
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider; });
|
|
168081
|
+
ScriptInfo.prototype.isContainedByBackgroundProject = function () {
|
|
168082
|
+
return ts.some(this.containingProjects, function (p) { return p.projectKind === server.ProjectKind.AutoImportProvider || p.projectKind === server.ProjectKind.Auxiliary; });
|
|
167950
168083
|
};
|
|
167951
168084
|
/**
|
|
167952
168085
|
* @param line 1 based index
|
|
@@ -167980,8 +168113,13 @@ var ts;
|
|
|
167980
168113
|
return ScriptInfo;
|
|
167981
168114
|
}());
|
|
167982
168115
|
server.ScriptInfo = ScriptInfo;
|
|
167983
|
-
|
|
167984
|
-
|
|
168116
|
+
/**
|
|
168117
|
+
* Throws an error if `project` is an AutoImportProvider or AuxiliaryProject,
|
|
168118
|
+
* which are used in the background by other Projects and should never be
|
|
168119
|
+
* reported as the default project for a ScriptInfo.
|
|
168120
|
+
*/
|
|
168121
|
+
function ensurePrimaryProjectKind(project) {
|
|
168122
|
+
if (!project || project.projectKind === server.ProjectKind.AutoImportProvider || project.projectKind === server.ProjectKind.Auxiliary) {
|
|
167985
168123
|
return server.Errors.ThrowNoProject();
|
|
167986
168124
|
}
|
|
167987
168125
|
return project;
|
|
@@ -168121,6 +168259,7 @@ var ts;
|
|
|
168121
168259
|
ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
|
|
168122
168260
|
ProjectKind[ProjectKind["External"] = 2] = "External";
|
|
168123
168261
|
ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
|
|
168262
|
+
ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
|
|
168124
168263
|
})(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
|
|
168125
168264
|
/* @internal */
|
|
168126
168265
|
function countEachFileTypes(infos, includeSizes) {
|
|
@@ -168146,7 +168285,7 @@ var ts;
|
|
|
168146
168285
|
result.jsxSize += fileSize;
|
|
168147
168286
|
break;
|
|
168148
168287
|
case 3 /* TS */:
|
|
168149
|
-
if (ts.
|
|
168288
|
+
if (ts.isDeclarationFileName(info.fileName)) {
|
|
168150
168289
|
result.dts += 1;
|
|
168151
168290
|
result.dtsSize += fileSize;
|
|
168152
168291
|
}
|
|
@@ -168184,7 +168323,7 @@ var ts;
|
|
|
168184
168323
|
server.allFilesAreJsOrDts = allFilesAreJsOrDts;
|
|
168185
168324
|
/* @internal */
|
|
168186
168325
|
function hasNoTypeScriptSource(fileNames) {
|
|
168187
|
-
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.
|
|
168326
|
+
return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); });
|
|
168188
168327
|
}
|
|
168189
168328
|
server.hasNoTypeScriptSource = hasNoTypeScriptSource;
|
|
168190
168329
|
function isGeneratedFileWatcher(watch) {
|
|
@@ -168588,7 +168727,7 @@ var ts;
|
|
|
168588
168727
|
}
|
|
168589
168728
|
// Update the signature
|
|
168590
168729
|
if (this.builderState && ts.getEmitDeclarations(this.compilerOptions)) {
|
|
168591
|
-
var dtsFiles = outputFiles.filter(function (f) { return ts.
|
|
168730
|
+
var dtsFiles = outputFiles.filter(function (f) { return ts.isDeclarationFileName(f.name); });
|
|
168592
168731
|
if (dtsFiles.length === 1) {
|
|
168593
168732
|
var sourceFile = this.program.getSourceFile(scriptInfo.fileName);
|
|
168594
168733
|
var signature = this.projectService.host.createHash ?
|
|
@@ -168707,6 +168846,10 @@ var ts;
|
|
|
168707
168846
|
this.autoImportProviderHost.close();
|
|
168708
168847
|
}
|
|
168709
168848
|
this.autoImportProviderHost = undefined;
|
|
168849
|
+
if (this.noDtsResolutionProject) {
|
|
168850
|
+
this.noDtsResolutionProject.close();
|
|
168851
|
+
}
|
|
168852
|
+
this.noDtsResolutionProject = undefined;
|
|
168710
168853
|
// signal language service to release source files acquired from document registry
|
|
168711
168854
|
this.languageService.dispose();
|
|
168712
168855
|
this.languageService = undefined;
|
|
@@ -169229,11 +169372,13 @@ var ts;
|
|
|
169229
169372
|
}
|
|
169230
169373
|
};
|
|
169231
169374
|
Project.prototype.setCompilerOptions = function (compilerOptions) {
|
|
169375
|
+
var _a;
|
|
169232
169376
|
if (compilerOptions) {
|
|
169233
169377
|
compilerOptions.allowNonTsExtensions = true;
|
|
169234
169378
|
var oldOptions = this.compilerOptions;
|
|
169235
169379
|
this.compilerOptions = compilerOptions;
|
|
169236
169380
|
this.setInternalCompilerOptionsForEmittingJsFiles();
|
|
169381
|
+
(_a = this.noDtsResolutionProject) === null || _a === void 0 ? void 0 : _a.setCompilerOptions(this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169237
169382
|
if (ts.changesAffectModuleResolution(oldOptions, compilerOptions)) {
|
|
169238
169383
|
// reset cached unresolved imports if changes in compiler options affected module resolution
|
|
169239
169384
|
this.cachedUnresolvedImportsPerFile.clear();
|
|
@@ -169573,6 +169718,31 @@ var ts;
|
|
|
169573
169718
|
Project.prototype.getIncompleteCompletionsCache = function () {
|
|
169574
169719
|
return this.projectService.getIncompleteCompletionsCache();
|
|
169575
169720
|
};
|
|
169721
|
+
/*@internal*/
|
|
169722
|
+
Project.prototype.getNoDtsResolutionProject = function (rootFileNames) {
|
|
169723
|
+
var _this = this;
|
|
169724
|
+
ts.Debug.assert(this.projectService.serverMode === ts.LanguageServiceMode.Semantic);
|
|
169725
|
+
if (!this.noDtsResolutionProject) {
|
|
169726
|
+
this.noDtsResolutionProject = new AuxiliaryProject(this.projectService, this.documentRegistry, this.getCompilerOptionsForNoDtsResolutionProject());
|
|
169727
|
+
}
|
|
169728
|
+
ts.enumerateInsertsAndDeletes(rootFileNames.map(server.toNormalizedPath), this.noDtsResolutionProject.getRootFiles(), ts.getStringComparer(!this.useCaseSensitiveFileNames()), function (pathToAdd) {
|
|
169729
|
+
var info = _this.projectService.getOrCreateScriptInfoNotOpenedByClient(pathToAdd, _this.currentDirectory, _this.noDtsResolutionProject.directoryStructureHost);
|
|
169730
|
+
if (info) {
|
|
169731
|
+
_this.noDtsResolutionProject.addRoot(info, pathToAdd);
|
|
169732
|
+
}
|
|
169733
|
+
}, function (pathToRemove) {
|
|
169734
|
+
// It may be preferable to remove roots only once project grows to a certain size?
|
|
169735
|
+
var info = _this.noDtsResolutionProject.getScriptInfo(pathToRemove);
|
|
169736
|
+
if (info) {
|
|
169737
|
+
_this.noDtsResolutionProject.removeRoot(info);
|
|
169738
|
+
}
|
|
169739
|
+
});
|
|
169740
|
+
return this.noDtsResolutionProject;
|
|
169741
|
+
};
|
|
169742
|
+
/*@internal*/
|
|
169743
|
+
Project.prototype.getCompilerOptionsForNoDtsResolutionProject = function () {
|
|
169744
|
+
return __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
|
|
169745
|
+
};
|
|
169576
169746
|
return Project;
|
|
169577
169747
|
}());
|
|
169578
169748
|
server.Project = Project;
|
|
@@ -169688,6 +169858,26 @@ var ts;
|
|
|
169688
169858
|
return InferredProject;
|
|
169689
169859
|
}(Project));
|
|
169690
169860
|
server.InferredProject = InferredProject;
|
|
169861
|
+
var AuxiliaryProject = /** @class */ (function (_super) {
|
|
169862
|
+
__extends(AuxiliaryProject, _super);
|
|
169863
|
+
function AuxiliaryProject(projectService, documentRegistry, compilerOptions) {
|
|
169864
|
+
return _super.call(this, projectService.newAuxiliaryProjectName(), ProjectKind.Auxiliary, projectService, documentRegistry,
|
|
169865
|
+
/*hasExplicitListOfFiles*/ false,
|
|
169866
|
+
/*lastFileExceededProgramSize*/ undefined, compilerOptions,
|
|
169867
|
+
/*compileOnSaveEnabled*/ false,
|
|
169868
|
+
/*watchOptions*/ undefined, projectService.host,
|
|
169869
|
+
/*currentDirectory*/ undefined) || this;
|
|
169870
|
+
}
|
|
169871
|
+
AuxiliaryProject.prototype.isOrphan = function () {
|
|
169872
|
+
return true;
|
|
169873
|
+
};
|
|
169874
|
+
/*@internal*/
|
|
169875
|
+
AuxiliaryProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
169876
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
169877
|
+
return;
|
|
169878
|
+
};
|
|
169879
|
+
return AuxiliaryProject;
|
|
169880
|
+
}(Project));
|
|
169691
169881
|
var AutoImportProviderProject = /** @class */ (function (_super) {
|
|
169692
169882
|
__extends(AutoImportProviderProject, _super);
|
|
169693
169883
|
/*@internal*/
|
|
@@ -169839,6 +170029,11 @@ var ts;
|
|
|
169839
170029
|
}
|
|
169840
170030
|
return hasSameSetOfFiles;
|
|
169841
170031
|
};
|
|
170032
|
+
/*@internal*/
|
|
170033
|
+
AutoImportProviderProject.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () {
|
|
170034
|
+
// Invalidation will happen on-demand as part of updateGraph
|
|
170035
|
+
return;
|
|
170036
|
+
};
|
|
169842
170037
|
AutoImportProviderProject.prototype.hasRoots = function () {
|
|
169843
170038
|
var _a;
|
|
169844
170039
|
return !!((_a = this.rootFileNames) === null || _a === void 0 ? void 0 : _a.length);
|
|
@@ -170524,6 +170719,8 @@ var ts;
|
|
|
170524
170719
|
this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName);
|
|
170525
170720
|
/*@internal*/
|
|
170526
170721
|
this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName);
|
|
170722
|
+
/*@internal*/
|
|
170723
|
+
this.newAuxiliaryProjectName = createProjectNameFactoryWithCounter(server.makeAuxiliaryProjectName);
|
|
170527
170724
|
/**
|
|
170528
170725
|
* Open files: with value being project root path, and key being Path of the file that is open
|
|
170529
170726
|
*/
|
|
@@ -170727,13 +170924,15 @@ var ts;
|
|
|
170727
170924
|
ProjectService.prototype.delayUpdateProjectGraph = function (project) {
|
|
170728
170925
|
var _this = this;
|
|
170729
170926
|
project.markAsDirty();
|
|
170730
|
-
|
|
170731
|
-
|
|
170732
|
-
|
|
170733
|
-
|
|
170734
|
-
|
|
170735
|
-
|
|
170736
|
-
|
|
170927
|
+
if (project.projectKind !== server.ProjectKind.AutoImportProvider && project.projectKind !== server.ProjectKind.Auxiliary) {
|
|
170928
|
+
var projectName_1 = project.getProjectName();
|
|
170929
|
+
this.pendingProjectUpdates.set(projectName_1, project);
|
|
170930
|
+
this.throttledOperations.schedule(projectName_1, /*delay*/ 250, function () {
|
|
170931
|
+
if (_this.pendingProjectUpdates.delete(projectName_1)) {
|
|
170932
|
+
updateProjectIfDirty(project);
|
|
170933
|
+
}
|
|
170934
|
+
});
|
|
170935
|
+
}
|
|
170737
170936
|
};
|
|
170738
170937
|
/*@internal*/
|
|
170739
170938
|
ProjectService.prototype.hasPendingProjectUpdate = function (project) {
|
|
@@ -173014,7 +173213,7 @@ var ts;
|
|
|
173014
173213
|
var toRemoveScriptInfos = new ts.Map(this.filenameToScriptInfo);
|
|
173015
173214
|
this.filenameToScriptInfo.forEach(function (info) {
|
|
173016
173215
|
// If script info is open or orphan, retain it and its dependencies
|
|
173017
|
-
if (!info.isScriptOpen() && info.isOrphan() && !info.
|
|
173216
|
+
if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByBackgroundProject()) {
|
|
173018
173217
|
// Otherwise if there is any source info that is alive, this alive too
|
|
173019
173218
|
if (!info.sourceMapFilePath)
|
|
173020
173219
|
return;
|
|
@@ -174310,6 +174509,9 @@ var ts;
|
|
|
174310
174509
|
_a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
|
|
174311
174510
|
return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
174312
174511
|
},
|
|
174512
|
+
_a[server.CommandNames.FindSourceDefinition] = function (request) {
|
|
174513
|
+
return _this.requiredResponse(_this.findSourceDefinition(request.arguments));
|
|
174514
|
+
},
|
|
174313
174515
|
_a[server.CommandNames.EmitOutput] = function (request) {
|
|
174314
174516
|
return _this.requiredResponse(_this.getEmitOutput(request.arguments));
|
|
174315
174517
|
},
|
|
@@ -175051,7 +175253,7 @@ var ts;
|
|
|
175051
175253
|
Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
|
|
175052
175254
|
return definitions.map(function (info) {
|
|
175053
175255
|
var newDocumentSpan = getMappedDocumentSpan(info, project);
|
|
175054
|
-
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
|
|
175256
|
+
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
|
|
175055
175257
|
});
|
|
175056
175258
|
};
|
|
175057
175259
|
Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
|
|
@@ -175078,6 +175280,152 @@ var ts;
|
|
|
175078
175280
|
textSpan: textSpan,
|
|
175079
175281
|
};
|
|
175080
175282
|
};
|
|
175283
|
+
Session.prototype.findSourceDefinition = function (args) {
|
|
175284
|
+
var _a;
|
|
175285
|
+
var _b = this.getFileAndProject(args), file = _b.file, project = _b.project;
|
|
175286
|
+
var position = this.getPositionInFile(args, file);
|
|
175287
|
+
var unmappedDefinitions = project.getLanguageService().getDefinitionAtPosition(file, position);
|
|
175288
|
+
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitions || server.emptyArray, project).slice();
|
|
175289
|
+
var needsJsResolution = this.projectService.serverMode === ts.LanguageServiceMode.Semantic && (!ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) ||
|
|
175290
|
+
ts.some(definitions, function (d) { return !!d.failedAliasResolution; }));
|
|
175291
|
+
if (needsJsResolution) {
|
|
175292
|
+
var definitionSet_1 = ts.createSet(function (d) { return d.textSpan.start; }, ts.documentSpansEqual);
|
|
175293
|
+
definitions === null || definitions === void 0 ? void 0 : definitions.forEach(function (d) { return definitionSet_1.add(d); });
|
|
175294
|
+
var noDtsProject = project.getNoDtsResolutionProject([file]);
|
|
175295
|
+
var ls = noDtsProject.getLanguageService();
|
|
175296
|
+
var jsDefinitions = (_a = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file; });
|
|
175297
|
+
if (ts.some(jsDefinitions)) {
|
|
175298
|
+
for (var _i = 0, jsDefinitions_1 = jsDefinitions; _i < jsDefinitions_1.length; _i++) {
|
|
175299
|
+
var jsDefinition = jsDefinitions_1[_i];
|
|
175300
|
+
if (jsDefinition.unverified) {
|
|
175301
|
+
var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
|
|
175302
|
+
if (ts.some(refined)) {
|
|
175303
|
+
for (var _c = 0, refined_1 = refined; _c < refined_1.length; _c++) {
|
|
175304
|
+
var def = refined_1[_c];
|
|
175305
|
+
definitionSet_1.add(def);
|
|
175306
|
+
}
|
|
175307
|
+
continue;
|
|
175308
|
+
}
|
|
175309
|
+
}
|
|
175310
|
+
definitionSet_1.add(jsDefinition);
|
|
175311
|
+
}
|
|
175312
|
+
}
|
|
175313
|
+
else {
|
|
175314
|
+
var ambientCandidates = definitions.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; });
|
|
175315
|
+
for (var _d = 0, _e = ts.some(ambientCandidates) ? ambientCandidates : getAmbientCandidatesByClimbingAccessChain(); _d < _e.length; _d++) {
|
|
175316
|
+
var candidate = _e[_d];
|
|
175317
|
+
var fileNameToSearch = findImplementationFileFromDtsFileName(candidate.fileName, file, noDtsProject);
|
|
175318
|
+
if (!fileNameToSearch || !ensureRoot(noDtsProject, fileNameToSearch)) {
|
|
175319
|
+
continue;
|
|
175320
|
+
}
|
|
175321
|
+
var noDtsProgram = ls.getProgram();
|
|
175322
|
+
var fileToSearch = ts.Debug.checkDefined(noDtsProgram.getSourceFile(fileNameToSearch));
|
|
175323
|
+
for (var _f = 0, _g = searchForDeclaration(candidate.name, fileToSearch, noDtsProgram); _f < _g.length; _f++) {
|
|
175324
|
+
var match = _g[_f];
|
|
175325
|
+
definitionSet_1.add(match);
|
|
175326
|
+
}
|
|
175327
|
+
}
|
|
175328
|
+
}
|
|
175329
|
+
definitions = ts.arrayFrom(definitionSet_1.values());
|
|
175330
|
+
}
|
|
175331
|
+
definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
|
|
175332
|
+
return this.mapDefinitionInfo(definitions, project);
|
|
175333
|
+
function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
|
|
175334
|
+
var _a;
|
|
175335
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
|
|
175336
|
+
if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
|
|
175337
|
+
// Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
|
|
175338
|
+
var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex);
|
|
175339
|
+
var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache();
|
|
175340
|
+
var compilerOptions = project.getCompilationSettings();
|
|
175341
|
+
var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions);
|
|
175342
|
+
if (!packageJson)
|
|
175343
|
+
return undefined;
|
|
175344
|
+
// Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext -
|
|
175345
|
+
// Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be
|
|
175346
|
+
// resolved from the package root under --moduleResolution node
|
|
175347
|
+
var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, project, project.getModuleResolutionCache());
|
|
175348
|
+
// This substring is correct only because we checked for a single `/node_modules/` at the top.
|
|
175349
|
+
var packageNamePathPart = fileName.substring(nodeModulesPathParts.topLevelPackageNameIndex + 1, nodeModulesPathParts.packageRootIndex);
|
|
175350
|
+
var packageName = ts.getPackageNameFromTypesPackageName(ts.unmangleScopedPackageName(packageNamePathPart));
|
|
175351
|
+
var path_1 = project.toPath(fileName);
|
|
175352
|
+
if (entrypoints && ts.some(entrypoints, function (e) { return project.toPath(e) === path_1; })) {
|
|
175353
|
+
// This file was the main entrypoint of a package. Try to resolve that same package name with
|
|
175354
|
+
// the auxiliary project that only resolves to implementation files.
|
|
175355
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
|
|
175356
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175357
|
+
}
|
|
175358
|
+
else {
|
|
175359
|
+
// It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
|
|
175360
|
+
var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
|
|
175361
|
+
var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
|
|
175362
|
+
var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
|
|
175363
|
+
return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
|
|
175364
|
+
}
|
|
175365
|
+
}
|
|
175366
|
+
// We're not in node_modules, and we only get to this function if non-dts module resolution failed.
|
|
175367
|
+
// I'm not sure what else I can do here that isn't already covered by that module resolution.
|
|
175368
|
+
return undefined;
|
|
175369
|
+
}
|
|
175370
|
+
// In 'foo.bar./**/baz', if we got not results on 'baz', see if we can get an ambient definition
|
|
175371
|
+
// for 'bar' or 'foo' (in that order) so we can search for declarations of 'baz' later.
|
|
175372
|
+
function getAmbientCandidatesByClimbingAccessChain() {
|
|
175373
|
+
var ls = project.getLanguageService();
|
|
175374
|
+
var program = ls.getProgram();
|
|
175375
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175376
|
+
if ((ts.isStringLiteralLike(initialNode) || ts.isIdentifier(initialNode)) && ts.isAccessExpression(initialNode.parent)) {
|
|
175377
|
+
return ts.forEachNameInAccessChainWalkingLeft(initialNode, function (nameInChain) {
|
|
175378
|
+
var _a;
|
|
175379
|
+
if (nameInChain === initialNode)
|
|
175380
|
+
return undefined;
|
|
175381
|
+
var candidates = (_a = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true)) === null || _a === void 0 ? void 0 : _a.filter(function (d) { return server.toNormalizedPath(d.fileName) !== file && d.isAmbient; }).map(function (d) { return ({
|
|
175382
|
+
fileName: d.fileName,
|
|
175383
|
+
name: ts.getTextOfIdentifierOrLiteral(initialNode)
|
|
175384
|
+
}); });
|
|
175385
|
+
if (ts.some(candidates)) {
|
|
175386
|
+
return candidates;
|
|
175387
|
+
}
|
|
175388
|
+
}) || server.emptyArray;
|
|
175389
|
+
}
|
|
175390
|
+
return server.emptyArray;
|
|
175391
|
+
}
|
|
175392
|
+
function tryRefineDefinition(definition, program, noDtsProgram) {
|
|
175393
|
+
var _a;
|
|
175394
|
+
var fileToSearch = noDtsProgram.getSourceFile(definition.fileName);
|
|
175395
|
+
if (!fileToSearch) {
|
|
175396
|
+
return undefined;
|
|
175397
|
+
}
|
|
175398
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
175399
|
+
var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
|
|
175400
|
+
var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */);
|
|
175401
|
+
if (!importSpecifier)
|
|
175402
|
+
return undefined;
|
|
175403
|
+
var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text;
|
|
175404
|
+
return searchForDeclaration(nameToSearch, fileToSearch, noDtsProgram);
|
|
175405
|
+
}
|
|
175406
|
+
function searchForDeclaration(declarationName, fileToSearch, noDtsProgram) {
|
|
175407
|
+
var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
|
|
175408
|
+
return ts.mapDefined(matches, function (match) {
|
|
175409
|
+
var symbol = noDtsProgram.getTypeChecker().getSymbolAtLocation(match);
|
|
175410
|
+
var decl = ts.getDeclarationFromName(match);
|
|
175411
|
+
if (symbol && decl) {
|
|
175412
|
+
// I think the last argument to this is supposed to be the start node, but it doesn't seem important.
|
|
175413
|
+
// Callers internal to GoToDefinition already get confused about this.
|
|
175414
|
+
return ts.GoToDefinition.createDefinitionInfo(decl, noDtsProgram.getTypeChecker(), symbol, decl, /*unverified*/ true);
|
|
175415
|
+
}
|
|
175416
|
+
});
|
|
175417
|
+
}
|
|
175418
|
+
function ensureRoot(project, fileName) {
|
|
175419
|
+
var info = project.getScriptInfo(fileName);
|
|
175420
|
+
if (!info)
|
|
175421
|
+
return false;
|
|
175422
|
+
if (!project.containsScriptInfo(info)) {
|
|
175423
|
+
project.addRoot(info);
|
|
175424
|
+
project.updateGraph();
|
|
175425
|
+
}
|
|
175426
|
+
return true;
|
|
175427
|
+
}
|
|
175428
|
+
};
|
|
175081
175429
|
Session.prototype.getEmitOutput = function (args) {
|
|
175082
175430
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
175083
175431
|
if (!project.shouldEmitFile(project.getScriptInfo(file))) {
|
|
@@ -175641,7 +175989,7 @@ var ts;
|
|
|
175641
175989
|
return undefined;
|
|
175642
175990
|
}
|
|
175643
175991
|
var compilationSettings = project.getCompilationSettings();
|
|
175644
|
-
if (!!compilationSettings.noEmit || ts.
|
|
175992
|
+
if (!!compilationSettings.noEmit || ts.isDeclarationFileName(info.fileName) && !dtsChangeCanAffectEmit(compilationSettings)) {
|
|
175645
175993
|
// avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled
|
|
175646
175994
|
return undefined;
|
|
175647
175995
|
}
|
|
@@ -176121,7 +176469,7 @@ var ts;
|
|
|
176121
176469
|
else {
|
|
176122
176470
|
var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217
|
|
176123
176471
|
if (!info.isScriptOpen()) {
|
|
176124
|
-
if (ts.
|
|
176472
|
+
if (ts.isDeclarationFileName(fileNameInProject)) {
|
|
176125
176473
|
veryLowPriorityFiles.push(fileNameInProject);
|
|
176126
176474
|
}
|
|
176127
176475
|
else {
|