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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220618";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8463,9 +8463,11 @@ var ts;
|
|
|
8463
8463
|
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),
|
|
8464
8464
|
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."),
|
|
8465
8465
|
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."),
|
|
8466
|
-
|
|
8466
|
+
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."),
|
|
8467
8467
|
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."),
|
|
8468
8468
|
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."),
|
|
8469
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8470
|
+
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"),
|
|
8469
8471
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8470
8472
|
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."),
|
|
8471
8473
|
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."),
|
|
@@ -9650,6 +9652,8 @@ var ts;
|
|
|
9650
9652
|
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}'."),
|
|
9651
9653
|
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."),
|
|
9652
9654
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9655
|
+
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."),
|
|
9656
|
+
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."),
|
|
9653
9657
|
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."),
|
|
9654
9658
|
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."),
|
|
9655
9659
|
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'."),
|
|
@@ -9920,6 +9924,9 @@ var ts;
|
|
|
9920
9924
|
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."),
|
|
9921
9925
|
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."),
|
|
9922
9926
|
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."),
|
|
9927
|
+
_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."),
|
|
9928
|
+
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."),
|
|
9929
|
+
_0_is_automatically_exported_here: diag(18044, ts.DiagnosticCategory.Message, "_0_is_automatically_exported_here_18044", "'{0}' is automatically exported here."),
|
|
9923
9930
|
};
|
|
9924
9931
|
})(ts || (ts = {}));
|
|
9925
9932
|
var ts;
|
|
@@ -34508,10 +34515,10 @@ var ts;
|
|
|
34508
34515
|
setDecoratorContext(/*val*/ false);
|
|
34509
34516
|
}
|
|
34510
34517
|
var pos = getNodePos();
|
|
34511
|
-
var expr = parseAssignmentExpressionOrHigher();
|
|
34518
|
+
var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
34512
34519
|
var operatorToken;
|
|
34513
34520
|
while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
|
|
34514
|
-
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
|
34521
|
+
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos);
|
|
34515
34522
|
}
|
|
34516
34523
|
if (saveDecoratorContext) {
|
|
34517
34524
|
setDecoratorContext(/*val*/ true);
|
|
@@ -34519,9 +34526,9 @@ var ts;
|
|
|
34519
34526
|
return expr;
|
|
34520
34527
|
}
|
|
34521
34528
|
function parseInitializer() {
|
|
34522
|
-
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
34529
|
+
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined;
|
|
34523
34530
|
}
|
|
34524
|
-
function parseAssignmentExpressionOrHigher() {
|
|
34531
|
+
function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) {
|
|
34525
34532
|
// AssignmentExpression[in,yield]:
|
|
34526
34533
|
// 1) ConditionalExpression[?in,?yield]
|
|
34527
34534
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -34547,7 +34554,7 @@ var ts;
|
|
|
34547
34554
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
34548
34555
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
34549
34556
|
// with AssignmentExpression if we see one.
|
|
34550
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
34557
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) || tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction);
|
|
34551
34558
|
if (arrowExpression) {
|
|
34552
34559
|
return arrowExpression;
|
|
34553
34560
|
}
|
|
@@ -34566,7 +34573,7 @@ var ts;
|
|
|
34566
34573
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
34567
34574
|
// identifier and the current token is an arrow.
|
|
34568
34575
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
34569
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
34576
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined);
|
|
34570
34577
|
}
|
|
34571
34578
|
// Now see if we might be in cases '2' or '3'.
|
|
34572
34579
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -34575,10 +34582,10 @@ var ts;
|
|
|
34575
34582
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
34576
34583
|
// for cases like `> > =` becoming `>>=`
|
|
34577
34584
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
34578
|
-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
|
34585
|
+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction), pos);
|
|
34579
34586
|
}
|
|
34580
34587
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
34581
|
-
return parseConditionalExpressionRest(expr, pos);
|
|
34588
|
+
return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction);
|
|
34582
34589
|
}
|
|
34583
34590
|
function isYieldExpression() {
|
|
34584
34591
|
if (token() === 125 /* YieldKeyword */) {
|
|
@@ -34618,7 +34625,7 @@ var ts;
|
|
|
34618
34625
|
nextToken();
|
|
34619
34626
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
34620
34627
|
(token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
|
|
34621
|
-
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
|
|
34628
|
+
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos);
|
|
34622
34629
|
}
|
|
34623
34630
|
else {
|
|
34624
34631
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
@@ -34626,7 +34633,7 @@ var ts;
|
|
|
34626
34633
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
34627
34634
|
}
|
|
34628
34635
|
}
|
|
34629
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
34636
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) {
|
|
34630
34637
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
34631
34638
|
var parameter = factory.createParameterDeclaration(
|
|
34632
34639
|
/*modifiers*/ undefined,
|
|
@@ -34637,11 +34644,11 @@ var ts;
|
|
|
34637
34644
|
finishNode(parameter, identifier.pos);
|
|
34638
34645
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
34639
34646
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34640
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
34647
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction);
|
|
34641
34648
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
34642
34649
|
return addJSDocComment(finishNode(node, pos));
|
|
34643
34650
|
}
|
|
34644
|
-
function tryParseParenthesizedArrowFunctionExpression() {
|
|
34651
|
+
function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34645
34652
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
34646
34653
|
if (triState === 0 /* False */) {
|
|
34647
34654
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -34652,8 +34659,8 @@ var ts;
|
|
|
34652
34659
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
34653
34660
|
// expression instead.
|
|
34654
34661
|
return triState === 1 /* True */ ?
|
|
34655
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
34656
|
-
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
34662
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) :
|
|
34663
|
+
tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); });
|
|
34657
34664
|
}
|
|
34658
34665
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
34659
34666
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -34787,25 +34794,25 @@ var ts;
|
|
|
34787
34794
|
return 2 /* Unknown */;
|
|
34788
34795
|
}
|
|
34789
34796
|
}
|
|
34790
|
-
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
34797
|
+
function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34791
34798
|
var tokenPos = scanner.getTokenPos();
|
|
34792
34799
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
34793
34800
|
return undefined;
|
|
34794
34801
|
}
|
|
34795
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
34802
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, allowReturnTypeInArrowFunction);
|
|
34796
34803
|
if (!result) {
|
|
34797
34804
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
34798
34805
|
}
|
|
34799
34806
|
return result;
|
|
34800
34807
|
}
|
|
34801
|
-
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
34808
|
+
function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) {
|
|
34802
34809
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
34803
34810
|
if (token() === 131 /* AsyncKeyword */) {
|
|
34804
34811
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
34805
34812
|
var pos = getNodePos();
|
|
34806
34813
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
34807
34814
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
34808
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
34815
|
+
return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier);
|
|
34809
34816
|
}
|
|
34810
34817
|
}
|
|
34811
34818
|
return undefined;
|
|
@@ -34829,7 +34836,7 @@ var ts;
|
|
|
34829
34836
|
}
|
|
34830
34837
|
return 0 /* False */;
|
|
34831
34838
|
}
|
|
34832
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
34839
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) {
|
|
34833
34840
|
var pos = getNodePos();
|
|
34834
34841
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34835
34842
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -34864,6 +34871,7 @@ var ts;
|
|
|
34864
34871
|
return undefined;
|
|
34865
34872
|
}
|
|
34866
34873
|
}
|
|
34874
|
+
var hasReturnColon = token() === 58 /* ColonToken */;
|
|
34867
34875
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
34868
34876
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
34869
34877
|
return undefined;
|
|
@@ -34892,12 +34900,37 @@ var ts;
|
|
|
34892
34900
|
var lastToken = token();
|
|
34893
34901
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34894
34902
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
34895
|
-
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
|
|
34903
|
+
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction)
|
|
34896
34904
|
: parseIdentifier();
|
|
34905
|
+
// Given:
|
|
34906
|
+
// x ? y => ({ y }) : z => ({ z })
|
|
34907
|
+
// We try to parse the body of the first arrow function by looking at:
|
|
34908
|
+
// ({ y }) : z => ({ z })
|
|
34909
|
+
// This is a valid arrow function with "z" as the return type.
|
|
34910
|
+
//
|
|
34911
|
+
// But, if we're in the true side of a conditional expression, this colon
|
|
34912
|
+
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34913
|
+
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34914
|
+
//
|
|
34915
|
+
// For example,
|
|
34916
|
+
// a() ? (b: number, c?: string): void => d() : e
|
|
34917
|
+
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34918
|
+
// be an arrow expression, so we allow a return type.
|
|
34919
|
+
if (!allowReturnTypeInArrowFunction && hasReturnColon) {
|
|
34920
|
+
// However, if the arrow function we were able to parse is followed by another colon
|
|
34921
|
+
// as in:
|
|
34922
|
+
// a ? (x): string => x : null
|
|
34923
|
+
// Then allow the arrow function, and treat the second colon as terminating
|
|
34924
|
+
// the conditional expression. It's okay to do this because this code would
|
|
34925
|
+
// be a syntax error in JavaScript (as the second colon shouldn't be there).
|
|
34926
|
+
if (token() !== 58 /* ColonToken */) {
|
|
34927
|
+
return undefined;
|
|
34928
|
+
}
|
|
34929
|
+
}
|
|
34897
34930
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
34898
34931
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
34899
34932
|
}
|
|
34900
|
-
function parseArrowFunctionExpressionBody(isAsync) {
|
|
34933
|
+
function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) {
|
|
34901
34934
|
if (token() === 18 /* OpenBraceToken */) {
|
|
34902
34935
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
34903
34936
|
}
|
|
@@ -34925,12 +34958,12 @@ var ts;
|
|
|
34925
34958
|
var savedTopLevel = topLevel;
|
|
34926
34959
|
topLevel = false;
|
|
34927
34960
|
var node = isAsync
|
|
34928
|
-
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
34929
|
-
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
34961
|
+
? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); })
|
|
34962
|
+
: doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction); });
|
|
34930
34963
|
topLevel = savedTopLevel;
|
|
34931
34964
|
return node;
|
|
34932
34965
|
}
|
|
34933
|
-
function parseConditionalExpressionRest(leftOperand, pos) {
|
|
34966
|
+
function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) {
|
|
34934
34967
|
// Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
|
|
34935
34968
|
var questionToken = parseOptionalToken(57 /* QuestionToken */);
|
|
34936
34969
|
if (!questionToken) {
|
|
@@ -34939,8 +34972,8 @@ var ts;
|
|
|
34939
34972
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
34940
34973
|
// we do not that for the 'whenFalse' part.
|
|
34941
34974
|
var colonToken;
|
|
34942
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
34943
|
-
? parseAssignmentExpressionOrHigher()
|
|
34975
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
34976
|
+
? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction)
|
|
34944
34977
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
34945
34978
|
}
|
|
34946
34979
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -35767,10 +35800,11 @@ var ts;
|
|
|
35767
35800
|
}
|
|
35768
35801
|
nextToken();
|
|
35769
35802
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35770
|
-
if (
|
|
35803
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35771
35804
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35772
35805
|
return undefined;
|
|
35773
35806
|
}
|
|
35807
|
+
nextToken();
|
|
35774
35808
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35775
35809
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35776
35810
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -35854,13 +35888,13 @@ var ts;
|
|
|
35854
35888
|
function parseSpreadElement() {
|
|
35855
35889
|
var pos = getNodePos();
|
|
35856
35890
|
parseExpected(25 /* DotDotDotToken */);
|
|
35857
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
35891
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35858
35892
|
return finishNode(factory.createSpreadElement(expression), pos);
|
|
35859
35893
|
}
|
|
35860
35894
|
function parseArgumentOrArrayLiteralElement() {
|
|
35861
35895
|
return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
35862
35896
|
token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
|
35863
|
-
parseAssignmentExpressionOrHigher();
|
|
35897
|
+
parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35864
35898
|
}
|
|
35865
35899
|
function parseArgumentExpression() {
|
|
35866
35900
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
@@ -35878,7 +35912,7 @@ var ts;
|
|
|
35878
35912
|
var pos = getNodePos();
|
|
35879
35913
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35880
35914
|
if (parseOptionalToken(25 /* DotDotDotToken */)) {
|
|
35881
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
35915
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
35882
35916
|
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
|
35883
35917
|
}
|
|
35884
35918
|
var decorators = parseDecorators();
|
|
@@ -35907,7 +35941,7 @@ var ts;
|
|
|
35907
35941
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
|
|
35908
35942
|
if (isShorthandPropertyAssignment) {
|
|
35909
35943
|
var equalsToken = parseOptionalToken(63 /* EqualsToken */);
|
|
35910
|
-
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
|
35944
|
+
var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined;
|
|
35911
35945
|
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
|
|
35912
35946
|
// Save equals token for error reporting.
|
|
35913
35947
|
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
|
@@ -35915,7 +35949,7 @@ var ts;
|
|
|
35915
35949
|
}
|
|
35916
35950
|
else {
|
|
35917
35951
|
parseExpected(58 /* ColonToken */);
|
|
35918
|
-
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
35952
|
+
var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
35919
35953
|
node = factory.createPropertyAssignment(name, initializer);
|
|
35920
35954
|
}
|
|
35921
35955
|
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
|
@@ -36092,7 +36126,7 @@ var ts;
|
|
|
36092
36126
|
}
|
|
36093
36127
|
var node;
|
|
36094
36128
|
if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
|
|
36095
|
-
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
36129
|
+
var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); });
|
|
36096
36130
|
parseExpected(21 /* CloseParenToken */);
|
|
36097
36131
|
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
|
36098
36132
|
}
|
|
@@ -37280,7 +37314,7 @@ var ts;
|
|
|
37280
37314
|
var pos = getNodePos();
|
|
37281
37315
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
37282
37316
|
parseExpected(58 /* ColonToken */);
|
|
37283
|
-
var value = parseAssignmentExpressionOrHigher();
|
|
37317
|
+
var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37284
37318
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
37285
37319
|
}
|
|
37286
37320
|
function parseAssertClause(skipAssertKeyword) {
|
|
@@ -37521,7 +37555,7 @@ var ts;
|
|
|
37521
37555
|
else {
|
|
37522
37556
|
parseExpected(88 /* DefaultKeyword */);
|
|
37523
37557
|
}
|
|
37524
|
-
var expression = parseAssignmentExpressionOrHigher();
|
|
37558
|
+
var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true);
|
|
37525
37559
|
parseSemicolon();
|
|
37526
37560
|
setAwaitContext(savedAwaitContext);
|
|
37527
37561
|
var node = factory.createExportAssignment(modifiers, isExportEquals, expression);
|
|
@@ -48887,9 +48921,9 @@ var ts;
|
|
|
48887
48921
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
48888
48922
|
},
|
|
48889
48923
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
48890
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
48924
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
48891
48925
|
var node = ts.getParseTreeNode(nodeIn);
|
|
48892
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
48926
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
48893
48927
|
},
|
|
48894
48928
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
48895
48929
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -52520,6 +52554,9 @@ var ts;
|
|
|
52520
52554
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52521
52555
|
return { accessibility: 0 /* Accessible */ };
|
|
52522
52556
|
}
|
|
52557
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52558
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52559
|
+
}
|
|
52523
52560
|
// Verify if the symbol is accessible
|
|
52524
52561
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52525
52562
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -59334,7 +59371,7 @@ var ts;
|
|
|
59334
59371
|
}
|
|
59335
59372
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59336
59373
|
var constraint = getBaseConstraint(t.type);
|
|
59337
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59374
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59338
59375
|
}
|
|
59339
59376
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59340
59377
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62304,9 +62341,12 @@ var ts;
|
|
|
62304
62341
|
}
|
|
62305
62342
|
function getStringMappingType(symbol, type) {
|
|
62306
62343
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62307
|
-
|
|
62308
|
-
|
|
62309
|
-
|
|
62344
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62345
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62346
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62347
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62348
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62349
|
+
type;
|
|
62310
62350
|
}
|
|
62311
62351
|
function applyStringMapping(symbol, str) {
|
|
62312
62352
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62317,6 +62357,15 @@ var ts;
|
|
|
62317
62357
|
}
|
|
62318
62358
|
return str;
|
|
62319
62359
|
}
|
|
62360
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62361
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62362
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62363
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62364
|
+
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];
|
|
62365
|
+
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];
|
|
62366
|
+
}
|
|
62367
|
+
return [texts, types];
|
|
62368
|
+
}
|
|
62320
62369
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62321
62370
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62322
62371
|
var result = stringMappingTypes.get(id);
|
|
@@ -62558,7 +62607,7 @@ var ts;
|
|
|
62558
62607
|
accessNode;
|
|
62559
62608
|
}
|
|
62560
62609
|
function isPatternLiteralPlaceholderType(type) {
|
|
62561
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62610
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62562
62611
|
}
|
|
62563
62612
|
function isPatternLiteralType(type) {
|
|
62564
62613
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -65480,8 +65529,13 @@ var ts;
|
|
|
65480
65529
|
return;
|
|
65481
65530
|
}
|
|
65482
65531
|
reportRelationError(headMessage, source, target);
|
|
65483
|
-
if (
|
|
65484
|
-
|
|
65532
|
+
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)) {
|
|
65533
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65534
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65535
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65536
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65537
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65538
|
+
}
|
|
65485
65539
|
}
|
|
65486
65540
|
}
|
|
65487
65541
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -66265,6 +66319,13 @@ var ts;
|
|
|
66265
66319
|
return -1 /* True */;
|
|
66266
66320
|
}
|
|
66267
66321
|
}
|
|
66322
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66323
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66324
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66325
|
+
return -1 /* True */;
|
|
66326
|
+
}
|
|
66327
|
+
}
|
|
66328
|
+
}
|
|
66268
66329
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66269
66330
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66270
66331
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66308,7 +66369,10 @@ var ts;
|
|
|
66308
66369
|
}
|
|
66309
66370
|
}
|
|
66310
66371
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66311
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66372
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66373
|
+
if (source.symbol !== target.symbol) {
|
|
66374
|
+
return 0 /* False */;
|
|
66375
|
+
}
|
|
66312
66376
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66313
66377
|
resetErrorInfo(saveErrorInfo);
|
|
66314
66378
|
return result;
|
|
@@ -67233,7 +67297,7 @@ var ts;
|
|
|
67233
67297
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67234
67298
|
}
|
|
67235
67299
|
}
|
|
67236
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67300
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67237
67301
|
}
|
|
67238
67302
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67239
67303
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68704,6 +68768,31 @@ var ts;
|
|
|
68704
68768
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68705
68769
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68706
68770
|
}
|
|
68771
|
+
function isMemberOfStringMapping(source, target) {
|
|
68772
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68773
|
+
return true;
|
|
68774
|
+
}
|
|
68775
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68776
|
+
return isTypeAssignableTo(source, target);
|
|
68777
|
+
}
|
|
68778
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68779
|
+
// We need to see whether applying the same mappings of the target
|
|
68780
|
+
// onto the source would produce an identical type *and* that
|
|
68781
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68782
|
+
//
|
|
68783
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68784
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68785
|
+
// still reside in the same domain.
|
|
68786
|
+
var mappingStack = [];
|
|
68787
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
68788
|
+
mappingStack.unshift(target.symbol);
|
|
68789
|
+
target = target.type;
|
|
68790
|
+
}
|
|
68791
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
68792
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
68793
|
+
}
|
|
68794
|
+
return false;
|
|
68795
|
+
}
|
|
68707
68796
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68708
68797
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68709
68798
|
return true;
|
|
@@ -68712,7 +68801,8 @@ var ts;
|
|
|
68712
68801
|
var value = source.value;
|
|
68713
68802
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68714
68803
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68715
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
68804
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
68805
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68716
68806
|
}
|
|
68717
68807
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68718
68808
|
var texts = source.texts;
|
|
@@ -85591,6 +85681,7 @@ var ts;
|
|
|
85591
85681
|
return true;
|
|
85592
85682
|
}
|
|
85593
85683
|
function checkAliasSymbol(node) {
|
|
85684
|
+
var _a, _b, _c, _d, _e;
|
|
85594
85685
|
var symbol = getSymbolOfNode(node);
|
|
85595
85686
|
var target = resolveAlias(symbol);
|
|
85596
85687
|
if (target !== unknownSymbol) {
|
|
@@ -85601,6 +85692,31 @@ var ts;
|
|
|
85601
85692
|
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
|
85602
85693
|
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
|
85603
85694
|
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
|
85695
|
+
// A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within
|
|
85696
|
+
if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) {
|
|
85697
|
+
var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name :
|
|
85698
|
+
ts.isNamedDeclaration(node) ? node.name :
|
|
85699
|
+
node;
|
|
85700
|
+
ts.Debug.assert(node.kind !== 274 /* NamespaceExport */);
|
|
85701
|
+
if (node.kind === 275 /* ExportSpecifier */) {
|
|
85702
|
+
var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files);
|
|
85703
|
+
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);
|
|
85704
|
+
if (alreadyExportedSymbol === target) {
|
|
85705
|
+
var exportingDeclaration = (_c = alreadyExportedSymbol.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isJSDocNode);
|
|
85706
|
+
if (exportingDeclaration) {
|
|
85707
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(exportingDeclaration, ts.Diagnostics._0_is_automatically_exported_here, ts.unescapeLeadingUnderscores(alreadyExportedSymbol.escapedName)));
|
|
85708
|
+
}
|
|
85709
|
+
}
|
|
85710
|
+
}
|
|
85711
|
+
else {
|
|
85712
|
+
ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */);
|
|
85713
|
+
var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration));
|
|
85714
|
+
var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "...";
|
|
85715
|
+
var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName);
|
|
85716
|
+
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);
|
|
85717
|
+
}
|
|
85718
|
+
return;
|
|
85719
|
+
}
|
|
85604
85720
|
var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) |
|
|
85605
85721
|
(symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) |
|
|
85606
85722
|
(symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0);
|
|
@@ -132,6 +132,8 @@
|
|
|
132
132
|
"Add_definite_assignment_assertion_to_property_0_95020": "向属性“{0}”添加明确的赋值断言",
|
|
133
133
|
"Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "将明确赋值断言添加到未初始化的所有属性",
|
|
134
134
|
"Add_export_to_make_this_file_into_a_module_95097": "添加 \"export {}\",将此文件变为模块",
|
|
135
|
+
"Add_extends_constraint_2211": "添加 `extends` 约束。",
|
|
136
|
+
"Add_extends_constraint_to_all_type_parameters_2212": "将 `extends` 约束添加到所有类型参数",
|
|
135
137
|
"Add_import_from_0_90057": "从“{0}”添加导入",
|
|
136
138
|
"Add_index_signature_for_property_0_90017": "为属性“{0}”添加索引签名",
|
|
137
139
|
"Add_initializer_to_property_0_95019": "向属性“{0}”添加初始值设定项",
|
|
@@ -1493,7 +1495,7 @@
|
|
|
1493
1495
|
"This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "此语法需要一个导入的帮助程序,但找不到模块“{0}”。",
|
|
1494
1496
|
"This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此语法需要名为 \"{1}\" 的导入帮助器,\"{0}\" 中不存在该帮助器。请考虑升级 \"{0}\" 的版本。",
|
|
1495
1497
|
"This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此语法需要一个名为 \"{1}\" 且包含 {2} 参数的导入帮助程序,该帮助程序与 \"{0}\" 中的相应帮助程序不兼容。请考虑升级 \"{0}\" 的版本。",
|
|
1496
|
-
"
|
|
1498
|
+
"This_type_parameter_might_need_an_extends_0_constraint_2208": "此类型参数可能需要 `extends {0}` 约束。",
|
|
1497
1499
|
"This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "“import” 的这种用法无效。可以写入 “import()” 调用,但它们必须具有括号,并且不能带有类型参数。",
|
|
1498
1500
|
"Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "仅当 “module” 选项设置为 “es2022”、“esnext”、“system”、“node16” 或 “nodenext”,且 “target” 选项设置为 “es2017” 或更高版本时,才允许使用顶级 “await” 表达式。",
|
|
1499
1501
|
"Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 文件中的顶级声明必须以 \"declare\" 或 \"export\" 修饰符开头。",
|
|
@@ -1651,6 +1653,7 @@
|
|
|
1651
1653
|
"Watch_and_Build_Modes_6250": "观看和生成模式",
|
|
1652
1654
|
"Watch_input_files_6005": "监视输入文件。",
|
|
1653
1655
|
"Watch_option_0_requires_a_value_of_type_1_5080": "观察选项 \"{0}\" 需要 {1} 类型的值。",
|
|
1656
|
+
"We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843": "我们只能通过在此处为整个参数添加类型来写入“{0}”的类型。",
|
|
1654
1657
|
"When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698": "分配函数时,请检查以确保参数和返回值与子类型兼容。",
|
|
1655
1658
|
"When_type_checking_take_into_account_null_and_undefined_6699": "进行类型检查时,请考虑 “null” 和 “undefined”。",
|
|
1656
1659
|
"Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191": "是否在监视模式下保留过时的控制台输出,而不是清除屏幕。",
|
|
@@ -1690,6 +1693,7 @@
|
|
|
1690
1693
|
"_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "“{0}”索引类型“{1}”不能分配给“{2}”索引类型“{3}”。",
|
|
1691
1694
|
"_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "“{0}”是基元,但“{1}”是包装器对象。如可能首选使用“{0}”。",
|
|
1692
1695
|
"_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "\"{0}\" 是一种类型,在同时启用了 \"preserveValueImports\" 和 \"isolatedModules\" 时,必须使用仅类型导入进行导入。",
|
|
1696
|
+
"_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "“{0}”是“{1}”的未使用重命名。是否打算将其用作类型批注?",
|
|
1693
1697
|
"_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "\"{0}\" 可赋给 \"{1}\" 类型的约束,但可以使用约束 \"{2}\" 的其他子类型实例化 \"{1}\"。",
|
|
1694
1698
|
"_0_is_declared_but_its_value_is_never_read_6133": "已声明“{0}”,但从未读取其值。",
|
|
1695
1699
|
"_0_is_declared_but_never_used_6196": "“{0}”已声明,但从未使用过。",
|
|
@@ -132,6 +132,8 @@
|
|
|
132
132
|
"Add_definite_assignment_assertion_to_property_0_95020": "將明確指派判斷提示新增至屬性 '{0}'",
|
|
133
133
|
"Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "為所有未初始化的屬性新增明確的指派判斷提示",
|
|
134
134
|
"Add_export_to_make_this_file_into_a_module_95097": "新增 'export {}' 以將此檔案轉為模組",
|
|
135
|
+
"Add_extends_constraint_2211": "新增 'extends' 限制式。",
|
|
136
|
+
"Add_extends_constraint_to_all_type_parameters_2212": "將 'extends' 限制式新增至所有類型參數",
|
|
135
137
|
"Add_import_from_0_90057": "從 \"{0}\" 新增匯入",
|
|
136
138
|
"Add_index_signature_for_property_0_90017": "為屬性 '{0}' 新增索引簽章",
|
|
137
139
|
"Add_initializer_to_property_0_95019": "將初始設定式新增至屬性 '{0}'",
|
|
@@ -1493,7 +1495,7 @@
|
|
|
1493
1495
|
"This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "此語法需要已匯入的協助程式,但找不到模組 '{0}'。",
|
|
1494
1496
|
"This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "此語法需要名為 '{1}' 的已匯入協助程式,但其不存在於 '{0}' 中。請考慮升級您的 '{0}' 版本。",
|
|
1495
1497
|
"This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "此語法需要名為 '{1}' 且具有 {2} 參數的匯入協助程式,其與 '{0}' 中的參數不相容。請考慮升級 '{0}' 的版本。",
|
|
1496
|
-
"
|
|
1498
|
+
"This_type_parameter_might_need_an_extends_0_constraint_2208": "此類型參數可能需要 'extends {0}' 限制式。",
|
|
1497
1499
|
"This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "此 'import' 的使用方式無效。'import()' 呼叫可以寫入,但必須有括弧,而且不能有類型引數。",
|
|
1498
1500
|
"Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "只有在 'module' 選項設定為 'es2022'、'esnext'、'system'、'node16' 或 'nodenext',而且 'target' 選項設定為 'es2017' 或更高版本時,才允許最上層的 'await' 運算式。",
|
|
1499
1501
|
"Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts 檔案中的最上層宣告必須以 'declare' 或 'export' 修飾元開頭。",
|
|
@@ -1651,6 +1653,7 @@
|
|
|
1651
1653
|
"Watch_and_Build_Modes_6250": "觀看及建置模式",
|
|
1652
1654
|
"Watch_input_files_6005": "監看輸入檔。",
|
|
1653
1655
|
"Watch_option_0_requires_a_value_of_type_1_5080": "監看選項 '{0}' 需要 {1} 類型的值。",
|
|
1656
|
+
"We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843": "我們只能在此新增整個參數的類型,來寫入 '{0}' 的類型。",
|
|
1654
1657
|
"When_assigning_functions_check_to_ensure_parameters_and_the_return_values_are_subtype_compatible_6698": "指派函式時,請檢查以確認參數,而且傳回值是子類型相容的。",
|
|
1655
1658
|
"When_type_checking_take_into_account_null_and_undefined_6699": "當型別檢查時,請將 'null' 和 'undefined' 納入考慮。",
|
|
1656
1659
|
"Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191": "是否要將已過期的主控台輸出,維持在監看模式下,而非清除螢幕。",
|
|
@@ -1690,6 +1693,7 @@
|
|
|
1690
1693
|
"_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}' 索引類型 '{1}' 無法指派給 '{2}' 索引類型 '{3}'。",
|
|
1691
1694
|
"_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' 為基元,但 '{1}' 為包裝函式物件。建議盡可能使用 '{0}'。",
|
|
1692
1695
|
"_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}' 是類型,而且當 'preserveValueImports' 和 'isolatedModules' 都啟用時,必須使用僅類型匯入來匯入。",
|
|
1696
|
+
"_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' 是未使用的 '{1}' 重新命名。您是否想要使用它作為類型註釋?",
|
|
1693
1697
|
"_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' 可指派給 '{1}' 類型的條件約束,但可能會將 '{1}' 以不同的條件約束 '{2}' 子類型來具現化。",
|
|
1694
1698
|
"_0_is_declared_but_its_value_is_never_read_6133": "'{0}' 已宣告但從未讀取其值。",
|
|
1695
1699
|
"_0_is_declared_but_never_used_6196": "宣告了 '{0}',但從未使用過。",
|