typescript 4.5.0-dev.20211020 → 4.5.0-dev.20211024
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/es/diagnosticMessages.generated.json +1 -0
- package/lib/fr/diagnosticMessages.generated.json +1 -0
- package/lib/it/diagnosticMessages.generated.json +1 -0
- package/lib/lib.es5.d.ts +2 -2
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +1 -0
- package/lib/ru/diagnosticMessages.generated.json +2 -0
- package/lib/tr/diagnosticMessages.generated.json +1 -0
- package/lib/tsc.js +50 -44
- package/lib/tsserver.js +113 -76
- package/lib/tsserverlibrary.js +113 -76
- package/lib/typescript.js +113 -76
- package/lib/typescriptServices.js +113 -76
- package/lib/typingsInstaller.js +56 -50
- package/lib/zh-cn/diagnosticMessages.generated.json +1 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -0
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211024";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8141,6 +8141,7 @@ var ts;
|
|
|
8141
8141
|
Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
|
|
8142
8142
|
Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."),
|
|
8143
8143
|
_0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."),
|
|
8144
|
+
_0_is_not_allowed_as_a_parameter_name: diag(1390, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_parameter_name_1390", "'{0}' is not allowed as a parameter name."),
|
|
8144
8145
|
An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"),
|
|
8145
8146
|
Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"),
|
|
8146
8147
|
Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"),
|
|
@@ -19993,7 +19994,7 @@ var ts;
|
|
|
19993
19994
|
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
|
19994
19995
|
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
|
19995
19996
|
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
|
19996
|
-
basePaths: getBasePaths(
|
|
19997
|
+
basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
|
|
19997
19998
|
};
|
|
19998
19999
|
}
|
|
19999
20000
|
ts.getFileMatcherPatterns = getFileMatcherPatterns;
|
|
@@ -20015,20 +20016,20 @@ var ts;
|
|
|
20015
20016
|
var visited = new ts.Map();
|
|
20016
20017
|
var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
|
|
20017
20018
|
for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
|
|
20018
|
-
var
|
|
20019
|
-
if (directoryExists(
|
|
20020
|
-
visitDirectory(
|
|
20019
|
+
var absoluteBasePath = _a[_i];
|
|
20020
|
+
if (directoryExists(absoluteBasePath)) {
|
|
20021
|
+
visitDirectory(absoluteBasePath, depth);
|
|
20021
20022
|
}
|
|
20022
20023
|
}
|
|
20023
20024
|
return ts.flatten(results);
|
|
20024
|
-
function visitDirectory(
|
|
20025
|
+
function visitDirectory(absolutePath, depth) {
|
|
20025
20026
|
var canonicalPath = toCanonical(realpath(absolutePath));
|
|
20026
20027
|
if (visited.has(canonicalPath))
|
|
20027
20028
|
return;
|
|
20028
20029
|
visited.set(canonicalPath, true);
|
|
20029
|
-
var _a = getFileSystemEntries(
|
|
20030
|
+
var _a = getFileSystemEntries(absolutePath), files = _a.files, directories = _a.directories;
|
|
20030
20031
|
var _loop_1 = function (current) {
|
|
20031
|
-
var name = ts.combinePaths(
|
|
20032
|
+
var name = ts.combinePaths(absolutePath, current);
|
|
20032
20033
|
var absoluteName = ts.combinePaths(absolutePath, current);
|
|
20033
20034
|
if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
|
|
20034
20035
|
return "continue";
|
|
@@ -20056,11 +20057,10 @@ var ts;
|
|
|
20056
20057
|
}
|
|
20057
20058
|
for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
|
|
20058
20059
|
var current = _d[_c];
|
|
20059
|
-
var name = ts.combinePaths(path, current);
|
|
20060
20060
|
var absoluteName = ts.combinePaths(absolutePath, current);
|
|
20061
20061
|
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
|
|
20062
20062
|
(!excludeRegex || !excludeRegex.test(absoluteName))) {
|
|
20063
|
-
visitDirectory(
|
|
20063
|
+
visitDirectory(absoluteName, depth);
|
|
20064
20064
|
}
|
|
20065
20065
|
}
|
|
20066
20066
|
}
|
|
@@ -20068,10 +20068,11 @@ var ts;
|
|
|
20068
20068
|
ts.matchFiles = matchFiles;
|
|
20069
20069
|
/**
|
|
20070
20070
|
* Computes the unique non-wildcard base paths amongst the provided include patterns.
|
|
20071
|
+
* @returns Absolute directory paths
|
|
20071
20072
|
*/
|
|
20072
|
-
function getBasePaths(
|
|
20073
|
+
function getBasePaths(absoluteTsconfigPath, includes, useCaseSensitiveFileNames) {
|
|
20073
20074
|
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
|
20074
|
-
var basePaths = [
|
|
20075
|
+
var basePaths = [absoluteTsconfigPath];
|
|
20075
20076
|
if (includes) {
|
|
20076
20077
|
// Storage for literal base paths amongst the include patterns.
|
|
20077
20078
|
var includeBasePaths = [];
|
|
@@ -20079,14 +20080,14 @@ var ts;
|
|
|
20079
20080
|
var include = includes_1[_i];
|
|
20080
20081
|
// We also need to check the relative paths by converting them to absolute and normalizing
|
|
20081
20082
|
// in case they escape the base path (e.g "..\somedirectory")
|
|
20082
|
-
var
|
|
20083
|
+
var absoluteIncludePath = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(absoluteTsconfigPath, include));
|
|
20083
20084
|
// Append the literal and canonical candidate base paths.
|
|
20084
|
-
includeBasePaths.push(getIncludeBasePath(
|
|
20085
|
+
includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
|
|
20085
20086
|
}
|
|
20086
20087
|
// Sort the offsets array using either the literal or canonical path representations.
|
|
20087
20088
|
includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
|
|
20088
20089
|
var _loop_2 = function (includeBasePath) {
|
|
20089
|
-
if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath,
|
|
20090
|
+
if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames); })) {
|
|
20090
20091
|
basePaths.push(includeBasePath);
|
|
20091
20092
|
}
|
|
20092
20093
|
};
|
|
@@ -31933,7 +31934,10 @@ var ts;
|
|
|
31933
31934
|
case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected);
|
|
31934
31935
|
case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected);
|
|
31935
31936
|
case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
|
|
31936
|
-
case 16 /* Parameters */:
|
|
31937
|
+
case 16 /* Parameters */:
|
|
31938
|
+
return ts.isKeyword(token())
|
|
31939
|
+
? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token()))
|
|
31940
|
+
: parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
|
|
31937
31941
|
case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected);
|
|
31938
31942
|
case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected);
|
|
31939
31943
|
case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected);
|
|
@@ -45693,6 +45697,7 @@ var ts;
|
|
|
45693
45697
|
case 168 /* MethodDeclaration */:
|
|
45694
45698
|
case 171 /* GetAccessor */:
|
|
45695
45699
|
case 172 /* SetAccessor */:
|
|
45700
|
+
case 169 /* ClassStaticBlockDeclaration */:
|
|
45696
45701
|
// this.foo assignment in a JavaScript class
|
|
45697
45702
|
// Bind this property to the containing class
|
|
45698
45703
|
var containingClass = thisContainer.parent;
|
|
@@ -49753,8 +49758,8 @@ var ts;
|
|
|
49753
49758
|
if (exportEquals !== moduleSymbol) {
|
|
49754
49759
|
var type = getTypeOfSymbol(exportEquals);
|
|
49755
49760
|
if (shouldTreatPropertiesOfExternalModuleAsExports(type)) {
|
|
49756
|
-
|
|
49757
|
-
cb(symbol,
|
|
49761
|
+
forEachPropertyOfType(type, function (symbol, escapedName) {
|
|
49762
|
+
cb(symbol, escapedName);
|
|
49758
49763
|
});
|
|
49759
49764
|
}
|
|
49760
49765
|
}
|
|
@@ -50086,12 +50091,15 @@ var ts;
|
|
|
50086
50091
|
function getNamedMembers(members) {
|
|
50087
50092
|
var result;
|
|
50088
50093
|
members.forEach(function (symbol, id) {
|
|
50089
|
-
if (
|
|
50094
|
+
if (isNamedMember(symbol, id)) {
|
|
50090
50095
|
(result || (result = [])).push(symbol);
|
|
50091
50096
|
}
|
|
50092
50097
|
});
|
|
50093
50098
|
return result || ts.emptyArray;
|
|
50094
50099
|
}
|
|
50100
|
+
function isNamedMember(member, escapedName) {
|
|
50101
|
+
return !isReservedMemberName(escapedName) && symbolIsValue(member);
|
|
50102
|
+
}
|
|
50095
50103
|
function getNamedOrIndexSignatureMembers(members) {
|
|
50096
50104
|
var result = getNamedMembers(members);
|
|
50097
50105
|
var index = getIndexSymbolFromSymbolTable(members);
|
|
@@ -56924,6 +56932,16 @@ var ts;
|
|
|
56924
56932
|
getPropertiesOfUnionOrIntersectionType(type) :
|
|
56925
56933
|
getPropertiesOfObjectType(type);
|
|
56926
56934
|
}
|
|
56935
|
+
function forEachPropertyOfType(type, action) {
|
|
56936
|
+
type = getReducedApparentType(type);
|
|
56937
|
+
if (type.flags & 3670016 /* StructuredType */) {
|
|
56938
|
+
resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) {
|
|
56939
|
+
if (isNamedMember(symbol, escapedName)) {
|
|
56940
|
+
action(symbol, escapedName);
|
|
56941
|
+
}
|
|
56942
|
+
});
|
|
56943
|
+
}
|
|
56944
|
+
}
|
|
56927
56945
|
function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
|
|
56928
56946
|
var list = obj.properties;
|
|
56929
56947
|
return list.some(function (property) {
|
|
@@ -60399,12 +60417,6 @@ var ts;
|
|
|
60399
60417
|
}
|
|
60400
60418
|
return type[cache] = type;
|
|
60401
60419
|
}
|
|
60402
|
-
function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) {
|
|
60403
|
-
var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; }));
|
|
60404
|
-
var checkType = type.checkType;
|
|
60405
|
-
var extendsType = type.extendsType;
|
|
60406
|
-
return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper)));
|
|
60407
|
-
}
|
|
60408
60420
|
function getSimplifiedConditionalType(type, writing) {
|
|
60409
60421
|
var checkType = type.checkType;
|
|
60410
60422
|
var extendsType = type.extendsType;
|
|
@@ -60713,6 +60725,10 @@ var ts;
|
|
|
60713
60725
|
}
|
|
60714
60726
|
return result;
|
|
60715
60727
|
}
|
|
60728
|
+
function isDistributionDependent(root) {
|
|
60729
|
+
return root.isDistributive && (isTypeParameterPossiblyReferenced(root.checkType, root.node.trueType) ||
|
|
60730
|
+
isTypeParameterPossiblyReferenced(root.checkType, root.node.falseType));
|
|
60731
|
+
}
|
|
60716
60732
|
function getTypeFromConditionalTypeNode(node) {
|
|
60717
60733
|
var links = getNodeLinks(node);
|
|
60718
60734
|
if (!links.resolvedType) {
|
|
@@ -63869,31 +63885,21 @@ var ts;
|
|
|
63869
63885
|
return 3 /* Maybe */;
|
|
63870
63886
|
}
|
|
63871
63887
|
var c = target;
|
|
63872
|
-
//
|
|
63873
|
-
|
|
63874
|
-
|
|
63875
|
-
|
|
63876
|
-
|
|
63877
|
-
|
|
63878
|
-
|
|
63879
|
-
|
|
63880
|
-
|
|
63881
|
-
|
|
63882
|
-
|
|
63883
|
-
|
|
63884
|
-
|
|
63885
|
-
|
|
63886
|
-
|
|
63887
|
-
var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
|
|
63888
|
-
var localResult = expanding ? 3 /* Maybe */ : undefined;
|
|
63889
|
-
if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
|
|
63890
|
-
if (!skipFalse && !expanding) {
|
|
63891
|
-
localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63892
|
-
}
|
|
63893
|
-
}
|
|
63894
|
-
if (localResult) {
|
|
63895
|
-
resetErrorInfo(saveErrorInfo);
|
|
63896
|
-
return localResult;
|
|
63888
|
+
// We check for a relationship to a conditional type target only when the conditional type has no
|
|
63889
|
+
// 'infer' positions and is not distributive or is distributive but doesn't reference the check type
|
|
63890
|
+
// parameter in either of the result types.
|
|
63891
|
+
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
|
|
63892
|
+
// Check if the conditional is always true or always false but still deferred for distribution purposes.
|
|
63893
|
+
var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
|
|
63894
|
+
var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
|
|
63895
|
+
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
|
|
63896
|
+
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
63897
|
+
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63898
|
+
if (result) {
|
|
63899
|
+
resetErrorInfo(saveErrorInfo);
|
|
63900
|
+
return result;
|
|
63901
|
+
}
|
|
63902
|
+
}
|
|
63897
63903
|
}
|
|
63898
63904
|
}
|
|
63899
63905
|
else if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
@@ -124611,9 +124617,9 @@ var ts;
|
|
|
124611
124617
|
return displayPart(text, ts.SymbolDisplayPartKind.linkText);
|
|
124612
124618
|
}
|
|
124613
124619
|
ts.linkTextPart = linkTextPart;
|
|
124614
|
-
function linkNamePart(
|
|
124620
|
+
function linkNamePart(text, target) {
|
|
124615
124621
|
return {
|
|
124616
|
-
text:
|
|
124622
|
+
text: text,
|
|
124617
124623
|
kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName],
|
|
124618
124624
|
target: {
|
|
124619
124625
|
fileName: ts.getSourceFileOfNode(target).fileName,
|
|
@@ -124638,20 +124644,41 @@ var ts;
|
|
|
124638
124644
|
}
|
|
124639
124645
|
else {
|
|
124640
124646
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
124647
|
+
var suffix = findLinkNameEnd(link.text);
|
|
124648
|
+
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
124649
|
+
var text = link.text.slice(suffix);
|
|
124641
124650
|
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
|
|
124642
124651
|
if (decl) {
|
|
124643
|
-
parts.push(linkNamePart(
|
|
124644
|
-
if (
|
|
124645
|
-
parts.push(linkTextPart(
|
|
124652
|
+
parts.push(linkNamePart(name, decl));
|
|
124653
|
+
if (text)
|
|
124654
|
+
parts.push(linkTextPart(text));
|
|
124646
124655
|
}
|
|
124647
124656
|
else {
|
|
124648
|
-
parts.push(linkTextPart(
|
|
124657
|
+
parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
|
|
124649
124658
|
}
|
|
124650
124659
|
}
|
|
124651
124660
|
parts.push(linkPart("}"));
|
|
124652
124661
|
return parts;
|
|
124653
124662
|
}
|
|
124654
124663
|
ts.buildLinkParts = buildLinkParts;
|
|
124664
|
+
function findLinkNameEnd(text) {
|
|
124665
|
+
if (text.indexOf("()") === 0)
|
|
124666
|
+
return 2;
|
|
124667
|
+
if (text[0] !== "<")
|
|
124668
|
+
return 0;
|
|
124669
|
+
var brackets = 0;
|
|
124670
|
+
var i = 0;
|
|
124671
|
+
while (i < text.length) {
|
|
124672
|
+
if (text[i] === "<")
|
|
124673
|
+
brackets++;
|
|
124674
|
+
if (text[i] === ">")
|
|
124675
|
+
brackets--;
|
|
124676
|
+
i++;
|
|
124677
|
+
if (!brackets)
|
|
124678
|
+
return i;
|
|
124679
|
+
}
|
|
124680
|
+
return 0;
|
|
124681
|
+
}
|
|
124655
124682
|
var carriageReturnLineFeed = "\r\n";
|
|
124656
124683
|
/**
|
|
124657
124684
|
* The default is CRLF.
|
|
@@ -125555,10 +125582,14 @@ var ts;
|
|
|
125555
125582
|
}
|
|
125556
125583
|
var isDefault = exportKind === 1 /* Default */;
|
|
125557
125584
|
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
125558
|
-
// A
|
|
125559
|
-
//
|
|
125560
|
-
//
|
|
125561
|
-
|
|
125585
|
+
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
|
|
125586
|
+
// 2. A re-export merged with an export from a module augmentation can result in `symbol`
|
|
125587
|
+
// being an external module symbol; the name it is re-exported by will be `symbolTableKey`
|
|
125588
|
+
// (which comes from the keys of `moduleSymbol.exports`.)
|
|
125589
|
+
// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
|
|
125590
|
+
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
|
|
125591
|
+
// get a better name.
|
|
125592
|
+
var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
125562
125593
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
125563
125594
|
: ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
|
|
125564
125595
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
@@ -125789,7 +125820,7 @@ var ts;
|
|
|
125789
125820
|
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker);
|
|
125790
125821
|
}
|
|
125791
125822
|
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
125792
|
-
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports,
|
|
125823
|
+
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
125793
125824
|
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker);
|
|
125794
125825
|
}
|
|
125795
125826
|
});
|
|
@@ -128644,8 +128675,8 @@ var ts;
|
|
|
128644
128675
|
}
|
|
128645
128676
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
128646
128677
|
var moduleSymbol = origin.moduleSymbol;
|
|
128647
|
-
var
|
|
128648
|
-
var _b = ts.codefix.getImportCompletionAction(
|
|
128678
|
+
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
128679
|
+
var _b = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions)), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _b.moduleSpecifier, codeAction = _b.codeAction;
|
|
128649
128680
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
128650
128681
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
128651
128682
|
}
|
|
@@ -129540,8 +129571,9 @@ var ts;
|
|
|
129540
129571
|
function isNewIdentifierDefinitionLocation() {
|
|
129541
129572
|
if (contextToken) {
|
|
129542
129573
|
var containingNodeKind = contextToken.parent.kind;
|
|
129574
|
+
var tokenKind = keywordForNode(contextToken);
|
|
129543
129575
|
// Previous token may have been a keyword that was converted to an identifier.
|
|
129544
|
-
switch (
|
|
129576
|
+
switch (tokenKind) {
|
|
129545
129577
|
case 27 /* CommaToken */:
|
|
129546
129578
|
return containingNodeKind === 207 /* CallExpression */ // func( a, |
|
|
129547
129579
|
|| containingNodeKind === 170 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
|
|
@@ -129576,10 +129608,12 @@ var ts;
|
|
|
129576
129608
|
return containingNodeKind === 222 /* TemplateExpression */; // `aa ${|
|
|
129577
129609
|
case 16 /* TemplateMiddle */:
|
|
129578
129610
|
return containingNodeKind === 232 /* TemplateSpan */; // `aa ${10} dd ${|
|
|
129579
|
-
case
|
|
129580
|
-
|
|
129581
|
-
|
|
129582
|
-
|
|
129611
|
+
case 131 /* AsyncKeyword */:
|
|
129612
|
+
return containingNodeKind === 168 /* MethodDeclaration */ // const obj = { async c|()
|
|
129613
|
+
|| containingNodeKind === 295 /* ShorthandPropertyAssignment */; // const obj = { async c|
|
|
129614
|
+
}
|
|
129615
|
+
if (isClassMemberCompletionKeyword(tokenKind)) {
|
|
129616
|
+
return true;
|
|
129583
129617
|
}
|
|
129584
129618
|
}
|
|
129585
129619
|
return false;
|
|
@@ -147884,11 +147918,11 @@ var ts;
|
|
|
147884
147918
|
AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
|
|
147885
147919
|
AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
|
|
147886
147920
|
})(AddAsTypeOnly || (AddAsTypeOnly = {}));
|
|
147887
|
-
function getImportCompletionAction(
|
|
147921
|
+
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
|
|
147888
147922
|
var compilerOptions = program.getCompilerOptions();
|
|
147889
147923
|
var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
|
|
147890
|
-
? [getSymbolExportInfoForSymbol(
|
|
147891
|
-
: getAllReExportingModules(sourceFile,
|
|
147924
|
+
? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
|
|
147925
|
+
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
147892
147926
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
147893
147927
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
|
|
147894
147928
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
@@ -147926,7 +147960,7 @@ var ts;
|
|
|
147926
147960
|
}
|
|
147927
147961
|
}
|
|
147928
147962
|
}
|
|
147929
|
-
function getAllReExportingModules(importingFile,
|
|
147963
|
+
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
|
|
147930
147964
|
var result = [];
|
|
147931
147965
|
var compilerOptions = program.getCompilerOptions();
|
|
147932
147966
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -147939,12 +147973,12 @@ var ts;
|
|
|
147939
147973
|
return;
|
|
147940
147974
|
}
|
|
147941
147975
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
147942
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) ===
|
|
147976
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
147943
147977
|
result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
147944
147978
|
}
|
|
147945
147979
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
147946
147980
|
var exported = _a[_i];
|
|
147947
|
-
if (exported.name === symbolName && ts.skipAlias(exported, checker) ===
|
|
147981
|
+
if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
147948
147982
|
result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
147949
147983
|
}
|
|
147950
147984
|
}
|
|
@@ -148195,12 +148229,14 @@ var ts;
|
|
|
148195
148229
|
}
|
|
148196
148230
|
var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
|
|
148197
148231
|
return fixes.reduce(function (best, fix) {
|
|
148232
|
+
// Takes true branch of conditional if `fix` is better than `best`
|
|
148198
148233
|
return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
148199
148234
|
});
|
|
148200
148235
|
}
|
|
148236
|
+
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
148201
148237
|
function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
|
|
148202
148238
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
148203
|
-
return ts.compareBooleans(allowsImportingSpecifier(
|
|
148239
|
+
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
148204
148240
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
148205
148241
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
148206
148242
|
}
|
|
@@ -150852,7 +150888,8 @@ var ts;
|
|
|
150852
150888
|
insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile);
|
|
150853
150889
|
break;
|
|
150854
150890
|
case 213 /* ArrowFunction */:
|
|
150855
|
-
|
|
150891
|
+
var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */;
|
|
150892
|
+
insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters);
|
|
150856
150893
|
break;
|
|
150857
150894
|
default:
|
|
150858
150895
|
return;
|