typescript 4.8.0-dev.20220615 → 4.8.0-dev.20220618
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 +2 -0
- package/lib/es/diagnosticMessages.generated.json +5 -1
- package/lib/fr/diagnosticMessages.generated.json +5 -1
- package/lib/it/diagnosticMessages.generated.json +2 -0
- package/lib/ja/diagnosticMessages.generated.json +2 -0
- 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 +2 -0
- package/lib/tsc.js +136 -49
- package/lib/tsserver.js +368 -104
- package/lib/tsserverlibrary.d.ts +10 -0
- package/lib/tsserverlibrary.js +368 -104
- package/lib/typescript.d.ts +9 -0
- package/lib/typescript.js +336 -82
- package/lib/typescriptServices.d.ts +9 -0
- package/lib/typescriptServices.js +336 -82
- package/lib/typingsInstaller.js +165 -49
- 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/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220618";
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -8483,9 +8483,11 @@ var ts;
|
|
|
8483
8483
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8484
8484
|
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8485
8485
|
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8486
|
-
|
|
8486
|
+
This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
|
|
8487
8487
|
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8488
8488
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8489
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8490
|
+
Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
|
|
8489
8491
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8490
8492
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8491
8493
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -9670,6 +9672,8 @@ var ts;
|
|
|
9670
9672
|
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}'."),
|
|
9671
9673
|
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."),
|
|
9672
9674
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9675
|
+
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."),
|
|
9676
|
+
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."),
|
|
9673
9677
|
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."),
|
|
9674
9678
|
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."),
|
|
9675
9679
|
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'."),
|
|
@@ -9940,6 +9944,9 @@ var ts;
|
|
|
9940
9944
|
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."),
|
|
9941
9945
|
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."),
|
|
9942
9946
|
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."),
|
|
9947
|
+
_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."),
|
|
9948
|
+
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."),
|
|
9949
|
+
_0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
|
|
9943
9950
|
};
|
|
9944
9951
|
})(ts || (ts = {}));
|
|
9945
9952
|
var ts;
|
|
@@ -34528,10 +34535,10 @@ var ts;
|
|
|
34528
34535
|
setDecoratorContext(/*val*/ false);
|
|
34529
34536
|
}
|
|
34530
34537
|
var pos = getNodePos();
|
|
34531
|
-
var expr = parseAssignmentExpressionOrHigher();
|
|
34538
|
+
var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
34532
34539
|
var operatorToken;
|
|
34533
34540
|
while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
|
|
34534
|
-
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
|
34541
|
+
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
|
|
34535
34542
|
}
|
|
34536
34543
|
if (saveDecoratorContext) {
|
|
34537
34544
|
setDecoratorContext(/*val*/ true);
|
|
@@ -34539,9 +34546,9 @@ var ts;
|
|
|
34539
34546
|
return expr;
|
|
34540
34547
|
}
|
|
34541
34548
|
function parseInitializer() {
|
|
34542
|
-
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
34549
|
+
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
|
|
34543
34550
|
}
|
|
34544
|
-
function parseAssignmentExpressionOrHigher() {
|
|
34551
|
+
function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
|
|
34545
34552
|
// AssignmentExpression[in,yield]:
|
|
34546
34553
|
// 1) ConditionalExpression[?in,?yield]
|
|
34547
34554
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -34567,7 +34574,7 @@ var ts;
|
|
|
34567
34574
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
34568
34575
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
34569
34576
|
// with AssignmentExpression if we see one.
|
|
34570
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
34577
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
|
|
34571
34578
|
if (arrowExpression) {
|
|
34572
34579
|
return arrowExpression;
|
|
34573
34580
|
}
|
|
@@ -34586,7 +34593,7 @@ var ts;
|
|
|
34586
34593
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
34587
34594
|
// identifier and the current token is an arrow.
|
|
34588
34595
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
34589
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
34596
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
|
|
34590
34597
|
}
|
|
34591
34598
|
// Now see if we might be in cases '2' or '3'.
|
|
34592
34599
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -34595,10 +34602,10 @@ var ts;
|
|
|
34595
34602
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
34596
34603
|
// for cases like `> > =` becoming `>>=`
|
|
34597
34604
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
34598
|
-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
|
34605
|
+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
|
|
34599
34606
|
}
|
|
34600
34607
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
34601
|
-
return parseConditionalExpressionRest(expr, pos);
|
|
34608
|
+
return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
|
|
34602
34609
|
}
|
|
34603
34610
|
function isYieldExpression() {
|
|
34604
34611
|
if (token() === 125 /* YieldKeyword */) {
|
|
@@ -34638,7 +34645,7 @@ var ts;
|
|
|
34638
34645
|
nextToken();
|
|
34639
34646
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
34640
34647
|
(token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
|
|
34641
|
-
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
|
|
34648
|
+
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
|
|
34642
34649
|
}
|
|
34643
34650
|
else {
|
|
34644
34651
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
@@ -34646,7 +34653,7 @@ var ts;
|
|
|
34646
34653
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
34647
34654
|
}
|
|
34648
34655
|
}
|
|
34649
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
34656
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
|
|
34650
34657
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
34651
34658
|
var parameter = factory.createParameterDeclaration(
|
|
34652
34659
|
/*modifiers*/ undefined,
|
|
@@ -34657,11 +34664,11 @@ var ts;
|
|
|
34657
34664
|
finishNode(parameter, identifier.pos);
|
|
34658
34665
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
34659
34666
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34660
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
34667
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
|
|
34661
34668
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
34662
34669
|
return addJSDocComment(finishNode(node, pos));
|
|
34663
34670
|
}
|
|
34664
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
34671
|
+
function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34665
34672
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
34666
34673
|
if (triState === 0 /* False */) {
|
|
34667
34674
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -34672,8 +34679,8 @@ var ts;
|
|
|
34672
34679
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
34673
34680
|
// expression instead.
|
|
34674
34681
|
return triState === 1 /* True */ ?
|
|
34675
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
34676
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
34682
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
|
|
34683
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
|
|
34677
34684
|
}
|
|
34678
34685
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
34679
34686
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -34807,25 +34814,25 @@ var ts;
|
|
|
34807
34814
|
return 2 /* Unknown */;
|
|
34808
34815
|
}
|
|
34809
34816
|
}
|
|
34810
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
34817
|
+
function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34811
34818
|
var tokenPos = scanner.getTokenPos();
|
|
34812
34819
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
34813
34820
|
return undefined;
|
|
34814
34821
|
}
|
|
34815
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
34822
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
|
|
34816
34823
|
if (!result) {
|
|
34817
34824
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
34818
34825
|
}
|
|
34819
34826
|
return result;
|
|
34820
34827
|
}
|
|
34821
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
34828
|
+
function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34822
34829
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
34823
34830
|
if (token() === 131 /* AsyncKeyword */) {
|
|
34824
34831
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
34825
34832
|
var pos = getNodePos();
|
|
34826
34833
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
34827
34834
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
34828
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
34835
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
|
|
34829
34836
|
}
|
|
34830
34837
|
}
|
|
34831
34838
|
return undefined;
|
|
@@ -34849,7 +34856,7 @@ var ts;
|
|
|
34849
34856
|
}
|
|
34850
34857
|
return 0 /* False */;
|
|
34851
34858
|
}
|
|
34852
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
34859
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
|
|
34853
34860
|
var pos = getNodePos();
|
|
34854
34861
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34855
34862
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -34884,6 +34891,7 @@ var ts;
|
|
|
34884
34891
|
return undefined;
|
|
34885
34892
|
}
|
|
34886
34893
|
}
|
|
34894
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
34887
34895
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
34888
34896
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
34889
34897
|
return undefined;
|
|
@@ -34912,12 +34920,37 @@ var ts;
|
|
|
34912
34920
|
var lastToken = token();
|
|
34913
34921
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34914
34922
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
34915
|
-
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
|
|
34923
|
+
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
|
|
34916
34924
|
: parseIdentifier();
|
|
34925
|
+
// Given:
|
|
34926
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
34927
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
34928
|
+
// ({ y }) : z => ({ z })
|
|
34929
|
+
// This is a valid arrow function with "z" as the return type.
|
|
34930
|
+
//
|
|
34931
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
34932
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34933
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34934
|
+
//
|
|
34935
|
+
// For example,
|
|
34936
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
34937
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34938
|
+
// be an arrow expression, so we allow a return type.
|
|
34939
|
+
if (!allowReturnTypeInArrowFunction && hasReturnColon) {
|
|
34940
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
34941
|
+
// as in:
|
|
34942
|
+
// a ? (x): string => x : null
|
|
34943
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
34944
|
+
// the conditional expression. It's okay to do this because this code would
|
|
34945
|
+
// be a syntax error in JavaScript (as the second colon shouldn't be there).
|
|
34946
|
+
if (token() !== 58 /* ColonToken */) {
|
|
34947
|
+
return undefined;
|
|
34948
|
+
}
|
|
34949
|
+
}
|
|
34917
34950
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
34918
34951
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
34919
34952
|
}
|
|
34920
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
34953
|
+
function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
|
|
34921
34954
|
if (token() === 18 /* OpenBraceToken */) {
|
|
34922
34955
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
34923
34956
|
}
|
|
@@ -34945,12 +34978,12 @@ var ts;
|
|
|
34945
34978
|
var savedTopLevel = topLevel;
|
|
34946
34979
|
topLevel = false;
|
|
34947
34980
|
var node = isAsync
|
|
34948
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
34949
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
34981
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
|
|
34982
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
|
|
34950
34983
|
topLevel = savedTopLevel;
|
|
34951
34984
|
return node;
|
|
34952
34985
|
}
|
|
34953
|
-
function parseConditionalExpressionRest(leftOperand, pos) {
|
|
34986
|
+
function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
|
|
34954
34987
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
|
34955
34988
|
var questionToken = parseOptionalToken(57 /* QuestionToken */);
|
|
34956
34989
|
if (!questionToken) {
|
|
@@ -34959,8 +34992,8 @@ var ts;
|
|
|
34959
34992
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
34960
34993
|
// we do not that for the 'whenFalse' part.
|
|
34961
34994
|
var colonToken;
|
|
34962
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
34963
|
-
? parseAssignmentExpressionOrHigher()
|
|
34995
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
34996
|
+
? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
|
|
34964
34997
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
34965
34998
|
}
|
|
34966
34999
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -35787,10 +35820,11 @@ var ts;
|
|
|
35787
35820
|
}
|
|
35788
35821
|
nextToken();
|
|
35789
35822
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35790
|
-
if (
|
|
35823
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35791
35824
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35792
35825
|
return undefined;
|
|
35793
35826
|
}
|
|
35827
|
+
nextToken();
|
|
35794
35828
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35795
35829
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35796
35830
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -35874,13 +35908,13 @@ var ts;
|
|
|
35874
35908
|
function parseSpreadElement() {
|
|
35875
35909
|
var pos = getNodePos();
|
|
35876
35910
|
parseExpected(25 /* DotDotDotToken */);
|
|
35877
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
35911
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35878
35912
|
return finishNode(factory.createSpreadElement(expression), pos);
|
|
35879
35913
|
}
|
|
35880
35914
|
function parseArgumentOrArrayLiteralElement() {
|
|
35881
35915
|
return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
35882
35916
|
token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
|
35883
|
-
parseAssignmentExpressionOrHigher();
|
|
35917
|
+
parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35884
35918
|
}
|
|
35885
35919
|
function parseArgumentExpression() {
|
|
35886
35920
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
@@ -35898,7 +35932,7 @@ var ts;
|
|
|
35898
35932
|
var pos = getNodePos();
|
|
35899
35933
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35900
35934
|
if (parseOptionalToken(25 /* DotDotDotToken */)) {
|
|
35901
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
35935
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35902
35936
|
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
|
35903
35937
|
}
|
|
35904
35938
|
var decorators = parseDecorators();
|
|
@@ -35927,7 +35961,7 @@ var ts;
|
|
|
35927
35961
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
|
|
35928
35962
|
if (isShorthandPropertyAssignment) {
|
|
35929
35963
|
var equalsToken = parseOptionalToken(63 /* EqualsToken */);
|
|
35930
|
-
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
|
35964
|
+
var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
|
|
35931
35965
|
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
|
|
35932
35966
|
// Save equals token for error reporting.
|
|
35933
35967
|
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
|
@@ -35935,7 +35969,7 @@ var ts;
|
|
|
35935
35969
|
}
|
|
35936
35970
|
else {
|
|
35937
35971
|
parseExpected(58 /* ColonToken */);
|
|
35938
|
-
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
35972
|
+
var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
35939
35973
|
node = factory.createPropertyAssignment(name, initializer);
|
|
35940
35974
|
}
|
|
35941
35975
|
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
|
@@ -36112,7 +36146,7 @@ var ts;
|
|
|
36112
36146
|
}
|
|
36113
36147
|
var node;
|
|
36114
36148
|
if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
|
|
36115
|
-
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36149
|
+
var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36116
36150
|
parseExpected(21 /* CloseParenToken */);
|
|
36117
36151
|
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
|
36118
36152
|
}
|
|
@@ -37300,7 +37334,7 @@ var ts;
|
|
|
37300
37334
|
var pos = getNodePos();
|
|
37301
37335
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
37302
37336
|
parseExpected(58 /* ColonToken */);
|
|
37303
|
-
var value = parseAssignmentExpressionOrHigher();
|
|
37337
|
+
var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37304
37338
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
37305
37339
|
}
|
|
37306
37340
|
function parseAssertClause(skipAssertKeyword) {
|
|
@@ -37541,7 +37575,7 @@ var ts;
|
|
|
37541
37575
|
else {
|
|
37542
37576
|
parseExpected(88 /* DefaultKeyword */);
|
|
37543
37577
|
}
|
|
37544
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
37578
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37545
37579
|
parseSemicolon();
|
|
37546
37580
|
setAwaitContext(savedAwaitContext);
|
|
37547
37581
|
var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
|
|
@@ -48907,9 +48941,9 @@ var ts;
|
|
|
48907
48941
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
48908
48942
|
},
|
|
48909
48943
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
48910
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
48944
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
48911
48945
|
var node = ts.getParseTreeNode(nodeIn);
|
|
48912
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
48946
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
48913
48947
|
},
|
|
48914
48948
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
48915
48949
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -52540,6 +52574,9 @@ var ts;
|
|
|
52540
52574
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52541
52575
|
return { accessibility: 0 /* Accessible */ };
|
|
52542
52576
|
}
|
|
52577
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52578
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52579
|
+
}
|
|
52543
52580
|
// Verify if the symbol is accessible
|
|
52544
52581
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52545
52582
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -59354,7 +59391,7 @@ var ts;
|
|
|
59354
59391
|
}
|
|
59355
59392
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59356
59393
|
var constraint = getBaseConstraint(t.type);
|
|
59357
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59394
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59358
59395
|
}
|
|
59359
59396
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59360
59397
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62324,9 +62361,12 @@ var ts;
|
|
|
62324
62361
|
}
|
|
62325
62362
|
function getStringMappingType(symbol, type) {
|
|
62326
62363
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62327
|
-
|
|
62328
|
-
|
|
62329
|
-
|
|
62364
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62365
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62366
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62367
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62368
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62369
|
+
type;
|
|
62330
62370
|
}
|
|
62331
62371
|
function applyStringMapping(symbol, str) {
|
|
62332
62372
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62337,6 +62377,15 @@ var ts;
|
|
|
62337
62377
|
}
|
|
62338
62378
|
return str;
|
|
62339
62379
|
}
|
|
62380
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62381
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62382
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62383
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62384
|
+
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];
|
|
62385
|
+
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];
|
|
62386
|
+
}
|
|
62387
|
+
return [texts, types];
|
|
62388
|
+
}
|
|
62340
62389
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62341
62390
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62342
62391
|
var result = stringMappingTypes.get(id);
|
|
@@ -62578,7 +62627,7 @@ var ts;
|
|
|
62578
62627
|
accessNode;
|
|
62579
62628
|
}
|
|
62580
62629
|
function isPatternLiteralPlaceholderType(type) {
|
|
62581
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62630
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62582
62631
|
}
|
|
62583
62632
|
function isPatternLiteralType(type) {
|
|
62584
62633
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -65500,8 +65549,13 @@ var ts;
|
|
|
65500
65549
|
return;
|
|
65501
65550
|
}
|
|
65502
65551
|
reportRelationError(headMessage, source, target);
|
|
65503
|
-
if (
|
|
65504
|
-
|
|
65552
|
+
if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
|
|
65553
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65554
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65555
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65556
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65557
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65558
|
+
}
|
|
65505
65559
|
}
|
|
65506
65560
|
}
|
|
65507
65561
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -66285,6 +66339,13 @@ var ts;
|
|
|
66285
66339
|
return -1 /* True */;
|
|
66286
66340
|
}
|
|
66287
66341
|
}
|
|
66342
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66343
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66344
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66345
|
+
return -1 /* True */;
|
|
66346
|
+
}
|
|
66347
|
+
}
|
|
66348
|
+
}
|
|
66288
66349
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66289
66350
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66290
66351
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66328,7 +66389,10 @@ var ts;
|
|
|
66328
66389
|
}
|
|
66329
66390
|
}
|
|
66330
66391
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66331
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66392
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66393
|
+
if (source.symbol !== target.symbol) {
|
|
66394
|
+
return 0 /* False */;
|
|
66395
|
+
}
|
|
66332
66396
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66333
66397
|
resetErrorInfo(saveErrorInfo);
|
|
66334
66398
|
return result;
|
|
@@ -67253,7 +67317,7 @@ var ts;
|
|
|
67253
67317
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67254
67318
|
}
|
|
67255
67319
|
}
|
|
67256
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67320
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67257
67321
|
}
|
|
67258
67322
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67259
67323
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68724,6 +68788,31 @@ var ts;
|
|
|
68724
68788
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68725
68789
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68726
68790
|
}
|
|
68791
|
+
function isMemberOfStringMapping(source, target) {
|
|
68792
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68793
|
+
return true;
|
|
68794
|
+
}
|
|
68795
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68796
|
+
return isTypeAssignableTo(source, target);
|
|
68797
|
+
}
|
|
68798
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68799
|
+
// We need to see whether applying the same mappings of the target
|
|
68800
|
+
// onto the source would produce an identical type *and* that
|
|
68801
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68802
|
+
//
|
|
68803
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68804
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68805
|
+
// still reside in the same domain.
|
|
68806
|
+
var mappingStack = [];
|
|
68807
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
68808
|
+
mappingStack.unshift(target.symbol);
|
|
68809
|
+
target = target.type;
|
|
68810
|
+
}
|
|
68811
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
68812
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
68813
|
+
}
|
|
68814
|
+
return false;
|
|
68815
|
+
}
|
|
68727
68816
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68728
68817
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68729
68818
|
return true;
|
|
@@ -68732,7 +68821,8 @@ var ts;
|
|
|
68732
68821
|
var value = source.value;
|
|
68733
68822
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68734
68823
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68735
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
68824
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
68825
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68736
68826
|
}
|
|
68737
68827
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68738
68828
|
var texts = source.texts;
|
|
@@ -85611,6 +85701,7 @@ var ts;
|
|
|
85611
85701
|
return true;
|
|
85612
85702
|
}
|
|
85613
85703
|
function checkAliasSymbol(node) {
|
|
85704
|
+
var _a, _b, _c, _d, _e;
|
|
85614
85705
|
var symbol = getSymbolOfNode(node);
|
|
85615
85706
|
var target = resolveAlias(symbol);
|
|
85616
85707
|
if (target !== unknownSymbol) {
|
|
@@ -85621,6 +85712,31 @@ var ts;
|
|
|
85621
85712
|
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
|
85622
85713
|
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
|
85623
85714
|
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
|
85715
|
+
// A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
|
|
85716
|
+
if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
|
|
85717
|
+
var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
|
|
85718
|
+
ts.isNamedDeclaration(node) ? node.name :
|
|
85719
|
+
node;
|
|
85720
|
+
ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
|
|
85721
|
+
if (node.kind === 275 /* ExportSpecifier */) {
|
|
85722
|
+
var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
85723
|
+
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);
|
|
85724
|
+
if (alreadyExportedSymbol === target) {
|
|
85725
|
+
var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
|
|
85726
|
+
if (exportingDeclaration) {
|
|
85727
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
|
|
85728
|
+
}
|
|
85729
|
+
}
|
|
85730
|
+
}
|
|
85731
|
+
else {
|
|
85732
|
+
ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
|
|
85733
|
+
var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
|
|
85734
|
+
var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
|
|
85735
|
+
var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
85736
|
+
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);
|
|
85737
|
+
}
|
|
85738
|
+
return;
|
|
85739
|
+
}
|
|
85624
85740
|
var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
|
|
85625
85741
|
(symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
|
|
85626
85742
|
(symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
@@ -130621,32 +130737,41 @@ var ts;
|
|
|
130621
130737
|
|| ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
|
|
130622
130738
|
|| (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
|
|
130623
130739
|
}
|
|
130624
|
-
function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
|
|
130740
|
+
function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
|
|
130625
130741
|
var _a, _b;
|
|
130626
|
-
|
|
130742
|
+
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
|
|
130743
|
+
var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
|
|
130744
|
+
// The client is expected to send rooted path specs since we don't know
|
|
130745
|
+
// what directory a relative path is relative to.
|
|
130746
|
+
var pattern = ts.getPatternFromSpec(spec, "", "exclude");
|
|
130747
|
+
return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
|
|
130748
|
+
});
|
|
130749
|
+
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
|
|
130627
130750
|
var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
130628
130751
|
if (autoImportProvider) {
|
|
130629
130752
|
var start = ts.timestamp();
|
|
130630
|
-
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
130753
|
+
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
130631
130754
|
(_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
|
|
130632
130755
|
}
|
|
130633
130756
|
}
|
|
130634
130757
|
ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
|
|
130635
|
-
function forEachExternalModule(checker, allSourceFiles, cb) {
|
|
130636
|
-
|
|
130637
|
-
|
|
130638
|
-
|
|
130758
|
+
function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
|
|
130759
|
+
var _a;
|
|
130760
|
+
var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
|
|
130761
|
+
for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
|
|
130762
|
+
var ambient = _b[_i];
|
|
130763
|
+
if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
|
|
130639
130764
|
cb(ambient, /*sourceFile*/ undefined);
|
|
130640
130765
|
}
|
|
130641
130766
|
}
|
|
130642
|
-
for (var
|
|
130643
|
-
var sourceFile = allSourceFiles_1[
|
|
130644
|
-
if (ts.isExternalOrCommonJsModule(sourceFile)) {
|
|
130767
|
+
for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
|
|
130768
|
+
var sourceFile = allSourceFiles_1[_c];
|
|
130769
|
+
if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
|
|
130645
130770
|
cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
|
|
130646
130771
|
}
|
|
130647
130772
|
}
|
|
130648
130773
|
}
|
|
130649
|
-
function getExportInfoMap(importingFile, host, program, cancellationToken) {
|
|
130774
|
+
function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
|
|
130650
130775
|
var _a, _b, _c, _d, _e;
|
|
130651
130776
|
var start = ts.timestamp();
|
|
130652
130777
|
// Pulling the AutoImportProvider project will trigger its updateGraph if pending,
|
|
@@ -130666,7 +130791,7 @@ var ts;
|
|
|
130666
130791
|
var compilerOptions = program.getCompilerOptions();
|
|
130667
130792
|
var moduleCount = 0;
|
|
130668
130793
|
try {
|
|
130669
|
-
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
130794
|
+
forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
130670
130795
|
if (++moduleCount % 100 === 0)
|
|
130671
130796
|
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
130672
130797
|
var seenExports = new ts.Map();
|
|
@@ -133062,7 +133187,7 @@ var ts;
|
|
|
133062
133187
|
if (!previousResponse)
|
|
133063
133188
|
return undefined;
|
|
133064
133189
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
133065
|
-
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
133190
|
+
var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
|
|
133066
133191
|
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
133067
133192
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133068
133193
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
@@ -134771,7 +134896,7 @@ var ts;
|
|
|
134771
134896
|
}
|
|
134772
134897
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
134773
134898
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
134774
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
134899
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
134775
134900
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
134776
134901
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
134777
134902
|
var symbol = _a[_i];
|
|
@@ -134874,7 +134999,7 @@ var ts;
|
|
|
134874
134999
|
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
|
|
134875
135000
|
"";
|
|
134876
135001
|
var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
134877
|
-
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
135002
|
+
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
|
|
134878
135003
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
134879
135004
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
134880
135005
|
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
@@ -144109,10 +144234,10 @@ var ts;
|
|
|
144109
144234
|
(function (ts) {
|
|
144110
144235
|
var Rename;
|
|
144111
144236
|
(function (Rename) {
|
|
144112
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144237
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144113
144238
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144114
144239
|
if (nodeIsEligibleForRename(node)) {
|
|
144115
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144240
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144116
144241
|
if (renameInfo) {
|
|
144117
144242
|
return renameInfo;
|
|
144118
144243
|
}
|
|
@@ -144120,7 +144245,7 @@ var ts;
|
|
|
144120
144245
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144121
144246
|
}
|
|
144122
144247
|
Rename.getRenameInfo = getRenameInfo;
|
|
144123
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144248
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144124
144249
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144125
144250
|
if (!symbol) {
|
|
144126
144251
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144148,7 +144273,12 @@ var ts;
|
|
|
144148
144273
|
return undefined;
|
|
144149
144274
|
}
|
|
144150
144275
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144151
|
-
return
|
|
144276
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144277
|
+
}
|
|
144278
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144279
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144280
|
+
if (wouldRenameNodeModules) {
|
|
144281
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144152
144282
|
}
|
|
144153
144283
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144154
144284
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144162,6 +144292,49 @@ var ts;
|
|
|
144162
144292
|
var sourceFile = declaration.getSourceFile();
|
|
144163
144293
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144164
144294
|
}
|
|
144295
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144296
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144297
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144298
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144299
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144300
|
+
}
|
|
144301
|
+
}
|
|
144302
|
+
var declarations = symbol.declarations;
|
|
144303
|
+
if (!declarations) {
|
|
144304
|
+
return undefined;
|
|
144305
|
+
}
|
|
144306
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144307
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144308
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144309
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144310
|
+
}
|
|
144311
|
+
else {
|
|
144312
|
+
return undefined;
|
|
144313
|
+
}
|
|
144314
|
+
}
|
|
144315
|
+
// original source file is in node_modules
|
|
144316
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144317
|
+
var declaration = declarations_4[_i];
|
|
144318
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144319
|
+
if (declPackage) {
|
|
144320
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144321
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144322
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144323
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144324
|
+
}
|
|
144325
|
+
}
|
|
144326
|
+
}
|
|
144327
|
+
}
|
|
144328
|
+
return undefined;
|
|
144329
|
+
}
|
|
144330
|
+
function getPackagePathComponents(filePath) {
|
|
144331
|
+
var components = ts.getPathComponents(filePath);
|
|
144332
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144333
|
+
if (nodeModulesIdx === -1) {
|
|
144334
|
+
return undefined;
|
|
144335
|
+
}
|
|
144336
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144337
|
+
}
|
|
144165
144338
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144166
144339
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144167
144340
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -145216,7 +145389,7 @@ var ts;
|
|
|
145216
145389
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145217
145390
|
}
|
|
145218
145391
|
function visitVariableLikeDeclaration(decl) {
|
|
145219
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145392
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145220
145393
|
return;
|
|
145221
145394
|
}
|
|
145222
145395
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145344,6 +145517,9 @@ var ts;
|
|
|
145344
145517
|
}
|
|
145345
145518
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145346
145519
|
var param = node.parameters[i];
|
|
145520
|
+
if (!isHintableDeclaration(param)) {
|
|
145521
|
+
continue;
|
|
145522
|
+
}
|
|
145347
145523
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145348
145524
|
if (effectiveTypeAnnotation) {
|
|
145349
145525
|
continue;
|
|
@@ -145385,6 +145561,13 @@ var ts;
|
|
|
145385
145561
|
function isUndefined(name) {
|
|
145386
145562
|
return name === "undefined";
|
|
145387
145563
|
}
|
|
145564
|
+
function isHintableDeclaration(node) {
|
|
145565
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
145566
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
145567
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
145568
|
+
}
|
|
145569
|
+
return true;
|
|
145570
|
+
}
|
|
145388
145571
|
}
|
|
145389
145572
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145390
145573
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -154013,7 +154196,7 @@ var ts;
|
|
|
154013
154196
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
154014
154197
|
return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
|
|
154015
154198
|
});
|
|
154016
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154199
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154017
154200
|
var checker = program.getTypeChecker();
|
|
154018
154201
|
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
|
154019
154202
|
if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
|
|
@@ -154482,7 +154665,7 @@ var ts;
|
|
|
154482
154665
|
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 });
|
|
154483
154666
|
}
|
|
154484
154667
|
}
|
|
154485
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
154668
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
154486
154669
|
var checker = program.getTypeChecker();
|
|
154487
154670
|
cancellationToken.throwIfCancellationRequested();
|
|
154488
154671
|
var compilerOptions = program.getCompilerOptions();
|
|
@@ -154823,6 +155006,77 @@ var ts;
|
|
|
154823
155006
|
})(ts || (ts = {}));
|
|
154824
155007
|
/* @internal */
|
|
154825
155008
|
var ts;
|
|
155009
|
+
(function (ts) {
|
|
155010
|
+
var codefix;
|
|
155011
|
+
(function (codefix) {
|
|
155012
|
+
var fixId = "addMissingConstraint";
|
|
155013
|
+
var errorCodes = [
|
|
155014
|
+
// We want errors this could be attached to:
|
|
155015
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155016
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155017
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155018
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
155019
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155020
|
+
ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
155021
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155022
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155023
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155024
|
+
];
|
|
155025
|
+
codefix.registerCodeFix({
|
|
155026
|
+
errorCodes: errorCodes,
|
|
155027
|
+
getCodeActions: function (context) {
|
|
155028
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155029
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155030
|
+
if (!related) {
|
|
155031
|
+
return;
|
|
155032
|
+
}
|
|
155033
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155034
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155035
|
+
},
|
|
155036
|
+
fixIds: [fixId],
|
|
155037
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155038
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155039
|
+
if (!info)
|
|
155040
|
+
return;
|
|
155041
|
+
return addMissingConstraint(changes, info);
|
|
155042
|
+
}); },
|
|
155043
|
+
});
|
|
155044
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155045
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155046
|
+
if (!diag || !diag.relatedInformation)
|
|
155047
|
+
return;
|
|
155048
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155049
|
+
if (!related)
|
|
155050
|
+
return;
|
|
155051
|
+
return related;
|
|
155052
|
+
}
|
|
155053
|
+
function addMissingConstraint(changes, related) {
|
|
155054
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155055
|
+
if (!decl)
|
|
155056
|
+
return;
|
|
155057
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155058
|
+
decl = decl.parent;
|
|
155059
|
+
}
|
|
155060
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155061
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155062
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155063
|
+
if (!newConstraint)
|
|
155064
|
+
return;
|
|
155065
|
+
var newConstraintText = newConstraint[1];
|
|
155066
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155067
|
+
}
|
|
155068
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155069
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155070
|
+
var end = ts.textSpanEnd(span);
|
|
155071
|
+
while (token.end < end) {
|
|
155072
|
+
token = token.parent;
|
|
155073
|
+
}
|
|
155074
|
+
return token;
|
|
155075
|
+
}
|
|
155076
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155077
|
+
})(ts || (ts = {}));
|
|
155078
|
+
/* @internal */
|
|
155079
|
+
var ts;
|
|
154826
155080
|
(function (ts) {
|
|
154827
155081
|
var codefix;
|
|
154828
155082
|
(function (codefix) {
|
|
@@ -161120,11 +161374,11 @@ var ts;
|
|
|
161120
161374
|
}
|
|
161121
161375
|
}
|
|
161122
161376
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161123
|
-
var
|
|
161377
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161124
161378
|
var numInitializers = 0;
|
|
161125
161379
|
var lastInitializer = void 0;
|
|
161126
|
-
for (var _i = 0,
|
|
161127
|
-
var declaration =
|
|
161380
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
161381
|
+
var declaration = declarations_5[_i];
|
|
161128
161382
|
if (declaration.initializer) {
|
|
161129
161383
|
numInitializers++;
|
|
161130
161384
|
lastInitializer = declaration.initializer;
|
|
@@ -165261,8 +165515,8 @@ var ts;
|
|
|
165261
165515
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165262
165516
|
}
|
|
165263
165517
|
};
|
|
165264
|
-
for (var _i = 0,
|
|
165265
|
-
var declaration =
|
|
165518
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
165519
|
+
var declaration = declarations_7[_i];
|
|
165266
165520
|
_loop_21(declaration);
|
|
165267
165521
|
}
|
|
165268
165522
|
}
|
|
@@ -165288,8 +165542,8 @@ var ts;
|
|
|
165288
165542
|
if (inheritedDocs)
|
|
165289
165543
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
165290
165544
|
};
|
|
165291
|
-
for (var _i = 0,
|
|
165292
|
-
var declaration =
|
|
165545
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
165546
|
+
var declaration = declarations_8[_i];
|
|
165293
165547
|
_loop_22(declaration);
|
|
165294
165548
|
}
|
|
165295
165549
|
}
|
|
@@ -166866,9 +167120,9 @@ var ts;
|
|
|
166866
167120
|
return ts.stringContains(path, "/node_modules/");
|
|
166867
167121
|
}
|
|
166868
167122
|
}
|
|
166869
|
-
function getRenameInfo(fileName, position,
|
|
167123
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
166870
167124
|
synchronizeHostData();
|
|
166871
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167125
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
166872
167126
|
}
|
|
166873
167127
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
166874
167128
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168234,9 +168488,9 @@ var ts;
|
|
|
168234
168488
|
var _this = this;
|
|
168235
168489
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168236
168490
|
};
|
|
168237
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
168491
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168238
168492
|
var _this = this;
|
|
168239
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
168493
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168240
168494
|
};
|
|
168241
168495
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168242
168496
|
var _this = this;
|
|
@@ -176406,7 +176660,7 @@ var ts;
|
|
|
176406
176660
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
176407
176661
|
}
|
|
176408
176662
|
function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
|
|
176409
|
-
var _a;
|
|
176663
|
+
var _a, _b;
|
|
176410
176664
|
var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
|
|
176411
176665
|
/*isForRename*/ false, function (project, position) {
|
|
176412
176666
|
logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
|
|
@@ -176426,7 +176680,7 @@ var ts;
|
|
|
176426
176680
|
// have started the other project searches from related symbols. Propagate the
|
|
176427
176681
|
// correct results to all other projects.
|
|
176428
176682
|
var defaultProjectResults = perProjectResults.get(defaultProject);
|
|
176429
|
-
if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null ||
|
|
176683
|
+
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) {
|
|
176430
176684
|
// Clear all isDefinition properties
|
|
176431
176685
|
perProjectResults.forEach(function (projectResults) {
|
|
176432
176686
|
for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
|
|
@@ -176443,8 +176697,8 @@ var ts;
|
|
|
176443
176697
|
var knownSymbolSpans_1 = createDocumentSpanSet();
|
|
176444
176698
|
for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
|
|
176445
176699
|
var referencedSymbol = defaultProjectResults_1[_i];
|
|
176446
|
-
for (var
|
|
176447
|
-
var ref = _c
|
|
176700
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
176701
|
+
var ref = _d[_c];
|
|
176448
176702
|
if (ref.isDefinition) {
|
|
176449
176703
|
knownSymbolSpans_1.add(ref);
|
|
176450
176704
|
// One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
|
|
@@ -176563,23 +176817,30 @@ var ts;
|
|
|
176563
176817
|
var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
|
|
176564
176818
|
defaultDefinition :
|
|
176565
176819
|
defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
|
|
176566
|
-
//
|
|
176567
|
-
//
|
|
176568
|
-
|
|
176569
|
-
var searchedProjects = new ts.Set();
|
|
176820
|
+
// The keys of resultsMap allow us to check which projects have already been searched, but we also
|
|
176821
|
+
// maintain a set of strings because that's what `loadAncestorProjectTree` wants.
|
|
176822
|
+
var searchedProjectKeys = new ts.Set();
|
|
176570
176823
|
onCancellation: while (queue.length) {
|
|
176571
176824
|
while (queue.length) {
|
|
176572
176825
|
if (cancellationToken.isCancellationRequested())
|
|
176573
176826
|
break onCancellation;
|
|
176827
|
+
var skipCount = 0;
|
|
176828
|
+
for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
|
|
176829
|
+
;
|
|
176830
|
+
if (skipCount === queue.length) {
|
|
176831
|
+
queue.length = 0;
|
|
176832
|
+
break;
|
|
176833
|
+
}
|
|
176834
|
+
if (skipCount > 0) {
|
|
176835
|
+
queue.splice(0, skipCount);
|
|
176836
|
+
}
|
|
176837
|
+
// NB: we may still skip if it's a project reference redirect
|
|
176574
176838
|
var _a = queue.shift(), project = _a.project, location = _a.location;
|
|
176575
176839
|
if (isLocationProjectReferenceRedirect(project, location))
|
|
176576
176840
|
continue;
|
|
176577
|
-
if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
|
|
176578
|
-
continue;
|
|
176579
176841
|
var projectResults = searchPosition(project, location);
|
|
176580
|
-
|
|
176581
|
-
|
|
176582
|
-
}
|
|
176842
|
+
resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
|
|
176843
|
+
searchedProjectKeys.add(getProjectKey(project));
|
|
176583
176844
|
}
|
|
176584
176845
|
// At this point, we know about all projects passed in as arguments and any projects in which
|
|
176585
176846
|
// `getResultsForPosition` has returned results. We expand that set to include any projects
|
|
@@ -176587,11 +176848,11 @@ var ts;
|
|
|
176587
176848
|
// containing `initialLocation`.
|
|
176588
176849
|
if (defaultDefinition) {
|
|
176589
176850
|
// This seems to mean "load all projects downstream from any member of `seenProjects`".
|
|
176590
|
-
projectService.loadAncestorProjectTree(
|
|
176851
|
+
projectService.loadAncestorProjectTree(searchedProjectKeys);
|
|
176591
176852
|
projectService.forEachEnabledProject(function (project) {
|
|
176592
176853
|
if (cancellationToken.isCancellationRequested())
|
|
176593
176854
|
return; // There's no mechanism for skipping the remaining projects
|
|
176594
|
-
if (
|
|
176855
|
+
if (resultsMap.has(project))
|
|
176595
176856
|
return; // Can loop forever without this (enqueue here, dequeue above, repeat)
|
|
176596
176857
|
var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
|
176597
176858
|
if (location) {
|
|
@@ -176602,9 +176863,10 @@ var ts;
|
|
|
176602
176863
|
}
|
|
176603
176864
|
// In the common case where there's only one project, return a simpler result to make
|
|
176604
176865
|
// it easier for the caller to skip post-processing.
|
|
176605
|
-
if (
|
|
176866
|
+
if (resultsMap.size === 1) {
|
|
176606
176867
|
var it = resultsMap.values().next();
|
|
176607
|
-
|
|
176868
|
+
ts.Debug.assert(!it.done);
|
|
176869
|
+
return it.value;
|
|
176608
176870
|
}
|
|
176609
176871
|
return resultsMap;
|
|
176610
176872
|
function searchPosition(project, location) {
|
|
@@ -176621,7 +176883,7 @@ var ts;
|
|
|
176621
176883
|
var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
|
|
176622
176884
|
for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
|
|
176623
176885
|
var project_1 = _a[_i];
|
|
176624
|
-
if (!project_1.isOrphan()) {
|
|
176886
|
+
if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
|
|
176625
176887
|
queue.push({ project: project_1, location: originalLocation });
|
|
176626
176888
|
}
|
|
176627
176889
|
}
|
|
@@ -176630,7 +176892,7 @@ var ts;
|
|
|
176630
176892
|
symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
|
|
176631
176893
|
for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
|
|
176632
176894
|
var symlinkedProject = symlinkedProjects_2[_i];
|
|
176633
|
-
if (!symlinkedProject.isOrphan()) {
|
|
176895
|
+
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
|
|
176634
176896
|
queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
|
|
176635
176897
|
}
|
|
176636
176898
|
}
|
|
@@ -177923,7 +178185,8 @@ var ts;
|
|
|
177923
178185
|
Session.prototype.getRenameInfo = function (args) {
|
|
177924
178186
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
177925
178187
|
var position = this.getPositionInFile(args, file);
|
|
177926
|
-
|
|
178188
|
+
var preferences = this.getPreferences(file);
|
|
178189
|
+
return project.getLanguageService().getRenameInfo(file, position, preferences);
|
|
177927
178190
|
};
|
|
177928
178191
|
Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
|
|
177929
178192
|
var _a;
|
|
@@ -177974,10 +178237,11 @@ var ts;
|
|
|
177974
178237
|
var position = this.getPositionInFile(args, file);
|
|
177975
178238
|
var projects = this.getProjects(args);
|
|
177976
178239
|
var defaultProject = this.getDefaultProject(args);
|
|
177977
|
-
var
|
|
178240
|
+
var preferences = this.getPreferences(file);
|
|
178241
|
+
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
177978
178242
|
if (!renameInfo.canRename)
|
|
177979
178243
|
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
177980
|
-
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments,
|
|
178244
|
+
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
|
|
177981
178245
|
if (!simplifiedResult)
|
|
177982
178246
|
return locations;
|
|
177983
178247
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|