typescript 4.8.0-dev.20220616 → 4.8.0-dev.20220619
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +5 -1
- package/lib/de/diagnosticMessages.generated.json +5 -1
- package/lib/es/diagnosticMessages.generated.json +5 -1
- package/lib/fr/diagnosticMessages.generated.json +5 -1
- package/lib/it/diagnosticMessages.generated.json +5 -1
- package/lib/ja/diagnosticMessages.generated.json +5 -1
- package/lib/ko/diagnosticMessages.generated.json +5 -1
- package/lib/lib.dom.d.ts +128 -183
- package/lib/lib.dom.iterable.d.ts +1 -11
- package/lib/lib.webworker.d.ts +54 -27
- package/lib/lib.webworker.iterable.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +5 -1
- package/lib/protocol.d.ts +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +5 -1
- package/lib/ru/diagnosticMessages.generated.json +5 -1
- package/lib/tr/diagnosticMessages.generated.json +5 -1
- package/lib/tsc.js +121 -45
- package/lib/tsserver.js +271 -99
- package/lib/tsserverlibrary.d.ts +10 -0
- package/lib/tsserverlibrary.js +271 -99
- package/lib/typescript.d.ts +9 -0
- package/lib/typescript.js +239 -77
- package/lib/typescriptServices.d.ts +9 -0
- package/lib/typescriptServices.js +239 -77
- package/lib/typingsInstaller.js +150 -45
- package/lib/zh-cn/diagnosticMessages.generated.json +5 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +5 -1
- package/package.json +20 -20
package/lib/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220619";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -9866,6 +9866,8 @@ var ts;
|
|
|
9866
9866
|
Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
|
|
9867
9867
|
A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
|
|
9868
9868
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9869
|
+
You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
|
|
9870
|
+
You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
|
|
9869
9871
|
Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
|
|
9870
9872
|
Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
|
|
9871
9873
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
@@ -10136,6 +10138,9 @@ var ts;
|
|
|
10136
10138
|
For_await_loops_cannot_be_used_inside_a_class_static_block: diag(18038, ts.DiagnosticCategory.Error, "For_await_loops_cannot_be_used_inside_a_class_static_block_18038", "'For await' loops cannot be used inside a class static block."),
|
|
10137
10139
|
Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block: diag(18039, ts.DiagnosticCategory.Error, "Invalid_use_of_0_It_cannot_be_used_inside_a_class_static_block_18039", "Invalid use of '{0}'. It cannot be used inside a class static block."),
|
|
10138
10140
|
A_return_statement_cannot_be_used_inside_a_class_static_block: diag(18041, ts.DiagnosticCategory.Error, "A_return_statement_cannot_be_used_inside_a_class_static_block_18041", "A 'return' statement cannot be used inside a class static block."),
|
|
10141
|
+
_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation: diag(18042, ts.DiagnosticCategory.Error, "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042", "'{0}' is a type and cannot be imported in JavaScript files. Use '{1}' in a JSDoc type annotation."),
|
|
10142
|
+
Types_cannot_appear_in_export_declarations_in_JavaScript_files: diag(18043, ts.DiagnosticCategory.Error, "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043", "Types cannot appear in export declarations in JavaScript files."),
|
|
10143
|
+
_0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
|
|
10139
10144
|
};
|
|
10140
10145
|
})(ts || (ts = {}));
|
|
10141
10146
|
var ts;
|
|
@@ -34724,10 +34729,10 @@ var ts;
|
|
|
34724
34729
|
setDecoratorContext(/*val*/ false);
|
|
34725
34730
|
}
|
|
34726
34731
|
var pos = getNodePos();
|
|
34727
|
-
var expr = parseAssignmentExpressionOrHigher();
|
|
34732
|
+
var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
34728
34733
|
var operatorToken;
|
|
34729
34734
|
while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
|
|
34730
|
-
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
|
34735
|
+
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
|
|
34731
34736
|
}
|
|
34732
34737
|
if (saveDecoratorContext) {
|
|
34733
34738
|
setDecoratorContext(/*val*/ true);
|
|
@@ -34735,9 +34740,9 @@ var ts;
|
|
|
34735
34740
|
return expr;
|
|
34736
34741
|
}
|
|
34737
34742
|
function parseInitializer() {
|
|
34738
|
-
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
34743
|
+
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
|
|
34739
34744
|
}
|
|
34740
|
-
function parseAssignmentExpressionOrHigher() {
|
|
34745
|
+
function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
|
|
34741
34746
|
// AssignmentExpression[in,yield]:
|
|
34742
34747
|
// 1) ConditionalExpression[?in,?yield]
|
|
34743
34748
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -34763,7 +34768,7 @@ var ts;
|
|
|
34763
34768
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
34764
34769
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
34765
34770
|
// with AssignmentExpression if we see one.
|
|
34766
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
34771
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
|
|
34767
34772
|
if (arrowExpression) {
|
|
34768
34773
|
return arrowExpression;
|
|
34769
34774
|
}
|
|
@@ -34782,7 +34787,7 @@ var ts;
|
|
|
34782
34787
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
34783
34788
|
// identifier and the current token is an arrow.
|
|
34784
34789
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
34785
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
34790
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
|
|
34786
34791
|
}
|
|
34787
34792
|
// Now see if we might be in cases '2' or '3'.
|
|
34788
34793
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -34791,10 +34796,10 @@ var ts;
|
|
|
34791
34796
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
34792
34797
|
// for cases like `> > =` becoming `>>=`
|
|
34793
34798
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
34794
|
-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
|
34799
|
+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
|
|
34795
34800
|
}
|
|
34796
34801
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
34797
|
-
return parseConditionalExpressionRest(expr, pos);
|
|
34802
|
+
return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
|
|
34798
34803
|
}
|
|
34799
34804
|
function isYieldExpression() {
|
|
34800
34805
|
if (token() === 125 /* YieldKeyword */) {
|
|
@@ -34834,7 +34839,7 @@ var ts;
|
|
|
34834
34839
|
nextToken();
|
|
34835
34840
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
34836
34841
|
(token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
|
|
34837
|
-
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
|
|
34842
|
+
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
|
|
34838
34843
|
}
|
|
34839
34844
|
else {
|
|
34840
34845
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
@@ -34842,7 +34847,7 @@ var ts;
|
|
|
34842
34847
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
34843
34848
|
}
|
|
34844
34849
|
}
|
|
34845
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
34850
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
|
|
34846
34851
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
34847
34852
|
var parameter = factory.createParameterDeclaration(
|
|
34848
34853
|
/*modifiers*/ undefined,
|
|
@@ -34853,11 +34858,11 @@ var ts;
|
|
|
34853
34858
|
finishNode(parameter, identifier.pos);
|
|
34854
34859
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
34855
34860
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34856
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
34861
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
|
|
34857
34862
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
34858
34863
|
return addJSDocComment(finishNode(node, pos));
|
|
34859
34864
|
}
|
|
34860
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
34865
|
+
function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34861
34866
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
34862
34867
|
if (triState === 0 /* False */) {
|
|
34863
34868
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -34868,8 +34873,8 @@ var ts;
|
|
|
34868
34873
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
34869
34874
|
// expression instead.
|
|
34870
34875
|
return triState === 1 /* True */ ?
|
|
34871
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
34872
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
34876
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
|
|
34877
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
|
|
34873
34878
|
}
|
|
34874
34879
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
34875
34880
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -35003,25 +35008,25 @@ var ts;
|
|
|
35003
35008
|
return 2 /* Unknown */;
|
|
35004
35009
|
}
|
|
35005
35010
|
}
|
|
35006
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
35011
|
+
function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
35007
35012
|
var tokenPos = scanner.getTokenPos();
|
|
35008
35013
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
35009
35014
|
return undefined;
|
|
35010
35015
|
}
|
|
35011
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
35016
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
|
|
35012
35017
|
if (!result) {
|
|
35013
35018
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
35014
35019
|
}
|
|
35015
35020
|
return result;
|
|
35016
35021
|
}
|
|
35017
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
35022
|
+
function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
35018
35023
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
35019
35024
|
if (token() === 131 /* AsyncKeyword */) {
|
|
35020
35025
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
35021
35026
|
var pos = getNodePos();
|
|
35022
35027
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
35023
35028
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
35024
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
35029
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
|
|
35025
35030
|
}
|
|
35026
35031
|
}
|
|
35027
35032
|
return undefined;
|
|
@@ -35045,7 +35050,7 @@ var ts;
|
|
|
35045
35050
|
}
|
|
35046
35051
|
return 0 /* False */;
|
|
35047
35052
|
}
|
|
35048
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
35053
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
|
|
35049
35054
|
var pos = getNodePos();
|
|
35050
35055
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35051
35056
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -35080,6 +35085,7 @@ var ts;
|
|
|
35080
35085
|
return undefined;
|
|
35081
35086
|
}
|
|
35082
35087
|
}
|
|
35088
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
35083
35089
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
35084
35090
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
35085
35091
|
return undefined;
|
|
@@ -35108,12 +35114,37 @@ var ts;
|
|
|
35108
35114
|
var lastToken = token();
|
|
35109
35115
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
35110
35116
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
35111
|
-
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
|
|
35117
|
+
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
|
|
35112
35118
|
: parseIdentifier();
|
|
35119
|
+
// Given:
|
|
35120
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
35121
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
35122
|
+
// ({ y }) : z => ({ z })
|
|
35123
|
+
// This is a valid arrow function with "z" as the return type.
|
|
35124
|
+
//
|
|
35125
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
35126
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
35127
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
35128
|
+
//
|
|
35129
|
+
// For example,
|
|
35130
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
35131
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
35132
|
+
// be an arrow expression, so we allow a return type.
|
|
35133
|
+
if (!allowReturnTypeInArrowFunction && hasReturnColon) {
|
|
35134
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
35135
|
+
// as in:
|
|
35136
|
+
// a ? (x): string => x : null
|
|
35137
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
35138
|
+
// the conditional expression. It's okay to do this because this code would
|
|
35139
|
+
// be a syntax error in JavaScript (as the second colon shouldn't be there).
|
|
35140
|
+
if (token() !== 58 /* ColonToken */) {
|
|
35141
|
+
return undefined;
|
|
35142
|
+
}
|
|
35143
|
+
}
|
|
35113
35144
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
35114
35145
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
35115
35146
|
}
|
|
35116
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
35147
|
+
function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
|
|
35117
35148
|
if (token() === 18 /* OpenBraceToken */) {
|
|
35118
35149
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
35119
35150
|
}
|
|
@@ -35141,12 +35172,12 @@ var ts;
|
|
|
35141
35172
|
var savedTopLevel = topLevel;
|
|
35142
35173
|
topLevel = false;
|
|
35143
35174
|
var node = isAsync
|
|
35144
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
35145
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
35175
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
|
|
35176
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
|
|
35146
35177
|
topLevel = savedTopLevel;
|
|
35147
35178
|
return node;
|
|
35148
35179
|
}
|
|
35149
|
-
function parseConditionalExpressionRest(leftOperand, pos) {
|
|
35180
|
+
function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
|
|
35150
35181
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
|
35151
35182
|
var questionToken = parseOptionalToken(57 /* QuestionToken */);
|
|
35152
35183
|
if (!questionToken) {
|
|
@@ -35155,8 +35186,8 @@ var ts;
|
|
|
35155
35186
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
35156
35187
|
// we do not that for the 'whenFalse' part.
|
|
35157
35188
|
var colonToken;
|
|
35158
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
35159
|
-
? parseAssignmentExpressionOrHigher()
|
|
35189
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
35190
|
+
? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
|
|
35160
35191
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
35161
35192
|
}
|
|
35162
35193
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -36071,13 +36102,13 @@ var ts;
|
|
|
36071
36102
|
function parseSpreadElement() {
|
|
36072
36103
|
var pos = getNodePos();
|
|
36073
36104
|
parseExpected(25 /* DotDotDotToken */);
|
|
36074
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
36105
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36075
36106
|
return finishNode(factory.createSpreadElement(expression), pos);
|
|
36076
36107
|
}
|
|
36077
36108
|
function parseArgumentOrArrayLiteralElement() {
|
|
36078
36109
|
return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
36079
36110
|
token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
|
36080
|
-
parseAssignmentExpressionOrHigher();
|
|
36111
|
+
parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36081
36112
|
}
|
|
36082
36113
|
function parseArgumentExpression() {
|
|
36083
36114
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
@@ -36095,7 +36126,7 @@ var ts;
|
|
|
36095
36126
|
var pos = getNodePos();
|
|
36096
36127
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
36097
36128
|
if (parseOptionalToken(25 /* DotDotDotToken */)) {
|
|
36098
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
36129
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36099
36130
|
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
|
36100
36131
|
}
|
|
36101
36132
|
var decorators = parseDecorators();
|
|
@@ -36124,7 +36155,7 @@ var ts;
|
|
|
36124
36155
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
|
|
36125
36156
|
if (isShorthandPropertyAssignment) {
|
|
36126
36157
|
var equalsToken = parseOptionalToken(63 /* EqualsToken */);
|
|
36127
|
-
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
|
36158
|
+
var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
|
|
36128
36159
|
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
|
|
36129
36160
|
// Save equals token for error reporting.
|
|
36130
36161
|
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
|
@@ -36132,7 +36163,7 @@ var ts;
|
|
|
36132
36163
|
}
|
|
36133
36164
|
else {
|
|
36134
36165
|
parseExpected(58 /* ColonToken */);
|
|
36135
|
-
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36166
|
+
var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36136
36167
|
node = factory.createPropertyAssignment(name, initializer);
|
|
36137
36168
|
}
|
|
36138
36169
|
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
|
@@ -36309,7 +36340,7 @@ var ts;
|
|
|
36309
36340
|
}
|
|
36310
36341
|
var node;
|
|
36311
36342
|
if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
|
|
36312
|
-
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36343
|
+
var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36313
36344
|
parseExpected(21 /* CloseParenToken */);
|
|
36314
36345
|
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
|
36315
36346
|
}
|
|
@@ -37497,7 +37528,7 @@ var ts;
|
|
|
37497
37528
|
var pos = getNodePos();
|
|
37498
37529
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
37499
37530
|
parseExpected(58 /* ColonToken */);
|
|
37500
|
-
var value = parseAssignmentExpressionOrHigher();
|
|
37531
|
+
var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37501
37532
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
37502
37533
|
}
|
|
37503
37534
|
function parseAssertClause(skipAssertKeyword) {
|
|
@@ -37738,7 +37769,7 @@ var ts;
|
|
|
37738
37769
|
else {
|
|
37739
37770
|
parseExpected(88 /* DefaultKeyword */);
|
|
37740
37771
|
}
|
|
37741
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
37772
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37742
37773
|
parseSemicolon();
|
|
37743
37774
|
setAwaitContext(savedAwaitContext);
|
|
37744
37775
|
var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
|
|
@@ -49104,9 +49135,9 @@ var ts;
|
|
|
49104
49135
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
49105
49136
|
},
|
|
49106
49137
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
49107
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
49138
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
49108
49139
|
var node = ts.getParseTreeNode(nodeIn);
|
|
49109
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
49140
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
49110
49141
|
},
|
|
49111
49142
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
49112
49143
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -59554,7 +59585,7 @@ var ts;
|
|
|
59554
59585
|
}
|
|
59555
59586
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59556
59587
|
var constraint = getBaseConstraint(t.type);
|
|
59557
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59588
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59558
59589
|
}
|
|
59559
59590
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59560
59591
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62524,9 +62555,12 @@ var ts;
|
|
|
62524
62555
|
}
|
|
62525
62556
|
function getStringMappingType(symbol, type) {
|
|
62526
62557
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62527
|
-
|
|
62528
|
-
|
|
62529
|
-
|
|
62558
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62559
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62560
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62561
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62562
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62563
|
+
type;
|
|
62530
62564
|
}
|
|
62531
62565
|
function applyStringMapping(symbol, str) {
|
|
62532
62566
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62537,6 +62571,15 @@ var ts;
|
|
|
62537
62571
|
}
|
|
62538
62572
|
return str;
|
|
62539
62573
|
}
|
|
62574
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62575
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62576
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62577
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62578
|
+
case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62579
|
+
case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62580
|
+
}
|
|
62581
|
+
return [texts, types];
|
|
62582
|
+
}
|
|
62540
62583
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62541
62584
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62542
62585
|
var result = stringMappingTypes.get(id);
|
|
@@ -62778,7 +62821,7 @@ var ts;
|
|
|
62778
62821
|
accessNode;
|
|
62779
62822
|
}
|
|
62780
62823
|
function isPatternLiteralPlaceholderType(type) {
|
|
62781
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62824
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62782
62825
|
}
|
|
62783
62826
|
function isPatternLiteralType(type) {
|
|
62784
62827
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -66490,6 +66533,13 @@ var ts;
|
|
|
66490
66533
|
return -1 /* True */;
|
|
66491
66534
|
}
|
|
66492
66535
|
}
|
|
66536
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66537
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66538
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66539
|
+
return -1 /* True */;
|
|
66540
|
+
}
|
|
66541
|
+
}
|
|
66542
|
+
}
|
|
66493
66543
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66494
66544
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66495
66545
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66533,7 +66583,10 @@ var ts;
|
|
|
66533
66583
|
}
|
|
66534
66584
|
}
|
|
66535
66585
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66536
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66586
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66587
|
+
if (source.symbol !== target.symbol) {
|
|
66588
|
+
return 0 /* False */;
|
|
66589
|
+
}
|
|
66537
66590
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66538
66591
|
resetErrorInfo(saveErrorInfo);
|
|
66539
66592
|
return result;
|
|
@@ -67458,7 +67511,7 @@ var ts;
|
|
|
67458
67511
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67459
67512
|
}
|
|
67460
67513
|
}
|
|
67461
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67514
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67462
67515
|
}
|
|
67463
67516
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67464
67517
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68929,6 +68982,31 @@ var ts;
|
|
|
68929
68982
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68930
68983
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68931
68984
|
}
|
|
68985
|
+
function isMemberOfStringMapping(source, target) {
|
|
68986
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68987
|
+
return true;
|
|
68988
|
+
}
|
|
68989
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68990
|
+
return isTypeAssignableTo(source, target);
|
|
68991
|
+
}
|
|
68992
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68993
|
+
// We need to see whether applying the same mappings of the target
|
|
68994
|
+
// onto the source would produce an identical type *and* that
|
|
68995
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68996
|
+
//
|
|
68997
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68998
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68999
|
+
// still reside in the same domain.
|
|
69000
|
+
var mappingStack = [];
|
|
69001
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
69002
|
+
mappingStack.unshift(target.symbol);
|
|
69003
|
+
target = target.type;
|
|
69004
|
+
}
|
|
69005
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
69006
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
69007
|
+
}
|
|
69008
|
+
return false;
|
|
69009
|
+
}
|
|
68932
69010
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68933
69011
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68934
69012
|
return true;
|
|
@@ -68937,7 +69015,8 @@ var ts;
|
|
|
68937
69015
|
var value = source.value;
|
|
68938
69016
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68939
69017
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68940
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
69018
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
69019
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68941
69020
|
}
|
|
68942
69021
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68943
69022
|
var texts = source.texts;
|
|
@@ -85816,6 +85895,7 @@ var ts;
|
|
|
85816
85895
|
return true;
|
|
85817
85896
|
}
|
|
85818
85897
|
function checkAliasSymbol(node) {
|
|
85898
|
+
var _a, _b, _c, _d, _e;
|
|
85819
85899
|
var symbol = getSymbolOfNode(node);
|
|
85820
85900
|
var target = resolveAlias(symbol);
|
|
85821
85901
|
if (target !== unknownSymbol) {
|
|
@@ -85826,6 +85906,31 @@ var ts;
|
|
|
85826
85906
|
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
|
85827
85907
|
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
|
85828
85908
|
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
|
85909
|
+
// A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
|
|
85910
|
+
if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
|
|
85911
|
+
var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
|
|
85912
|
+
ts.isNamedDeclaration(node) ? node.name :
|
|
85913
|
+
node;
|
|
85914
|
+
ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
|
|
85915
|
+
if (node.kind === 275 /* ExportSpecifier */) {
|
|
85916
|
+
var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
85917
|
+
var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText);
|
|
85918
|
+
if (alreadyExportedSymbol === target) {
|
|
85919
|
+
var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
|
|
85920
|
+
if (exportingDeclaration) {
|
|
85921
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
|
|
85922
|
+
}
|
|
85923
|
+
}
|
|
85924
|
+
}
|
|
85925
|
+
else {
|
|
85926
|
+
ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
|
|
85927
|
+
var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
|
|
85928
|
+
var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
|
|
85929
|
+
var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
85930
|
+
error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier);
|
|
85931
|
+
}
|
|
85932
|
+
return;
|
|
85933
|
+
}
|
|
85829
85934
|
var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
|
|
85830
85935
|
(symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
|
|
85831
85936
|
(symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
@@ -131245,32 +131350,41 @@ var ts;
|
|
|
131245
131350
|
|| ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
|
|
131246
131351
|
|| (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
|
|
131247
131352
|
}
|
|
131248
|
-
function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
|
|
131353
|
+
function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
|
|
131249
131354
|
var _a, _b;
|
|
131250
|
-
|
|
131355
|
+
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
|
|
131356
|
+
var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
|
|
131357
|
+
// The client is expected to send rooted path specs since we don't know
|
|
131358
|
+
// what directory a relative path is relative to.
|
|
131359
|
+
var pattern = ts.getPatternFromSpec(spec, "", "exclude");
|
|
131360
|
+
return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
|
|
131361
|
+
});
|
|
131362
|
+
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
|
|
131251
131363
|
var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
131252
131364
|
if (autoImportProvider) {
|
|
131253
131365
|
var start = ts.timestamp();
|
|
131254
|
-
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131366
|
+
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131255
131367
|
(_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
|
|
131256
131368
|
}
|
|
131257
131369
|
}
|
|
131258
131370
|
ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
|
|
131259
|
-
function forEachExternalModule(checker, allSourceFiles, cb) {
|
|
131260
|
-
|
|
131261
|
-
|
|
131262
|
-
|
|
131371
|
+
function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
|
|
131372
|
+
var _a;
|
|
131373
|
+
var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
|
|
131374
|
+
for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
|
|
131375
|
+
var ambient = _b[_i];
|
|
131376
|
+
if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
|
|
131263
131377
|
cb(ambient, /*sourceFile*/ undefined);
|
|
131264
131378
|
}
|
|
131265
131379
|
}
|
|
131266
|
-
for (var
|
|
131267
|
-
var sourceFile = allSourceFiles_1[
|
|
131268
|
-
if (ts.isExternalOrCommonJsModule(sourceFile)) {
|
|
131380
|
+
for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
|
|
131381
|
+
var sourceFile = allSourceFiles_1[_c];
|
|
131382
|
+
if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
|
|
131269
131383
|
cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
|
|
131270
131384
|
}
|
|
131271
131385
|
}
|
|
131272
131386
|
}
|
|
131273
|
-
function getExportInfoMap(importingFile, host, program, cancellationToken) {
|
|
131387
|
+
function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
|
|
131274
131388
|
var _a, _b, _c, _d, _e;
|
|
131275
131389
|
var start = ts.timestamp();
|
|
131276
131390
|
// Pulling the AutoImportProvider project will trigger its updateGraph if pending,
|
|
@@ -131290,7 +131404,7 @@ var ts;
|
|
|
131290
131404
|
var compilerOptions = program.getCompilerOptions();
|
|
131291
131405
|
var moduleCount = 0;
|
|
131292
131406
|
try {
|
|
131293
|
-
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131407
|
+
forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131294
131408
|
if (++moduleCount % 100 === 0)
|
|
131295
131409
|
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
131296
131410
|
var seenExports = new ts.Map();
|
|
@@ -133686,7 +133800,7 @@ var ts;
|
|
|
133686
133800
|
if (!previousResponse)
|
|
133687
133801
|
return undefined;
|
|
133688
133802
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
133689
|
-
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
133803
|
+
var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
|
|
133690
133804
|
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
133691
133805
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133692
133806
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
@@ -135395,7 +135509,7 @@ var ts;
|
|
|
135395
135509
|
}
|
|
135396
135510
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
135397
135511
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
135398
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
135512
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
135399
135513
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
135400
135514
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
135401
135515
|
var symbol = _a[_i];
|
|
@@ -135498,7 +135612,7 @@ var ts;
|
|
|
135498
135612
|
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
|
|
135499
135613
|
"";
|
|
135500
135614
|
var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
135501
|
-
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
135615
|
+
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
|
|
135502
135616
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
135503
135617
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
135504
135618
|
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
@@ -144733,10 +144847,10 @@ var ts;
|
|
|
144733
144847
|
(function (ts) {
|
|
144734
144848
|
var Rename;
|
|
144735
144849
|
(function (Rename) {
|
|
144736
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144850
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144737
144851
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144738
144852
|
if (nodeIsEligibleForRename(node)) {
|
|
144739
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144853
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144740
144854
|
if (renameInfo) {
|
|
144741
144855
|
return renameInfo;
|
|
144742
144856
|
}
|
|
@@ -144744,7 +144858,7 @@ var ts;
|
|
|
144744
144858
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144745
144859
|
}
|
|
144746
144860
|
Rename.getRenameInfo = getRenameInfo;
|
|
144747
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144861
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144748
144862
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144749
144863
|
if (!symbol) {
|
|
144750
144864
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144772,7 +144886,12 @@ var ts;
|
|
|
144772
144886
|
return undefined;
|
|
144773
144887
|
}
|
|
144774
144888
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144775
|
-
return
|
|
144889
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144890
|
+
}
|
|
144891
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144892
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144893
|
+
if (wouldRenameNodeModules) {
|
|
144894
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144776
144895
|
}
|
|
144777
144896
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144778
144897
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144786,6 +144905,49 @@ var ts;
|
|
|
144786
144905
|
var sourceFile = declaration.getSourceFile();
|
|
144787
144906
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144788
144907
|
}
|
|
144908
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144909
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144910
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144911
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144912
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144913
|
+
}
|
|
144914
|
+
}
|
|
144915
|
+
var declarations = symbol.declarations;
|
|
144916
|
+
if (!declarations) {
|
|
144917
|
+
return undefined;
|
|
144918
|
+
}
|
|
144919
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144920
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144921
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144922
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144923
|
+
}
|
|
144924
|
+
else {
|
|
144925
|
+
return undefined;
|
|
144926
|
+
}
|
|
144927
|
+
}
|
|
144928
|
+
// original source file is in node_modules
|
|
144929
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144930
|
+
var declaration = declarations_4[_i];
|
|
144931
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144932
|
+
if (declPackage) {
|
|
144933
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144934
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144935
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144936
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144937
|
+
}
|
|
144938
|
+
}
|
|
144939
|
+
}
|
|
144940
|
+
}
|
|
144941
|
+
return undefined;
|
|
144942
|
+
}
|
|
144943
|
+
function getPackagePathComponents(filePath) {
|
|
144944
|
+
var components = ts.getPathComponents(filePath);
|
|
144945
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144946
|
+
if (nodeModulesIdx === -1) {
|
|
144947
|
+
return undefined;
|
|
144948
|
+
}
|
|
144949
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144950
|
+
}
|
|
144789
144951
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144790
144952
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144791
144953
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -154647,7 +154809,7 @@ var ts;
|
|
|
154647
154809
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
154648
154810
|
return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
|
|
154649
154811
|
});
|
|
154650
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154812
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154651
154813
|
var checker = program.getTypeChecker();
|
|
154652
154814
|
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
|
154653
154815
|
if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
|
|
@@ -155116,7 +155278,7 @@ var ts;
|
|
|
155116
155278
|
originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
155117
155279
|
}
|
|
155118
155280
|
}
|
|
155119
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155281
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155120
155282
|
var checker = program.getTypeChecker();
|
|
155121
155283
|
cancellationToken.throwIfCancellationRequested();
|
|
155122
155284
|
var compilerOptions = program.getCompilerOptions();
|
|
@@ -161825,11 +161987,11 @@ var ts;
|
|
|
161825
161987
|
}
|
|
161826
161988
|
}
|
|
161827
161989
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161828
|
-
var
|
|
161990
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161829
161991
|
var numInitializers = 0;
|
|
161830
161992
|
var lastInitializer = void 0;
|
|
161831
|
-
for (var _i = 0,
|
|
161832
|
-
var declaration =
|
|
161993
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
161994
|
+
var declaration = declarations_5[_i];
|
|
161833
161995
|
if (declaration.initializer) {
|
|
161834
161996
|
numInitializers++;
|
|
161835
161997
|
lastInitializer = declaration.initializer;
|
|
@@ -165966,8 +166128,8 @@ var ts;
|
|
|
165966
166128
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165967
166129
|
}
|
|
165968
166130
|
};
|
|
165969
|
-
for (var _i = 0,
|
|
165970
|
-
var declaration =
|
|
166131
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166132
|
+
var declaration = declarations_7[_i];
|
|
165971
166133
|
_loop_21(declaration);
|
|
165972
166134
|
}
|
|
165973
166135
|
}
|
|
@@ -165993,8 +166155,8 @@ var ts;
|
|
|
165993
166155
|
if (inheritedDocs)
|
|
165994
166156
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
165995
166157
|
};
|
|
165996
|
-
for (var _i = 0,
|
|
165997
|
-
var declaration =
|
|
166158
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166159
|
+
var declaration = declarations_8[_i];
|
|
165998
166160
|
_loop_22(declaration);
|
|
165999
166161
|
}
|
|
166000
166162
|
}
|
|
@@ -167571,9 +167733,9 @@ var ts;
|
|
|
167571
167733
|
return ts.stringContains(path, "/node_modules/");
|
|
167572
167734
|
}
|
|
167573
167735
|
}
|
|
167574
|
-
function getRenameInfo(fileName, position,
|
|
167736
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
167575
167737
|
synchronizeHostData();
|
|
167576
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167738
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
167577
167739
|
}
|
|
167578
167740
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
167579
167741
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168939,9 +169101,9 @@ var ts;
|
|
|
168939
169101
|
var _this = this;
|
|
168940
169102
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168941
169103
|
};
|
|
168942
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
169104
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168943
169105
|
var _this = this;
|
|
168944
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
169106
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168945
169107
|
};
|
|
168946
169108
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168947
169109
|
var _this = this;
|
|
@@ -176692,7 +176854,7 @@ var ts;
|
|
|
176692
176854
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
176693
176855
|
}
|
|
176694
176856
|
function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
|
|
176695
|
-
var _a;
|
|
176857
|
+
var _a, _b;
|
|
176696
176858
|
var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
|
|
176697
176859
|
/*isForRename*/ false, function (project, position) {
|
|
176698
176860
|
logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
|
|
@@ -176712,7 +176874,7 @@ var ts;
|
|
|
176712
176874
|
// have started the other project searches from related symbols. Propagate the
|
|
176713
176875
|
// correct results to all other projects.
|
|
176714
176876
|
var defaultProjectResults = perProjectResults.get(defaultProject);
|
|
176715
|
-
if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null ||
|
|
176877
|
+
if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
|
|
176716
176878
|
// Clear all isDefinition properties
|
|
176717
176879
|
perProjectResults.forEach(function (projectResults) {
|
|
176718
176880
|
for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
|
|
@@ -176729,8 +176891,8 @@ var ts;
|
|
|
176729
176891
|
var knownSymbolSpans_1 = createDocumentSpanSet();
|
|
176730
176892
|
for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
|
|
176731
176893
|
var referencedSymbol = defaultProjectResults_1[_i];
|
|
176732
|
-
for (var
|
|
176733
|
-
var ref = _c
|
|
176894
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
176895
|
+
var ref = _d[_c];
|
|
176734
176896
|
if (ref.isDefinition) {
|
|
176735
176897
|
knownSymbolSpans_1.add(ref);
|
|
176736
176898
|
// One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
|
|
@@ -176849,23 +177011,30 @@ var ts;
|
|
|
176849
177011
|
var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
|
|
176850
177012
|
defaultDefinition :
|
|
176851
177013
|
defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
|
|
176852
|
-
//
|
|
176853
|
-
//
|
|
176854
|
-
|
|
176855
|
-
var searchedProjects = new ts.Set();
|
|
177014
|
+
// The keys of resultsMap allow us to check which projects have already been searched, but we also
|
|
177015
|
+
// maintain a set of strings because that's what `loadAncestorProjectTree` wants.
|
|
177016
|
+
var searchedProjectKeys = new ts.Set();
|
|
176856
177017
|
onCancellation: while (queue.length) {
|
|
176857
177018
|
while (queue.length) {
|
|
176858
177019
|
if (cancellationToken.isCancellationRequested())
|
|
176859
177020
|
break onCancellation;
|
|
177021
|
+
var skipCount = 0;
|
|
177022
|
+
for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
|
|
177023
|
+
;
|
|
177024
|
+
if (skipCount === queue.length) {
|
|
177025
|
+
queue.length = 0;
|
|
177026
|
+
break;
|
|
177027
|
+
}
|
|
177028
|
+
if (skipCount > 0) {
|
|
177029
|
+
queue.splice(0, skipCount);
|
|
177030
|
+
}
|
|
177031
|
+
// NB: we may still skip if it's a project reference redirect
|
|
176860
177032
|
var _a = queue.shift(), project = _a.project, location = _a.location;
|
|
176861
177033
|
if (isLocationProjectReferenceRedirect(project, location))
|
|
176862
177034
|
continue;
|
|
176863
|
-
if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
|
|
176864
|
-
continue;
|
|
176865
177035
|
var projectResults = searchPosition(project, location);
|
|
176866
|
-
|
|
176867
|
-
|
|
176868
|
-
}
|
|
177036
|
+
resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
|
|
177037
|
+
searchedProjectKeys.add(getProjectKey(project));
|
|
176869
177038
|
}
|
|
176870
177039
|
// At this point, we know about all projects passed in as arguments and any projects in which
|
|
176871
177040
|
// `getResultsForPosition` has returned results. We expand that set to include any projects
|
|
@@ -176873,11 +177042,11 @@ var ts;
|
|
|
176873
177042
|
// containing `initialLocation`.
|
|
176874
177043
|
if (defaultDefinition) {
|
|
176875
177044
|
// This seems to mean "load all projects downstream from any member of `seenProjects`".
|
|
176876
|
-
projectService.loadAncestorProjectTree(
|
|
177045
|
+
projectService.loadAncestorProjectTree(searchedProjectKeys);
|
|
176877
177046
|
projectService.forEachEnabledProject(function (project) {
|
|
176878
177047
|
if (cancellationToken.isCancellationRequested())
|
|
176879
177048
|
return; // There's no mechanism for skipping the remaining projects
|
|
176880
|
-
if (
|
|
177049
|
+
if (resultsMap.has(project))
|
|
176881
177050
|
return; // Can loop forever without this (enqueue here, dequeue above, repeat)
|
|
176882
177051
|
var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
|
176883
177052
|
if (location) {
|
|
@@ -176888,9 +177057,10 @@ var ts;
|
|
|
176888
177057
|
}
|
|
176889
177058
|
// In the common case where there's only one project, return a simpler result to make
|
|
176890
177059
|
// it easier for the caller to skip post-processing.
|
|
176891
|
-
if (
|
|
177060
|
+
if (resultsMap.size === 1) {
|
|
176892
177061
|
var it = resultsMap.values().next();
|
|
176893
|
-
|
|
177062
|
+
ts.Debug.assert(!it.done);
|
|
177063
|
+
return it.value;
|
|
176894
177064
|
}
|
|
176895
177065
|
return resultsMap;
|
|
176896
177066
|
function searchPosition(project, location) {
|
|
@@ -176907,7 +177077,7 @@ var ts;
|
|
|
176907
177077
|
var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
|
|
176908
177078
|
for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
|
|
176909
177079
|
var project_1 = _a[_i];
|
|
176910
|
-
if (!project_1.isOrphan()) {
|
|
177080
|
+
if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
|
|
176911
177081
|
queue.push({ project: project_1, location: originalLocation });
|
|
176912
177082
|
}
|
|
176913
177083
|
}
|
|
@@ -176916,7 +177086,7 @@ var ts;
|
|
|
176916
177086
|
symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
|
|
176917
177087
|
for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
|
|
176918
177088
|
var symlinkedProject = symlinkedProjects_2[_i];
|
|
176919
|
-
if (!symlinkedProject.isOrphan()) {
|
|
177089
|
+
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
|
|
176920
177090
|
queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
|
|
176921
177091
|
}
|
|
176922
177092
|
}
|
|
@@ -178209,7 +178379,8 @@ var ts;
|
|
|
178209
178379
|
Session.prototype.getRenameInfo = function (args) {
|
|
178210
178380
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
178211
178381
|
var position = this.getPositionInFile(args, file);
|
|
178212
|
-
|
|
178382
|
+
var preferences = this.getPreferences(file);
|
|
178383
|
+
return project.getLanguageService().getRenameInfo(file, position, preferences);
|
|
178213
178384
|
};
|
|
178214
178385
|
Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
|
|
178215
178386
|
var _a;
|
|
@@ -178260,10 +178431,11 @@ var ts;
|
|
|
178260
178431
|
var position = this.getPositionInFile(args, file);
|
|
178261
178432
|
var projects = this.getProjects(args);
|
|
178262
178433
|
var defaultProject = this.getDefaultProject(args);
|
|
178263
|
-
var
|
|
178434
|
+
var preferences = this.getPreferences(file);
|
|
178435
|
+
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
178264
178436
|
if (!renameInfo.canRename)
|
|
178265
178437
|
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
178266
|
-
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments,
|
|
178438
|
+
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
|
|
178267
178439
|
if (!simplifiedResult)
|
|
178268
178440
|
return locations;
|
|
178269
178441
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|