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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220618";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8668,9 +8668,11 @@ var ts;
|
|
|
8668
8668
|
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),
|
|
8669
8669
|
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."),
|
|
8670
8670
|
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."),
|
|
8671
|
-
|
|
8671
|
+
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."),
|
|
8672
8672
|
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."),
|
|
8673
8673
|
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."),
|
|
8674
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8675
|
+
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"),
|
|
8674
8676
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8675
8677
|
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."),
|
|
8676
8678
|
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."),
|
|
@@ -9855,6 +9857,8 @@ var ts;
|
|
|
9855
9857
|
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}'."),
|
|
9856
9858
|
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."),
|
|
9857
9859
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9860
|
+
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."),
|
|
9861
|
+
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."),
|
|
9858
9862
|
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."),
|
|
9859
9863
|
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."),
|
|
9860
9864
|
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'."),
|
|
@@ -10125,6 +10129,9 @@ var ts;
|
|
|
10125
10129
|
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."),
|
|
10126
10130
|
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."),
|
|
10127
10131
|
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."),
|
|
10132
|
+
_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."),
|
|
10133
|
+
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."),
|
|
10134
|
+
_0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
|
|
10128
10135
|
};
|
|
10129
10136
|
})(ts || (ts = {}));
|
|
10130
10137
|
var ts;
|
|
@@ -34713,10 +34720,10 @@ var ts;
|
|
|
34713
34720
|
setDecoratorContext(/*val*/ false);
|
|
34714
34721
|
}
|
|
34715
34722
|
var pos = getNodePos();
|
|
34716
|
-
var expr = parseAssignmentExpressionOrHigher();
|
|
34723
|
+
var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
34717
34724
|
var operatorToken;
|
|
34718
34725
|
while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
|
|
34719
|
-
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
|
34726
|
+
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
|
|
34720
34727
|
}
|
|
34721
34728
|
if (saveDecoratorContext) {
|
|
34722
34729
|
setDecoratorContext(/*val*/ true);
|
|
@@ -34724,9 +34731,9 @@ var ts;
|
|
|
34724
34731
|
return expr;
|
|
34725
34732
|
}
|
|
34726
34733
|
function parseInitializer() {
|
|
34727
|
-
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
34734
|
+
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
|
|
34728
34735
|
}
|
|
34729
|
-
function parseAssignmentExpressionOrHigher() {
|
|
34736
|
+
function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
|
|
34730
34737
|
// AssignmentExpression[in,yield]:
|
|
34731
34738
|
// 1) ConditionalExpression[?in,?yield]
|
|
34732
34739
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -34752,7 +34759,7 @@ var ts;
|
|
|
34752
34759
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
34753
34760
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
34754
34761
|
// with AssignmentExpression if we see one.
|
|
34755
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
34762
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
|
|
34756
34763
|
if (arrowExpression) {
|
|
34757
34764
|
return arrowExpression;
|
|
34758
34765
|
}
|
|
@@ -34771,7 +34778,7 @@ var ts;
|
|
|
34771
34778
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
34772
34779
|
// identifier and the current token is an arrow.
|
|
34773
34780
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
34774
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
34781
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
|
|
34775
34782
|
}
|
|
34776
34783
|
// Now see if we might be in cases '2' or '3'.
|
|
34777
34784
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -34780,10 +34787,10 @@ var ts;
|
|
|
34780
34787
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
34781
34788
|
// for cases like `> > =` becoming `>>=`
|
|
34782
34789
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
34783
|
-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
|
34790
|
+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
|
|
34784
34791
|
}
|
|
34785
34792
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
34786
|
-
return parseConditionalExpressionRest(expr, pos);
|
|
34793
|
+
return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
|
|
34787
34794
|
}
|
|
34788
34795
|
function isYieldExpression() {
|
|
34789
34796
|
if (token() === 125 /* YieldKeyword */) {
|
|
@@ -34823,7 +34830,7 @@ var ts;
|
|
|
34823
34830
|
nextToken();
|
|
34824
34831
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
34825
34832
|
(token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
|
|
34826
|
-
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
|
|
34833
|
+
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
|
|
34827
34834
|
}
|
|
34828
34835
|
else {
|
|
34829
34836
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
@@ -34831,7 +34838,7 @@ var ts;
|
|
|
34831
34838
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
34832
34839
|
}
|
|
34833
34840
|
}
|
|
34834
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
34841
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
|
|
34835
34842
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
34836
34843
|
var parameter = factory.createParameterDeclaration(
|
|
34837
34844
|
/*modifiers*/ undefined,
|
|
@@ -34842,11 +34849,11 @@ var ts;
|
|
|
34842
34849
|
finishNode(parameter, identifier.pos);
|
|
34843
34850
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
34844
34851
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34845
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
34852
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
|
|
34846
34853
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
34847
34854
|
return addJSDocComment(finishNode(node, pos));
|
|
34848
34855
|
}
|
|
34849
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
34856
|
+
function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34850
34857
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
34851
34858
|
if (triState === 0 /* False */) {
|
|
34852
34859
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -34857,8 +34864,8 @@ var ts;
|
|
|
34857
34864
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
34858
34865
|
// expression instead.
|
|
34859
34866
|
return triState === 1 /* True */ ?
|
|
34860
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
34861
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
34867
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
|
|
34868
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
|
|
34862
34869
|
}
|
|
34863
34870
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
34864
34871
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -34992,25 +34999,25 @@ var ts;
|
|
|
34992
34999
|
return 2 /* Unknown */;
|
|
34993
35000
|
}
|
|
34994
35001
|
}
|
|
34995
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
35002
|
+
function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34996
35003
|
var tokenPos = scanner.getTokenPos();
|
|
34997
35004
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
34998
35005
|
return undefined;
|
|
34999
35006
|
}
|
|
35000
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
35007
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
|
|
35001
35008
|
if (!result) {
|
|
35002
35009
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
35003
35010
|
}
|
|
35004
35011
|
return result;
|
|
35005
35012
|
}
|
|
35006
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
35013
|
+
function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
35007
35014
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
35008
35015
|
if (token() === 131 /* AsyncKeyword */) {
|
|
35009
35016
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
35010
35017
|
var pos = getNodePos();
|
|
35011
35018
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
35012
35019
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
35013
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
35020
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
|
|
35014
35021
|
}
|
|
35015
35022
|
}
|
|
35016
35023
|
return undefined;
|
|
@@ -35034,7 +35041,7 @@ var ts;
|
|
|
35034
35041
|
}
|
|
35035
35042
|
return 0 /* False */;
|
|
35036
35043
|
}
|
|
35037
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
35044
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
|
|
35038
35045
|
var pos = getNodePos();
|
|
35039
35046
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35040
35047
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -35069,6 +35076,7 @@ var ts;
|
|
|
35069
35076
|
return undefined;
|
|
35070
35077
|
}
|
|
35071
35078
|
}
|
|
35079
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
35072
35080
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
35073
35081
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
35074
35082
|
return undefined;
|
|
@@ -35097,12 +35105,37 @@ var ts;
|
|
|
35097
35105
|
var lastToken = token();
|
|
35098
35106
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
35099
35107
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
35100
|
-
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
|
|
35108
|
+
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
|
|
35101
35109
|
: parseIdentifier();
|
|
35110
|
+
// Given:
|
|
35111
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
35112
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
35113
|
+
// ({ y }) : z => ({ z })
|
|
35114
|
+
// This is a valid arrow function with "z" as the return type.
|
|
35115
|
+
//
|
|
35116
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
35117
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
35118
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
35119
|
+
//
|
|
35120
|
+
// For example,
|
|
35121
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
35122
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
35123
|
+
// be an arrow expression, so we allow a return type.
|
|
35124
|
+
if (!allowReturnTypeInArrowFunction && hasReturnColon) {
|
|
35125
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
35126
|
+
// as in:
|
|
35127
|
+
// a ? (x): string => x : null
|
|
35128
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
35129
|
+
// the conditional expression. It's okay to do this because this code would
|
|
35130
|
+
// be a syntax error in JavaScript (as the second colon shouldn't be there).
|
|
35131
|
+
if (token() !== 58 /* ColonToken */) {
|
|
35132
|
+
return undefined;
|
|
35133
|
+
}
|
|
35134
|
+
}
|
|
35102
35135
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
35103
35136
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
35104
35137
|
}
|
|
35105
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
35138
|
+
function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
|
|
35106
35139
|
if (token() === 18 /* OpenBraceToken */) {
|
|
35107
35140
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
35108
35141
|
}
|
|
@@ -35130,12 +35163,12 @@ var ts;
|
|
|
35130
35163
|
var savedTopLevel = topLevel;
|
|
35131
35164
|
topLevel = false;
|
|
35132
35165
|
var node = isAsync
|
|
35133
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
35134
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
35166
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
|
|
35167
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
|
|
35135
35168
|
topLevel = savedTopLevel;
|
|
35136
35169
|
return node;
|
|
35137
35170
|
}
|
|
35138
|
-
function parseConditionalExpressionRest(leftOperand, pos) {
|
|
35171
|
+
function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
|
|
35139
35172
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
|
35140
35173
|
var questionToken = parseOptionalToken(57 /* QuestionToken */);
|
|
35141
35174
|
if (!questionToken) {
|
|
@@ -35144,8 +35177,8 @@ var ts;
|
|
|
35144
35177
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
35145
35178
|
// we do not that for the 'whenFalse' part.
|
|
35146
35179
|
var colonToken;
|
|
35147
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
35148
|
-
? parseAssignmentExpressionOrHigher()
|
|
35180
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
35181
|
+
? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
|
|
35149
35182
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
35150
35183
|
}
|
|
35151
35184
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -35972,10 +36005,11 @@ var ts;
|
|
|
35972
36005
|
}
|
|
35973
36006
|
nextToken();
|
|
35974
36007
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35975
|
-
if (
|
|
36008
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35976
36009
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35977
36010
|
return undefined;
|
|
35978
36011
|
}
|
|
36012
|
+
nextToken();
|
|
35979
36013
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35980
36014
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35981
36015
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -36059,13 +36093,13 @@ var ts;
|
|
|
36059
36093
|
function parseSpreadElement() {
|
|
36060
36094
|
var pos = getNodePos();
|
|
36061
36095
|
parseExpected(25 /* DotDotDotToken */);
|
|
36062
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
36096
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36063
36097
|
return finishNode(factory.createSpreadElement(expression), pos);
|
|
36064
36098
|
}
|
|
36065
36099
|
function parseArgumentOrArrayLiteralElement() {
|
|
36066
36100
|
return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
36067
36101
|
token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
|
36068
|
-
parseAssignmentExpressionOrHigher();
|
|
36102
|
+
parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36069
36103
|
}
|
|
36070
36104
|
function parseArgumentExpression() {
|
|
36071
36105
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
@@ -36083,7 +36117,7 @@ var ts;
|
|
|
36083
36117
|
var pos = getNodePos();
|
|
36084
36118
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
36085
36119
|
if (parseOptionalToken(25 /* DotDotDotToken */)) {
|
|
36086
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
36120
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
36087
36121
|
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
|
36088
36122
|
}
|
|
36089
36123
|
var decorators = parseDecorators();
|
|
@@ -36112,7 +36146,7 @@ var ts;
|
|
|
36112
36146
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
|
|
36113
36147
|
if (isShorthandPropertyAssignment) {
|
|
36114
36148
|
var equalsToken = parseOptionalToken(63 /* EqualsToken */);
|
|
36115
|
-
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
|
36149
|
+
var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
|
|
36116
36150
|
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
|
|
36117
36151
|
// Save equals token for error reporting.
|
|
36118
36152
|
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
|
@@ -36120,7 +36154,7 @@ var ts;
|
|
|
36120
36154
|
}
|
|
36121
36155
|
else {
|
|
36122
36156
|
parseExpected(58 /* ColonToken */);
|
|
36123
|
-
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36157
|
+
var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36124
36158
|
node = factory.createPropertyAssignment(name, initializer);
|
|
36125
36159
|
}
|
|
36126
36160
|
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
|
@@ -36297,7 +36331,7 @@ var ts;
|
|
|
36297
36331
|
}
|
|
36298
36332
|
var node;
|
|
36299
36333
|
if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
|
|
36300
|
-
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36334
|
+
var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36301
36335
|
parseExpected(21 /* CloseParenToken */);
|
|
36302
36336
|
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
|
36303
36337
|
}
|
|
@@ -37485,7 +37519,7 @@ var ts;
|
|
|
37485
37519
|
var pos = getNodePos();
|
|
37486
37520
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
37487
37521
|
parseExpected(58 /* ColonToken */);
|
|
37488
|
-
var value = parseAssignmentExpressionOrHigher();
|
|
37522
|
+
var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37489
37523
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
37490
37524
|
}
|
|
37491
37525
|
function parseAssertClause(skipAssertKeyword) {
|
|
@@ -37726,7 +37760,7 @@ var ts;
|
|
|
37726
37760
|
else {
|
|
37727
37761
|
parseExpected(88 /* DefaultKeyword */);
|
|
37728
37762
|
}
|
|
37729
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
37763
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37730
37764
|
parseSemicolon();
|
|
37731
37765
|
setAwaitContext(savedAwaitContext);
|
|
37732
37766
|
var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
|
|
@@ -49092,9 +49126,9 @@ var ts;
|
|
|
49092
49126
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
49093
49127
|
},
|
|
49094
49128
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
49095
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
49129
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
49096
49130
|
var node = ts.getParseTreeNode(nodeIn);
|
|
49097
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
49131
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
49098
49132
|
},
|
|
49099
49133
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
49100
49134
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -52725,6 +52759,9 @@ var ts;
|
|
|
52725
52759
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52726
52760
|
return { accessibility: 0 /* Accessible */ };
|
|
52727
52761
|
}
|
|
52762
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52763
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52764
|
+
}
|
|
52728
52765
|
// Verify if the symbol is accessible
|
|
52729
52766
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52730
52767
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -59539,7 +59576,7 @@ var ts;
|
|
|
59539
59576
|
}
|
|
59540
59577
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59541
59578
|
var constraint = getBaseConstraint(t.type);
|
|
59542
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59579
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59543
59580
|
}
|
|
59544
59581
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59545
59582
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62509,9 +62546,12 @@ var ts;
|
|
|
62509
62546
|
}
|
|
62510
62547
|
function getStringMappingType(symbol, type) {
|
|
62511
62548
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62512
|
-
|
|
62513
|
-
|
|
62514
|
-
|
|
62549
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62550
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62551
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62552
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62553
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62554
|
+
type;
|
|
62515
62555
|
}
|
|
62516
62556
|
function applyStringMapping(symbol, str) {
|
|
62517
62557
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62522,6 +62562,15 @@ var ts;
|
|
|
62522
62562
|
}
|
|
62523
62563
|
return str;
|
|
62524
62564
|
}
|
|
62565
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62566
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62567
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62568
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62569
|
+
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];
|
|
62570
|
+
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];
|
|
62571
|
+
}
|
|
62572
|
+
return [texts, types];
|
|
62573
|
+
}
|
|
62525
62574
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62526
62575
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62527
62576
|
var result = stringMappingTypes.get(id);
|
|
@@ -62763,7 +62812,7 @@ var ts;
|
|
|
62763
62812
|
accessNode;
|
|
62764
62813
|
}
|
|
62765
62814
|
function isPatternLiteralPlaceholderType(type) {
|
|
62766
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62815
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62767
62816
|
}
|
|
62768
62817
|
function isPatternLiteralType(type) {
|
|
62769
62818
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -65685,8 +65734,13 @@ var ts;
|
|
|
65685
65734
|
return;
|
|
65686
65735
|
}
|
|
65687
65736
|
reportRelationError(headMessage, source, target);
|
|
65688
|
-
if (
|
|
65689
|
-
|
|
65737
|
+
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)) {
|
|
65738
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65739
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65740
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65741
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65742
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65743
|
+
}
|
|
65690
65744
|
}
|
|
65691
65745
|
}
|
|
65692
65746
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -66470,6 +66524,13 @@ var ts;
|
|
|
66470
66524
|
return -1 /* True */;
|
|
66471
66525
|
}
|
|
66472
66526
|
}
|
|
66527
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66528
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66529
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66530
|
+
return -1 /* True */;
|
|
66531
|
+
}
|
|
66532
|
+
}
|
|
66533
|
+
}
|
|
66473
66534
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66474
66535
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66475
66536
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66513,7 +66574,10 @@ var ts;
|
|
|
66513
66574
|
}
|
|
66514
66575
|
}
|
|
66515
66576
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66516
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66577
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66578
|
+
if (source.symbol !== target.symbol) {
|
|
66579
|
+
return 0 /* False */;
|
|
66580
|
+
}
|
|
66517
66581
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66518
66582
|
resetErrorInfo(saveErrorInfo);
|
|
66519
66583
|
return result;
|
|
@@ -67438,7 +67502,7 @@ var ts;
|
|
|
67438
67502
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67439
67503
|
}
|
|
67440
67504
|
}
|
|
67441
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67505
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67442
67506
|
}
|
|
67443
67507
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67444
67508
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68909,6 +68973,31 @@ var ts;
|
|
|
68909
68973
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68910
68974
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68911
68975
|
}
|
|
68976
|
+
function isMemberOfStringMapping(source, target) {
|
|
68977
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68978
|
+
return true;
|
|
68979
|
+
}
|
|
68980
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68981
|
+
return isTypeAssignableTo(source, target);
|
|
68982
|
+
}
|
|
68983
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68984
|
+
// We need to see whether applying the same mappings of the target
|
|
68985
|
+
// onto the source would produce an identical type *and* that
|
|
68986
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68987
|
+
//
|
|
68988
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68989
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68990
|
+
// still reside in the same domain.
|
|
68991
|
+
var mappingStack = [];
|
|
68992
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
68993
|
+
mappingStack.unshift(target.symbol);
|
|
68994
|
+
target = target.type;
|
|
68995
|
+
}
|
|
68996
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
68997
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
68998
|
+
}
|
|
68999
|
+
return false;
|
|
69000
|
+
}
|
|
68912
69001
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68913
69002
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68914
69003
|
return true;
|
|
@@ -68917,7 +69006,8 @@ var ts;
|
|
|
68917
69006
|
var value = source.value;
|
|
68918
69007
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68919
69008
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68920
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
69009
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
69010
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68921
69011
|
}
|
|
68922
69012
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68923
69013
|
var texts = source.texts;
|
|
@@ -85796,6 +85886,7 @@ var ts;
|
|
|
85796
85886
|
return true;
|
|
85797
85887
|
}
|
|
85798
85888
|
function checkAliasSymbol(node) {
|
|
85889
|
+
var _a, _b, _c, _d, _e;
|
|
85799
85890
|
var symbol = getSymbolOfNode(node);
|
|
85800
85891
|
var target = resolveAlias(symbol);
|
|
85801
85892
|
if (target !== unknownSymbol) {
|
|
@@ -85806,6 +85897,31 @@ var ts;
|
|
|
85806
85897
|
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
|
85807
85898
|
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
|
85808
85899
|
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
|
85900
|
+
// A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
|
|
85901
|
+
if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
|
|
85902
|
+
var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
|
|
85903
|
+
ts.isNamedDeclaration(node) ? node.name :
|
|
85904
|
+
node;
|
|
85905
|
+
ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
|
|
85906
|
+
if (node.kind === 275 /* ExportSpecifier */) {
|
|
85907
|
+
var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
85908
|
+
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);
|
|
85909
|
+
if (alreadyExportedSymbol === target) {
|
|
85910
|
+
var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
|
|
85911
|
+
if (exportingDeclaration) {
|
|
85912
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
|
|
85913
|
+
}
|
|
85914
|
+
}
|
|
85915
|
+
}
|
|
85916
|
+
else {
|
|
85917
|
+
ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
|
|
85918
|
+
var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
|
|
85919
|
+
var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
|
|
85920
|
+
var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
85921
|
+
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);
|
|
85922
|
+
}
|
|
85923
|
+
return;
|
|
85924
|
+
}
|
|
85809
85925
|
var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
|
|
85810
85926
|
(symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
|
|
85811
85927
|
(symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
@@ -131225,32 +131341,41 @@ var ts;
|
|
|
131225
131341
|
|| ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
|
|
131226
131342
|
|| (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
|
|
131227
131343
|
}
|
|
131228
|
-
function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
|
|
131344
|
+
function forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, cb) {
|
|
131229
131345
|
var _a, _b;
|
|
131230
|
-
|
|
131346
|
+
var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host);
|
|
131347
|
+
var excludePatterns = preferences.autoImportFileExcludePatterns && ts.mapDefined(preferences.autoImportFileExcludePatterns, function (spec) {
|
|
131348
|
+
// The client is expected to send rooted path specs since we don't know
|
|
131349
|
+
// what directory a relative path is relative to.
|
|
131350
|
+
var pattern = ts.getPatternFromSpec(spec, "", "exclude");
|
|
131351
|
+
return pattern ? ts.getRegexFromPattern(pattern, useCaseSensitiveFileNames) : undefined;
|
|
131352
|
+
});
|
|
131353
|
+
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
|
|
131231
131354
|
var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
131232
131355
|
if (autoImportProvider) {
|
|
131233
131356
|
var start = ts.timestamp();
|
|
131234
|
-
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131357
|
+
forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
|
|
131235
131358
|
(_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
|
|
131236
131359
|
}
|
|
131237
131360
|
}
|
|
131238
131361
|
ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
|
|
131239
|
-
function forEachExternalModule(checker, allSourceFiles, cb) {
|
|
131240
|
-
|
|
131241
|
-
|
|
131242
|
-
|
|
131362
|
+
function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
|
|
131363
|
+
var _a;
|
|
131364
|
+
var isExcluded = function (fileName) { return excludePatterns === null || excludePatterns === void 0 ? void 0 : excludePatterns.some(function (p) { return p.test(fileName); }); };
|
|
131365
|
+
for (var _i = 0, _b = checker.getAmbientModules(); _i < _b.length; _i++) {
|
|
131366
|
+
var ambient = _b[_i];
|
|
131367
|
+
if (!ts.stringContains(ambient.name, "*") && !(excludePatterns && ((_a = ambient.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return isExcluded(d.getSourceFile().fileName); })))) {
|
|
131243
131368
|
cb(ambient, /*sourceFile*/ undefined);
|
|
131244
131369
|
}
|
|
131245
131370
|
}
|
|
131246
|
-
for (var
|
|
131247
|
-
var sourceFile = allSourceFiles_1[
|
|
131248
|
-
if (ts.isExternalOrCommonJsModule(sourceFile)) {
|
|
131371
|
+
for (var _c = 0, allSourceFiles_1 = allSourceFiles; _c < allSourceFiles_1.length; _c++) {
|
|
131372
|
+
var sourceFile = allSourceFiles_1[_c];
|
|
131373
|
+
if (ts.isExternalOrCommonJsModule(sourceFile) && !isExcluded(sourceFile.fileName)) {
|
|
131249
131374
|
cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
|
|
131250
131375
|
}
|
|
131251
131376
|
}
|
|
131252
131377
|
}
|
|
131253
|
-
function getExportInfoMap(importingFile, host, program, cancellationToken) {
|
|
131378
|
+
function getExportInfoMap(importingFile, host, program, preferences, cancellationToken) {
|
|
131254
131379
|
var _a, _b, _c, _d, _e;
|
|
131255
131380
|
var start = ts.timestamp();
|
|
131256
131381
|
// Pulling the AutoImportProvider project will trigger its updateGraph if pending,
|
|
@@ -131270,7 +131395,7 @@ var ts;
|
|
|
131270
131395
|
var compilerOptions = program.getCompilerOptions();
|
|
131271
131396
|
var moduleCount = 0;
|
|
131272
131397
|
try {
|
|
131273
|
-
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131398
|
+
forEachExternalModuleToImportFrom(program, host, preferences, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
131274
131399
|
if (++moduleCount % 100 === 0)
|
|
131275
131400
|
cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
|
|
131276
131401
|
var seenExports = new ts.Map();
|
|
@@ -133666,7 +133791,7 @@ var ts;
|
|
|
133666
133791
|
if (!previousResponse)
|
|
133667
133792
|
return undefined;
|
|
133668
133793
|
var lowerCaseTokenText = location.text.toLowerCase();
|
|
133669
|
-
var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
|
|
133794
|
+
var exportMap = ts.getExportInfoMap(file, host, program, preferences, cancellationToken);
|
|
133670
133795
|
var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, ts.codefix.createImportSpecifierResolver(file, program, host, preferences), program, location.getStart(), preferences,
|
|
133671
133796
|
/*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
133672
133797
|
var entries = ts.mapDefined(previousResponse.entries, function (entry) {
|
|
@@ -135375,7 +135500,7 @@ var ts;
|
|
|
135375
135500
|
}
|
|
135376
135501
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
135377
135502
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
135378
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
135503
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
135379
135504
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
135380
135505
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
135381
135506
|
var symbol = _a[_i];
|
|
@@ -135478,7 +135603,7 @@ var ts;
|
|
|
135478
135603
|
previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
|
|
135479
135604
|
"";
|
|
135480
135605
|
var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
135481
|
-
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
|
|
135606
|
+
var exportInfo = ts.getExportInfoMap(sourceFile, host, program, preferences, cancellationToken);
|
|
135482
135607
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
135483
135608
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
135484
135609
|
resolvingModuleSpecifiers("collectAutoImports", host, importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences)), program, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
|
|
@@ -144713,10 +144838,10 @@ var ts;
|
|
|
144713
144838
|
(function (ts) {
|
|
144714
144839
|
var Rename;
|
|
144715
144840
|
(function (Rename) {
|
|
144716
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144841
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144717
144842
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144718
144843
|
if (nodeIsEligibleForRename(node)) {
|
|
144719
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144844
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144720
144845
|
if (renameInfo) {
|
|
144721
144846
|
return renameInfo;
|
|
144722
144847
|
}
|
|
@@ -144724,7 +144849,7 @@ var ts;
|
|
|
144724
144849
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144725
144850
|
}
|
|
144726
144851
|
Rename.getRenameInfo = getRenameInfo;
|
|
144727
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144852
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144728
144853
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144729
144854
|
if (!symbol) {
|
|
144730
144855
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144752,7 +144877,12 @@ var ts;
|
|
|
144752
144877
|
return undefined;
|
|
144753
144878
|
}
|
|
144754
144879
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144755
|
-
return
|
|
144880
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144881
|
+
}
|
|
144882
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144883
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144884
|
+
if (wouldRenameNodeModules) {
|
|
144885
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144756
144886
|
}
|
|
144757
144887
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144758
144888
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144766,6 +144896,49 @@ var ts;
|
|
|
144766
144896
|
var sourceFile = declaration.getSourceFile();
|
|
144767
144897
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144768
144898
|
}
|
|
144899
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144900
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144901
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144902
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144903
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144904
|
+
}
|
|
144905
|
+
}
|
|
144906
|
+
var declarations = symbol.declarations;
|
|
144907
|
+
if (!declarations) {
|
|
144908
|
+
return undefined;
|
|
144909
|
+
}
|
|
144910
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144911
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144912
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144913
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144914
|
+
}
|
|
144915
|
+
else {
|
|
144916
|
+
return undefined;
|
|
144917
|
+
}
|
|
144918
|
+
}
|
|
144919
|
+
// original source file is in node_modules
|
|
144920
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144921
|
+
var declaration = declarations_4[_i];
|
|
144922
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144923
|
+
if (declPackage) {
|
|
144924
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144925
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144926
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144927
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144928
|
+
}
|
|
144929
|
+
}
|
|
144930
|
+
}
|
|
144931
|
+
}
|
|
144932
|
+
return undefined;
|
|
144933
|
+
}
|
|
144934
|
+
function getPackagePathComponents(filePath) {
|
|
144935
|
+
var components = ts.getPathComponents(filePath);
|
|
144936
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144937
|
+
if (nodeModulesIdx === -1) {
|
|
144938
|
+
return undefined;
|
|
144939
|
+
}
|
|
144940
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144941
|
+
}
|
|
144769
144942
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144770
144943
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144771
144944
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -145820,7 +145993,7 @@ var ts;
|
|
|
145820
145993
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145821
145994
|
}
|
|
145822
145995
|
function visitVariableLikeDeclaration(decl) {
|
|
145823
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145996
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145824
145997
|
return;
|
|
145825
145998
|
}
|
|
145826
145999
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145948,6 +146121,9 @@ var ts;
|
|
|
145948
146121
|
}
|
|
145949
146122
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145950
146123
|
var param = node.parameters[i];
|
|
146124
|
+
if (!isHintableDeclaration(param)) {
|
|
146125
|
+
continue;
|
|
146126
|
+
}
|
|
145951
146127
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145952
146128
|
if (effectiveTypeAnnotation) {
|
|
145953
146129
|
continue;
|
|
@@ -145989,6 +146165,13 @@ var ts;
|
|
|
145989
146165
|
function isUndefined(name) {
|
|
145990
146166
|
return name === "undefined";
|
|
145991
146167
|
}
|
|
146168
|
+
function isHintableDeclaration(node) {
|
|
146169
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
146170
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
146171
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
146172
|
+
}
|
|
146173
|
+
return true;
|
|
146174
|
+
}
|
|
145992
146175
|
}
|
|
145993
146176
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145994
146177
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -154617,7 +154800,7 @@ var ts;
|
|
|
154617
154800
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
154618
154801
|
return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
|
|
154619
154802
|
});
|
|
154620
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154803
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
154621
154804
|
var checker = program.getTypeChecker();
|
|
154622
154805
|
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
|
154623
154806
|
if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
|
|
@@ -155086,7 +155269,7 @@ var ts;
|
|
|
155086
155269
|
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 });
|
|
155087
155270
|
}
|
|
155088
155271
|
}
|
|
155089
|
-
ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155272
|
+
ts.forEachExternalModuleToImportFrom(program, host, preferences, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
|
|
155090
155273
|
var checker = program.getTypeChecker();
|
|
155091
155274
|
cancellationToken.throwIfCancellationRequested();
|
|
155092
155275
|
var compilerOptions = program.getCompilerOptions();
|
|
@@ -155427,6 +155610,77 @@ var ts;
|
|
|
155427
155610
|
})(ts || (ts = {}));
|
|
155428
155611
|
/* @internal */
|
|
155429
155612
|
var ts;
|
|
155613
|
+
(function (ts) {
|
|
155614
|
+
var codefix;
|
|
155615
|
+
(function (codefix) {
|
|
155616
|
+
var fixId = "addMissingConstraint";
|
|
155617
|
+
var errorCodes = [
|
|
155618
|
+
// We want errors this could be attached to:
|
|
155619
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155620
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155621
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155622
|
+
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,
|
|
155623
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155624
|
+
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,
|
|
155625
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155626
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155627
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155628
|
+
];
|
|
155629
|
+
codefix.registerCodeFix({
|
|
155630
|
+
errorCodes: errorCodes,
|
|
155631
|
+
getCodeActions: function (context) {
|
|
155632
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155633
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155634
|
+
if (!related) {
|
|
155635
|
+
return;
|
|
155636
|
+
}
|
|
155637
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155638
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155639
|
+
},
|
|
155640
|
+
fixIds: [fixId],
|
|
155641
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155642
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155643
|
+
if (!info)
|
|
155644
|
+
return;
|
|
155645
|
+
return addMissingConstraint(changes, info);
|
|
155646
|
+
}); },
|
|
155647
|
+
});
|
|
155648
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155649
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155650
|
+
if (!diag || !diag.relatedInformation)
|
|
155651
|
+
return;
|
|
155652
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155653
|
+
if (!related)
|
|
155654
|
+
return;
|
|
155655
|
+
return related;
|
|
155656
|
+
}
|
|
155657
|
+
function addMissingConstraint(changes, related) {
|
|
155658
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155659
|
+
if (!decl)
|
|
155660
|
+
return;
|
|
155661
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155662
|
+
decl = decl.parent;
|
|
155663
|
+
}
|
|
155664
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155665
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155666
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155667
|
+
if (!newConstraint)
|
|
155668
|
+
return;
|
|
155669
|
+
var newConstraintText = newConstraint[1];
|
|
155670
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155671
|
+
}
|
|
155672
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155673
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155674
|
+
var end = ts.textSpanEnd(span);
|
|
155675
|
+
while (token.end < end) {
|
|
155676
|
+
token = token.parent;
|
|
155677
|
+
}
|
|
155678
|
+
return token;
|
|
155679
|
+
}
|
|
155680
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155681
|
+
})(ts || (ts = {}));
|
|
155682
|
+
/* @internal */
|
|
155683
|
+
var ts;
|
|
155430
155684
|
(function (ts) {
|
|
155431
155685
|
var codefix;
|
|
155432
155686
|
(function (codefix) {
|
|
@@ -161724,11 +161978,11 @@ var ts;
|
|
|
161724
161978
|
}
|
|
161725
161979
|
}
|
|
161726
161980
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161727
|
-
var
|
|
161981
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161728
161982
|
var numInitializers = 0;
|
|
161729
161983
|
var lastInitializer = void 0;
|
|
161730
|
-
for (var _i = 0,
|
|
161731
|
-
var declaration =
|
|
161984
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
161985
|
+
var declaration = declarations_5[_i];
|
|
161732
161986
|
if (declaration.initializer) {
|
|
161733
161987
|
numInitializers++;
|
|
161734
161988
|
lastInitializer = declaration.initializer;
|
|
@@ -165865,8 +166119,8 @@ var ts;
|
|
|
165865
166119
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165866
166120
|
}
|
|
165867
166121
|
};
|
|
165868
|
-
for (var _i = 0,
|
|
165869
|
-
var declaration =
|
|
166122
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166123
|
+
var declaration = declarations_7[_i];
|
|
165870
166124
|
_loop_21(declaration);
|
|
165871
166125
|
}
|
|
165872
166126
|
}
|
|
@@ -165892,8 +166146,8 @@ var ts;
|
|
|
165892
166146
|
if (inheritedDocs)
|
|
165893
166147
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
165894
166148
|
};
|
|
165895
|
-
for (var _i = 0,
|
|
165896
|
-
var declaration =
|
|
166149
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166150
|
+
var declaration = declarations_8[_i];
|
|
165897
166151
|
_loop_22(declaration);
|
|
165898
166152
|
}
|
|
165899
166153
|
}
|
|
@@ -167470,9 +167724,9 @@ var ts;
|
|
|
167470
167724
|
return ts.stringContains(path, "/node_modules/");
|
|
167471
167725
|
}
|
|
167472
167726
|
}
|
|
167473
|
-
function getRenameInfo(fileName, position,
|
|
167727
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
167474
167728
|
synchronizeHostData();
|
|
167475
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167729
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
167476
167730
|
}
|
|
167477
167731
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
167478
167732
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168838,9 +169092,9 @@ var ts;
|
|
|
168838
169092
|
var _this = this;
|
|
168839
169093
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168840
169094
|
};
|
|
168841
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
169095
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168842
169096
|
var _this = this;
|
|
168843
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
169097
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168844
169098
|
};
|
|
168845
169099
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168846
169100
|
var _this = this;
|