typescript 4.6.0-dev.20220203 → 4.6.0-dev.20220207
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/tsc.js +54 -43
- package/lib/tsserver.js +233 -139
- package/lib/tsserverlibrary.js +233 -139
- package/lib/typescript.js +233 -139
- package/lib/typescriptServices.js +233 -139
- package/lib/typingsInstaller.js +66 -46
- 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.20220207";
|
|
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?"),
|
|
@@ -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
|
},
|
|
@@ -131639,44 +131679,47 @@ var ts;
|
|
|
131639
131679
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
131640
131680
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
131641
131681
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
131642
|
-
exportInfo.
|
|
131643
|
-
|
|
131682
|
+
exportInfo.search(sourceFile.path,
|
|
131683
|
+
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
131644
131684
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
131645
|
-
return;
|
|
131685
|
+
return false;
|
|
131646
131686
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
131647
|
-
return;
|
|
131648
|
-
|
|
131649
|
-
|
|
131650
|
-
|
|
131651
|
-
|
|
131652
|
-
return;
|
|
131687
|
+
return false;
|
|
131688
|
+
if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
|
|
131689
|
+
return false;
|
|
131690
|
+
if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
131691
|
+
return false;
|
|
131653
131692
|
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
131654
131693
|
var firstChar = symbolName.charCodeAt(0);
|
|
131655
131694
|
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
131695
|
+
return false;
|
|
131696
|
+
if (detailsEntryId)
|
|
131697
|
+
return true;
|
|
131698
|
+
return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
|
|
131699
|
+
}, function (info, symbolName, isFromAmbientModule, exportMapKey) {
|
|
131700
|
+
if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
|
|
131701
|
+
return;
|
|
131702
|
+
}
|
|
131703
|
+
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
131704
|
+
if (!defaultExportInfo) {
|
|
131656
131705
|
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
131706
|
}
|
|
131707
|
+
// If we don't need to resolve module specifiers, we can use any re-export that is importable at all
|
|
131708
|
+
// (We need to ensure that at least one is importable to show a completion.)
|
|
131709
|
+
var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
|
|
131710
|
+
var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
|
|
131711
|
+
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
|
|
131712
|
+
pushAutoImportSymbol(symbol, {
|
|
131713
|
+
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
131714
|
+
moduleSpecifier: moduleSpecifier,
|
|
131715
|
+
symbolName: symbolName,
|
|
131716
|
+
exportMapKey: exportMapKey,
|
|
131717
|
+
exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
|
|
131718
|
+
fileName: exportInfo.moduleFileName,
|
|
131719
|
+
isDefaultExport: isDefaultExport,
|
|
131720
|
+
moduleSymbol: exportInfo.moduleSymbol,
|
|
131721
|
+
isFromPackageJson: exportInfo.isFromPackageJson,
|
|
131722
|
+
});
|
|
131680
131723
|
});
|
|
131681
131724
|
hasUnresolvedAutoImports = context.resolutionLimitExceeded();
|
|
131682
131725
|
});
|
|
@@ -137615,7 +137658,27 @@ var ts;
|
|
|
137615
137658
|
case 326 /* JSDocAugmentsTag */:
|
|
137616
137659
|
return withNode(tag.class);
|
|
137617
137660
|
case 342 /* JSDocTemplateTag */:
|
|
137618
|
-
|
|
137661
|
+
var templateTag = tag;
|
|
137662
|
+
var displayParts_3 = [];
|
|
137663
|
+
if (templateTag.constraint) {
|
|
137664
|
+
displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
|
|
137665
|
+
}
|
|
137666
|
+
if (ts.length(templateTag.typeParameters)) {
|
|
137667
|
+
if (ts.length(displayParts_3)) {
|
|
137668
|
+
displayParts_3.push(ts.spacePart());
|
|
137669
|
+
}
|
|
137670
|
+
var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
|
|
137671
|
+
ts.forEach(templateTag.typeParameters, function (tp) {
|
|
137672
|
+
displayParts_3.push(namePart(tp.getText()));
|
|
137673
|
+
if (lastTypeParameter_1 !== tp) {
|
|
137674
|
+
displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
|
|
137675
|
+
}
|
|
137676
|
+
});
|
|
137677
|
+
}
|
|
137678
|
+
if (comment) {
|
|
137679
|
+
displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
|
|
137680
|
+
}
|
|
137681
|
+
return displayParts_3;
|
|
137619
137682
|
case 341 /* JSDocTypeTag */:
|
|
137620
137683
|
return withNode(tag.typeExpression);
|
|
137621
137684
|
case 343 /* JSDocTypedefTag */:
|
|
@@ -141041,12 +141104,12 @@ var ts;
|
|
|
141041
141104
|
: { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
|
|
141042
141105
|
}
|
|
141043
141106
|
SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
|
|
141044
|
-
function getArgumentOrParameterListInfo(node, sourceFile) {
|
|
141107
|
+
function getArgumentOrParameterListInfo(node, position, sourceFile) {
|
|
141045
141108
|
var info = getArgumentOrParameterListAndIndex(node, sourceFile);
|
|
141046
141109
|
if (!info)
|
|
141047
141110
|
return undefined;
|
|
141048
141111
|
var list = info.list, argumentIndex = info.argumentIndex;
|
|
141049
|
-
var argumentCount = getArgumentCount(list);
|
|
141112
|
+
var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
|
|
141050
141113
|
if (argumentIndex !== 0) {
|
|
141051
141114
|
ts.Debug.assertLessThan(argumentIndex, argumentCount);
|
|
141052
141115
|
}
|
|
@@ -141092,7 +141155,7 @@ var ts;
|
|
|
141092
141155
|
// Case 3:
|
|
141093
141156
|
// foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
|
|
141094
141157
|
// Find out if 'node' is an argument, a type argument, or neither
|
|
141095
|
-
var info = getArgumentOrParameterListInfo(node, sourceFile);
|
|
141158
|
+
var info = getArgumentOrParameterListInfo(node, position, sourceFile);
|
|
141096
141159
|
if (!info)
|
|
141097
141160
|
return undefined;
|
|
141098
141161
|
var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141161,8 +141224,8 @@ var ts;
|
|
|
141161
141224
|
function countBinaryExpressionParameters(b) {
|
|
141162
141225
|
return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
|
|
141163
141226
|
}
|
|
141164
|
-
function tryGetParameterInfo(startingToken,
|
|
141165
|
-
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
|
|
141227
|
+
function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
|
|
141228
|
+
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
|
|
141166
141229
|
if (!info)
|
|
141167
141230
|
return undefined;
|
|
141168
141231
|
var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141174,7 +141237,7 @@ var ts;
|
|
|
141174
141237
|
var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
|
|
141175
141238
|
return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
|
|
141176
141239
|
}
|
|
141177
|
-
function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
|
|
141240
|
+
function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
|
|
141178
141241
|
if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
|
|
141179
141242
|
return undefined;
|
|
141180
141243
|
var parent = startingToken.parent;
|
|
@@ -141183,7 +141246,7 @@ var ts;
|
|
|
141183
141246
|
case 168 /* MethodDeclaration */:
|
|
141184
141247
|
case 212 /* FunctionExpression */:
|
|
141185
141248
|
case 213 /* ArrowFunction */:
|
|
141186
|
-
var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
|
|
141249
|
+
var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
|
|
141187
141250
|
if (!info)
|
|
141188
141251
|
return undefined;
|
|
141189
141252
|
var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -141230,7 +141293,7 @@ var ts;
|
|
|
141230
141293
|
}
|
|
141231
141294
|
return argumentIndex;
|
|
141232
141295
|
}
|
|
141233
|
-
function getArgumentCount(argumentsList) {
|
|
141296
|
+
function getArgumentCount(argumentsList, ignoreTrailingComma) {
|
|
141234
141297
|
// The argument count for a list is normally the number of non-comma children it has.
|
|
141235
141298
|
// For example, if you have "Foo(a,b)" then there will be three children of the arg
|
|
141236
141299
|
// list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
|
|
@@ -141244,7 +141307,7 @@ var ts;
|
|
|
141244
141307
|
// arg count of 3.
|
|
141245
141308
|
var listChildren = argumentsList.getChildren();
|
|
141246
141309
|
var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
|
|
141247
|
-
if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
141310
|
+
if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
141248
141311
|
argumentCount++;
|
|
141249
141312
|
}
|
|
141250
141313
|
return argumentCount;
|
|
@@ -142698,6 +142761,18 @@ var ts;
|
|
|
142698
142761
|
}
|
|
142699
142762
|
}
|
|
142700
142763
|
}
|
|
142764
|
+
if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
|
|
142765
|
+
var declaration = symbol.valueDeclaration;
|
|
142766
|
+
var parent = declaration.parent;
|
|
142767
|
+
if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
|
|
142768
|
+
var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
|
|
142769
|
+
var objectType = typeChecker.getTypeAtLocation(parent);
|
|
142770
|
+
documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
|
|
142771
|
+
var prop = t.getProperty(name_4);
|
|
142772
|
+
return prop ? prop.getDocumentationComment(typeChecker) : undefined;
|
|
142773
|
+
}) || ts.emptyArray;
|
|
142774
|
+
}
|
|
142775
|
+
}
|
|
142701
142776
|
if (tags.length === 0 && !hasMultipleSignatures) {
|
|
142702
142777
|
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
|
|
142703
142778
|
}
|
|
@@ -156231,51 +156306,53 @@ var ts;
|
|
|
156231
156306
|
(function (ts) {
|
|
156232
156307
|
var refactor;
|
|
156233
156308
|
(function (refactor) {
|
|
156309
|
+
var _a;
|
|
156234
156310
|
var refactorName = "Convert import";
|
|
156235
|
-
var
|
|
156236
|
-
|
|
156237
|
-
|
|
156238
|
-
|
|
156239
|
-
|
|
156240
|
-
|
|
156241
|
-
|
|
156242
|
-
|
|
156243
|
-
|
|
156244
|
-
|
|
156311
|
+
var actions = (_a = {},
|
|
156312
|
+
_a[0 /* Named */] = {
|
|
156313
|
+
name: "Convert namespace import to named imports",
|
|
156314
|
+
description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
|
|
156315
|
+
kind: "refactor.rewrite.import.named",
|
|
156316
|
+
},
|
|
156317
|
+
_a[2 /* Namespace */] = {
|
|
156318
|
+
name: "Convert named imports to namespace import",
|
|
156319
|
+
description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
|
|
156320
|
+
kind: "refactor.rewrite.import.namespace",
|
|
156321
|
+
},
|
|
156322
|
+
_a[1 /* Default */] = {
|
|
156323
|
+
name: "Convert named imports to default import",
|
|
156324
|
+
description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
|
|
156325
|
+
kind: "refactor.rewrite.import.default",
|
|
156326
|
+
},
|
|
156327
|
+
_a);
|
|
156245
156328
|
refactor.registerRefactor(refactorName, {
|
|
156246
|
-
kinds:
|
|
156247
|
-
namespaceToNamedAction.kind,
|
|
156248
|
-
namedToNamespaceAction.kind
|
|
156249
|
-
],
|
|
156329
|
+
kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
|
|
156250
156330
|
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
|
|
156251
|
-
var info =
|
|
156331
|
+
var info = getImportConversionInfo(context, context.triggerReason === "invoked");
|
|
156252
156332
|
if (!info)
|
|
156253
156333
|
return ts.emptyArray;
|
|
156254
156334
|
if (!refactor.isRefactorErrorInfo(info)) {
|
|
156255
|
-
var
|
|
156256
|
-
var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
|
|
156335
|
+
var action = actions[info.convertTo];
|
|
156257
156336
|
return [{ name: refactorName, description: action.description, actions: [action] }];
|
|
156258
156337
|
}
|
|
156259
156338
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
156260
|
-
return
|
|
156261
|
-
|
|
156262
|
-
|
|
156263
|
-
|
|
156264
|
-
|
|
156265
|
-
];
|
|
156339
|
+
return ts.getOwnValues(actions).map(function (action) { return ({
|
|
156340
|
+
name: refactorName,
|
|
156341
|
+
description: action.description,
|
|
156342
|
+
actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
|
|
156343
|
+
}); });
|
|
156266
156344
|
}
|
|
156267
156345
|
return ts.emptyArray;
|
|
156268
156346
|
},
|
|
156269
156347
|
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
|
|
156270
|
-
ts.Debug.assert(
|
|
156271
|
-
var info =
|
|
156348
|
+
ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
|
|
156349
|
+
var info = getImportConversionInfo(context);
|
|
156272
156350
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156273
156351
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
|
|
156274
156352
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
156275
156353
|
}
|
|
156276
156354
|
});
|
|
156277
|
-
|
|
156278
|
-
function getImportToConvert(context, considerPartialSpans) {
|
|
156355
|
+
function getImportConversionInfo(context, considerPartialSpans) {
|
|
156279
156356
|
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
|
|
156280
156357
|
var file = context.file;
|
|
156281
156358
|
var span = ts.getRefactorContextSpan(context);
|
|
@@ -156294,15 +156371,23 @@ var ts;
|
|
|
156294
156371
|
if (!importClause.namedBindings) {
|
|
156295
156372
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
|
|
156296
156373
|
}
|
|
156297
|
-
|
|
156374
|
+
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
156375
|
+
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
156376
|
+
}
|
|
156377
|
+
var compilerOptions = context.program.getCompilerOptions();
|
|
156378
|
+
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
156379
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
156380
|
+
return shouldUseDefault
|
|
156381
|
+
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
156382
|
+
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
156298
156383
|
}
|
|
156299
|
-
function doChange(sourceFile, program, changes,
|
|
156384
|
+
function doChange(sourceFile, program, changes, info) {
|
|
156300
156385
|
var checker = program.getTypeChecker();
|
|
156301
|
-
if (
|
|
156302
|
-
doChangeNamespaceToNamed(sourceFile, checker, changes,
|
|
156386
|
+
if (info.convertTo === 0 /* Named */) {
|
|
156387
|
+
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
156303
156388
|
}
|
|
156304
156389
|
else {
|
|
156305
|
-
|
|
156390
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
|
|
156306
156391
|
}
|
|
156307
156392
|
}
|
|
156308
156393
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -156352,7 +156437,7 @@ var ts;
|
|
|
156352
156437
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
156353
156438
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
156354
156439
|
}
|
|
156355
|
-
function
|
|
156440
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
|
|
156356
156441
|
var importDecl = toConvert.parent.parent;
|
|
156357
156442
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
156358
156443
|
var toConvertSymbols = new ts.Set();
|
|
@@ -156403,7 +156488,9 @@ var ts;
|
|
|
156403
156488
|
var element = _a[_i];
|
|
156404
156489
|
_loop_17(element);
|
|
156405
156490
|
}
|
|
156406
|
-
changes.replaceNode(sourceFile, toConvert,
|
|
156491
|
+
changes.replaceNode(sourceFile, toConvert, shouldUseDefault
|
|
156492
|
+
? ts.factory.createIdentifier(namespaceImportName)
|
|
156493
|
+
: ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
|
|
156407
156494
|
if (neededNamedImports.size) {
|
|
156408
156495
|
var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
|
|
156409
156496
|
return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
|
|
@@ -156411,6 +156498,13 @@ var ts;
|
|
|
156411
156498
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
156412
156499
|
}
|
|
156413
156500
|
}
|
|
156501
|
+
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
156502
|
+
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
156503
|
+
if (!externalModule)
|
|
156504
|
+
return false;
|
|
156505
|
+
var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
|
|
156506
|
+
return externalModule !== exportEquals;
|
|
156507
|
+
}
|
|
156414
156508
|
function updateImport(old, defaultImportName, elements) {
|
|
156415
156509
|
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);
|
|
156416
156510
|
}
|
|
@@ -159690,7 +159784,7 @@ var ts;
|
|
|
159690
159784
|
var convertParamsToDestructuredObject;
|
|
159691
159785
|
(function (convertParamsToDestructuredObject) {
|
|
159692
159786
|
var refactorName = "Convert parameters to destructured object";
|
|
159693
|
-
var minimumParameterLength =
|
|
159787
|
+
var minimumParameterLength = 1;
|
|
159694
159788
|
var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
|
|
159695
159789
|
var toDestructuredAction = {
|
|
159696
159790
|
name: refactorName,
|