@typescript-deploys/pr-build 4.8.0-pr-49554-2 → 4.8.0-pr-49627-10
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 +10 -1
- package/lib/de/diagnosticMessages.generated.json +10 -1
- package/lib/es/diagnosticMessages.generated.json +10 -1
- package/lib/fr/diagnosticMessages.generated.json +10 -1
- package/lib/it/diagnosticMessages.generated.json +10 -1
- package/lib/ja/diagnosticMessages.generated.json +10 -1
- package/lib/ko/diagnosticMessages.generated.json +10 -1
- package/lib/lib.dom.d.ts +128 -183
- package/lib/lib.dom.iterable.d.ts +1 -11
- package/lib/lib.es2017.intl.d.ts +16 -1
- package/lib/lib.es2021.intl.d.ts +4 -0
- package/lib/lib.es5.d.ts +12 -0
- package/lib/lib.webworker.d.ts +54 -27
- package/lib/lib.webworker.iterable.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +10 -1
- package/lib/protocol.d.ts +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +10 -1
- package/lib/ru/diagnosticMessages.generated.json +10 -1
- package/lib/tr/diagnosticMessages.generated.json +10 -1
- package/lib/tsc.js +153 -57
- package/lib/tsserver.js +330 -111
- package/lib/tsserverlibrary.d.ts +10 -0
- package/lib/tsserverlibrary.js +330 -111
- package/lib/typescript.d.ts +9 -0
- package/lib/typescript.js +298 -89
- package/lib/typescriptServices.d.ts +9 -0
- package/lib/typescriptServices.js +298 -89
- package/lib/typingsInstaller.js +205 -57
- package/lib/zh-cn/diagnosticMessages.generated.json +10 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +10 -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-insiders.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220622";
|
|
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);
|
|
@@ -49272,6 +49303,9 @@ var ts;
|
|
|
49272
49303
|
var markerSubType = createTypeParameter();
|
|
49273
49304
|
markerSubType.constraint = markerSuperType;
|
|
49274
49305
|
var markerOtherType = createTypeParameter();
|
|
49306
|
+
var markerSuperTypeForCheck = createTypeParameter();
|
|
49307
|
+
var markerSubTypeForCheck = createTypeParameter();
|
|
49308
|
+
markerSubTypeForCheck.constraint = markerSuperTypeForCheck;
|
|
49275
49309
|
var noTypePredicate = createTypePredicate(1 /* Identifier */, "<<unresolved>>", 0, anyType);
|
|
49276
49310
|
var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
|
|
49277
49311
|
var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */);
|
|
@@ -53099,7 +53133,7 @@ var ts;
|
|
|
53099
53133
|
}
|
|
53100
53134
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
|
|
53101
53135
|
type.flags & 262144 /* TypeParameter */ &&
|
|
53102
|
-
|
|
53136
|
+
typeParameterIsCachedOrNotAccessible(type, context)) {
|
|
53103
53137
|
var name_2 = typeParameterToName(type, context);
|
|
53104
53138
|
context.approximateLength += ts.idText(name_2).length;
|
|
53105
53139
|
return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name_2)), /*typeArguments*/ undefined);
|
|
@@ -53108,8 +53142,8 @@ var ts;
|
|
|
53108
53142
|
if (type.symbol) {
|
|
53109
53143
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
53110
53144
|
}
|
|
53111
|
-
var name = (type ===
|
|
53112
|
-
(type ===
|
|
53145
|
+
var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ?
|
|
53146
|
+
(type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?";
|
|
53113
53147
|
return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined);
|
|
53114
53148
|
}
|
|
53115
53149
|
if (type.flags & 1048576 /* Union */ && type.origin) {
|
|
@@ -53804,6 +53838,23 @@ var ts;
|
|
|
53804
53838
|
else {
|
|
53805
53839
|
typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
|
|
53806
53840
|
}
|
|
53841
|
+
// For regular function/method declarations, the enclosing declaration will already be signature.declaration,
|
|
53842
|
+
// so this is a no-op, but for arrow functions and function expressions, the enclosing declaration will be
|
|
53843
|
+
// the declaration that the arrow function / function expression is assigned to, which is not the right scope.
|
|
53844
|
+
//
|
|
53845
|
+
// If the parameters or return type include "typeof globalThis.paramName", using the wrong scope will lead
|
|
53846
|
+
// us to believe that we can emit "typeof paramName" instead, even though that would refer to the parameter,
|
|
53847
|
+
// not the global. Make sure we are in the right scope by changing the enclosingDeclaration to the function.
|
|
53848
|
+
//
|
|
53849
|
+
// We check that this signature's declaration is within the existing enclosing declaration so we don't pull
|
|
53850
|
+
// in types from other files; if it is outside of the enclosing declaration, then we shouldn't be able to
|
|
53851
|
+
// access those parameter types via typeof anyway. The declaration should also not be in a JS file; those can
|
|
53852
|
+
// only be typed via JSDoc, but JSDoc annotations appear outside of the function and therefore are not in
|
|
53853
|
+
// the function's scope, unlike true type annotations.
|
|
53854
|
+
var saveEnclosingDeclaration = context.enclosingDeclaration;
|
|
53855
|
+
if (signature.declaration && !ts.isInJSFile(signature.declaration) && saveEnclosingDeclaration && ts.findAncestor(signature.declaration, function (n) { return n === saveEnclosingDeclaration; })) {
|
|
53856
|
+
context.enclosingDeclaration = signature.declaration;
|
|
53857
|
+
}
|
|
53807
53858
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53808
53859
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53809
53860
|
var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
|
|
@@ -53855,6 +53906,7 @@ var ts;
|
|
|
53855
53906
|
if (typeArguments) {
|
|
53856
53907
|
node.typeArguments = ts.factory.createNodeArray(typeArguments);
|
|
53857
53908
|
}
|
|
53909
|
+
context.enclosingDeclaration = saveEnclosingDeclaration;
|
|
53858
53910
|
return node;
|
|
53859
53911
|
}
|
|
53860
53912
|
function tryGetThisParameterDeclaration(signature, context) {
|
|
@@ -54284,14 +54336,27 @@ var ts;
|
|
|
54284
54336
|
}
|
|
54285
54337
|
return false;
|
|
54286
54338
|
}
|
|
54287
|
-
|
|
54288
|
-
|
|
54339
|
+
// Returns true if this type parameter should be converted to a name via typeParameterToName,
|
|
54340
|
+
// either because it is not accessible, or because it's a use of a type variable that has
|
|
54341
|
+
// already been rewritten by typeParameterToName and so needs that rewritten name.
|
|
54342
|
+
function typeParameterIsCachedOrNotAccessible(type, context) {
|
|
54343
|
+
return !!getCachedTypeParameterName(type, context) || !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration);
|
|
54344
|
+
}
|
|
54345
|
+
function getCachedTypeParameterName(type, context) {
|
|
54289
54346
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) {
|
|
54290
54347
|
var cached = context.typeParameterNames.get(getTypeId(type));
|
|
54291
54348
|
if (cached) {
|
|
54292
54349
|
return cached;
|
|
54293
54350
|
}
|
|
54294
54351
|
}
|
|
54352
|
+
return undefined;
|
|
54353
|
+
}
|
|
54354
|
+
function typeParameterToName(type, context) {
|
|
54355
|
+
var _a, _b;
|
|
54356
|
+
var cached = getCachedTypeParameterName(type, context);
|
|
54357
|
+
if (cached) {
|
|
54358
|
+
return cached;
|
|
54359
|
+
}
|
|
54295
54360
|
var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true);
|
|
54296
54361
|
if (!(result.kind & 79 /* Identifier */)) {
|
|
54297
54362
|
return ts.factory.createIdentifier("(Missing type parameter)");
|
|
@@ -54524,7 +54589,7 @@ var ts;
|
|
|
54524
54589
|
}
|
|
54525
54590
|
if (ts.isIdentifier(node)) {
|
|
54526
54591
|
var type = getDeclaredTypeOfSymbol(sym);
|
|
54527
|
-
var name = sym.flags & 262144 /* TypeParameter */ &&
|
|
54592
|
+
var name = sym.flags & 262144 /* TypeParameter */ && typeParameterIsCachedOrNotAccessible(type, context) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
|
|
54528
54593
|
name.symbol = sym; // for quickinfo, which uses identifier symbol information
|
|
54529
54594
|
return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
54530
54595
|
}
|
|
@@ -59554,7 +59619,7 @@ var ts;
|
|
|
59554
59619
|
}
|
|
59555
59620
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59556
59621
|
var constraint = getBaseConstraint(t.type);
|
|
59557
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59622
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59558
59623
|
}
|
|
59559
59624
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59560
59625
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62524,9 +62589,12 @@ var ts;
|
|
|
62524
62589
|
}
|
|
62525
62590
|
function getStringMappingType(symbol, type) {
|
|
62526
62591
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62527
|
-
|
|
62528
|
-
|
|
62529
|
-
|
|
62592
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62593
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62594
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62595
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62596
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62597
|
+
type;
|
|
62530
62598
|
}
|
|
62531
62599
|
function applyStringMapping(symbol, str) {
|
|
62532
62600
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62537,6 +62605,15 @@ var ts;
|
|
|
62537
62605
|
}
|
|
62538
62606
|
return str;
|
|
62539
62607
|
}
|
|
62608
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62609
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62610
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62611
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62612
|
+
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];
|
|
62613
|
+
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];
|
|
62614
|
+
}
|
|
62615
|
+
return [texts, types];
|
|
62616
|
+
}
|
|
62540
62617
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62541
62618
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62542
62619
|
var result = stringMappingTypes.get(id);
|
|
@@ -62778,7 +62855,7 @@ var ts;
|
|
|
62778
62855
|
accessNode;
|
|
62779
62856
|
}
|
|
62780
62857
|
function isPatternLiteralPlaceholderType(type) {
|
|
62781
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62858
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62782
62859
|
}
|
|
62783
62860
|
function isPatternLiteralType(type) {
|
|
62784
62861
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -64778,7 +64855,7 @@ var ts;
|
|
|
64778
64855
|
});
|
|
64779
64856
|
}
|
|
64780
64857
|
function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
|
|
64781
|
-
if (target.flags & 131068 /* Primitive */)
|
|
64858
|
+
if (target.flags & (131068 /* Primitive */ | 131072 /* Never */))
|
|
64782
64859
|
return false;
|
|
64783
64860
|
if (isTupleLikeType(source)) {
|
|
64784
64861
|
return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
|
|
@@ -64845,7 +64922,7 @@ var ts;
|
|
|
64845
64922
|
});
|
|
64846
64923
|
}
|
|
64847
64924
|
function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
|
|
64848
|
-
if (target.flags & 131068 /* Primitive */)
|
|
64925
|
+
if (target.flags & (131068 /* Primitive */ | 131072 /* Never */))
|
|
64849
64926
|
return false;
|
|
64850
64927
|
return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
|
|
64851
64928
|
}
|
|
@@ -65444,7 +65521,7 @@ var ts;
|
|
|
65444
65521
|
ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
|
|
65445
65522
|
generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
|
|
65446
65523
|
}
|
|
65447
|
-
if (target.flags & 262144 /* TypeParameter */ && target !==
|
|
65524
|
+
if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) {
|
|
65448
65525
|
var constraint = getBaseConstraintOfType(target);
|
|
65449
65526
|
var needsOriginalSource = void 0;
|
|
65450
65527
|
if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
|
|
@@ -66490,6 +66567,13 @@ var ts;
|
|
|
66490
66567
|
return -1 /* True */;
|
|
66491
66568
|
}
|
|
66492
66569
|
}
|
|
66570
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66571
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66572
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66573
|
+
return -1 /* True */;
|
|
66574
|
+
}
|
|
66575
|
+
}
|
|
66576
|
+
}
|
|
66493
66577
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66494
66578
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66495
66579
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66533,7 +66617,10 @@ var ts;
|
|
|
66533
66617
|
}
|
|
66534
66618
|
}
|
|
66535
66619
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66536
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66620
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66621
|
+
if (source.symbol !== target.symbol) {
|
|
66622
|
+
return 0 /* False */;
|
|
66623
|
+
}
|
|
66537
66624
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66538
66625
|
resetErrorInfo(saveErrorInfo);
|
|
66539
66626
|
return result;
|
|
@@ -67458,7 +67545,7 @@ var ts;
|
|
|
67458
67545
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67459
67546
|
}
|
|
67460
67547
|
}
|
|
67461
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67548
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67462
67549
|
}
|
|
67463
67550
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67464
67551
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68929,6 +69016,31 @@ var ts;
|
|
|
68929
69016
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68930
69017
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68931
69018
|
}
|
|
69019
|
+
function isMemberOfStringMapping(source, target) {
|
|
69020
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
69021
|
+
return true;
|
|
69022
|
+
}
|
|
69023
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
69024
|
+
return isTypeAssignableTo(source, target);
|
|
69025
|
+
}
|
|
69026
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
69027
|
+
// We need to see whether applying the same mappings of the target
|
|
69028
|
+
// onto the source would produce an identical type *and* that
|
|
69029
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
69030
|
+
//
|
|
69031
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
69032
|
+
// and the source is compatible with the unmapped target, then they must
|
|
69033
|
+
// still reside in the same domain.
|
|
69034
|
+
var mappingStack = [];
|
|
69035
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
69036
|
+
mappingStack.unshift(target.symbol);
|
|
69037
|
+
target = target.type;
|
|
69038
|
+
}
|
|
69039
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
69040
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
69041
|
+
}
|
|
69042
|
+
return false;
|
|
69043
|
+
}
|
|
68932
69044
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68933
69045
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68934
69046
|
return true;
|
|
@@ -68937,7 +69049,8 @@ var ts;
|
|
|
68937
69049
|
var value = source.value;
|
|
68938
69050
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68939
69051
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68940
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
69052
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
69053
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68941
69054
|
}
|
|
68942
69055
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68943
69056
|
var texts = source.texts;
|
|
@@ -76755,6 +76868,15 @@ var ts;
|
|
|
76755
76868
|
if (result) {
|
|
76756
76869
|
return result;
|
|
76757
76870
|
}
|
|
76871
|
+
result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
76872
|
+
// Preemptively cache the result; getResolvedSignature will do this after we return, but
|
|
76873
|
+
// we need to ensure that the result is present for the error checks below so that if
|
|
76874
|
+
// this signature is encountered again, we handle the circularity (rather than producing a
|
|
76875
|
+
// different result which may produce no errors and assert). Callers of getResolvedSignature
|
|
76876
|
+
// don't hit this issue because they only observe this result after it's had a chance to
|
|
76877
|
+
// be cached, but the error reporting code below executes before getResolvedSignature sets
|
|
76878
|
+
// resolvedSignature.
|
|
76879
|
+
getNodeLinks(node).resolvedSignature = result;
|
|
76758
76880
|
// No signatures were applicable. Now report errors based on the last applicable signature with
|
|
76759
76881
|
// no arguments excluded from assignability checks.
|
|
76760
76882
|
// If candidate is undefined, it means that no candidates had a suitable arity. In that case,
|
|
@@ -76846,7 +76968,7 @@ var ts;
|
|
|
76846
76968
|
}
|
|
76847
76969
|
}
|
|
76848
76970
|
}
|
|
76849
|
-
return
|
|
76971
|
+
return result;
|
|
76850
76972
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
76851
76973
|
var _a, _b;
|
|
76852
76974
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -80649,8 +80771,8 @@ var ts;
|
|
|
80649
80771
|
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
80650
80772
|
}
|
|
80651
80773
|
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
80652
|
-
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ?
|
|
80653
|
-
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ?
|
|
80774
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
|
|
80775
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
|
|
80654
80776
|
var saveVarianceTypeParameter = typeParameter;
|
|
80655
80777
|
varianceTypeParameter = typeParameter;
|
|
80656
80778
|
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
@@ -85816,6 +85938,7 @@ var ts;
|
|
|
85816
85938
|
return true;
|
|
85817
85939
|
}
|
|
85818
85940
|
function checkAliasSymbol(node) {
|
|
85941
|
+
var _a, _b, _c, _d, _e;
|
|
85819
85942
|
var symbol = getSymbolOfNode(node);
|
|
85820
85943
|
var target = resolveAlias(symbol);
|
|
85821
85944
|
if (target !== unknownSymbol) {
|
|
@@ -85826,6 +85949,31 @@ var ts;
|
|
|
85826
85949
|
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
|
85827
85950
|
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
|
85828
85951
|
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
|
85952
|
+
// A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
|
|
85953
|
+
if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
|
|
85954
|
+
var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
|
|
85955
|
+
ts.isNamedDeclaration(node) ? node.name :
|
|
85956
|
+
node;
|
|
85957
|
+
ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
|
|
85958
|
+
if (node.kind === 275 /* ExportSpecifier */) {
|
|
85959
|
+
var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
85960
|
+
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);
|
|
85961
|
+
if (alreadyExportedSymbol === target) {
|
|
85962
|
+
var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
|
|
85963
|
+
if (exportingDeclaration) {
|
|
85964
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
|
|
85965
|
+
}
|
|
85966
|
+
}
|
|
85967
|
+
}
|
|
85968
|
+
else {
|
|
85969
|
+
ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
|
|
85970
|
+
var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
|
|
85971
|
+
var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
|
|
85972
|
+
var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
85973
|
+
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);
|
|
85974
|
+
}
|
|
85975
|
+
return;
|
|
85976
|
+
}
|
|
85829
85977
|
var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
|
|
85830
85978
|
(symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
|
|
85831
85979
|
(symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
@@ -131245,32 +131393,41 @@ var ts;
|
|
|
131245
131393
|
|| ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
|
|
131246
131394
|
|| (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
|
|
131247
131395
|
}
|
|
131248
|
-
function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
|
|
131396
|
+
function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
|
|
131249
131397
|
var _a, _b;
|
|
131250
|
-
|
|
131398
|
+
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
|
|
131399
|
+
var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
|
|
131400
|
+
// The client is expected to send rooted path specs since we don't know
|
|
131401
|
+
// what directory a relative path is relative to.
|
|
131402
|
+
var pattern = ts.getPatternFromSpec(spec, "", "exclude");
|
|
131403
|
+
return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
|
|
131404
|
+
});
|
|
131405
|
+
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
|
|
131251
131406
|
var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
131252
131407
|
if (autoImportProvider) {
|
|
131253
131408
|
var start = ts.timestamp();
|
|
131254
|
-
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131409
|
+
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131255
131410
|
(_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
|
|
131256
131411
|
}
|
|
131257
131412
|
}
|
|
131258
131413
|
ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
|
|
131259
|
-
function forEachExternalModule(checker, allSourceFiles, cb) {
|
|
131260
|
-
|
|
131261
|
-
|
|
131262
|
-
|
|
131414
|
+
function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
|
|
131415
|
+
var _a;
|
|
131416
|
+
var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
|
|
131417
|
+
for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
|
|
131418
|
+
var ambient = _b[_i];
|
|
131419
|
+
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
131420
|
cb(ambient, /*sourceFile*/ undefined);
|
|
131264
131421
|
}
|
|
131265
131422
|
}
|
|
131266
|
-
for (var
|
|
131267
|
-
var sourceFile = allSourceFiles_1[
|
|
131268
|
-
if (ts.isExternalOrCommonJsModule(sourceFile)) {
|
|
131423
|
+
for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
|
|
131424
|
+
var sourceFile = allSourceFiles_1[_c];
|
|
131425
|
+
if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
|
|
131269
131426
|
cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
|
|
131270
131427
|
}
|
|
131271
131428
|
}
|
|
131272
131429
|
}
|
|
131273
|
-
function getExportInfoMap(importingFile, host, program, cancellationToken) {
|
|
131430
|
+
function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
|
|
131274
131431
|
var _a, _b, _c, _d, _e;
|
|
131275
131432
|
var start = ts.timestamp();
|
|
131276
131433
|
// Pulling the AutoImportProvider project will trigger its updateGraph if pending,
|
|
@@ -131290,7 +131447,7 @@ var ts;
|
|
|
131290
131447
|
var compilerOptions = program.getCompilerOptions();
|
|
131291
131448
|
var moduleCount = 0;
|
|
131292
131449
|
try {
|
|
131293
|
-
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131450
|
+
forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131294
131451
|
if (++moduleCount % 100 === 0)
|
|
131295
131452
|
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
131296
131453
|
var seenExports = new ts.Map();
|
|
@@ -133686,7 +133843,7 @@ var ts;
|
|
|
133686
133843
|
if (!previousResponse)
|
|
133687
133844
|
return undefined;
|
|
133688
133845
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
133689
|
-
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
133846
|
+
var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
|
|
133690
133847
|
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
133691
133848
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133692
133849
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
@@ -135395,7 +135552,7 @@ var ts;
|
|
|
135395
135552
|
}
|
|
135396
135553
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
135397
135554
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
135398
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
135555
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
135399
135556
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
135400
135557
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
135401
135558
|
var symbol = _a[_i];
|
|
@@ -135498,7 +135655,7 @@ var ts;
|
|
|
135498
135655
|
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
|
|
135499
135656
|
"";
|
|
135500
135657
|
var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
135501
|
-
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
135658
|
+
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
|
|
135502
135659
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
135503
135660
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
135504
135661
|
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
@@ -136698,6 +136855,10 @@ var ts;
|
|
|
136698
136855
|
}
|
|
136699
136856
|
break;
|
|
136700
136857
|
case 79 /* Identifier */: {
|
|
136858
|
+
var originalKeywordKind = location.originalKeywordKind;
|
|
136859
|
+
if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) {
|
|
136860
|
+
return undefined;
|
|
136861
|
+
}
|
|
136701
136862
|
// class c { public prop = c| }
|
|
136702
136863
|
if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) {
|
|
136703
136864
|
return undefined;
|
|
@@ -144733,10 +144894,10 @@ var ts;
|
|
|
144733
144894
|
(function (ts) {
|
|
144734
144895
|
var Rename;
|
|
144735
144896
|
(function (Rename) {
|
|
144736
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144897
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144737
144898
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144738
144899
|
if (nodeIsEligibleForRename(node)) {
|
|
144739
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144900
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144740
144901
|
if (renameInfo) {
|
|
144741
144902
|
return renameInfo;
|
|
144742
144903
|
}
|
|
@@ -144744,7 +144905,7 @@ var ts;
|
|
|
144744
144905
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144745
144906
|
}
|
|
144746
144907
|
Rename.getRenameInfo = getRenameInfo;
|
|
144747
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144908
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144748
144909
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144749
144910
|
if (!symbol) {
|
|
144750
144911
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144772,7 +144933,12 @@ var ts;
|
|
|
144772
144933
|
return undefined;
|
|
144773
144934
|
}
|
|
144774
144935
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144775
|
-
return
|
|
144936
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144937
|
+
}
|
|
144938
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144939
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144940
|
+
if (wouldRenameNodeModules) {
|
|
144941
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144776
144942
|
}
|
|
144777
144943
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144778
144944
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144786,6 +144952,49 @@ var ts;
|
|
|
144786
144952
|
var sourceFile = declaration.getSourceFile();
|
|
144787
144953
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144788
144954
|
}
|
|
144955
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144956
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144957
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144958
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144959
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144960
|
+
}
|
|
144961
|
+
}
|
|
144962
|
+
var declarations = symbol.declarations;
|
|
144963
|
+
if (!declarations) {
|
|
144964
|
+
return undefined;
|
|
144965
|
+
}
|
|
144966
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144967
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144968
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144969
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144970
|
+
}
|
|
144971
|
+
else {
|
|
144972
|
+
return undefined;
|
|
144973
|
+
}
|
|
144974
|
+
}
|
|
144975
|
+
// original source file is in node_modules
|
|
144976
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144977
|
+
var declaration = declarations_4[_i];
|
|
144978
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144979
|
+
if (declPackage) {
|
|
144980
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144981
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144982
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144983
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144984
|
+
}
|
|
144985
|
+
}
|
|
144986
|
+
}
|
|
144987
|
+
}
|
|
144988
|
+
return undefined;
|
|
144989
|
+
}
|
|
144990
|
+
function getPackagePathComponents(filePath) {
|
|
144991
|
+
var components = ts.getPathComponents(filePath);
|
|
144992
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144993
|
+
if (nodeModulesIdx === -1) {
|
|
144994
|
+
return undefined;
|
|
144995
|
+
}
|
|
144996
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144997
|
+
}
|
|
144789
144998
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144790
144999
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144791
145000
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -154647,7 +154856,7 @@ var ts;
|
|
|
154647
154856
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
154648
154857
|
return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
|
|
154649
154858
|
});
|
|
154650
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154859
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154651
154860
|
var checker = program.getTypeChecker();
|
|
154652
154861
|
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
|
154653
154862
|
if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
|
|
@@ -155116,7 +155325,7 @@ var ts;
|
|
|
155116
155325
|
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
155326
|
}
|
|
155118
155327
|
}
|
|
155119
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155328
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155120
155329
|
var checker = program.getTypeChecker();
|
|
155121
155330
|
cancellationToken.throwIfCancellationRequested();
|
|
155122
155331
|
var compilerOptions = program.getCompilerOptions();
|
|
@@ -161834,11 +162043,11 @@ var ts;
|
|
|
161834
162043
|
}
|
|
161835
162044
|
}
|
|
161836
162045
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161837
|
-
var
|
|
162046
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161838
162047
|
var numInitializers = 0;
|
|
161839
162048
|
var lastInitializer = void 0;
|
|
161840
|
-
for (var _i = 0,
|
|
161841
|
-
var declaration =
|
|
162049
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
162050
|
+
var declaration = declarations_5[_i];
|
|
161842
162051
|
if (declaration.initializer) {
|
|
161843
162052
|
numInitializers++;
|
|
161844
162053
|
lastInitializer = declaration.initializer;
|
|
@@ -165975,8 +166184,8 @@ var ts;
|
|
|
165975
166184
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165976
166185
|
}
|
|
165977
166186
|
};
|
|
165978
|
-
for (var _i = 0,
|
|
165979
|
-
var declaration =
|
|
166187
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166188
|
+
var declaration = declarations_7[_i];
|
|
165980
166189
|
_loop_21(declaration);
|
|
165981
166190
|
}
|
|
165982
166191
|
}
|
|
@@ -166002,8 +166211,8 @@ var ts;
|
|
|
166002
166211
|
if (inheritedDocs)
|
|
166003
166212
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
166004
166213
|
};
|
|
166005
|
-
for (var _i = 0,
|
|
166006
|
-
var declaration =
|
|
166214
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166215
|
+
var declaration = declarations_8[_i];
|
|
166007
166216
|
_loop_22(declaration);
|
|
166008
166217
|
}
|
|
166009
166218
|
}
|
|
@@ -167580,9 +167789,9 @@ var ts;
|
|
|
167580
167789
|
return ts.stringContains(path, "/node_modules/");
|
|
167581
167790
|
}
|
|
167582
167791
|
}
|
|
167583
|
-
function getRenameInfo(fileName, position,
|
|
167792
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
167584
167793
|
synchronizeHostData();
|
|
167585
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167794
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
167586
167795
|
}
|
|
167587
167796
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
167588
167797
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168948,9 +169157,9 @@ var ts;
|
|
|
168948
169157
|
var _this = this;
|
|
168949
169158
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168950
169159
|
};
|
|
168951
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
169160
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168952
169161
|
var _this = this;
|
|
168953
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
169162
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168954
169163
|
};
|
|
168955
169164
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168956
169165
|
var _this = this;
|
|
@@ -176701,7 +176910,7 @@ var ts;
|
|
|
176701
176910
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
176702
176911
|
}
|
|
176703
176912
|
function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
|
|
176704
|
-
var _a;
|
|
176913
|
+
var _a, _b;
|
|
176705
176914
|
var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
|
|
176706
176915
|
/*isForRename*/ false, function (project, position) {
|
|
176707
176916
|
logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
|
|
@@ -176721,7 +176930,7 @@ var ts;
|
|
|
176721
176930
|
// have started the other project searches from related symbols. Propagate the
|
|
176722
176931
|
// correct results to all other projects.
|
|
176723
176932
|
var defaultProjectResults = perProjectResults.get(defaultProject);
|
|
176724
|
-
if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null ||
|
|
176933
|
+
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) {
|
|
176725
176934
|
// Clear all isDefinition properties
|
|
176726
176935
|
perProjectResults.forEach(function (projectResults) {
|
|
176727
176936
|
for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
|
|
@@ -176738,8 +176947,8 @@ var ts;
|
|
|
176738
176947
|
var knownSymbolSpans_1 = createDocumentSpanSet();
|
|
176739
176948
|
for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
|
|
176740
176949
|
var referencedSymbol = defaultProjectResults_1[_i];
|
|
176741
|
-
for (var
|
|
176742
|
-
var ref = _c
|
|
176950
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
176951
|
+
var ref = _d[_c];
|
|
176743
176952
|
if (ref.isDefinition) {
|
|
176744
176953
|
knownSymbolSpans_1.add(ref);
|
|
176745
176954
|
// One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
|
|
@@ -176858,23 +177067,30 @@ var ts;
|
|
|
176858
177067
|
var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
|
|
176859
177068
|
defaultDefinition :
|
|
176860
177069
|
defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
|
|
176861
|
-
//
|
|
176862
|
-
//
|
|
176863
|
-
|
|
176864
|
-
var searchedProjects = new ts.Set();
|
|
177070
|
+
// The keys of resultsMap allow us to check which projects have already been searched, but we also
|
|
177071
|
+
// maintain a set of strings because that's what `loadAncestorProjectTree` wants.
|
|
177072
|
+
var searchedProjectKeys = new ts.Set();
|
|
176865
177073
|
onCancellation: while (queue.length) {
|
|
176866
177074
|
while (queue.length) {
|
|
176867
177075
|
if (cancellationToken.isCancellationRequested())
|
|
176868
177076
|
break onCancellation;
|
|
177077
|
+
var skipCount = 0;
|
|
177078
|
+
for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
|
|
177079
|
+
;
|
|
177080
|
+
if (skipCount === queue.length) {
|
|
177081
|
+
queue.length = 0;
|
|
177082
|
+
break;
|
|
177083
|
+
}
|
|
177084
|
+
if (skipCount > 0) {
|
|
177085
|
+
queue.splice(0, skipCount);
|
|
177086
|
+
}
|
|
177087
|
+
// NB: we may still skip if it's a project reference redirect
|
|
176869
177088
|
var _a = queue.shift(), project = _a.project, location = _a.location;
|
|
176870
177089
|
if (isLocationProjectReferenceRedirect(project, location))
|
|
176871
177090
|
continue;
|
|
176872
|
-
if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
|
|
176873
|
-
continue;
|
|
176874
177091
|
var projectResults = searchPosition(project, location);
|
|
176875
|
-
|
|
176876
|
-
|
|
176877
|
-
}
|
|
177092
|
+
resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
|
|
177093
|
+
searchedProjectKeys.add(getProjectKey(project));
|
|
176878
177094
|
}
|
|
176879
177095
|
// At this point, we know about all projects passed in as arguments and any projects in which
|
|
176880
177096
|
// `getResultsForPosition` has returned results. We expand that set to include any projects
|
|
@@ -176882,11 +177098,11 @@ var ts;
|
|
|
176882
177098
|
// containing `initialLocation`.
|
|
176883
177099
|
if (defaultDefinition) {
|
|
176884
177100
|
// This seems to mean "load all projects downstream from any member of `seenProjects`".
|
|
176885
|
-
projectService.loadAncestorProjectTree(
|
|
177101
|
+
projectService.loadAncestorProjectTree(searchedProjectKeys);
|
|
176886
177102
|
projectService.forEachEnabledProject(function (project) {
|
|
176887
177103
|
if (cancellationToken.isCancellationRequested())
|
|
176888
177104
|
return; // There's no mechanism for skipping the remaining projects
|
|
176889
|
-
if (
|
|
177105
|
+
if (resultsMap.has(project))
|
|
176890
177106
|
return; // Can loop forever without this (enqueue here, dequeue above, repeat)
|
|
176891
177107
|
var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
|
176892
177108
|
if (location) {
|
|
@@ -176897,9 +177113,10 @@ var ts;
|
|
|
176897
177113
|
}
|
|
176898
177114
|
// In the common case where there's only one project, return a simpler result to make
|
|
176899
177115
|
// it easier for the caller to skip post-processing.
|
|
176900
|
-
if (
|
|
177116
|
+
if (resultsMap.size === 1) {
|
|
176901
177117
|
var it = resultsMap.values().next();
|
|
176902
|
-
|
|
177118
|
+
ts.Debug.assert(!it.done);
|
|
177119
|
+
return it.value;
|
|
176903
177120
|
}
|
|
176904
177121
|
return resultsMap;
|
|
176905
177122
|
function searchPosition(project, location) {
|
|
@@ -176916,7 +177133,7 @@ var ts;
|
|
|
176916
177133
|
var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
|
|
176917
177134
|
for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
|
|
176918
177135
|
var project_1 = _a[_i];
|
|
176919
|
-
if (!project_1.isOrphan()) {
|
|
177136
|
+
if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
|
|
176920
177137
|
queue.push({ project: project_1, location: originalLocation });
|
|
176921
177138
|
}
|
|
176922
177139
|
}
|
|
@@ -176925,7 +177142,7 @@ var ts;
|
|
|
176925
177142
|
symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
|
|
176926
177143
|
for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
|
|
176927
177144
|
var symlinkedProject = symlinkedProjects_2[_i];
|
|
176928
|
-
if (!symlinkedProject.isOrphan()) {
|
|
177145
|
+
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
|
|
176929
177146
|
queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
|
|
176930
177147
|
}
|
|
176931
177148
|
}
|
|
@@ -178218,7 +178435,8 @@ var ts;
|
|
|
178218
178435
|
Session.prototype.getRenameInfo = function (args) {
|
|
178219
178436
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
178220
178437
|
var position = this.getPositionInFile(args, file);
|
|
178221
|
-
|
|
178438
|
+
var preferences = this.getPreferences(file);
|
|
178439
|
+
return project.getLanguageService().getRenameInfo(file, position, preferences);
|
|
178222
178440
|
};
|
|
178223
178441
|
Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
|
|
178224
178442
|
var _a;
|
|
@@ -178269,10 +178487,11 @@ var ts;
|
|
|
178269
178487
|
var position = this.getPositionInFile(args, file);
|
|
178270
178488
|
var projects = this.getProjects(args);
|
|
178271
178489
|
var defaultProject = this.getDefaultProject(args);
|
|
178272
|
-
var
|
|
178490
|
+
var preferences = this.getPreferences(file);
|
|
178491
|
+
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
178273
178492
|
if (!renameInfo.canRename)
|
|
178274
178493
|
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
178275
|
-
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments,
|
|
178494
|
+
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
|
|
178276
178495
|
if (!simplifiedResult)
|
|
178277
178496
|
return locations;
|
|
178278
178497
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|