@typescript-deploys/pr-build 4.7.0-pr-48294-7 → 4.7.0-pr-48264-4
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 +98 -96
- package/lib/tsserver.js +393 -164
- package/lib/tsserverlibrary.d.ts +10 -1
- package/lib/tsserverlibrary.js +393 -164
- package/lib/typescript.js +278 -160
- package/lib/typescriptServices.js +278 -160
- package/lib/typingsInstaller.js +121 -100
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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 {
|
|
@@ -39639,6 +39651,13 @@ var ts;
|
|
|
39639
39651
|
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
|
|
39640
39652
|
defaultValueDescription: false,
|
|
39641
39653
|
},
|
|
39654
|
+
{
|
|
39655
|
+
name: "noDtsResolution",
|
|
39656
|
+
type: "boolean",
|
|
39657
|
+
affectsModuleResolution: true,
|
|
39658
|
+
category: ts.Diagnostics.Modules,
|
|
39659
|
+
defaultValueDescription: false,
|
|
39660
|
+
},
|
|
39642
39661
|
// Source Maps
|
|
39643
39662
|
{
|
|
39644
39663
|
name: "sourceRoot",
|
|
@@ -42018,7 +42037,8 @@ var ts;
|
|
|
42018
42037
|
Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
|
|
42019
42038
|
Extensions[Extensions["Json"] = 2] = "Json";
|
|
42020
42039
|
Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
|
|
42021
|
-
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42040
|
+
Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
|
|
42041
|
+
Extensions[Extensions["TypeScriptButNotDts"] = 5] = "TypeScriptButNotDts";
|
|
42022
42042
|
})(Extensions || (Extensions = {}));
|
|
42023
42043
|
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
|
|
42024
42044
|
function resolvedTypeScriptOnly(resolved) {
|
|
@@ -42963,7 +42983,21 @@ var ts;
|
|
|
42963
42983
|
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
42964
42984
|
}
|
|
42965
42985
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
42966
|
-
|
|
42986
|
+
var extensions;
|
|
42987
|
+
if (lookupConfig) {
|
|
42988
|
+
extensions = tsconfigExtensions;
|
|
42989
|
+
}
|
|
42990
|
+
else if (compilerOptions.noDtsResolution) {
|
|
42991
|
+
extensions = [Extensions.TypeScriptButNotDts];
|
|
42992
|
+
if (compilerOptions.allowJs)
|
|
42993
|
+
extensions.push(Extensions.JavaScript);
|
|
42994
|
+
if (compilerOptions.resolveJsonModule)
|
|
42995
|
+
extensions.push(Extensions.Json);
|
|
42996
|
+
}
|
|
42997
|
+
else {
|
|
42998
|
+
extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
|
|
42999
|
+
}
|
|
43000
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
|
|
42967
43001
|
}
|
|
42968
43002
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
42969
43003
|
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
@@ -42972,6 +43006,10 @@ var ts;
|
|
|
42972
43006
|
var failedLookupLocations = [];
|
|
42973
43007
|
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42974
43008
|
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
43009
|
+
var conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
43010
|
+
if (compilerOptions.noDtsResolution) {
|
|
43011
|
+
conditions.pop();
|
|
43012
|
+
}
|
|
42975
43013
|
var state = {
|
|
42976
43014
|
compilerOptions: compilerOptions,
|
|
42977
43015
|
host: host,
|
|
@@ -42979,7 +43017,7 @@ var ts;
|
|
|
42979
43017
|
failedLookupLocations: failedLookupLocations,
|
|
42980
43018
|
packageJsonInfoCache: cache,
|
|
42981
43019
|
features: features,
|
|
42982
|
-
conditions:
|
|
43020
|
+
conditions: conditions,
|
|
42983
43021
|
};
|
|
42984
43022
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
42985
43023
|
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);
|
|
@@ -43187,20 +43225,22 @@ var ts;
|
|
|
43187
43225
|
default: return tryExtension(".d.ts" /* Dts */);
|
|
43188
43226
|
}
|
|
43189
43227
|
case Extensions.TypeScript:
|
|
43228
|
+
case Extensions.TypeScriptButNotDts:
|
|
43229
|
+
var useDts = extensions === Extensions.TypeScript;
|
|
43190
43230
|
switch (originalExtension) {
|
|
43191
43231
|
case ".mjs" /* Mjs */:
|
|
43192
43232
|
case ".mts" /* Mts */:
|
|
43193
43233
|
case ".d.mts" /* Dmts */:
|
|
43194
|
-
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
43234
|
+
return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined);
|
|
43195
43235
|
case ".cjs" /* Cjs */:
|
|
43196
43236
|
case ".cts" /* Cts */:
|
|
43197
43237
|
case ".d.cts" /* Dcts */:
|
|
43198
|
-
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
43238
|
+
return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined);
|
|
43199
43239
|
case ".json" /* Json */:
|
|
43200
43240
|
candidate += ".json" /* Json */;
|
|
43201
|
-
return tryExtension(".d.ts" /* Dts */);
|
|
43241
|
+
return useDts ? tryExtension(".d.ts" /* Dts */) : undefined;
|
|
43202
43242
|
default:
|
|
43203
|
-
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
43243
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined);
|
|
43204
43244
|
}
|
|
43205
43245
|
case Extensions.JavaScript:
|
|
43206
43246
|
switch (originalExtension) {
|
|
@@ -43418,6 +43458,7 @@ var ts;
|
|
|
43418
43458
|
switch (extensions) {
|
|
43419
43459
|
case Extensions.JavaScript:
|
|
43420
43460
|
case Extensions.Json:
|
|
43461
|
+
case Extensions.TypeScriptButNotDts:
|
|
43421
43462
|
packageFile = readPackageJsonMainField(jsonContent, candidate, state);
|
|
43422
43463
|
break;
|
|
43423
43464
|
case Extensions.TypeScript:
|
|
@@ -43496,6 +43537,8 @@ var ts;
|
|
|
43496
43537
|
return extension === ".json" /* Json */;
|
|
43497
43538
|
case Extensions.TypeScript:
|
|
43498
43539
|
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */;
|
|
43540
|
+
case Extensions.TypeScriptButNotDts:
|
|
43541
|
+
return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */;
|
|
43499
43542
|
case Extensions.DtsOnly:
|
|
43500
43543
|
return extension === ".d.ts" /* Dts */;
|
|
43501
43544
|
}
|
|
@@ -55112,7 +55155,7 @@ var ts;
|
|
|
55112
55155
|
if (!omitTypeAlias) {
|
|
55113
55156
|
return errorType;
|
|
55114
55157
|
}
|
|
55115
|
-
return
|
|
55158
|
+
return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
|
|
55116
55159
|
}
|
|
55117
55160
|
var members = ts.createSymbolTable();
|
|
55118
55161
|
for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
|
|
@@ -55564,7 +55607,7 @@ var ts;
|
|
|
55564
55607
|
}
|
|
55565
55608
|
}
|
|
55566
55609
|
var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217
|
|
55567
|
-
type = getUnionType(sourceTypes
|
|
55610
|
+
type = getUnionType(sourceTypes);
|
|
55568
55611
|
}
|
|
55569
55612
|
}
|
|
55570
55613
|
var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor));
|
|
@@ -56879,7 +56922,7 @@ var ts;
|
|
|
56879
56922
|
}
|
|
56880
56923
|
}
|
|
56881
56924
|
if (memberTypeList.length) {
|
|
56882
|
-
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined
|
|
56925
|
+
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
|
|
56883
56926
|
if (enumType_1.flags & 1048576 /* Union */) {
|
|
56884
56927
|
enumType_1.flags |= 1024 /* EnumLiteral */;
|
|
56885
56928
|
enumType_1.symbol = symbol;
|
|
@@ -59602,7 +59645,7 @@ var ts;
|
|
|
59602
59645
|
type.resolvedTypeArguments = source.resolvedTypeArguments;
|
|
59603
59646
|
return type;
|
|
59604
59647
|
}
|
|
59605
|
-
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments
|
|
59648
|
+
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59606
59649
|
if (!aliasSymbol) {
|
|
59607
59650
|
aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59608
59651
|
var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
|
|
@@ -59614,7 +59657,6 @@ var ts;
|
|
|
59614
59657
|
type.mapper = mapper;
|
|
59615
59658
|
type.aliasSymbol = aliasSymbol;
|
|
59616
59659
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
59617
|
-
type.aliasMapper = aliasMapper;
|
|
59618
59660
|
return type;
|
|
59619
59661
|
}
|
|
59620
59662
|
function getTypeArguments(type) {
|
|
@@ -59679,7 +59721,7 @@ var ts;
|
|
|
59679
59721
|
}
|
|
59680
59722
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59681
59723
|
}
|
|
59682
|
-
function
|
|
59724
|
+
function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
|
|
59683
59725
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59684
59726
|
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59685
59727
|
return getStringMappingType(symbol, typeArguments[0]);
|
|
@@ -59693,33 +59735,6 @@ var ts;
|
|
|
59693
59735
|
}
|
|
59694
59736
|
return instantiation;
|
|
59695
59737
|
}
|
|
59696
|
-
function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
|
|
59697
|
-
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59698
|
-
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59699
|
-
return getStringMappingType(symbol, typeArguments[0]);
|
|
59700
|
-
}
|
|
59701
|
-
var links = getSymbolLinks(symbol);
|
|
59702
|
-
var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
|
|
59703
|
-
var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
|
|
59704
|
-
var typeParameters = links.typeParameters;
|
|
59705
|
-
var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59706
|
-
var instantiation = links.instantiations.get(id);
|
|
59707
|
-
if (!instantiation) {
|
|
59708
|
-
var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
|
|
59709
|
-
var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
|
|
59710
|
-
var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
|
|
59711
|
-
links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
|
|
59712
|
-
}
|
|
59713
|
-
return instantiation;
|
|
59714
|
-
}
|
|
59715
|
-
function getOuterTypeParametersOfAlias(symbol) {
|
|
59716
|
-
var _a;
|
|
59717
|
-
var links = getSymbolLinks(symbol);
|
|
59718
|
-
if (!links.outerTypeParameters) {
|
|
59719
|
-
links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
|
|
59720
|
-
}
|
|
59721
|
-
return links.outerTypeParameters;
|
|
59722
|
-
}
|
|
59723
59738
|
/**
|
|
59724
59739
|
* Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
|
|
59725
59740
|
* references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
|
|
@@ -59755,7 +59770,7 @@ var ts;
|
|
|
59755
59770
|
// a .d.ts file. See #43622 for an example.
|
|
59756
59771
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59757
59772
|
var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
|
|
59758
|
-
return
|
|
59773
|
+
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
|
|
59759
59774
|
}
|
|
59760
59775
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59761
59776
|
}
|
|
@@ -60670,7 +60685,14 @@ var ts;
|
|
|
60670
60685
|
result.types = types;
|
|
60671
60686
|
return result;
|
|
60672
60687
|
}
|
|
60673
|
-
|
|
60688
|
+
// We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
|
|
60689
|
+
// flag is specified we also reduce the constituent type set to only include types that aren't subtypes
|
|
60690
|
+
// of other types. Subtype reduction is expensive for large union types and is possible only when union
|
|
60691
|
+
// types are known not to circularly reference themselves (as is the case with union types created by
|
|
60692
|
+
// expression constructs such as array literals and the || and ?: operators). Named types can
|
|
60693
|
+
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
|
|
60694
|
+
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
|
|
60695
|
+
function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
|
|
60674
60696
|
if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
|
|
60675
60697
|
if (types.length === 0) {
|
|
60676
60698
|
return neverType;
|
|
@@ -60739,7 +60761,7 @@ var ts;
|
|
|
60739
60761
|
}
|
|
60740
60762
|
var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
|
|
60741
60763
|
(includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
|
|
60742
|
-
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60764
|
+
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60743
60765
|
}
|
|
60744
60766
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
60745
60767
|
var first;
|
|
@@ -60777,7 +60799,7 @@ var ts;
|
|
|
60777
60799
|
return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
|
|
60778
60800
|
}
|
|
60779
60801
|
// This function assumes the constituent type list is sorted and deduplicated.
|
|
60780
|
-
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60802
|
+
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
|
|
60781
60803
|
if (types.length === 0) {
|
|
60782
60804
|
return neverType;
|
|
60783
60805
|
}
|
|
@@ -60797,7 +60819,6 @@ var ts;
|
|
|
60797
60819
|
type.origin = origin;
|
|
60798
60820
|
type.aliasSymbol = aliasSymbol;
|
|
60799
60821
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60800
|
-
type.aliasMapper = aliasMapper;
|
|
60801
60822
|
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
60802
60823
|
type.flags |= 16 /* Boolean */;
|
|
60803
60824
|
type.intrinsicName = "boolean";
|
|
@@ -60810,7 +60831,7 @@ var ts;
|
|
|
60810
60831
|
var links = getNodeLinks(node);
|
|
60811
60832
|
if (!links.resolvedType) {
|
|
60812
60833
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
60813
|
-
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
60834
|
+
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60814
60835
|
}
|
|
60815
60836
|
return links.resolvedType;
|
|
60816
60837
|
}
|
|
@@ -60969,16 +60990,25 @@ var ts;
|
|
|
60969
60990
|
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
|
|
60970
60991
|
return true;
|
|
60971
60992
|
}
|
|
60972
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments
|
|
60993
|
+
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60973
60994
|
var result = createType(2097152 /* Intersection */);
|
|
60974
60995
|
result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
|
|
60975
60996
|
result.types = types;
|
|
60976
60997
|
result.aliasSymbol = aliasSymbol;
|
|
60977
60998
|
result.aliasTypeArguments = aliasTypeArguments;
|
|
60978
|
-
result.aliasMapper = aliasMapper;
|
|
60979
60999
|
return result;
|
|
60980
61000
|
}
|
|
60981
|
-
|
|
61001
|
+
// We normalize combinations of intersection and union types based on the distributive property of the '&'
|
|
61002
|
+
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
|
|
61003
|
+
// types with union type constituents into equivalent union types with intersection type constituents and
|
|
61004
|
+
// effectively ensure that union types are always at the top level in type representations.
|
|
61005
|
+
//
|
|
61006
|
+
// We do not perform structural deduplication on intersection types. Intersection types are created only by the &
|
|
61007
|
+
// type operator and we can't reduce those because we want to support recursive intersection types. For example,
|
|
61008
|
+
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
61009
|
+
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
61010
|
+
// for intersections of types with signatures can be deterministic.
|
|
61011
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60982
61012
|
var typeMembershipMap = new ts.Map();
|
|
60983
61013
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
60984
61014
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -61038,16 +61068,16 @@ var ts;
|
|
|
61038
61068
|
// When the intersection creates a reduced set (which might mean that *all* union types have
|
|
61039
61069
|
// disappeared), we restart the operation to get a new set of combined flags. Once we have
|
|
61040
61070
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
61041
|
-
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments
|
|
61071
|
+
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
61042
61072
|
}
|
|
61043
61073
|
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
61044
61074
|
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
61045
61075
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
61046
|
-
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61076
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61047
61077
|
}
|
|
61048
61078
|
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
61049
61079
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
61050
|
-
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61080
|
+
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61051
61081
|
}
|
|
61052
61082
|
else {
|
|
61053
61083
|
// We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
|
|
@@ -61060,7 +61090,7 @@ var ts;
|
|
|
61060
61090
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
61061
61091
|
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
|
|
61062
61092
|
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61063
|
-
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments,
|
|
61093
|
+
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61064
61094
|
}
|
|
61065
61095
|
}
|
|
61066
61096
|
else {
|
|
@@ -61106,7 +61136,7 @@ var ts;
|
|
|
61106
61136
|
var links = getNodeLinks(node);
|
|
61107
61137
|
if (!links.resolvedType) {
|
|
61108
61138
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61109
|
-
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
61139
|
+
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
61110
61140
|
}
|
|
61111
61141
|
return links.resolvedType;
|
|
61112
61142
|
}
|
|
@@ -61225,7 +61255,7 @@ var ts;
|
|
|
61225
61255
|
var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
|
|
61226
61256
|
info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
|
|
61227
61257
|
return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
|
|
61228
|
-
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
61258
|
+
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
|
|
61229
61259
|
}
|
|
61230
61260
|
/**
|
|
61231
61261
|
* A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
|
|
@@ -61258,7 +61288,7 @@ var ts;
|
|
|
61258
61288
|
return type;
|
|
61259
61289
|
}
|
|
61260
61290
|
var extractTypeAlias = getGlobalExtractSymbol();
|
|
61261
|
-
return extractTypeAlias ?
|
|
61291
|
+
return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
|
|
61262
61292
|
}
|
|
61263
61293
|
function getIndexTypeOrString(type) {
|
|
61264
61294
|
var indexType = getExtractStringType(getIndexType(type));
|
|
@@ -61388,14 +61418,13 @@ var ts;
|
|
|
61388
61418
|
result.type = type;
|
|
61389
61419
|
return result;
|
|
61390
61420
|
}
|
|
61391
|
-
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments
|
|
61421
|
+
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
|
|
61392
61422
|
var type = createType(8388608 /* IndexedAccess */);
|
|
61393
61423
|
type.objectType = objectType;
|
|
61394
61424
|
type.indexType = indexType;
|
|
61395
61425
|
type.accessFlags = accessFlags;
|
|
61396
61426
|
type.aliasSymbol = aliasSymbol;
|
|
61397
61427
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
61398
|
-
type.aliasMapper = aliasMapper;
|
|
61399
61428
|
return type;
|
|
61400
61429
|
}
|
|
61401
61430
|
/**
|
|
@@ -61753,9 +61782,9 @@ var ts;
|
|
|
61753
61782
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
61754
61783
|
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
61755
61784
|
}
|
|
61756
|
-
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61785
|
+
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61757
61786
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61758
|
-
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61787
|
+
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61759
61788
|
}
|
|
61760
61789
|
function indexTypeLessThan(indexType, limit) {
|
|
61761
61790
|
return everyType(indexType, function (t) {
|
|
@@ -61769,7 +61798,7 @@ var ts;
|
|
|
61769
61798
|
return false;
|
|
61770
61799
|
});
|
|
61771
61800
|
}
|
|
61772
|
-
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61801
|
+
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61773
61802
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61774
61803
|
if (objectType === wildcardType || indexType === wildcardType) {
|
|
61775
61804
|
return wildcardType;
|
|
@@ -61800,7 +61829,7 @@ var ts;
|
|
|
61800
61829
|
var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
61801
61830
|
var type = indexedAccessTypes.get(id);
|
|
61802
61831
|
if (!type) {
|
|
61803
|
-
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments
|
|
61832
|
+
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
|
|
61804
61833
|
}
|
|
61805
61834
|
return type;
|
|
61806
61835
|
}
|
|
@@ -61830,8 +61859,8 @@ var ts;
|
|
|
61830
61859
|
return undefined;
|
|
61831
61860
|
}
|
|
61832
61861
|
return accessFlags & 4 /* Writing */
|
|
61833
|
-
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments
|
|
61834
|
-
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61862
|
+
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
|
|
61863
|
+
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61835
61864
|
}
|
|
61836
61865
|
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
|
|
61837
61866
|
}
|
|
@@ -61841,7 +61870,7 @@ var ts;
|
|
|
61841
61870
|
var objectType = getTypeFromTypeNode(node.objectType);
|
|
61842
61871
|
var indexType = getTypeFromTypeNode(node.indexType);
|
|
61843
61872
|
var potentialAlias = getAliasSymbolForTypeNode(node);
|
|
61844
|
-
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)
|
|
61873
|
+
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
|
|
61845
61874
|
links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
|
|
61846
61875
|
resolved.objectType === objectType &&
|
|
61847
61876
|
resolved.indexType === indexType ?
|
|
@@ -62008,7 +62037,6 @@ var ts;
|
|
|
62008
62037
|
result.combinedMapper = combinedMapper;
|
|
62009
62038
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
62010
62039
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
62011
|
-
result.aliasMapper = result.aliasSymbol ? mapper : undefined;
|
|
62012
62040
|
return "break";
|
|
62013
62041
|
};
|
|
62014
62042
|
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
@@ -62804,7 +62832,7 @@ var ts;
|
|
|
62804
62832
|
var result = target.instantiations.get(id);
|
|
62805
62833
|
if (!result) {
|
|
62806
62834
|
var newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62807
|
-
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments
|
|
62835
|
+
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62808
62836
|
target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62809
62837
|
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62810
62838
|
target.instantiations.set(id, result);
|
|
@@ -62893,7 +62921,7 @@ var ts;
|
|
|
62893
62921
|
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
62894
62922
|
}
|
|
62895
62923
|
return t;
|
|
62896
|
-
}, aliasSymbol, aliasTypeArguments
|
|
62924
|
+
}, aliasSymbol, aliasTypeArguments);
|
|
62897
62925
|
}
|
|
62898
62926
|
}
|
|
62899
62927
|
// If the constraint type of the instantiation is the wildcard type, return the wildcard type.
|
|
@@ -62962,7 +62990,6 @@ var ts;
|
|
|
62962
62990
|
result.mapper = mapper;
|
|
62963
62991
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
62964
62992
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
62965
|
-
result.aliasMapper = mapper;
|
|
62966
62993
|
return result;
|
|
62967
62994
|
}
|
|
62968
62995
|
function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
@@ -62982,7 +63009,7 @@ var ts;
|
|
|
62982
63009
|
// distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
|
|
62983
63010
|
// result is (A extends U ? X : Y) | (B extends U ? X : Y).
|
|
62984
63011
|
result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
|
|
62985
|
-
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments
|
|
63012
|
+
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
|
|
62986
63013
|
getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
|
|
62987
63014
|
root.instantiations.set(id, result);
|
|
62988
63015
|
}
|
|
@@ -63042,8 +63069,8 @@ var ts;
|
|
|
63042
63069
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
63043
63070
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
63044
63071
|
return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
|
|
63045
|
-
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments
|
|
63046
|
-
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments
|
|
63072
|
+
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
|
|
63073
|
+
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
|
|
63047
63074
|
}
|
|
63048
63075
|
if (flags & 4194304 /* Index */) {
|
|
63049
63076
|
return getIndexType(instantiateType(type.type, mapper));
|
|
@@ -63057,7 +63084,7 @@ var ts;
|
|
|
63057
63084
|
if (flags & 8388608 /* IndexedAccess */) {
|
|
63058
63085
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
63059
63086
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
63060
|
-
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments
|
|
63087
|
+
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
|
|
63061
63088
|
}
|
|
63062
63089
|
if (flags & 16777216 /* Conditional */) {
|
|
63063
63090
|
return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
|
|
@@ -65051,10 +65078,7 @@ var ts;
|
|
|
65051
65078
|
if (variances === ts.emptyArray) {
|
|
65052
65079
|
return 1 /* Unknown */;
|
|
65053
65080
|
}
|
|
65054
|
-
var
|
|
65055
|
-
var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
|
|
65056
|
-
var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
|
|
65057
|
-
var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
|
|
65081
|
+
var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
|
|
65058
65082
|
if (varianceResult !== undefined) {
|
|
65059
65083
|
return varianceResult;
|
|
65060
65084
|
}
|
|
@@ -66343,11 +66367,8 @@ var ts;
|
|
|
66343
66367
|
}
|
|
66344
66368
|
function getAliasVariances(symbol) {
|
|
66345
66369
|
var links = getSymbolLinks(symbol);
|
|
66346
|
-
|
|
66347
|
-
|
|
66348
|
-
return getVariancesWorker(params, links, function (_links, param, marker) {
|
|
66349
|
-
var mapper = makeUnaryTypeMapper(param, marker);
|
|
66350
|
-
var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
|
|
66370
|
+
return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
|
|
66371
|
+
var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
|
|
66351
66372
|
type.aliasTypeArgumentsContainsMarker = true;
|
|
66352
66373
|
return type;
|
|
66353
66374
|
});
|
|
@@ -67004,7 +67025,7 @@ var ts;
|
|
|
67004
67025
|
}
|
|
67005
67026
|
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
67006
67027
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
67007
|
-
|
|
67028
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
|
|
67008
67029
|
reducedType;
|
|
67009
67030
|
}
|
|
67010
67031
|
function getNonNullableType(type) {
|
|
@@ -69230,7 +69251,7 @@ var ts;
|
|
|
69230
69251
|
newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
|
|
69231
69252
|
}
|
|
69232
69253
|
}
|
|
69233
|
-
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
69254
|
+
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
|
|
69234
69255
|
}
|
|
69235
69256
|
return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
|
|
69236
69257
|
}
|
|
@@ -69266,9 +69287,9 @@ var ts;
|
|
|
69266
69287
|
}
|
|
69267
69288
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
69268
69289
|
}
|
|
69269
|
-
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments
|
|
69290
|
+
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
69270
69291
|
return type.flags & 1048576 /* Union */ && aliasSymbol ?
|
|
69271
|
-
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
69292
|
+
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
69272
69293
|
mapType(type, mapper);
|
|
69273
69294
|
}
|
|
69274
69295
|
function extractTypesOfKind(type, kind) {
|
|
@@ -72453,7 +72474,7 @@ var ts;
|
|
|
72453
72474
|
var params = getSymbolLinks(managedSym).typeParameters;
|
|
72454
72475
|
if (ts.length(params) >= 2) {
|
|
72455
72476
|
var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
|
|
72456
|
-
return
|
|
72477
|
+
return getTypeAliasInstantiation(managedSym, args);
|
|
72457
72478
|
}
|
|
72458
72479
|
}
|
|
72459
72480
|
if (ts.length(declaredManagedType.typeParameters) >= 2) {
|
|
@@ -80597,7 +80618,7 @@ var ts;
|
|
|
80597
80618
|
if (awaitedSymbol) {
|
|
80598
80619
|
// Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
|
|
80599
80620
|
// an `Awaited<T | U>` would suffice.
|
|
80600
|
-
return
|
|
80621
|
+
return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
|
|
80601
80622
|
}
|
|
80602
80623
|
}
|
|
80603
80624
|
}
|
|
@@ -127648,6 +127669,20 @@ var ts;
|
|
|
127648
127669
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127649
127670
|
}
|
|
127650
127671
|
ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName;
|
|
127672
|
+
/**
|
|
127673
|
+
* Returns true if `node` is the declaration of `n` in:
|
|
127674
|
+
* - `import n from "m"`
|
|
127675
|
+
* - `import * as n from "m"`
|
|
127676
|
+
* - `import n = require("m")`
|
|
127677
|
+
* - `const n = require("m")`
|
|
127678
|
+
*/
|
|
127679
|
+
function isFreelyNameableImport(node) {
|
|
127680
|
+
return node.kind === 266 /* ImportClause */
|
|
127681
|
+
|| node.kind === 267 /* NamespaceImport */
|
|
127682
|
+
|| ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
|
|
127683
|
+
|| ts.isVariableDeclarationInitializedToRequire(node);
|
|
127684
|
+
}
|
|
127685
|
+
ts.isFreelyNameableImport = isFreelyNameableImport;
|
|
127651
127686
|
function getScriptKind(fileName, host) {
|
|
127652
127687
|
// First check to see if the script kind was specified by the host. Chances are the host
|
|
127653
127688
|
// may override the default script kind for the file extension.
|
|
@@ -130941,14 +130976,15 @@ var ts;
|
|
|
130941
130976
|
SortText["SuggestedClassMembers"] = "14";
|
|
130942
130977
|
SortText["GlobalsOrKeywords"] = "15";
|
|
130943
130978
|
SortText["AutoImportSuggestions"] = "16";
|
|
130944
|
-
SortText["
|
|
130945
|
-
SortText["
|
|
130946
|
-
SortText["
|
|
130947
|
-
SortText["
|
|
130948
|
-
SortText["
|
|
130949
|
-
SortText["
|
|
130950
|
-
SortText["
|
|
130951
|
-
SortText["
|
|
130979
|
+
SortText["ClassMemberSnippets"] = "17";
|
|
130980
|
+
SortText["JavascriptIdentifiers"] = "18";
|
|
130981
|
+
SortText["DeprecatedLocalDeclarationPriority"] = "19";
|
|
130982
|
+
SortText["DeprecatedLocationPriority"] = "20";
|
|
130983
|
+
SortText["DeprecatedOptionalMember"] = "21";
|
|
130984
|
+
SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
|
|
130985
|
+
SortText["DeprecatedSuggestedClassMembers"] = "23";
|
|
130986
|
+
SortText["DeprecatedGlobalsOrKeywords"] = "24";
|
|
130987
|
+
SortText["DeprecatedAutoImportSuggestions"] = "25";
|
|
130952
130988
|
})(SortText = Completions.SortText || (Completions.SortText = {}));
|
|
130953
130989
|
var SortTextId;
|
|
130954
130990
|
(function (SortTextId) {
|
|
@@ -130960,10 +130996,10 @@ var ts;
|
|
|
130960
130996
|
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130961
130997
|
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130962
130998
|
// Don't use these directly.
|
|
130963
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] =
|
|
130964
|
-
SortTextId[SortTextId["_DeprecatedStart"] =
|
|
130999
|
+
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
131000
|
+
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130965
131001
|
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130966
|
-
SortTextId[SortTextId["DeprecatedOffset"] =
|
|
131002
|
+
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130967
131003
|
})(SortTextId || (SortTextId = {}));
|
|
130968
131004
|
/**
|
|
130969
131005
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
@@ -131444,6 +131480,7 @@ var ts;
|
|
|
131444
131480
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131445
131481
|
var importAdder = void 0;
|
|
131446
131482
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
131483
|
+
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131447
131484
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131448
131485
|
hasAction = true;
|
|
131449
131486
|
source = CompletionSource.ClassMemberSnippet;
|
|
@@ -131807,7 +131844,7 @@ var ts;
|
|
|
131807
131844
|
}
|
|
131808
131845
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131809
131846
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
131810
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131847
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
131811
131848
|
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
131812
131849
|
if (!entry) {
|
|
131813
131850
|
continue;
|
|
@@ -136662,6 +136699,29 @@ var ts;
|
|
|
136662
136699
|
}
|
|
136663
136700
|
}
|
|
136664
136701
|
Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile;
|
|
136702
|
+
function getTopMostDeclarationNamesInFile(declarationName, sourceFile) {
|
|
136703
|
+
var candidates = ts.filter(getPossibleSymbolReferenceNodes(sourceFile, declarationName), function (name) { return !!ts.getDeclarationFromName(name); });
|
|
136704
|
+
return candidates.reduce(function (topMost, decl) {
|
|
136705
|
+
var depth = getDepth(decl);
|
|
136706
|
+
if (!ts.some(topMost.declarationNames) || depth === topMost.depth) {
|
|
136707
|
+
topMost.declarationNames.push(decl);
|
|
136708
|
+
}
|
|
136709
|
+
else if (depth < topMost.depth) {
|
|
136710
|
+
topMost.declarationNames = [decl];
|
|
136711
|
+
}
|
|
136712
|
+
topMost.depth = depth;
|
|
136713
|
+
return topMost;
|
|
136714
|
+
}, { depth: Infinity, declarationNames: [] }).declarationNames;
|
|
136715
|
+
function getDepth(declaration) {
|
|
136716
|
+
var depth = 0;
|
|
136717
|
+
while (declaration) {
|
|
136718
|
+
declaration = ts.getContainerNode(declaration);
|
|
136719
|
+
depth++;
|
|
136720
|
+
}
|
|
136721
|
+
return depth;
|
|
136722
|
+
}
|
|
136723
|
+
}
|
|
136724
|
+
Core.getTopMostDeclarationNamesInFile = getTopMostDeclarationNamesInFile;
|
|
136665
136725
|
function someSignatureUsage(signature, sourceFiles, checker, cb) {
|
|
136666
136726
|
if (!signature.name || !ts.isIdentifier(signature.name))
|
|
136667
136727
|
return false;
|
|
@@ -138294,7 +138354,9 @@ var ts;
|
|
|
138294
138354
|
(function (ts) {
|
|
138295
138355
|
var GoToDefinition;
|
|
138296
138356
|
(function (GoToDefinition) {
|
|
138297
|
-
function getDefinitionAtPosition(program, sourceFile, position) {
|
|
138357
|
+
function getDefinitionAtPosition(program, sourceFile, position, aliasesOnly) {
|
|
138358
|
+
var _a;
|
|
138359
|
+
var _b;
|
|
138298
138360
|
var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
|
|
138299
138361
|
var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
|
|
138300
138362
|
if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
|
|
@@ -138317,33 +138379,63 @@ var ts;
|
|
|
138317
138379
|
}
|
|
138318
138380
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
138319
138381
|
var classDecl = node.parent.parent;
|
|
138320
|
-
var
|
|
138382
|
+
var _c = getSymbol(classDecl, typeChecker), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
138321
138383
|
var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
|
|
138322
138384
|
var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
|
|
138323
138385
|
var sourceFile_1 = node.getSourceFile();
|
|
138324
138386
|
return ts.map(staticBlocks, function (staticBlock) {
|
|
138325
138387
|
var pos = ts.moveRangePastModifiers(staticBlock).pos;
|
|
138326
138388
|
pos = ts.skipTrivia(sourceFile_1.text, pos);
|
|
138327
|
-
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, { start: pos, length: "static".length });
|
|
138389
|
+
return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, failedAliasResolution_1, { start: pos, length: "static".length });
|
|
138328
138390
|
});
|
|
138329
138391
|
}
|
|
138330
|
-
var
|
|
138392
|
+
var _d = getSymbol(node, typeChecker), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
|
|
138393
|
+
var fallbackNode = node;
|
|
138394
|
+
if (aliasesOnly && failedAliasResolution) {
|
|
138395
|
+
// We couldn't resolve the specific import, try on the module specifier.
|
|
138396
|
+
var importDeclaration = ts.findAncestor(node, ts.isAnyImportOrBareOrAccessedRequire);
|
|
138397
|
+
var moduleSpecifier = importDeclaration && ts.tryGetModuleSpecifierFromDeclaration(importDeclaration);
|
|
138398
|
+
if (moduleSpecifier) {
|
|
138399
|
+
(_a = getSymbol(moduleSpecifier, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution);
|
|
138400
|
+
fallbackNode = moduleSpecifier;
|
|
138401
|
+
}
|
|
138402
|
+
}
|
|
138403
|
+
if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
|
|
138404
|
+
// We couldn't resolve the module specifier as an external module, but it could
|
|
138405
|
+
// be that module resolution succeeded but the target was not a module.
|
|
138406
|
+
var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
|
|
138407
|
+
if (ref) {
|
|
138408
|
+
return [{
|
|
138409
|
+
name: fallbackNode.text,
|
|
138410
|
+
fileName: ref.resolvedFileName,
|
|
138411
|
+
containerName: undefined,
|
|
138412
|
+
containerKind: undefined,
|
|
138413
|
+
kind: "script" /* scriptElement */,
|
|
138414
|
+
textSpan: ts.createTextSpan(0, 0),
|
|
138415
|
+
failedAliasResolution: failedAliasResolution,
|
|
138416
|
+
isAmbient: ts.isDeclarationFileName(ref.resolvedFileName),
|
|
138417
|
+
unverified: fallbackNode !== node,
|
|
138418
|
+
}];
|
|
138419
|
+
}
|
|
138420
|
+
}
|
|
138331
138421
|
// Could not find a symbol e.g. node is string or number keyword,
|
|
138332
138422
|
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
|
138333
138423
|
if (!symbol) {
|
|
138334
138424
|
return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker));
|
|
138335
138425
|
}
|
|
138426
|
+
if (aliasesOnly && ts.every(symbol.declarations, function (d) { return d.getSourceFile().fileName === sourceFile.fileName; }))
|
|
138427
|
+
return undefined;
|
|
138336
138428
|
var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
|
138337
138429
|
// Don't go to the component constructor definition for a JSX element, just go to the component definition.
|
|
138338
138430
|
if (calledDeclaration && !(ts.isJsxOpeningLikeElement(node.parent) && isConstructorLike(calledDeclaration))) {
|
|
138339
|
-
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration);
|
|
138431
|
+
var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration, failedAliasResolution);
|
|
138340
138432
|
// For a function, if this is the original function definition, return just sigInfo.
|
|
138341
138433
|
// If this is the original constructor definition, parent is the class.
|
|
138342
138434
|
if (typeChecker.getRootSymbols(symbol).some(function (s) { return symbolMatchesSignature(s, calledDeclaration); })) {
|
|
138343
138435
|
return [sigInfo];
|
|
138344
138436
|
}
|
|
138345
138437
|
else {
|
|
138346
|
-
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray;
|
|
138438
|
+
var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray;
|
|
138347
138439
|
// For a 'super()' call, put the signature first, else put the variable first.
|
|
138348
138440
|
return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false);
|
|
138349
138441
|
}
|
|
@@ -138355,7 +138447,7 @@ var ts;
|
|
|
138355
138447
|
// assignment. This case and others are handled by the following code.
|
|
138356
138448
|
if (node.parent.kind === 296 /* ShorthandPropertyAssignment */) {
|
|
138357
138449
|
var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
|
138358
|
-
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;
|
|
138450
|
+
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, failedAliasResolution); }) : ts.emptyArray;
|
|
138359
138451
|
return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray);
|
|
138360
138452
|
}
|
|
138361
138453
|
// If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the
|
|
@@ -138378,7 +138470,7 @@ var ts;
|
|
|
138378
138470
|
return prop && getDefinitionFromSymbol(typeChecker, prop, node);
|
|
138379
138471
|
});
|
|
138380
138472
|
}
|
|
138381
|
-
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node));
|
|
138473
|
+
return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution));
|
|
138382
138474
|
}
|
|
138383
138475
|
GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
138384
138476
|
/**
|
|
@@ -138476,24 +138568,24 @@ var ts;
|
|
|
138476
138568
|
return undefined;
|
|
138477
138569
|
}
|
|
138478
138570
|
if (ts.isImportMeta(node.parent) && node.parent.name === node) {
|
|
138479
|
-
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
|
138571
|
+
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
|
|
138480
138572
|
}
|
|
138481
|
-
var
|
|
138573
|
+
var _a = getSymbol(node, typeChecker), symbol = _a.symbol, failedAliasResolution = _a.failedAliasResolution;
|
|
138482
138574
|
if (!symbol)
|
|
138483
138575
|
return undefined;
|
|
138484
138576
|
var typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
138485
138577
|
var returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
138486
|
-
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node);
|
|
138578
|
+
var fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
138487
138579
|
// If a function returns 'void' or some other type with no definition, just return the function definition.
|
|
138488
|
-
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node);
|
|
138580
|
+
var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
138489
138581
|
return typeDefinitions.length ? typeDefinitions
|
|
138490
|
-
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node)
|
|
138582
|
+
: !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution)
|
|
138491
138583
|
: undefined;
|
|
138492
138584
|
}
|
|
138493
138585
|
GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
138494
|
-
function definitionFromType(type, checker, node) {
|
|
138586
|
+
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
138495
138587
|
return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) {
|
|
138496
|
-
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node);
|
|
138588
|
+
return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution);
|
|
138497
138589
|
});
|
|
138498
138590
|
}
|
|
138499
138591
|
function tryGetReturnTypeOfFunction(symbol, type, checker) {
|
|
@@ -138508,8 +138600,8 @@ var ts;
|
|
|
138508
138600
|
}
|
|
138509
138601
|
return undefined;
|
|
138510
138602
|
}
|
|
138511
|
-
function getDefinitionAndBoundSpan(program, sourceFile, position) {
|
|
138512
|
-
var definitions = getDefinitionAtPosition(program, sourceFile, position);
|
|
138603
|
+
function getDefinitionAndBoundSpan(program, sourceFile, position, aliasesOnly) {
|
|
138604
|
+
var definitions = getDefinitionAtPosition(program, sourceFile, position, aliasesOnly);
|
|
138513
138605
|
if (!definitions || definitions.length === 0) {
|
|
138514
138606
|
return undefined;
|
|
138515
138607
|
}
|
|
@@ -138535,13 +138627,17 @@ var ts;
|
|
|
138535
138627
|
// get the aliased symbol instead. This allows for goto def on an import e.g.
|
|
138536
138628
|
// import {A, B} from "mod";
|
|
138537
138629
|
// to jump to the implementation directly.
|
|
138630
|
+
var failedAliasResolution = false;
|
|
138538
138631
|
if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) {
|
|
138539
138632
|
var aliased = checker.getAliasedSymbol(symbol);
|
|
138540
138633
|
if (aliased.declarations) {
|
|
138541
|
-
return aliased;
|
|
138634
|
+
return { symbol: aliased };
|
|
138635
|
+
}
|
|
138636
|
+
else {
|
|
138637
|
+
failedAliasResolution = true;
|
|
138542
138638
|
}
|
|
138543
138639
|
}
|
|
138544
|
-
return symbol;
|
|
138640
|
+
return { symbol: symbol, failedAliasResolution: failedAliasResolution };
|
|
138545
138641
|
}
|
|
138546
138642
|
// Go to the original declaration for cases:
|
|
138547
138643
|
//
|
|
@@ -138555,26 +138651,45 @@ var ts;
|
|
|
138555
138651
|
if (node.parent === declaration) {
|
|
138556
138652
|
return true;
|
|
138557
138653
|
}
|
|
138558
|
-
|
|
138559
|
-
|
|
138560
|
-
case 264 /* ImportEqualsDeclaration */:
|
|
138561
|
-
return true;
|
|
138562
|
-
case 269 /* ImportSpecifier */:
|
|
138563
|
-
return declaration.parent.kind === 268 /* NamedImports */;
|
|
138564
|
-
case 202 /* BindingElement */:
|
|
138565
|
-
case 253 /* VariableDeclaration */:
|
|
138566
|
-
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
138567
|
-
default:
|
|
138568
|
-
return false;
|
|
138654
|
+
if (declaration.kind === 267 /* NamespaceImport */) {
|
|
138655
|
+
return false;
|
|
138569
138656
|
}
|
|
138657
|
+
return true;
|
|
138570
138658
|
}
|
|
138571
|
-
|
|
138572
|
-
|
|
138573
|
-
|
|
138574
|
-
|
|
138575
|
-
|
|
138576
|
-
|
|
138577
|
-
|
|
138659
|
+
/**
|
|
138660
|
+
* ```ts
|
|
138661
|
+
* function f() {}
|
|
138662
|
+
* f.foo = 0;
|
|
138663
|
+
* ```
|
|
138664
|
+
*
|
|
138665
|
+
* Here, `f` has two declarations: the function declaration, and the identifier in the next line.
|
|
138666
|
+
* The latter is a declaration for `f` because it gives `f` the `SymbolFlags.Namespace` meaning so
|
|
138667
|
+
* it can contain `foo`. However, that declaration is pretty uninteresting and not intuitively a
|
|
138668
|
+
* "definition" for `f`. Ideally, the question we'd like to answer is "what SymbolFlags does this
|
|
138669
|
+
* declaration contribute to the symbol for `f`?" If the answer is just `Namespace` and the
|
|
138670
|
+
* declaration looks like an assignment, that declaration is in no sense a definition for `f`.
|
|
138671
|
+
* But that information is totally lost during binding and/or symbol merging, so we need to do
|
|
138672
|
+
* our best to reconstruct it or use other heuristics. This function (and the logic around its
|
|
138673
|
+
* calling) covers our tests but feels like a hack, and it would be great if someone could come
|
|
138674
|
+
* up with a more precise definition of what counts as a definition.
|
|
138675
|
+
*/
|
|
138676
|
+
function isExpandoDeclaration(node) {
|
|
138677
|
+
if (!ts.isAssignmentDeclaration(node))
|
|
138678
|
+
return false;
|
|
138679
|
+
var containingAssignment = ts.findAncestor(node, function (p) {
|
|
138680
|
+
if (ts.isAssignmentExpression(p))
|
|
138681
|
+
return true;
|
|
138682
|
+
if (!ts.isAssignmentDeclaration(p))
|
|
138683
|
+
return "quit";
|
|
138684
|
+
return false;
|
|
138685
|
+
});
|
|
138686
|
+
return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */;
|
|
138687
|
+
}
|
|
138688
|
+
function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) {
|
|
138689
|
+
var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; });
|
|
138690
|
+
var withoutExpandos = ts.filter(filteredDeclarations, function (d) { return !isExpandoDeclaration(d); });
|
|
138691
|
+
var results = ts.some(withoutExpandos) ? withoutExpandos : filteredDeclarations;
|
|
138692
|
+
return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(results, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node, failedAliasResolution); });
|
|
138578
138693
|
function getConstructSignatureDefinition() {
|
|
138579
138694
|
// Applicable only if we are in a new expression, or we are on a constructor declaration
|
|
138580
138695
|
// and in either case the symbol has a construct signature definition, i.e. class
|
|
@@ -138598,26 +138713,27 @@ var ts;
|
|
|
138598
138713
|
return declarations.length
|
|
138599
138714
|
? declarationsWithBody.length !== 0
|
|
138600
138715
|
? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); })
|
|
138601
|
-
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)]
|
|
138716
|
+
: [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node, failedAliasResolution)]
|
|
138602
138717
|
: undefined;
|
|
138603
138718
|
}
|
|
138604
138719
|
}
|
|
138605
138720
|
/** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */
|
|
138606
|
-
function createDefinitionInfo(declaration, checker, symbol, node) {
|
|
138721
|
+
function createDefinitionInfo(declaration, checker, symbol, node, failedAliasResolution) {
|
|
138607
138722
|
var symbolName = checker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
|
138608
138723
|
var symbolKind = ts.SymbolDisplay.getSymbolKind(checker, symbol, node);
|
|
138609
138724
|
var containerName = symbol.parent ? checker.symbolToString(symbol.parent, node) : "";
|
|
138610
|
-
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName);
|
|
138725
|
+
return createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution);
|
|
138611
138726
|
}
|
|
138727
|
+
GoToDefinition.createDefinitionInfo = createDefinitionInfo;
|
|
138612
138728
|
/** Creates a DefinitionInfo directly from the name of a declaration. */
|
|
138613
|
-
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, textSpan) {
|
|
138729
|
+
function createDefinitionInfoFromName(checker, declaration, symbolKind, symbolName, containerName, failedAliasResolution, textSpan) {
|
|
138614
138730
|
var sourceFile = declaration.getSourceFile();
|
|
138615
138731
|
if (!textSpan) {
|
|
138616
138732
|
var name = ts.getNameOfDeclaration(declaration) || declaration;
|
|
138617
138733
|
textSpan = ts.createTextSpanFromNode(name, sourceFile);
|
|
138618
138734
|
}
|
|
138619
138735
|
return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217
|
|
138620
|
-
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) });
|
|
138736
|
+
containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 8388608 /* Ambient */), failedAliasResolution: failedAliasResolution });
|
|
138621
138737
|
}
|
|
138622
138738
|
function isDefinitionVisible(checker, declaration) {
|
|
138623
138739
|
if (checker.isDeclarationVisible(declaration))
|
|
@@ -138650,8 +138766,8 @@ var ts;
|
|
|
138650
138766
|
return false;
|
|
138651
138767
|
}
|
|
138652
138768
|
}
|
|
138653
|
-
function createDefinitionFromSignatureDeclaration(typeChecker, decl) {
|
|
138654
|
-
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl);
|
|
138769
|
+
function createDefinitionFromSignatureDeclaration(typeChecker, decl, failedAliasResolution) {
|
|
138770
|
+
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, failedAliasResolution);
|
|
138655
138771
|
}
|
|
138656
138772
|
function findReferenceInPosition(refs, pos) {
|
|
138657
138773
|
return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); });
|
|
@@ -151699,9 +151815,10 @@ var ts;
|
|
|
151699
151815
|
// 2. add "member3" to the second import statement's import list
|
|
151700
151816
|
// and it is up to the user to decide which one fits best.
|
|
151701
151817
|
return ts.firstDefined(existingImports, function (_a) {
|
|
151818
|
+
var _b;
|
|
151702
151819
|
var declaration = _a.declaration;
|
|
151703
151820
|
var namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
151704
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
151821
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151705
151822
|
if (namespacePrefix && moduleSpecifier) {
|
|
151706
151823
|
var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
151707
151824
|
if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) {
|
|
@@ -151877,8 +151994,9 @@ var ts;
|
|
|
151877
151994
|
return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
|
|
151878
151995
|
}
|
|
151879
151996
|
function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
|
|
151997
|
+
var _b;
|
|
151880
151998
|
var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags;
|
|
151881
|
-
var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration);
|
|
151999
|
+
var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text;
|
|
151882
152000
|
if (moduleSpecifier) {
|
|
151883
152001
|
var addAsTypeOnly = useRequire
|
|
151884
152002
|
? 4 /* NotAllowed */
|
|
@@ -163687,9 +163805,9 @@ var ts;
|
|
|
163687
163805
|
synchronizeHostData();
|
|
163688
163806
|
return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position);
|
|
163689
163807
|
}
|
|
163690
|
-
function getDefinitionAndBoundSpan(fileName, position) {
|
|
163808
|
+
function getDefinitionAndBoundSpan(fileName, position, aliasesOnly) {
|
|
163691
163809
|
synchronizeHostData();
|
|
163692
|
-
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position);
|
|
163810
|
+
return ts.GoToDefinition.getDefinitionAndBoundSpan(program, getValidSourceFile(fileName), position, aliasesOnly);
|
|
163693
163811
|
}
|
|
163694
163812
|
function getTypeDefinitionAtPosition(fileName, position) {
|
|
163695
163813
|
synchronizeHostData();
|
|
@@ -166441,6 +166559,9 @@ var ts;
|
|
|
166441
166559
|
CommandTypes["SignatureHelp"] = "signatureHelp";
|
|
166442
166560
|
/* @internal */
|
|
166443
166561
|
CommandTypes["SignatureHelpFull"] = "signatureHelp-full";
|
|
166562
|
+
CommandTypes["SourceDefinitionAndBoundSpan"] = "sourceDefinitionAndBoundSpan";
|
|
166563
|
+
/* @internal */
|
|
166564
|
+
CommandTypes["SourceDefinitionAndBoundSpanFull"] = "sourceDefinitionAndBoundSpan-full";
|
|
166444
166565
|
CommandTypes["Status"] = "status";
|
|
166445
166566
|
CommandTypes["TypeDefinition"] = "typeDefinition";
|
|
166446
166567
|
CommandTypes["ProjectInfo"] = "projectInfo";
|
|
@@ -167310,6 +167431,7 @@ var ts;
|
|
|
167310
167431
|
ProjectKind[ProjectKind["Configured"] = 1] = "Configured";
|
|
167311
167432
|
ProjectKind[ProjectKind["External"] = 2] = "External";
|
|
167312
167433
|
ProjectKind[ProjectKind["AutoImportProvider"] = 3] = "AutoImportProvider";
|
|
167434
|
+
ProjectKind[ProjectKind["Auxiliary"] = 4] = "Auxiliary";
|
|
167313
167435
|
})(ProjectKind = server.ProjectKind || (server.ProjectKind = {}));
|
|
167314
167436
|
/* @internal */
|
|
167315
167437
|
function countEachFileTypes(infos, includeSizes) {
|
|
@@ -168755,6 +168877,17 @@ var ts;
|
|
|
168755
168877
|
Project.prototype.getIncompleteCompletionsCache = function () {
|
|
168756
168878
|
return this.projectService.getIncompleteCompletionsCache();
|
|
168757
168879
|
};
|
|
168880
|
+
Project.prototype.withAuxiliaryProjectForFiles = function (fileNames, cb) {
|
|
168881
|
+
var options = __assign(__assign({}, this.getCompilerOptions()), { noDtsResolution: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
|
|
168882
|
+
var project = new AuxiliaryProject(this.projectService, this.documentRegistry, options);
|
|
168883
|
+
for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
|
|
168884
|
+
var fileName = fileNames_1[_i];
|
|
168885
|
+
project.addRoot(this.getScriptInfo(fileName));
|
|
168886
|
+
}
|
|
168887
|
+
project.updateGraph();
|
|
168888
|
+
cb(project);
|
|
168889
|
+
project.close();
|
|
168890
|
+
};
|
|
168758
168891
|
return Project;
|
|
168759
168892
|
}());
|
|
168760
168893
|
server.Project = Project;
|
|
@@ -168866,6 +168999,22 @@ var ts;
|
|
|
168866
168999
|
return InferredProject;
|
|
168867
169000
|
}(Project));
|
|
168868
169001
|
server.InferredProject = InferredProject;
|
|
169002
|
+
var AuxiliaryProject = /** @class */ (function (_super) {
|
|
169003
|
+
__extends(AuxiliaryProject, _super);
|
|
169004
|
+
function AuxiliaryProject(projectService, documentRegistry, parentCompilerOptions) {
|
|
169005
|
+
var _this = this;
|
|
169006
|
+
var options = __assign(__assign({}, parentCompilerOptions), { resolveJsOnly: true, allowJs: true, maxNodeModuleJsDepth: 3, diagnostics: false, skipLibCheck: true, sourceMap: false, types: ts.emptyArray, lib: ts.emptyArray, noLib: true });
|
|
169007
|
+
_this = _super.call(this, "js-analysis", ProjectKind.Auxiliary, projectService, documentRegistry,
|
|
169008
|
+
/*hasExplicitListOfFiles*/ false,
|
|
169009
|
+
/*lastFileExceededProgramSize*/ undefined, options,
|
|
169010
|
+
/*compileOnSaveEnabled*/ false,
|
|
169011
|
+
/*watchOptions*/ undefined, projectService.host,
|
|
169012
|
+
/*currentDirectory*/ undefined) || this;
|
|
169013
|
+
return _this;
|
|
169014
|
+
}
|
|
169015
|
+
return AuxiliaryProject;
|
|
169016
|
+
}(Project));
|
|
169017
|
+
server.AuxiliaryProject = AuxiliaryProject;
|
|
168869
169018
|
var AutoImportProviderProject = /** @class */ (function (_super) {
|
|
168870
169019
|
__extends(AutoImportProviderProject, _super);
|
|
168871
169020
|
/*@internal*/
|
|
@@ -170754,8 +170903,8 @@ var ts;
|
|
|
170754
170903
|
this.projectToSizeMap.set(name, 0);
|
|
170755
170904
|
this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); });
|
|
170756
170905
|
var totalNonTsFileSize = 0;
|
|
170757
|
-
for (var _i = 0,
|
|
170758
|
-
var f =
|
|
170906
|
+
for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
|
|
170907
|
+
var f = fileNames_2[_i];
|
|
170759
170908
|
var fileName = propertyReader.getFileName(f);
|
|
170760
170909
|
if (ts.hasTSFileExtension(fileName)) {
|
|
170761
170910
|
continue;
|
|
@@ -173468,6 +173617,12 @@ var ts;
|
|
|
173468
173617
|
_a[server.CommandNames.DefinitionAndBoundSpanFull] = function (request) {
|
|
173469
173618
|
return _this.requiredResponse(_this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
173470
173619
|
},
|
|
173620
|
+
// [CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
|
|
173621
|
+
// return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
|
|
173622
|
+
// },
|
|
173623
|
+
// [CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
|
|
173624
|
+
// return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
|
|
173625
|
+
// },
|
|
173471
173626
|
_a[server.CommandNames.EmitOutput] = function (request) {
|
|
173472
173627
|
return _this.requiredResponse(_this.getEmitOutput(request.arguments));
|
|
173473
173628
|
},
|
|
@@ -174204,10 +174359,34 @@ var ts;
|
|
|
174204
174359
|
Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
|
|
174205
174360
|
return definitions.map(function (info) {
|
|
174206
174361
|
var newDocumentSpan = getMappedDocumentSpan(info, project);
|
|
174207
|
-
return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified });
|
|
174362
|
+
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 });
|
|
174208
174363
|
});
|
|
174209
174364
|
};
|
|
174210
174365
|
Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) {
|
|
174366
|
+
// const { file, project } = this.getFileAndProject(args);
|
|
174367
|
+
// const position = this.getPositionInFile(args, file);
|
|
174368
|
+
// const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
|
|
174369
|
+
// const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);
|
|
174370
|
+
// if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
|
|
174371
|
+
// return {
|
|
174372
|
+
// definitions: emptyArray,
|
|
174373
|
+
// textSpan: undefined! // TODO: GH#18217
|
|
174374
|
+
// };
|
|
174375
|
+
// }
|
|
174376
|
+
// const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
|
|
174377
|
+
// const { textSpan } = unmappedDefinitionAndBoundSpan;
|
|
174378
|
+
// if (simplifiedResult) {
|
|
174379
|
+
// return {
|
|
174380
|
+
// definitions: this.mapDefinitionInfo(definitions, project),
|
|
174381
|
+
// textSpan: toProtocolTextSpan(textSpan, scriptInfo)
|
|
174382
|
+
// };
|
|
174383
|
+
// }
|
|
174384
|
+
// return {
|
|
174385
|
+
// definitions: definitions.map(Session.mapToOriginalLocation),
|
|
174386
|
+
// textSpan,
|
|
174387
|
+
// };
|
|
174388
|
+
// }
|
|
174389
|
+
// private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
|
|
174211
174390
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
174212
174391
|
var position = this.getPositionInFile(args, file);
|
|
174213
174392
|
var scriptInfo = ts.Debug.checkDefined(project.getScriptInfo(file));
|
|
@@ -174218,7 +174397,31 @@ var ts;
|
|
|
174218
174397
|
textSpan: undefined // TODO: GH#18217
|
|
174219
174398
|
};
|
|
174220
174399
|
}
|
|
174221
|
-
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
|
|
174400
|
+
var definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project).slice();
|
|
174401
|
+
var needsJsResolution = !ts.some(definitions, function (d) { return server.toNormalizedPath(d.fileName) !== file && !d.isAmbient; }) || ts.some(definitions, function (d) { return !!d.failedAliasResolution; });
|
|
174402
|
+
if (needsJsResolution) {
|
|
174403
|
+
project.withAuxiliaryProjectForFiles([file], function (auxiliaryProject) {
|
|
174404
|
+
var ls = auxiliaryProject.getLanguageService();
|
|
174405
|
+
var jsDefinitions = ls.getDefinitionAndBoundSpan(file, position, /*aliasesOnly*/ true);
|
|
174406
|
+
if (ts.some(jsDefinitions === null || jsDefinitions === void 0 ? void 0 : jsDefinitions.definitions)) {
|
|
174407
|
+
for (var _i = 0, _a = jsDefinitions.definitions; _i < _a.length; _i++) {
|
|
174408
|
+
var jsDefinition = _a[_i];
|
|
174409
|
+
if (jsDefinition.unverified) {
|
|
174410
|
+
var refined = tryRefineDefinition(jsDefinition, project.getLanguageService().getProgram(), ls.getProgram());
|
|
174411
|
+
if (ts.some(refined)) {
|
|
174412
|
+
for (var _b = 0, _c = refined || server.emptyArray; _b < _c.length; _b++) {
|
|
174413
|
+
var def = _c[_b];
|
|
174414
|
+
ts.pushIfUnique(definitions, def, ts.documentSpansEqual);
|
|
174415
|
+
}
|
|
174416
|
+
continue;
|
|
174417
|
+
}
|
|
174418
|
+
}
|
|
174419
|
+
ts.pushIfUnique(definitions, jsDefinition, ts.documentSpansEqual);
|
|
174420
|
+
}
|
|
174421
|
+
}
|
|
174422
|
+
});
|
|
174423
|
+
}
|
|
174424
|
+
definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
|
|
174222
174425
|
var textSpan = unmappedDefinitionAndBoundSpan.textSpan;
|
|
174223
174426
|
if (simplifiedResult) {
|
|
174224
174427
|
return {
|
|
@@ -174230,6 +174433,32 @@ var ts;
|
|
|
174230
174433
|
definitions: definitions.map(Session.mapToOriginalLocation),
|
|
174231
174434
|
textSpan: textSpan,
|
|
174232
174435
|
};
|
|
174436
|
+
function tryRefineDefinition(definition, program, auxiliaryProgram) {
|
|
174437
|
+
var _a, _b;
|
|
174438
|
+
var fileToSearch = auxiliaryProgram.getSourceFile(definition.fileName);
|
|
174439
|
+
if (!fileToSearch) {
|
|
174440
|
+
return undefined;
|
|
174441
|
+
}
|
|
174442
|
+
var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position);
|
|
174443
|
+
var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode);
|
|
174444
|
+
if (!symbol || !symbol.declarations || ts.some(symbol.declarations, ts.isFreelyNameableImport)) {
|
|
174445
|
+
return undefined;
|
|
174446
|
+
}
|
|
174447
|
+
var nameToSearch = ((_b = (_a = ts.find(symbol.declarations, ts.isImportSpecifier)) === null || _a === void 0 ? void 0 : _a.propertyName) === null || _b === void 0 ? void 0 : _b.text) || symbol.name;
|
|
174448
|
+
return searchForDeclaration(nameToSearch, fileToSearch, auxiliaryProgram);
|
|
174449
|
+
}
|
|
174450
|
+
function searchForDeclaration(declarationName, fileToSearch, auxiliaryProgram) {
|
|
174451
|
+
var matches = ts.FindAllReferences.Core.getTopMostDeclarationNamesInFile(declarationName, fileToSearch);
|
|
174452
|
+
return ts.mapDefined(matches, function (match) {
|
|
174453
|
+
var symbol = auxiliaryProgram.getTypeChecker().getSymbolAtLocation(match);
|
|
174454
|
+
var decl = ts.getDeclarationFromName(match);
|
|
174455
|
+
if (symbol && decl) {
|
|
174456
|
+
// I think the last argument to this is supposed to be the start node, but it doesn't seem important.
|
|
174457
|
+
// Callers internal to GoToDefinition already get confused about this.
|
|
174458
|
+
return ts.GoToDefinition.createDefinitionInfo(decl, auxiliaryProgram.getTypeChecker(), symbol, decl);
|
|
174459
|
+
}
|
|
174460
|
+
});
|
|
174461
|
+
}
|
|
174233
174462
|
};
|
|
174234
174463
|
Session.prototype.getEmitOutput = function (args) {
|
|
174235
174464
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|