typescript 4.6.0-dev.20220204 → 4.6.0-dev.20220208
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/de/diagnosticMessages.generated.json +1 -2
- package/lib/ru/diagnosticMessages.generated.json +1 -2
- package/lib/tsc.js +55 -44
- package/lib/tsserver.js +245 -144
- package/lib/tsserverlibrary.js +245 -144
- package/lib/typescript.js +242 -142
- package/lib/typescriptServices.js +242 -142
- package/lib/typingsInstaller.js +67 -47
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -2
- package/package.json +1 -1
|
@@ -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.20220208";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -1468,11 +1468,11 @@ var ts;
|
|
|
1468
1468
|
return result;
|
|
1469
1469
|
}
|
|
1470
1470
|
ts.getAllKeys = getAllKeys;
|
|
1471
|
-
function getOwnValues(
|
|
1471
|
+
function getOwnValues(collection) {
|
|
1472
1472
|
var values = [];
|
|
1473
|
-
for (var key in
|
|
1474
|
-
if (hasOwnProperty.call(
|
|
1475
|
-
values.push(
|
|
1473
|
+
for (var key in collection) {
|
|
1474
|
+
if (hasOwnProperty.call(collection, key)) {
|
|
1475
|
+
values.push(collection[key]);
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
return values;
|
|
@@ -8875,12 +8875,10 @@ var ts;
|
|
|
8875
8875
|
Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."),
|
|
8876
8876
|
Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."),
|
|
8877
8877
|
Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."),
|
|
8878
|
-
Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."),
|
|
8879
8878
|
Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."),
|
|
8880
8879
|
This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
|
|
8881
8880
|
A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
|
|
8882
8881
|
Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
|
|
8883
|
-
Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."),
|
|
8884
8882
|
Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
|
|
8885
8883
|
Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
|
|
8886
8884
|
Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
|
|
@@ -9831,6 +9829,7 @@ var ts;
|
|
|
9831
9829
|
Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
|
|
9832
9830
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9833
9831
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9832
|
+
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9834
9833
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
9835
9834
|
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9836
9835
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -59239,7 +59238,7 @@ var ts;
|
|
|
59239
59238
|
}
|
|
59240
59239
|
function getImpliedConstraint(type, checkNode, extendsNode) {
|
|
59241
59240
|
return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
|
|
59242
|
-
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
|
|
59241
|
+
getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
|
|
59243
59242
|
undefined;
|
|
59244
59243
|
}
|
|
59245
59244
|
function getConditionalFlowTypeOfType(type, node) {
|
|
@@ -73146,23 +73145,6 @@ var ts;
|
|
|
73146
73145
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
73147
73146
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
73148
73147
|
}
|
|
73149
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
73150
|
-
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
73151
|
-
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
73152
|
-
if (n === lexicalClass_1)
|
|
73153
|
-
return "quit";
|
|
73154
|
-
if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
|
|
73155
|
-
return true;
|
|
73156
|
-
}
|
|
73157
|
-
return false;
|
|
73158
|
-
});
|
|
73159
|
-
if (parentStaticFieldInitializer) {
|
|
73160
|
-
var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
|
|
73161
|
-
ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
|
|
73162
|
-
var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol));
|
|
73163
|
-
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
|
|
73164
|
-
}
|
|
73165
|
-
}
|
|
73166
73148
|
if (isAnyLike) {
|
|
73167
73149
|
if (lexicallyScopedSymbol) {
|
|
73168
73150
|
return isErrorType(apparentType) ? errorType : apparentType;
|
|
@@ -78798,9 +78780,6 @@ var ts;
|
|
|
78798
78780
|
checkGrammarComputedPropertyName(node.name);
|
|
78799
78781
|
checkVariableLikeDeclaration(node);
|
|
78800
78782
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
78801
|
-
if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
|
|
78802
|
-
error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
|
|
78803
|
-
}
|
|
78804
78783
|
// property signatures already report "initializer not allowed in ambient context" elsewhere
|
|
78805
78784
|
if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
|
|
78806
78785
|
error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
|
|
@@ -92490,10 +92469,12 @@ var ts;
|
|
|
92490
92469
|
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
92491
92470
|
var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
|
|
92492
92471
|
var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
|
|
92472
|
+
// We need to transform `this` in a static initializer into a reference to the class
|
|
92473
|
+
// when targeting < ES2022 since the assignment will be moved outside of the class body.
|
|
92474
|
+
var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
|
|
92493
92475
|
// We don't need to transform `super` property access when targeting ES5, ES3 because
|
|
92494
92476
|
// the es2015 transformation handles those.
|
|
92495
|
-
var shouldTransformSuperInStaticInitializers =
|
|
92496
|
-
var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
|
|
92477
|
+
var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
|
|
92497
92478
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
92498
92479
|
context.onSubstituteNode = onSubstituteNode;
|
|
92499
92480
|
var previousOnEmitNode = context.onEmitNode;
|
|
@@ -92722,6 +92703,10 @@ var ts;
|
|
|
92722
92703
|
ts.Debug.assert(!ts.some(node.decorators));
|
|
92723
92704
|
if (ts.isPrivateIdentifier(node.name)) {
|
|
92724
92705
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
92706
|
+
if (ts.isStatic(node)) {
|
|
92707
|
+
// static fields are left as is
|
|
92708
|
+
return ts.visitEachChild(node, visitor, context);
|
|
92709
|
+
}
|
|
92725
92710
|
// Initializer is elided as the field is initialized in transformConstructor.
|
|
92726
92711
|
return factory.updatePropertyDeclaration(node,
|
|
92727
92712
|
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
|
|
@@ -92743,6 +92728,22 @@ var ts;
|
|
|
92743
92728
|
if (expr && !ts.isSimpleInlineableExpression(expr)) {
|
|
92744
92729
|
getPendingExpressions().push(expr);
|
|
92745
92730
|
}
|
|
92731
|
+
if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
92732
|
+
var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
|
|
92733
|
+
if (initializerStatement) {
|
|
92734
|
+
var staticBlock = factory.createClassStaticBlockDeclaration(
|
|
92735
|
+
/*decorators*/ undefined,
|
|
92736
|
+
/*modifiers*/ undefined, factory.createBlock([initializerStatement]));
|
|
92737
|
+
ts.setOriginalNode(staticBlock, node);
|
|
92738
|
+
ts.setCommentRange(staticBlock, node);
|
|
92739
|
+
// Set the comment range for the statement to an empty synthetic range
|
|
92740
|
+
// and drop synthetic comments from the statement to avoid printing them twice.
|
|
92741
|
+
ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
|
|
92742
|
+
ts.setSyntheticLeadingComments(initializerStatement, undefined);
|
|
92743
|
+
ts.setSyntheticTrailingComments(initializerStatement, undefined);
|
|
92744
|
+
return staticBlock;
|
|
92745
|
+
}
|
|
92746
|
+
}
|
|
92746
92747
|
return undefined;
|
|
92747
92748
|
}
|
|
92748
92749
|
function createPrivateIdentifierAccess(info, receiver) {
|
|
@@ -93130,7 +93131,6 @@ var ts;
|
|
|
93130
93131
|
if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
|
|
93131
93132
|
enableSubstitutionForClassStaticThisOrSuperReference();
|
|
93132
93133
|
}
|
|
93133
|
-
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
93134
93134
|
// If a class has private static fields, or a static field has a `this` or `super` reference,
|
|
93135
93135
|
// then we need to allocate a temp variable to hold on to that reference.
|
|
93136
93136
|
var pendingClassReferenceAssignment;
|
|
@@ -93158,6 +93158,7 @@ var ts;
|
|
|
93158
93158
|
// From ES6 specification:
|
|
93159
93159
|
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
|
93160
93160
|
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
|
93161
|
+
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
93161
93162
|
if (ts.some(staticProperties)) {
|
|
93162
93163
|
addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
|
|
93163
93164
|
}
|
|
@@ -93196,7 +93197,7 @@ var ts;
|
|
|
93196
93197
|
}
|
|
93197
93198
|
var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
|
|
93198
93199
|
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
|
|
93199
|
-
var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer ||
|
|
93200
|
+
var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
|
|
93200
93201
|
if (hasTransformableStatics || ts.some(pendingExpressions)) {
|
|
93201
93202
|
if (isDecoratedClassDeclaration) {
|
|
93202
93203
|
ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
|
|
@@ -93243,6 +93244,7 @@ var ts;
|
|
|
93243
93244
|
return undefined;
|
|
93244
93245
|
}
|
|
93245
93246
|
function transformClassMembers(node, isDerivedClass) {
|
|
93247
|
+
var members = [];
|
|
93246
93248
|
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
93247
93249
|
// Declare private names.
|
|
93248
93250
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
@@ -93255,12 +93257,20 @@ var ts;
|
|
|
93255
93257
|
createBrandCheckWeakSetForPrivateMethods();
|
|
93256
93258
|
}
|
|
93257
93259
|
}
|
|
93258
|
-
var members = [];
|
|
93259
93260
|
var constructor = transformConstructor(node, isDerivedClass);
|
|
93261
|
+
var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
|
|
93260
93262
|
if (constructor) {
|
|
93261
93263
|
members.push(constructor);
|
|
93262
93264
|
}
|
|
93263
|
-
|
|
93265
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
|
|
93266
|
+
members.push(factory.createClassStaticBlockDeclaration(
|
|
93267
|
+
/*decorators*/ undefined,
|
|
93268
|
+
/*modifiers*/ undefined, factory.createBlock([
|
|
93269
|
+
factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
|
|
93270
|
+
])));
|
|
93271
|
+
pendingExpressions = undefined;
|
|
93272
|
+
}
|
|
93273
|
+
ts.addRange(members, visitedMembers);
|
|
93264
93274
|
return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
|
93265
93275
|
}
|
|
93266
93276
|
function createBrandCheckWeakSetForPrivateMethods() {
|
|
@@ -93403,24 +93413,34 @@ var ts;
|
|
|
93403
93413
|
function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
|
|
93404
93414
|
for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
|
|
93405
93415
|
var property = properties_7[_i];
|
|
93406
|
-
|
|
93407
|
-
|
|
93408
|
-
|
|
93409
|
-
|
|
93416
|
+
if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
93417
|
+
continue;
|
|
93418
|
+
}
|
|
93419
|
+
var statement = transformPropertyOrClassStaticBlock(property, receiver);
|
|
93420
|
+
if (!statement) {
|
|
93410
93421
|
continue;
|
|
93411
93422
|
}
|
|
93412
|
-
var statement = factory.createExpressionStatement(expression);
|
|
93413
|
-
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93414
|
-
ts.setCommentRange(statement, property);
|
|
93415
|
-
ts.setOriginalNode(statement, property);
|
|
93416
|
-
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93417
|
-
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93418
|
-
// Drop the comments from expression to avoid printing them twice.
|
|
93419
|
-
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93420
|
-
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93421
93423
|
statements.push(statement);
|
|
93422
93424
|
}
|
|
93423
93425
|
}
|
|
93426
|
+
function transformPropertyOrClassStaticBlock(property, receiver) {
|
|
93427
|
+
var expression = ts.isClassStaticBlockDeclaration(property) ?
|
|
93428
|
+
transformClassStaticBlockDeclaration(property) :
|
|
93429
|
+
transformProperty(property, receiver);
|
|
93430
|
+
if (!expression) {
|
|
93431
|
+
return undefined;
|
|
93432
|
+
}
|
|
93433
|
+
var statement = factory.createExpressionStatement(expression);
|
|
93434
|
+
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93435
|
+
ts.setCommentRange(statement, property);
|
|
93436
|
+
ts.setOriginalNode(statement, property);
|
|
93437
|
+
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93438
|
+
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93439
|
+
// Drop the comments from expression to avoid printing them twice.
|
|
93440
|
+
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93441
|
+
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93442
|
+
return statement;
|
|
93443
|
+
}
|
|
93424
93444
|
/**
|
|
93425
93445
|
* Generates assignment expressions for property initializers.
|
|
93426
93446
|
*
|
|
@@ -127300,15 +127320,35 @@ var ts;
|
|
|
127300
127320
|
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
|
|
127301
127321
|
}
|
|
127302
127322
|
ts.firstOrOnly = firstOrOnly;
|
|
127323
|
+
function getNamesForExportedSymbol(symbol, scriptTarget) {
|
|
127324
|
+
if (needsNameFromDeclaration(symbol)) {
|
|
127325
|
+
var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
|
|
127326
|
+
if (fromDeclaration)
|
|
127327
|
+
return fromDeclaration;
|
|
127328
|
+
var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
|
|
127329
|
+
var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
|
|
127330
|
+
if (fileNameCase === capitalized)
|
|
127331
|
+
return fileNameCase;
|
|
127332
|
+
return [fileNameCase, capitalized];
|
|
127333
|
+
}
|
|
127334
|
+
return symbol.name;
|
|
127335
|
+
}
|
|
127336
|
+
ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
|
|
127303
127337
|
function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
|
|
127304
|
-
if (
|
|
127338
|
+
if (needsNameFromDeclaration(symbol)) {
|
|
127305
127339
|
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
|
127306
|
-
return
|
|
127340
|
+
return getDefaultLikeExportNameFromDeclaration(symbol)
|
|
127307
127341
|
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
|
|
127308
127342
|
}
|
|
127309
127343
|
return symbol.name;
|
|
127310
127344
|
}
|
|
127311
127345
|
ts.getNameForExportedSymbol = getNameForExportedSymbol;
|
|
127346
|
+
function needsNameFromDeclaration(symbol) {
|
|
127347
|
+
return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
|
|
127348
|
+
}
|
|
127349
|
+
function getDefaultLikeExportNameFromDeclaration(symbol) {
|
|
127350
|
+
return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; });
|
|
127351
|
+
}
|
|
127312
127352
|
function getSymbolParentOrFail(symbol) {
|
|
127313
127353
|
var _a;
|
|
127314
127354
|
return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
|
|
@@ -127478,9 +127518,11 @@ var ts;
|
|
|
127478
127518
|
// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
|
|
127479
127519
|
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
|
|
127480
127520
|
// get a better name.
|
|
127481
|
-
var
|
|
127521
|
+
var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
127482
127522
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
127483
|
-
: ts.
|
|
127523
|
+
: ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
|
|
127524
|
+
var symbolName = typeof names === "string" ? names : names[0];
|
|
127525
|
+
var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
|
|
127484
127526
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
127485
127527
|
var id = exportInfoId++;
|
|
127486
127528
|
var target = ts.skipAlias(symbol, checker);
|
|
@@ -127488,10 +127530,11 @@ var ts;
|
|
|
127488
127530
|
var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
|
|
127489
127531
|
if (!storedSymbol || !storedModuleSymbol)
|
|
127490
127532
|
symbols.set(id, [symbol, moduleSymbol]);
|
|
127491
|
-
exportInfo.add(key(
|
|
127533
|
+
exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
|
|
127492
127534
|
id: id,
|
|
127493
127535
|
symbolTableKey: symbolTableKey,
|
|
127494
|
-
symbolName:
|
|
127536
|
+
symbolName: symbolName,
|
|
127537
|
+
capitalizedSymbolName: capitalizedSymbolName,
|
|
127495
127538
|
moduleName: moduleName,
|
|
127496
127539
|
moduleFile: moduleFile,
|
|
127497
127540
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
@@ -127509,21 +127552,18 @@ var ts;
|
|
|
127509
127552
|
var result = exportInfo.get(key);
|
|
127510
127553
|
return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
|
|
127511
127554
|
},
|
|
127512
|
-
|
|
127555
|
+
search: function (importingFile, preferCapitalized, matches, action) {
|
|
127513
127556
|
if (importingFile !== usableByFileName)
|
|
127514
127557
|
return;
|
|
127515
127558
|
exportInfo.forEach(function (info, key) {
|
|
127516
127559
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
127517
|
-
var
|
|
127518
|
-
|
|
127519
|
-
|
|
127520
|
-
|
|
127521
|
-
|
|
127522
|
-
|
|
127523
|
-
|
|
127524
|
-
? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
|
|
127525
|
-
: symbolName;
|
|
127526
|
-
}, !!ambientModuleName, key);
|
|
127560
|
+
var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
|
|
127561
|
+
if (matches(name, info[0].targetFlags)) {
|
|
127562
|
+
var rehydrated = info.map(rehydrateCachedInfo);
|
|
127563
|
+
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
|
|
127564
|
+
if (filtered.length) {
|
|
127565
|
+
action(filtered, name, !!ambientModuleName, key);
|
|
127566
|
+
}
|
|
127527
127567
|
}
|
|
127528
127568
|
});
|
|
127529
127569
|
},
|
|
@@ -130899,7 +130939,8 @@ var ts;
|
|
|
130899
130939
|
case 103 /* NewKeyword */:
|
|
130900
130940
|
return checker.getContextualType(parent);
|
|
130901
130941
|
case 82 /* CaseKeyword */:
|
|
130902
|
-
|
|
130942
|
+
var caseClause = ts.tryCast(parent, ts.isCaseClause);
|
|
130943
|
+
return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
|
|
130903
130944
|
case 18 /* OpenBraceToken */:
|
|
130904
130945
|
return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
|
|
130905
130946
|
default:
|
|
@@ -131639,44 +131680,47 @@ var ts;
|
|
|
131639
131680
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
131640
131681
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
131641
131682
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
131642
|
-
exportInfo.
|
|
131643
|
-
|
|
131683
|
+
exportInfo.search(sourceFile.path,
|
|
131684
|
+
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
131644
131685
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
131645
|
-
return;
|
|
131686
|
+
return false;
|
|
131646
131687
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
131647
|
-
return;
|
|
131648
|
-
|
|
131649
|
-
|
|
131650
|
-
|
|
131651
|
-
|
|
131652
|
-
return;
|
|
131688
|
+
return false;
|
|
131689
|
+
if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
|
|
131690
|
+
return false;
|
|
131691
|
+
if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
131692
|
+
return false;
|
|
131653
131693
|
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
131654
131694
|
var firstChar = symbolName.charCodeAt(0);
|
|
131655
131695
|
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
131696
|
+
return false;
|
|
131697
|
+
if (detailsEntryId)
|
|
131698
|
+
return true;
|
|
131699
|
+
return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
|
|
131700
|
+
}, function (info, symbolName, isFromAmbientModule, exportMapKey) {
|
|
131701
|
+
if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
|
|
131702
|
+
return;
|
|
131703
|
+
}
|
|
131704
|
+
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
131705
|
+
if (!defaultExportInfo) {
|
|
131656
131706
|
return;
|
|
131657
|
-
var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
|
|
131658
|
-
if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
|
|
131659
|
-
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
131660
|
-
if (!defaultExportInfo) {
|
|
131661
|
-
return;
|
|
131662
|
-
}
|
|
131663
|
-
// If we don't need to resolve module specifiers, we can use any re-export that is importable at all
|
|
131664
|
-
// (We need to ensure that at least one is importable to show a completion.)
|
|
131665
|
-
var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
|
|
131666
|
-
var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
|
|
131667
|
-
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
|
|
131668
|
-
pushAutoImportSymbol(symbol, {
|
|
131669
|
-
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
131670
|
-
moduleSpecifier: moduleSpecifier,
|
|
131671
|
-
symbolName: symbolName,
|
|
131672
|
-
exportMapKey: exportMapKey,
|
|
131673
|
-
exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
|
|
131674
|
-
fileName: exportInfo_1.moduleFileName,
|
|
131675
|
-
isDefaultExport: isDefaultExport,
|
|
131676
|
-
moduleSymbol: exportInfo_1.moduleSymbol,
|
|
131677
|
-
isFromPackageJson: exportInfo_1.isFromPackageJson,
|
|
131678
|
-
});
|
|
131679
131707
|
}
|
|
131708
|
+
// If we don't need to resolve module specifiers, we can use any re-export that is importable at all
|
|
131709
|
+
// (We need to ensure that at least one is importable to show a completion.)
|
|
131710
|
+
var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
|
|
131711
|
+
var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
|
|
131712
|
+
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
|
|
131713
|
+
pushAutoImportSymbol(symbol, {
|
|
131714
|
+
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
131715
|
+
moduleSpecifier: moduleSpecifier,
|
|
131716
|
+
symbolName: symbolName,
|
|
131717
|
+
exportMapKey: exportMapKey,
|
|
131718
|
+
exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
|
|
131719
|
+
fileName: exportInfo.moduleFileName,
|
|
131720
|
+
isDefaultExport: isDefaultExport,
|
|
131721
|
+
moduleSymbol: exportInfo.moduleSymbol,
|
|
131722
|
+
isFromPackageJson: exportInfo.isFromPackageJson,
|
|
131723
|
+
});
|
|
131680
131724
|
});
|
|
131681
131725
|
hasUnresolvedAutoImports = context.resolutionLimitExceeded();
|
|
131682
131726
|
});
|
|
@@ -133541,7 +133585,24 @@ var ts;
|
|
|
133541
133585
|
function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
133542
133586
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
133543
133587
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
133588
|
+
var oldBucketCount = buckets.size;
|
|
133544
133589
|
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
|
|
133590
|
+
if (ts.tracing) {
|
|
133591
|
+
if (buckets.size > oldBucketCount) {
|
|
133592
|
+
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
133593
|
+
// perhaps they are for two projects that don't have any overlap.
|
|
133594
|
+
// Bonus: these events can help us interpret the more interesting event below.
|
|
133595
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
|
|
133596
|
+
}
|
|
133597
|
+
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
133598
|
+
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
133599
|
+
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
133600
|
+
var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
|
|
133601
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
|
|
133602
|
+
if (otherBucketKey) {
|
|
133603
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
|
|
133604
|
+
}
|
|
133605
|
+
}
|
|
133545
133606
|
var bucketEntry = bucket.get(path);
|
|
133546
133607
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
133547
133608
|
if (!entry && externalCache) {
|
|
@@ -137615,7 +137676,27 @@ var ts;
|
|
|
137615
137676
|
case 326 /* JSDocAugmentsTag */:
|
|
137616
137677
|
return withNode(tag.class);
|
|
137617
137678
|
case 342 /* JSDocTemplateTag */:
|
|
137618
|
-
|
|
137679
|
+
var templateTag = tag;
|
|
137680
|
+
var displayParts_3 = [];
|
|
137681
|
+
if (templateTag.constraint) {
|
|
137682
|
+
displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
|
|
137683
|
+
}
|
|
137684
|
+
if (ts.length(templateTag.typeParameters)) {
|
|
137685
|
+
if (ts.length(displayParts_3)) {
|
|
137686
|
+
displayParts_3.push(ts.spacePart());
|
|
137687
|
+
}
|
|
137688
|
+
var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
|
|
137689
|
+
ts.forEach(templateTag.typeParameters, function (tp) {
|
|
137690
|
+
displayParts_3.push(namePart(tp.getText()));
|
|
137691
|
+
if (lastTypeParameter_1 !== tp) {
|
|
137692
|
+
displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
|
|
137693
|
+
}
|
|
137694
|
+
});
|
|
137695
|
+
}
|
|
137696
|
+
if (comment) {
|
|
137697
|
+
displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
|
|
137698
|
+
}
|
|
137699
|
+
return displayParts_3;
|
|
137619
137700
|
case 341 /* JSDocTypeTag */:
|
|
137620
137701
|
return withNode(tag.typeExpression);
|
|
137621
137702
|
case 343 /* JSDocTypedefTag */:
|
|
@@ -141041,12 +141122,12 @@ var ts;
|
|
|
141041
141122
|
: { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
|
|
141042
141123
|
}
|
|
141043
141124
|
SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
|
|
141044
|
-
function getArgumentOrParameterListInfo(node, sourceFile) {
|
|
141125
|
+
function getArgumentOrParameterListInfo(node, position, sourceFile) {
|
|
141045
141126
|
var info = getArgumentOrParameterListAndIndex(node, sourceFile);
|
|
141046
141127
|
if (!info)
|
|
141047
141128
|
return undefined;
|
|
141048
141129
|
var list = info.list, argumentIndex = info.argumentIndex;
|
|
141049
|
-
var argumentCount = getArgumentCount(list);
|
|
141130
|
+
var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
|
|
141050
141131
|
if (argumentIndex !== 0) {
|
|
141051
141132
|
ts.Debug.assertLessThan(argumentIndex, argumentCount);
|
|
141052
141133
|
}
|
|
@@ -141092,7 +141173,7 @@ var ts;
|
|
|
141092
141173
|
// Case 3:
|
|
141093
141174
|
// foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
|
|
141094
141175
|
// Find out if 'node' is an argument, a type argument, or neither
|
|
141095
|
-
var info = getArgumentOrParameterListInfo(node, sourceFile);
|
|
141176
|
+
var info = getArgumentOrParameterListInfo(node, position, sourceFile);
|
|
141096
141177
|
if (!info)
|
|
141097
141178
|
return undefined;
|
|
141098
141179
|
var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141161,8 +141242,8 @@ var ts;
|
|
|
141161
141242
|
function countBinaryExpressionParameters(b) {
|
|
141162
141243
|
return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
|
|
141163
141244
|
}
|
|
141164
|
-
function tryGetParameterInfo(startingToken,
|
|
141165
|
-
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
|
|
141245
|
+
function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
|
|
141246
|
+
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
|
|
141166
141247
|
if (!info)
|
|
141167
141248
|
return undefined;
|
|
141168
141249
|
var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141174,7 +141255,7 @@ var ts;
|
|
|
141174
141255
|
var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
|
|
141175
141256
|
return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
|
|
141176
141257
|
}
|
|
141177
|
-
function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
|
|
141258
|
+
function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
|
|
141178
141259
|
if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
|
|
141179
141260
|
return undefined;
|
|
141180
141261
|
var parent = startingToken.parent;
|
|
@@ -141183,7 +141264,7 @@ var ts;
|
|
|
141183
141264
|
case 168 /* MethodDeclaration */:
|
|
141184
141265
|
case 212 /* FunctionExpression */:
|
|
141185
141266
|
case 213 /* ArrowFunction */:
|
|
141186
|
-
var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
|
|
141267
|
+
var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
|
|
141187
141268
|
if (!info)
|
|
141188
141269
|
return undefined;
|
|
141189
141270
|
var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141230,7 +141311,7 @@ var ts;
|
|
|
141230
141311
|
}
|
|
141231
141312
|
return argumentIndex;
|
|
141232
141313
|
}
|
|
141233
|
-
function getArgumentCount(argumentsList) {
|
|
141314
|
+
function getArgumentCount(argumentsList, ignoreTrailingComma) {
|
|
141234
141315
|
// The argument count for a list is normally the number of non-comma children it has.
|
|
141235
141316
|
// For example, if you have "Foo(a,b)" then there will be three children of the arg
|
|
141236
141317
|
// list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
|
|
@@ -141244,7 +141325,7 @@ var ts;
|
|
|
141244
141325
|
// arg count of 3.
|
|
141245
141326
|
var listChildren = argumentsList.getChildren();
|
|
141246
141327
|
var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
|
|
141247
|
-
if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
141328
|
+
if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
141248
141329
|
argumentCount++;
|
|
141249
141330
|
}
|
|
141250
141331
|
return argumentCount;
|
|
@@ -156243,51 +156324,53 @@ var ts;
|
|
|
156243
156324
|
(function (ts) {
|
|
156244
156325
|
var refactor;
|
|
156245
156326
|
(function (refactor) {
|
|
156327
|
+
var _a;
|
|
156246
156328
|
var refactorName = "Convert import";
|
|
156247
|
-
var
|
|
156248
|
-
|
|
156249
|
-
|
|
156250
|
-
|
|
156251
|
-
|
|
156252
|
-
|
|
156253
|
-
|
|
156254
|
-
|
|
156255
|
-
|
|
156256
|
-
|
|
156329
|
+
var actions = (_a = {},
|
|
156330
|
+
_a[0 /* Named */] = {
|
|
156331
|
+
name: "Convert namespace import to named imports",
|
|
156332
|
+
description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
|
|
156333
|
+
kind: "refactor.rewrite.import.named",
|
|
156334
|
+
},
|
|
156335
|
+
_a[2 /* Namespace */] = {
|
|
156336
|
+
name: "Convert named imports to namespace import",
|
|
156337
|
+
description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
|
|
156338
|
+
kind: "refactor.rewrite.import.namespace",
|
|
156339
|
+
},
|
|
156340
|
+
_a[1 /* Default */] = {
|
|
156341
|
+
name: "Convert named imports to default import",
|
|
156342
|
+
description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
|
|
156343
|
+
kind: "refactor.rewrite.import.default",
|
|
156344
|
+
},
|
|
156345
|
+
_a);
|
|
156257
156346
|
refactor.registerRefactor(refactorName, {
|
|
156258
|
-
kinds:
|
|
156259
|
-
namespaceToNamedAction.kind,
|
|
156260
|
-
namedToNamespaceAction.kind
|
|
156261
|
-
],
|
|
156347
|
+
kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
|
|
156262
156348
|
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
|
|
156263
|
-
var info =
|
|
156349
|
+
var info = getImportConversionInfo(context, context.triggerReason === "invoked");
|
|
156264
156350
|
if (!info)
|
|
156265
156351
|
return ts.emptyArray;
|
|
156266
156352
|
if (!refactor.isRefactorErrorInfo(info)) {
|
|
156267
|
-
var
|
|
156268
|
-
var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
|
|
156353
|
+
var action = actions[info.convertTo];
|
|
156269
156354
|
return [{ name: refactorName, description: action.description, actions: [action] }];
|
|
156270
156355
|
}
|
|
156271
156356
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
156272
|
-
return
|
|
156273
|
-
|
|
156274
|
-
|
|
156275
|
-
|
|
156276
|
-
|
|
156277
|
-
];
|
|
156357
|
+
return ts.getOwnValues(actions).map(function (action) { return ({
|
|
156358
|
+
name: refactorName,
|
|
156359
|
+
description: action.description,
|
|
156360
|
+
actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
|
|
156361
|
+
}); });
|
|
156278
156362
|
}
|
|
156279
156363
|
return ts.emptyArray;
|
|
156280
156364
|
},
|
|
156281
156365
|
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
|
|
156282
|
-
ts.Debug.assert(
|
|
156283
|
-
var info =
|
|
156366
|
+
ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
|
|
156367
|
+
var info = getImportConversionInfo(context);
|
|
156284
156368
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156285
156369
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
|
|
156286
156370
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
156287
156371
|
}
|
|
156288
156372
|
});
|
|
156289
|
-
|
|
156290
|
-
function getImportToConvert(context, considerPartialSpans) {
|
|
156373
|
+
function getImportConversionInfo(context, considerPartialSpans) {
|
|
156291
156374
|
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
|
|
156292
156375
|
var file = context.file;
|
|
156293
156376
|
var span = ts.getRefactorContextSpan(context);
|
|
@@ -156306,15 +156389,23 @@ var ts;
|
|
|
156306
156389
|
if (!importClause.namedBindings) {
|
|
156307
156390
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
|
|
156308
156391
|
}
|
|
156309
|
-
|
|
156392
|
+
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
156393
|
+
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
156394
|
+
}
|
|
156395
|
+
var compilerOptions = context.program.getCompilerOptions();
|
|
156396
|
+
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
156397
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
156398
|
+
return shouldUseDefault
|
|
156399
|
+
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
156400
|
+
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
156310
156401
|
}
|
|
156311
|
-
function doChange(sourceFile, program, changes,
|
|
156402
|
+
function doChange(sourceFile, program, changes, info) {
|
|
156312
156403
|
var checker = program.getTypeChecker();
|
|
156313
|
-
if (
|
|
156314
|
-
doChangeNamespaceToNamed(sourceFile, checker, changes,
|
|
156404
|
+
if (info.convertTo === 0 /* Named */) {
|
|
156405
|
+
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
156315
156406
|
}
|
|
156316
156407
|
else {
|
|
156317
|
-
|
|
156408
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
|
|
156318
156409
|
}
|
|
156319
156410
|
}
|
|
156320
156411
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -156364,7 +156455,7 @@ var ts;
|
|
|
156364
156455
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
156365
156456
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
156366
156457
|
}
|
|
156367
|
-
function
|
|
156458
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
|
|
156368
156459
|
var importDecl = toConvert.parent.parent;
|
|
156369
156460
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
156370
156461
|
var toConvertSymbols = new ts.Set();
|
|
@@ -156415,7 +156506,9 @@ var ts;
|
|
|
156415
156506
|
var element = _a[_i];
|
|
156416
156507
|
_loop_17(element);
|
|
156417
156508
|
}
|
|
156418
|
-
changes.replaceNode(sourceFile, toConvert,
|
|
156509
|
+
changes.replaceNode(sourceFile, toConvert, shouldUseDefault
|
|
156510
|
+
? ts.factory.createIdentifier(namespaceImportName)
|
|
156511
|
+
: ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
|
|
156419
156512
|
if (neededNamedImports.size) {
|
|
156420
156513
|
var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
|
|
156421
156514
|
return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
|
|
@@ -156423,6 +156516,13 @@ var ts;
|
|
|
156423
156516
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
156424
156517
|
}
|
|
156425
156518
|
}
|
|
156519
|
+
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
156520
|
+
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
156521
|
+
if (!externalModule)
|
|
156522
|
+
return false;
|
|
156523
|
+
var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
|
|
156524
|
+
return externalModule !== exportEquals;
|
|
156525
|
+
}
|
|
156426
156526
|
function updateImport(old, defaultImportName, elements) {
|
|
156427
156527
|
return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
|
|
156428
156528
|
}
|
|
@@ -157278,8 +157378,8 @@ var ts;
|
|
|
157278
157378
|
// but a super *method call* simply implies a 'this' reference
|
|
157279
157379
|
if (node.parent.kind === 207 /* CallExpression */) {
|
|
157280
157380
|
// Super constructor call
|
|
157281
|
-
var containingClass_1 = ts.getContainingClass(node);
|
|
157282
|
-
if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
157381
|
+
var containingClass_1 = ts.getContainingClass(node);
|
|
157382
|
+
if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
|
|
157283
157383
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
|
|
157284
157384
|
return true;
|
|
157285
157385
|
}
|