@typescript-deploys/pr-build 4.7.0-pr-48094-5 → 4.7.0-pr-48264-3
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/protocol.d.ts +4 -0
- package/lib/tsc.js +64 -88
- package/lib/tsserver.js +332 -155
- package/lib/tsserverlibrary.d.ts +10 -1
- package/lib/tsserverlibrary.js +332 -155
- package/lib/typescript.js +217 -151
- package/lib/typescriptServices.js +217 -151
- package/lib/typingsInstaller.js +70 -103
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220315";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -15144,6 +15144,10 @@ var ts;
|
|
|
15144
15144
|
}
|
|
15145
15145
|
}
|
|
15146
15146
|
ts.isAnyImportSyntax = isAnyImportSyntax;
|
|
15147
|
+
function isAnyImportOrBareOrAccessedRequire(node) {
|
|
15148
|
+
return isAnyImportSyntax(node) || isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
15149
|
+
}
|
|
15150
|
+
ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire;
|
|
15147
15151
|
function isLateVisibilityPaintedStatement(node) {
|
|
15148
15152
|
switch (node.kind) {
|
|
15149
15153
|
case 265 /* ImportDeclaration */:
|
|
@@ -16722,14 +16726,14 @@ var ts;
|
|
|
16722
16726
|
}
|
|
16723
16727
|
ts.isFunctionSymbol = isFunctionSymbol;
|
|
16724
16728
|
function tryGetModuleSpecifierFromDeclaration(node) {
|
|
16725
|
-
var _a, _b
|
|
16729
|
+
var _a, _b;
|
|
16726
16730
|
switch (node.kind) {
|
|
16727
16731
|
case 253 /* VariableDeclaration */:
|
|
16728
|
-
return node.initializer.arguments[0]
|
|
16732
|
+
return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0];
|
|
16729
16733
|
case 265 /* ImportDeclaration */:
|
|
16730
|
-
return
|
|
16734
|
+
return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike);
|
|
16731
16735
|
case 264 /* ImportEqualsDeclaration */:
|
|
16732
|
-
return
|
|
16736
|
+
return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike);
|
|
16733
16737
|
default:
|
|
16734
16738
|
ts.Debug.assertNever(node);
|
|
16735
16739
|
}
|
|
@@ -17256,21 +17260,28 @@ var ts;
|
|
|
17256
17260
|
// export = <EntityNameExpression>
|
|
17257
17261
|
// export default <EntityNameExpression>
|
|
17258
17262
|
// module.exports = <EntityNameExpression>
|
|
17259
|
-
//
|
|
17260
|
-
//
|
|
17263
|
+
// module.exports.x = <EntityNameExpression>
|
|
17264
|
+
// const x = require("...")
|
|
17265
|
+
// const { x } = require("...")
|
|
17266
|
+
// const x = require("...").y
|
|
17267
|
+
// const { x } = require("...").y
|
|
17261
17268
|
function isAliasSymbolDeclaration(node) {
|
|
17262
|
-
|
|
17269
|
+
if (node.kind === 264 /* ImportEqualsDeclaration */ ||
|
|
17263
17270
|
node.kind === 263 /* NamespaceExportDeclaration */ ||
|
|
17264
17271
|
node.kind === 266 /* ImportClause */ && !!node.name ||
|
|
17265
17272
|
node.kind === 267 /* NamespaceImport */ ||
|
|
17266
17273
|
node.kind === 273 /* NamespaceExport */ ||
|
|
17267
17274
|
node.kind === 269 /* ImportSpecifier */ ||
|
|
17268
17275
|
node.kind === 274 /* ExportSpecifier */ ||
|
|
17269
|
-
node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node)
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17276
|
+
node.kind === 270 /* ExportAssignment */ && exportAssignmentIsAlias(node)) {
|
|
17277
|
+
return true;
|
|
17278
|
+
}
|
|
17279
|
+
return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) ||
|
|
17280
|
+
ts.isPropertyAccessExpression(node)
|
|
17281
|
+
&& ts.isBinaryExpression(node.parent)
|
|
17282
|
+
&& node.parent.left === node
|
|
17283
|
+
&& node.parent.operatorToken.kind === 63 /* EqualsToken */
|
|
17284
|
+
&& isAliasableExpression(node.parent.right));
|
|
17274
17285
|
}
|
|
17275
17286
|
ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
|
|
17276
17287
|
function getAliasDeclarationFromName(node) {
|
|
@@ -17281,6 +17292,7 @@ var ts;
|
|
|
17281
17292
|
case 274 /* ExportSpecifier */:
|
|
17282
17293
|
case 270 /* ExportAssignment */:
|
|
17283
17294
|
case 264 /* ImportEqualsDeclaration */:
|
|
17295
|
+
case 273 /* NamespaceExport */:
|
|
17284
17296
|
return node.parent;
|
|
17285
17297
|
case 160 /* QualifiedName */:
|
|
17286
17298
|
do {
|
|
@@ -39628,6 +39640,13 @@ var ts;
|
|
|
39628
39640
|
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
|
|
39629
39641
|
defaultValueDescription: false,
|
|
39630
39642
|
},
|
|
39643
|
+
{
|
|
39644
|
+
name: "noDtsResolution",
|
|
39645
|
+
type: "boolean",
|
|
39646
|
+
affectsModuleResolution: true,
|
|
39647
|
+
category: ts.Diagnostics.Modules,
|
|
39648
|
+
defaultValueDescription: false,
|
|
39649
|
+
},
|
|
39631
39650
|
// Source Maps
|
|
39632
39651
|
{
|
|
39633
39652
|
name: "sourceRoot",
|
|
@@ -42007,7 +42026,8 @@ var ts;
|
|
|
42007
42026
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42008
42027
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42009
42028
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42010
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42029
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42030
|
+
Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
|
|
42011
42031
|
})(Extensions || (Extensions = {}));
|
|
42012
42032
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42013
42033
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -42952,7 +42972,21 @@ var ts;
|
|
|
42952
42972
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
42953
42973
|
}
|
|
42954
42974
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
42955
|
-
|
|
42975
|
+
var extensions;
|
|
42976
|
+
if (lookupConfig) {
|
|
42977
|
+
extensions = tsconfigExtensions;
|
|
42978
|
+
}
|
|
42979
|
+
else if (compilerOptions.noDtsResolution) {
|
|
42980
|
+
extensions = [Extensions.TypeScriptButNotDts];
|
|
42981
|
+
if (compilerOptions.allowJs)
|
|
42982
|
+
extensions.push(Extensions.JavaScript);
|
|
42983
|
+
if (compilerOptions.resolveJsonModule)
|
|
42984
|
+
extensions.push(Extensions.Json);
|
|
42985
|
+
}
|
|
42986
|
+
else {
|
|
42987
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
42988
|
+
}
|
|
42989
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
42956
42990
|
}
|
|
42957
42991
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
42958
42992
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -42961,6 +42995,10 @@ var ts;
|
|
|
42961
42995
|
var failedLookupLocations = [];
|
|
42962
42996
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42963
42997
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
42998
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
42999
|
+
if (compilerOptions.noDtsResolution) {
|
|
43000
|
+
conditions.pop();
|
|
43001
|
+
}
|
|
42964
43002
|
var state = {
|
|
42965
43003
|
compilerOptions: compilerOptions,
|
|
42966
43004
|
host: host,
|
|
@@ -42968,7 +43006,7 @@ var ts;
|
|
|
42968
43006
|
failedLookupLocations: failedLookupLocations,
|
|
42969
43007
|
packageJsonInfoCache: cache,
|
|
42970
43008
|
features: features,
|
|
42971
|
-
conditions:
|
|
43009
|
+
conditions: conditions,
|
|
42972
43010
|
};
|
|
42973
43011
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
42974
43012
|
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);
|
|
@@ -43176,20 +43214,22 @@ var ts;
|
|
|
43176
43214
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43177
43215
|
}
|
|
43178
43216
|
case Extensions.TypeScript:
|
|
43217
|
+
case Extensions.TypeScriptButNotDts:
|
|
43218
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43179
43219
|
switch (originalExtension) {
|
|
43180
43220
|
case ".mjs" /* Mjs */:
|
|
43181
43221
|
case ".mts" /* Mts */:
|
|
43182
43222
|
case ".d.mts" /* Dmts */:
|
|
43183
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43223
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43184
43224
|
case ".cjs" /* Cjs */:
|
|
43185
43225
|
case ".cts" /* Cts */:
|
|
43186
43226
|
case ".d.cts" /* Dcts */:
|
|
43187
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43227
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43188
43228
|
case ".json" /* Json */:
|
|
43189
43229
|
candidate += ".json" /* Json */;
|
|
43190
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43230
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43191
43231
|
default:
|
|
43192
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43232
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43193
43233
|
}
|
|
43194
43234
|
case Extensions.JavaScript:
|
|
43195
43235
|
switch (originalExtension) {
|
|
@@ -43407,6 +43447,7 @@ var ts;
|
|
|
43407
43447
|
switch (extensions) {
|
|
43408
43448
|
case Extensions.JavaScript:
|
|
43409
43449
|
case Extensions.Json:
|
|
43450
|
+
case Extensions.TypeScriptButNotDts:
|
|
43410
43451
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43411
43452
|
break;
|
|
43412
43453
|
case Extensions.TypeScript:
|
|
@@ -43485,6 +43526,8 @@ var ts;
|
|
|
43485
43526
|
return extension === ".json" /* Json */;
|
|
43486
43527
|
case Extensions.TypeScript:
|
|
43487
43528
|
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43529
|
+
case Extensions.TypeScriptButNotDts:
|
|
43530
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
|
|
43488
43531
|
case Extensions.DtsOnly:
|
|
43489
43532
|
return extension === ".d.ts" /* Dts */;
|
|
43490
43533
|
}
|
|
@@ -55553,7 +55596,7 @@ var ts;
|
|
|
55553
55596
|
}
|
|
55554
55597
|
}
|
|
55555
55598
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55556
|
-
type = getUnionType(sourceTypes
|
|
55599
|
+
type = getUnionType(sourceTypes);
|
|
55557
55600
|
}
|
|
55558
55601
|
}
|
|
55559
55602
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -67606,32 +67649,13 @@ var ts;
|
|
|
67606
67649
|
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
|
67607
67650
|
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
|
|
67608
67651
|
}
|
|
67609
|
-
|
|
67610
|
-
* Tests whether the provided string can be parsed as a number.
|
|
67611
|
-
* @param s The string to test.
|
|
67612
|
-
* @param roundTripOnly Indicates the resulting number matches the input when converted back to a string.
|
|
67613
|
-
*/
|
|
67614
|
-
function isValidNumberString(s, roundTripOnly) {
|
|
67615
|
-
if (s === "")
|
|
67616
|
-
return false;
|
|
67617
|
-
var n = +s;
|
|
67618
|
-
return isFinite(n) && (!roundTripOnly || "" + n === s);
|
|
67619
|
-
}
|
|
67620
|
-
/**
|
|
67621
|
-
* Tests whether the provided string can be parsed as a bigint.
|
|
67622
|
-
* @param s The string to test.
|
|
67623
|
-
* @param roundTripOnly Indicates the resulting bigint matches the input when converted back to a string.
|
|
67624
|
-
*/
|
|
67625
|
-
function isValidBigIntString(s, roundTripOnly) {
|
|
67626
|
-
if (s === "")
|
|
67627
|
-
return false;
|
|
67652
|
+
function isValidBigIntString(s) {
|
|
67628
67653
|
var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
|
|
67629
67654
|
var success = true;
|
|
67630
67655
|
scanner.setOnError(function () { return success = false; });
|
|
67631
67656
|
scanner.setText(s + "n");
|
|
67632
67657
|
var result = scanner.scan();
|
|
67633
|
-
|
|
67634
|
-
if (negative) {
|
|
67658
|
+
if (result === 40 /* MinusToken */) {
|
|
67635
67659
|
result = scanner.scan();
|
|
67636
67660
|
}
|
|
67637
67661
|
var flags = scanner.getTokenFlags();
|
|
@@ -67640,8 +67664,7 @@ var ts;
|
|
|
67640
67664
|
// * a bigint can be scanned, and that when it is scanned, it is
|
|
67641
67665
|
// * the full length of the input string (so the scanner is one character beyond the augmented input length)
|
|
67642
67666
|
// * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input)
|
|
67643
|
-
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
67644
|
-
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
67667
|
+
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */);
|
|
67645
67668
|
}
|
|
67646
67669
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
67647
67670
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
@@ -67649,8 +67672,8 @@ var ts;
|
|
|
67649
67672
|
}
|
|
67650
67673
|
if (source.flags & 128 /* StringLiteral */) {
|
|
67651
67674
|
var value = source.value;
|
|
67652
|
-
return !!(target.flags & 8 /* Number */ &&
|
|
67653
|
-
target.flags & 64 /* BigInt */ && isValidBigIntString(value
|
|
67675
|
+
return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) ||
|
|
67676
|
+
target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) ||
|
|
67654
67677
|
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
|
|
67655
67678
|
}
|
|
67656
67679
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -68224,63 +68247,7 @@ var ts;
|
|
|
68224
68247
|
// succeed. That would be a pointless and confusing outcome.
|
|
68225
68248
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
68226
68249
|
for (var i = 0; i < types.length; i++) {
|
|
68227
|
-
|
|
68228
|
-
var target_3 = types[i];
|
|
68229
|
-
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
68230
|
-
// allowed template literal placeholder types, infer from a literal type corresponding to the constraint.
|
|
68231
|
-
var sourceTypes = void 0;
|
|
68232
|
-
if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) {
|
|
68233
|
-
var inferenceContext = getInferenceInfoForType(target_3);
|
|
68234
|
-
var constraint = inferenceContext ? getConstraintOfTypeParameter(inferenceContext.typeParameter) : undefined;
|
|
68235
|
-
if (inferenceContext && constraint) {
|
|
68236
|
-
var str = source_1.value;
|
|
68237
|
-
var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint];
|
|
68238
|
-
for (var _i = 0, constraintTypes_1 = constraintTypes; _i < constraintTypes_1.length; _i++) {
|
|
68239
|
-
var constraintType = constraintTypes_1[_i];
|
|
68240
|
-
if (constraintType.flags & 402653316 /* StringLike */) {
|
|
68241
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68242
|
-
sourceTypes.push(source_1);
|
|
68243
|
-
}
|
|
68244
|
-
if (constraintType.flags & 296 /* NumberLike */ && isValidNumberString(str, /*roundTripOnly*/ true)) {
|
|
68245
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68246
|
-
sourceTypes.push(getNumberLiteralType(+str));
|
|
68247
|
-
}
|
|
68248
|
-
if (constraintType.flags & 2112 /* BigIntLike */ && isValidBigIntString(str, /*roundTripOnly*/ true)) {
|
|
68249
|
-
var negative = str.startsWith("-");
|
|
68250
|
-
var base10Value = ts.parsePseudoBigInt((negative ? str.slice(1) : str) + "n");
|
|
68251
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68252
|
-
sourceTypes.push(getBigIntLiteralType({ negative: negative, base10Value: base10Value }));
|
|
68253
|
-
}
|
|
68254
|
-
if (constraintType.flags & 528 /* BooleanLike */) {
|
|
68255
|
-
if (str === trueType.intrinsicName) {
|
|
68256
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68257
|
-
sourceTypes.push(trueType);
|
|
68258
|
-
}
|
|
68259
|
-
else if (str === falseType.intrinsicName) {
|
|
68260
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68261
|
-
sourceTypes.push(falseType);
|
|
68262
|
-
}
|
|
68263
|
-
}
|
|
68264
|
-
if (constraintType.flags & 65536 /* Null */ && str === nullType.intrinsicName) {
|
|
68265
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68266
|
-
sourceTypes.push(nullType);
|
|
68267
|
-
}
|
|
68268
|
-
if (constraintType.flags & 32768 /* Undefined */ && str === undefinedType.intrinsicName) {
|
|
68269
|
-
sourceTypes !== null && sourceTypes !== void 0 ? sourceTypes : (sourceTypes = []);
|
|
68270
|
-
sourceTypes.push(undefinedType);
|
|
68271
|
-
}
|
|
68272
|
-
}
|
|
68273
|
-
}
|
|
68274
|
-
}
|
|
68275
|
-
if (sourceTypes) {
|
|
68276
|
-
for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) {
|
|
68277
|
-
var source_2 = sourceTypes_3[_a];
|
|
68278
|
-
inferFromTypes(source_2, target_3);
|
|
68279
|
-
}
|
|
68280
|
-
}
|
|
68281
|
-
else {
|
|
68282
|
-
inferFromTypes(source_1, target_3);
|
|
68283
|
-
}
|
|
68250
|
+
inferFromTypes(matches ? matches[i] : neverType, types[i]);
|
|
68284
68251
|
}
|
|
68285
68252
|
}
|
|
68286
68253
|
}
|
|
@@ -127673,6 +127640,20 @@ var ts;
|
|
|
127673
127640
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127674
127641
|
}
|
|
127675
127642
|
ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
|
|
127643
|
+
/**
|
|
127644
|
+
* Returns true if `node` is the declaration of `n` in:
|
|
127645
|
+
* - `import n from "m"`
|
|
127646
|
+
* - `import * as n from "m"`
|
|
127647
|
+
* - `import n = require("m")`
|
|
127648
|
+
* - `const n = require("m")`
|
|
127649
|
+
*/
|
|
127650
|
+
function isFreelyNameableImport(node) {
|
|
127651
|
+
return node.kind === 266 /* ImportClause */
|
|
127652
|
+
|| node.kind === 267 /* NamespaceImport */
|
|
127653
|
+
|| ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
|
|
127654
|
+
|| ts.isVariableDeclarationInitializedToRequire(node);
|
|
127655
|
+
}
|
|
127656
|
+
ts.isFreelyNameableImport = isFreelyNameableImport;
|
|
127676
127657
|
function getScriptKind(fileName, host) {
|
|
127677
127658
|
// First check to see if the script kind was specified by the host. Chances are the host
|
|
127678
127659
|
// may override the default script kind for the file extension.
|
|
@@ -136687,6 +136668,29 @@ var ts;
|
|
|
136687
136668
|
}
|
|
136688
136669
|
}
|
|
136689
136670
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
136671
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
136672
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
136673
|
+
return candidates.reduce(function (topMost, decl) {
|
|
136674
|
+
var depth = getDepth(decl);
|
|
136675
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
136676
|
+
topMost.declarationNames.push(decl);
|
|
136677
|
+
}
|
|
136678
|
+
else if (depth < topMost.depth) {
|
|
136679
|
+
topMost.declarationNames = [decl];
|
|
136680
|
+
}
|
|
136681
|
+
topMost.depth = depth;
|
|
136682
|
+
return topMost;
|
|
136683
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
136684
|
+
function getDepth(declaration) {
|
|
136685
|
+
var depth = 0;
|
|
136686
|
+
while (declaration) {
|
|
136687
|
+
declaration = ts.getContainerNode(declaration);
|
|
136688
|
+
depth++;
|
|
136689
|
+
}
|
|
136690
|
+
return depth;
|
|
136691
|
+
}
|
|
136692
|
+
}
|
|
136693
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
136690
136694
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
136691
136695
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
136692
136696
|
return false;
|
|
@@ -138319,7 +138323,9 @@ var ts;
|
|
|
138319
138323
|
(function (ts) {
|
|
138320
138324
|
var GoToDefinition;
|
|
138321
138325
|
(function (GoToDefinition) {
|
|
138322
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
138326
|
+
function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
|
|
138327
|
+
var _a;
|
|
138328
|
+
var _b;
|
|
138323
138329
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
138324
138330
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
138325
138331
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -138342,17 +138348,50 @@ var ts;
|
|
|
138342
138348
|
}
|
|
138343
138349
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
138344
138350
|
var classDecl = node.parent.parent;
|
|
138345
|
-
var
|
|
138351
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, isAliasTarget_1 = _c.isAliasTarget, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
138352
|
+
if (aliasesOnly && !isAliasTarget_1)
|
|
138353
|
+
return undefined;
|
|
138346
138354
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
138347
138355
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
138348
138356
|
var sourceFile_1 = node.getSourceFile();
|
|
138349
138357
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
138350
138358
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
138351
138359
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
138352
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
138360
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, isAliasTarget_1, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
138353
138361
|
});
|
|
138354
138362
|
}
|
|
138355
|
-
var
|
|
138363
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, isAliasTarget = _d.isAliasTarget, failedAliasResolution = _d.failedAliasResolution;
|
|
138364
|
+
var fallbackNode = node;
|
|
138365
|
+
if (aliasesOnly && failedAliasResolution) {
|
|
138366
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
138367
|
+
var importDeclaration = ts.findAncestor(node, ts.isAnyImportOrBareOrAccessedRequire);
|
|
138368
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
138369
|
+
if (moduleSpecifier) {
|
|
138370
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, isAliasTarget = _a.isAliasTarget, failedAliasResolution = _a.failedAliasResolution);
|
|
138371
|
+
fallbackNode = moduleSpecifier;
|
|
138372
|
+
}
|
|
138373
|
+
}
|
|
138374
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
138375
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
138376
|
+
// be that module resolution succeeded but the target was not a module.
|
|
138377
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
138378
|
+
if (ref) {
|
|
138379
|
+
return [{
|
|
138380
|
+
name: fallbackNode.text,
|
|
138381
|
+
fileName: ref.resolvedFileName,
|
|
138382
|
+
containerName: undefined,
|
|
138383
|
+
containerKind: undefined,
|
|
138384
|
+
kind: "script" /* scriptElement */,
|
|
138385
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
138386
|
+
isAliasTarget: true,
|
|
138387
|
+
failedAliasResolution: failedAliasResolution,
|
|
138388
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
138389
|
+
unverified: fallbackNode !== node,
|
|
138390
|
+
}];
|
|
138391
|
+
}
|
|
138392
|
+
}
|
|
138393
|
+
if (aliasesOnly && !isAliasTarget)
|
|
138394
|
+
return undefined;
|
|
138356
138395
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
138357
138396
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
138358
138397
|
if (!symbol) {
|
|
@@ -138361,14 +138400,14 @@ var ts;
|
|
|
138361
138400
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
138362
138401
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
138363
138402
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
138364
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
138403
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, isAliasTarget, failedAliasResolution);
|
|
138365
138404
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
138366
138405
|
// If this is the original constructor definition, parent is the class.
|
|
138367
138406
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
138368
138407
|
return [sigInfo];
|
|
138369
138408
|
}
|
|
138370
138409
|
else {
|
|
138371
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
138410
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
138372
138411
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
138373
138412
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
138374
138413
|
}
|
|
@@ -138380,7 +138419,7 @@ var ts;
|
|
|
138380
138419
|
// assignment. This case and others are handled by the following code.
|
|
138381
138420
|
if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
|
|
138382
138421
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
138383
|
-
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;
|
|
138422
|
+
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, isAliasTarget, failedAliasResolution); }) : ts.emptyArray;
|
|
138384
138423
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
138385
138424
|
}
|
|
138386
138425
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -138403,7 +138442,7 @@ var ts;
|
|
|
138403
138442
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
138404
138443
|
});
|
|
138405
138444
|
}
|
|
138406
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
138445
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution));
|
|
138407
138446
|
}
|
|
138408
138447
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
138409
138448
|
/**
|
|
@@ -138501,24 +138540,24 @@ var ts;
|
|
|
138501
138540
|
return undefined;
|
|
138502
138541
|
}
|
|
138503
138542
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
138504
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
138543
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*isAliasTarget*/ false, /*failedAliasResolution*/ false);
|
|
138505
138544
|
}
|
|
138506
|
-
var
|
|
138545
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, isAliasTarget = _a.isAliasTarget, failedAliasResolution = _a.failedAliasResolution;
|
|
138507
138546
|
if (!symbol)
|
|
138508
138547
|
return undefined;
|
|
138509
138548
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
138510
138549
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
138511
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
138550
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, isAliasTarget, failedAliasResolution);
|
|
138512
138551
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
138513
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
138552
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, isAliasTarget, failedAliasResolution);
|
|
138514
138553
|
return typeDefinitions.length ? typeDefinitions
|
|
138515
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
138554
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, isAliasTarget, failedAliasResolution)
|
|
138516
138555
|
: undefined;
|
|
138517
138556
|
}
|
|
138518
138557
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
138519
|
-
function definitionFromType(type, checker, node) {
|
|
138558
|
+
function definitionFromType(type, checker, node, isAliasTarget, failedAliasResolution) {
|
|
138520
138559
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
138521
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
138560
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, isAliasTarget, failedAliasResolution);
|
|
138522
138561
|
});
|
|
138523
138562
|
}
|
|
138524
138563
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -138533,8 +138572,8 @@ var ts;
|
|
|
138533
138572
|
}
|
|
138534
138573
|
return undefined;
|
|
138535
138574
|
}
|
|
138536
|
-
function getDefinitionAndBoundSpan(program, sourceFile, position) {
|
|
138537
|
-
var definitions = getDefinitionAtPosition(program, sourceFile, position);
|
|
138575
|
+
function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
|
|
138576
|
+
var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
|
|
138538
138577
|
if (!definitions || definitions.length === 0) {
|
|
138539
138578
|
return undefined;
|
|
138540
138579
|
}
|
|
@@ -138560,13 +138599,17 @@ var ts;
|
|
|
138560
138599
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
138561
138600
|
// import {A, B} from "mod";
|
|
138562
138601
|
// to jump to the implementation directly.
|
|
138602
|
+
var failedAliasResolution = false;
|
|
138563
138603
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
138564
138604
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
138565
138605
|
if (aliased.declarations) {
|
|
138566
|
-
return aliased;
|
|
138606
|
+
return { symbol: aliased, isAliasTarget: true };
|
|
138607
|
+
}
|
|
138608
|
+
else {
|
|
138609
|
+
failedAliasResolution = true;
|
|
138567
138610
|
}
|
|
138568
138611
|
}
|
|
138569
|
-
return symbol;
|
|
138612
|
+
return { symbol: symbol, isAliasTarget: !!(symbol && ts.isExternalModuleSymbol(symbol)), failedAliasResolution: failedAliasResolution };
|
|
138570
138613
|
}
|
|
138571
138614
|
// Go to the original declaration for cases:
|
|
138572
138615
|
//
|
|
@@ -138580,26 +138623,45 @@ var ts;
|
|
|
138580
138623
|
if (node.parent === declaration) {
|
|
138581
138624
|
return true;
|
|
138582
138625
|
}
|
|
138583
|
-
|
|
138584
|
-
|
|
138585
|
-
case 264 /* ImportEqualsDeclaration */:
|
|
138586
|
-
return true;
|
|
138587
|
-
case 269 /* ImportSpecifier */:
|
|
138588
|
-
return declaration.parent.kind === 268 /* NamedImports */;
|
|
138589
|
-
case 202 /* BindingElement */:
|
|
138590
|
-
case 253 /* VariableDeclaration */:
|
|
138591
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
138592
|
-
default:
|
|
138593
|
-
return false;
|
|
138626
|
+
if (declaration.kind === 267 /* NamespaceImport */) {
|
|
138627
|
+
return false;
|
|
138594
138628
|
}
|
|
138629
|
+
return true;
|
|
138630
|
+
}
|
|
138631
|
+
/**
|
|
138632
|
+
* ```ts
|
|
138633
|
+
* function f() {}
|
|
138634
|
+
* f.foo = 0;
|
|
138635
|
+
* ```
|
|
138636
|
+
*
|
|
138637
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
138638
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
138639
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
138640
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
138641
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
138642
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
138643
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
138644
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
138645
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
138646
|
+
* up with a more precise definition of what counts as a definition.
|
|
138647
|
+
*/
|
|
138648
|
+
function isExpandoDeclaration(node) {
|
|
138649
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
138650
|
+
return false;
|
|
138651
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
138652
|
+
if (ts.isAssignmentExpression(p))
|
|
138653
|
+
return true;
|
|
138654
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
138655
|
+
return "quit";
|
|
138656
|
+
return false;
|
|
138657
|
+
});
|
|
138658
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
138595
138659
|
}
|
|
138596
|
-
function getDefinitionFromSymbol(typeChecker, symbol, node,
|
|
138597
|
-
|
|
138598
|
-
|
|
138599
|
-
|
|
138600
|
-
|
|
138601
|
-
|| undefined;
|
|
138602
|
-
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); });
|
|
138660
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, isAliasTarget, failedAliasResolution, excludeDeclaration) {
|
|
138661
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
138662
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
138663
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
138664
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, isAliasTarget, failedAliasResolution); });
|
|
138603
138665
|
function getConstructSignatureDefinition() {
|
|
138604
138666
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
138605
138667
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -138623,26 +138685,27 @@ var ts;
|
|
|
138623
138685
|
return declarations.length
|
|
138624
138686
|
? declarationsWithBody.length !== 0
|
|
138625
138687
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
138626
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
138688
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, isAliasTarget, failedAliasResolution)]
|
|
138627
138689
|
: undefined;
|
|
138628
138690
|
}
|
|
138629
138691
|
}
|
|
138630
138692
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
138631
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
138693
|
+
function createDefinitionInfo(declaration, checker, symbol, node, isAliasTarget, failedAliasResolution) {
|
|
138632
138694
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
138633
138695
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
138634
138696
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
138635
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
138697
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, isAliasTarget, failedAliasResolution);
|
|
138636
138698
|
}
|
|
138699
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
138637
138700
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
138638
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
138701
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, isAliasTarget, failedAliasResolution, textSpan) {
|
|
138639
138702
|
var sourceFile = declaration.getSourceFile();
|
|
138640
138703
|
if (!textSpan) {
|
|
138641
138704
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
138642
138705
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
138643
138706
|
}
|
|
138644
138707
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
138645
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
138708
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 8388608 /* Ambient */), isAliasTarget: isAliasTarget, failedAliasResolution: failedAliasResolution });
|
|
138646
138709
|
}
|
|
138647
138710
|
function isDefinitionVisible(checker, declaration) {
|
|
138648
138711
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -138675,8 +138738,8 @@ var ts;
|
|
|
138675
138738
|
return false;
|
|
138676
138739
|
}
|
|
138677
138740
|
}
|
|
138678
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
138679
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
138741
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, isAliasTarget, failedAliasResolution) {
|
|
138742
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, isAliasTarget, failedAliasResolution);
|
|
138680
138743
|
}
|
|
138681
138744
|
function findReferenceInPosition(refs, pos) {
|
|
138682
138745
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -138691,6 +138754,7 @@ var ts;
|
|
|
138691
138754
|
containerName: undefined,
|
|
138692
138755
|
containerKind: undefined,
|
|
138693
138756
|
unverified: unverified,
|
|
138757
|
+
isAliasTarget: true,
|
|
138694
138758
|
};
|
|
138695
138759
|
}
|
|
138696
138760
|
/** Returns a CallLikeExpression where `node` is the target being invoked. */
|
|
@@ -151689,9 +151753,10 @@ var ts;
|
|
|
151689
151753
|
// 2. add "member3" to the second import statement's import list
|
|
151690
151754
|
// and it is up to the user to decide which one fits best.
|
|
151691
151755
|
return ts.firstDefined(existingImports, function (_a) {
|
|
151756
|
+
var _b;
|
|
151692
151757
|
var declaration = _a.declaration;
|
|
151693
151758
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
151694
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
151759
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151695
151760
|
if (namespacePrefix && moduleSpecifier) {
|
|
151696
151761
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
151697
151762
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -151867,8 +151932,9 @@ var ts;
|
|
|
151867
151932
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
151868
151933
|
}
|
|
151869
151934
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
151935
|
+
var _b;
|
|
151870
151936
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
151871
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
151937
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151872
151938
|
if (moduleSpecifier) {
|
|
151873
151939
|
var addAsTypeOnly = useRequire
|
|
151874
151940
|
? 4 /* NotAllowed */
|
|
@@ -163677,9 +163743,9 @@ var ts;
|
|
|
163677
163743
|
synchronizeHostData();
|
|
163678
163744
|
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
163679
163745
|
}
|
|
163680
|
-
function getDefinitionAndBoundSpan(fileName, position) {
|
|
163746
|
+
function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
|
|
163681
163747
|
synchronizeHostData();
|
|
163682
|
-
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
|
|
163748
|
+
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
|
|
163683
163749
|
}
|
|
163684
163750
|
function getTypeDefinitionAtPosition(fileName, position) {
|
|
163685
163751
|
synchronizeHostData();
|