@typescript-deploys/pr-build 5.2.0-pr-54546-4 → 5.2.0-pr-54281-18
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/lib.es2023.array.d.ts +36 -618
- package/lib/tsc.js +37 -127
- package/lib/tsserver.js +242 -285
- package/lib/tsserverlibrary.js +260 -291
- package/lib/typescript.js +260 -288
- package/lib/typingsInstaller.js +10 -14
- package/package.json +2 -3
package/lib/tsserverlibrary.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.2";
|
|
38
|
-
version = `${versionMajorMinor}.0-insiders.
|
|
38
|
+
version = `${versionMajorMinor}.0-insiders.20230607`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -7300,6 +7300,8 @@ ${lanes.join("\n")}
|
|
|
7300
7300
|
Class_constructor_may_not_be_a_generator: diag(1368, 1 /* Error */, "Class_constructor_may_not_be_a_generator_1368", "Class constructor may not be a generator."),
|
|
7301
7301
|
Did_you_mean_0: diag(1369, 3 /* Message */, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
|
|
7302
7302
|
This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error: diag(1371, 1 /* Error */, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371", "This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'."),
|
|
7303
|
+
Convert_to_type_only_import: diag(1373, 3 /* Message */, "Convert_to_type_only_import_1373", "Convert to type-only import"),
|
|
7304
|
+
Convert_all_imports_not_used_as_a_value_to_type_only_imports: diag(1374, 3 /* Message */, "Convert_all_imports_not_used_as_a_value_to_type_only_imports_1374", "Convert all imports not used as a value to type-only imports"),
|
|
7303
7305
|
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, 1 /* Error */, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
7304
7306
|
_0_was_imported_here: diag(1376, 3 /* Message */, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
7305
7307
|
_0_was_exported_here: diag(1377, 3 /* Message */, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
@@ -7452,7 +7454,6 @@ ${lanes.join("\n")}
|
|
|
7452
7454
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
7453
7455
|
Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
7454
7456
|
Add_extends_constraint_to_all_type_parameters: diag(2212, 3 /* Message */, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
|
|
7455
|
-
The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2213, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supp_2213", "The project root is ambiguous, but is required to determine the module format of output '.js' files. Supply the `rootDir` compiler option to disambiguate."),
|
|
7456
7457
|
Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
7457
7458
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, 1 /* Error */, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
7458
7459
|
Static_members_cannot_reference_class_type_parameters: diag(2302, 1 /* Error */, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -8506,8 +8507,6 @@ ${lanes.join("\n")}
|
|
|
8506
8507
|
Resolved_under_condition_0: diag(6414, 3 /* Message */, "Resolved_under_condition_0_6414", "Resolved under condition '{0}'."),
|
|
8507
8508
|
Failed_to_resolve_under_condition_0: diag(6415, 3 /* Message */, "Failed_to_resolve_under_condition_0_6415", "Failed to resolve under condition '{0}'."),
|
|
8508
8509
|
Exiting_conditional_exports: diag(6416, 3 /* Message */, "Exiting_conditional_exports_6416", "Exiting conditional exports."),
|
|
8509
|
-
Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0: diag(6417, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0_6417", "Searching all ancestor node_modules directories for preferred extensions: {0}."),
|
|
8510
|
-
Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0: diag(6418, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0_6418", "Searching all ancestor node_modules directories for fallback extensions: {0}."),
|
|
8511
8510
|
The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, 3 /* Message */, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
|
|
8512
8511
|
The_expected_type_comes_from_this_index_signature: diag(6501, 3 /* Message */, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
|
|
8513
8512
|
The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, 3 /* Message */, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
|
|
@@ -9020,9 +9019,9 @@ ${lanes.join("\n")}
|
|
|
9020
9019
|
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
9021
9020
|
Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
|
|
9022
9021
|
Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9022
|
+
Inline_variable: diag(95180, 3 /* Message */, "Inline_variable_95180", "Inline variable"),
|
|
9023
|
+
Could_not_find_variable_to_inline: diag(95181, 3 /* Message */, "Could_not_find_variable_to_inline_95181", "Could not find variable to inline."),
|
|
9024
|
+
Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined: diag(95182, 3 /* Message */, "Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined_95182", "Variables that share a name with a type or namespace in the same scope cannot be inlined."),
|
|
9026
9025
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* 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."),
|
|
9027
9026
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9028
9027
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* 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?"),
|
|
@@ -40952,13 +40951,11 @@ ${lanes.join("\n")}
|
|
|
40952
40951
|
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
40953
40952
|
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
40954
40953
|
if (priorityExtensions) {
|
|
40955
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0, formatExtensions(priorityExtensions));
|
|
40956
40954
|
const result = lookup(priorityExtensions);
|
|
40957
40955
|
if (result)
|
|
40958
40956
|
return result;
|
|
40959
40957
|
}
|
|
40960
40958
|
if (secondaryExtensions && !typesScopeOnly) {
|
|
40961
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0, formatExtensions(secondaryExtensions));
|
|
40962
40959
|
return lookup(secondaryExtensions);
|
|
40963
40960
|
}
|
|
40964
40961
|
function lookup(extensions2) {
|
|
@@ -45383,9 +45380,9 @@ ${lanes.join("\n")}
|
|
|
45383
45380
|
candidatesOutArray,
|
|
45384
45381
|
/*argumentCount*/
|
|
45385
45382
|
void 0,
|
|
45386
|
-
|
|
45383
|
+
32 /* IsForStringLiteralArgumentCompletions */
|
|
45387
45384
|
)),
|
|
45388
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
45385
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
45389
45386
|
getExpandedParameters,
|
|
45390
45387
|
hasEffectiveRestParameter,
|
|
45391
45388
|
containsArgumentsReference,
|
|
@@ -53340,7 +53337,7 @@ ${lanes.join("\n")}
|
|
|
53340
53337
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53341
53338
|
}
|
|
53342
53339
|
function getTypeForBindingElement(declaration) {
|
|
53343
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53340
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
53344
53341
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53345
53342
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53346
53343
|
}
|
|
@@ -60538,10 +60535,7 @@ ${lanes.join("\n")}
|
|
|
60538
60535
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
60539
60536
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
60540
60537
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60541
|
-
|
|
60542
|
-
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
60543
|
-
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
60544
|
-
}
|
|
60538
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
60545
60539
|
}
|
|
60546
60540
|
target.instantiations.set(id, result);
|
|
60547
60541
|
}
|
|
@@ -67164,8 +67158,6 @@ ${lanes.join("\n")}
|
|
|
67164
67158
|
}
|
|
67165
67159
|
function isConstantReference(node) {
|
|
67166
67160
|
switch (node.kind) {
|
|
67167
|
-
case 110 /* ThisKeyword */:
|
|
67168
|
-
return true;
|
|
67169
67161
|
case 80 /* Identifier */:
|
|
67170
67162
|
if (!isThisInTypeQuery(node)) {
|
|
67171
67163
|
const symbol = getResolvedSymbol(node);
|
|
@@ -68240,7 +68232,7 @@ ${lanes.join("\n")}
|
|
|
68240
68232
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68241
68233
|
}
|
|
68242
68234
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68243
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
68235
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
68244
68236
|
node,
|
|
68245
68237
|
/*contextFlags*/
|
|
68246
68238
|
void 0
|
|
@@ -68997,7 +68989,7 @@ ${lanes.join("\n")}
|
|
|
68997
68989
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
68998
68990
|
const parent2 = declaration.parent.parent;
|
|
68999
68991
|
const name = declaration.propertyName || declaration.name;
|
|
69000
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
68992
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
69001
68993
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
69002
68994
|
return void 0;
|
|
69003
68995
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -70046,9 +70038,7 @@ ${lanes.join("\n")}
|
|
|
70046
70038
|
elementTypes.push(undefinedOrMissingType);
|
|
70047
70039
|
elementFlags.push(2 /* Optional */);
|
|
70048
70040
|
} else {
|
|
70049
|
-
const
|
|
70050
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70051
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70041
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
70052
70042
|
elementTypes.push(addOptionality(
|
|
70053
70043
|
type,
|
|
70054
70044
|
/*isProperty*/
|
|
@@ -70056,7 +70046,7 @@ ${lanes.join("\n")}
|
|
|
70056
70046
|
hasOmittedExpression
|
|
70057
70047
|
));
|
|
70058
70048
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70059
|
-
if (
|
|
70049
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
70060
70050
|
const inferenceContext = getInferenceContext(node);
|
|
70061
70051
|
Debug.assert(inferenceContext);
|
|
70062
70052
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70197,13 +70187,11 @@ ${lanes.join("\n")}
|
|
|
70197
70187
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70198
70188
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70199
70189
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70200
|
-
|
|
70201
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70202
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70190
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
70203
70191
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70204
70192
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70205
70193
|
// we don't want to say "could not find 'a'".
|
|
70206
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
70194
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
70207
70195
|
);
|
|
70208
70196
|
if (isInJavascript) {
|
|
70209
70197
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70247,7 +70235,7 @@ ${lanes.join("\n")}
|
|
|
70247
70235
|
prop.links.target = member;
|
|
70248
70236
|
member = prop;
|
|
70249
70237
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70250
|
-
if (
|
|
70238
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
70251
70239
|
const inferenceContext = getInferenceContext(node);
|
|
70252
70240
|
Debug.assert(inferenceContext);
|
|
70253
70241
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70420,9 +70408,7 @@ ${lanes.join("\n")}
|
|
|
70420
70408
|
for (const attributeDecl of attributes.properties) {
|
|
70421
70409
|
const member = attributeDecl.symbol;
|
|
70422
70410
|
if (isJsxAttribute(attributeDecl)) {
|
|
70423
|
-
const
|
|
70424
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70425
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70411
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
70426
70412
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70427
70413
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70428
70414
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70443,7 +70429,7 @@ ${lanes.join("\n")}
|
|
|
70443
70429
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70444
70430
|
}
|
|
70445
70431
|
}
|
|
70446
|
-
if (
|
|
70432
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
70447
70433
|
const inferenceContext = getInferenceContext(attributes);
|
|
70448
70434
|
Debug.assert(inferenceContext);
|
|
70449
70435
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72061,7 +72047,7 @@ ${lanes.join("\n")}
|
|
|
72061
72047
|
}
|
|
72062
72048
|
for (let i = 0; i < argCount; i++) {
|
|
72063
72049
|
const arg = args[i];
|
|
72064
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
72050
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
72065
72051
|
const paramType = getTypeAtPosition(signature, i);
|
|
72066
72052
|
if (couldContainTypeVariables(paramType)) {
|
|
72067
72053
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72674,12 +72660,12 @@ ${lanes.join("\n")}
|
|
|
72674
72660
|
const args = getEffectiveCallArguments(node);
|
|
72675
72661
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72676
72662
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72677
|
-
argCheckMode |= checkMode &
|
|
72663
|
+
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72678
72664
|
let candidatesForArgumentError;
|
|
72679
72665
|
let candidateForArgumentArityError;
|
|
72680
72666
|
let candidateForTypeArgumentError;
|
|
72681
72667
|
let result;
|
|
72682
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72668
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72683
72669
|
if (candidates.length > 1) {
|
|
72684
72670
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72685
72671
|
}
|
|
@@ -72898,7 +72884,7 @@ ${lanes.join("\n")}
|
|
|
72898
72884
|
continue;
|
|
72899
72885
|
}
|
|
72900
72886
|
if (argCheckMode) {
|
|
72901
|
-
argCheckMode = checkMode &
|
|
72887
|
+
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72902
72888
|
if (inferenceContext) {
|
|
72903
72889
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72904
72890
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75976,7 +75962,7 @@ ${lanes.join("\n")}
|
|
|
75976
75962
|
case 36 /* ExclamationEqualsToken */:
|
|
75977
75963
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75978
75964
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75979
|
-
if (!(checkMode && checkMode &
|
|
75965
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
75980
75966
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
75981
75967
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75982
75968
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -76635,7 +76621,7 @@ ${lanes.join("\n")}
|
|
|
76635
76621
|
}
|
|
76636
76622
|
}
|
|
76637
76623
|
const startInvocationCount = flowInvocationCount;
|
|
76638
|
-
const type = checkExpression(node,
|
|
76624
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
76639
76625
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76640
76626
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76641
76627
|
cache[getNodeId(node)] = type;
|
|
@@ -79106,7 +79092,7 @@ ${lanes.join("\n")}
|
|
|
79106
79092
|
checkComputedPropertyName(node.propertyName);
|
|
79107
79093
|
}
|
|
79108
79094
|
const parent2 = node.parent.parent;
|
|
79109
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79095
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
79110
79096
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79111
79097
|
const name = node.propertyName || node.name;
|
|
79112
79098
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -85842,11 +85828,10 @@ ${lanes.join("\n")}
|
|
|
85842
85828
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85843
85829
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85844
85830
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85845
|
-
CheckMode3[CheckMode3["
|
|
85846
|
-
CheckMode3[CheckMode3["
|
|
85847
|
-
CheckMode3[CheckMode3["
|
|
85848
|
-
CheckMode3[CheckMode3["
|
|
85849
|
-
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
85831
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
85832
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
85833
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
85834
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
85850
85835
|
return CheckMode3;
|
|
85851
85836
|
})(CheckMode || {});
|
|
85852
85837
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -98265,7 +98250,7 @@ ${lanes.join("\n")}
|
|
|
98265
98250
|
continue;
|
|
98266
98251
|
}
|
|
98267
98252
|
finishObjectLiteralIfNeeded();
|
|
98268
|
-
expressions.push(
|
|
98253
|
+
expressions.push(attr.expression);
|
|
98269
98254
|
continue;
|
|
98270
98255
|
}
|
|
98271
98256
|
properties.push(transformJsxAttributeToObjectLiteralElement(attr));
|
|
@@ -110087,15 +110072,6 @@ ${lanes.join("\n")}
|
|
|
110087
110072
|
getDeclarationEmitExtensionForPath(inputFileName)
|
|
110088
110073
|
);
|
|
110089
110074
|
}
|
|
110090
|
-
function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
|
|
110091
|
-
const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
|
|
110092
|
-
const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
|
|
110093
|
-
const outputFileName = changeExtension(
|
|
110094
|
-
outputPathWithoutChangedExtension,
|
|
110095
|
-
getDeclarationEmitExtensionForPath(inputFileName)
|
|
110096
|
-
);
|
|
110097
|
-
return outputFileName;
|
|
110098
|
-
}
|
|
110099
110075
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
|
|
110100
110076
|
if (configFile.options.emitDeclarationOnly)
|
|
110101
110077
|
return void 0;
|
|
@@ -110106,18 +110082,6 @@ ${lanes.join("\n")}
|
|
|
110106
110082
|
);
|
|
110107
110083
|
return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
110108
110084
|
}
|
|
110109
|
-
function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
|
|
110110
|
-
if (options.emitDeclarationOnly)
|
|
110111
|
-
return void 0;
|
|
110112
|
-
const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
110113
|
-
const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
|
|
110114
|
-
const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
|
|
110115
|
-
const outputFileName = changeExtension(
|
|
110116
|
-
outputPathWithoutChangedExtension,
|
|
110117
|
-
getOutputExtension(inputFileName, options)
|
|
110118
|
-
);
|
|
110119
|
-
return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
110120
|
-
}
|
|
110121
110085
|
function createAddOutput() {
|
|
110122
110086
|
let outputs;
|
|
110123
110087
|
return { addOutput, getOutputs };
|
|
@@ -116648,15 +116612,6 @@ ${lanes.join("\n")}
|
|
|
116648
116612
|
return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
|
|
116649
116613
|
}
|
|
116650
116614
|
}
|
|
116651
|
-
function moduleFormatNeedsPackageJsonLookup(fileName, options) {
|
|
116652
|
-
switch (getEmitModuleResolutionKind(options)) {
|
|
116653
|
-
case 3 /* Node16 */:
|
|
116654
|
-
case 99 /* NodeNext */:
|
|
116655
|
-
return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
|
|
116656
|
-
default:
|
|
116657
|
-
return false;
|
|
116658
|
-
}
|
|
116659
|
-
}
|
|
116660
116615
|
function shouldProgramCreateNewSourceFiles(program, newOptions) {
|
|
116661
116616
|
if (!program)
|
|
116662
116617
|
return false;
|
|
@@ -116683,7 +116638,6 @@ ${lanes.join("\n")}
|
|
|
116683
116638
|
let files;
|
|
116684
116639
|
let symlinks;
|
|
116685
116640
|
let commonSourceDirectory;
|
|
116686
|
-
let assumedCommonSourceDirectory;
|
|
116687
116641
|
let typeChecker;
|
|
116688
116642
|
let classifiableNames;
|
|
116689
116643
|
const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
|
|
@@ -117175,9 +117129,6 @@ ${lanes.join("\n")}
|
|
|
117175
117129
|
}
|
|
117176
117130
|
return commonSourceDirectory;
|
|
117177
117131
|
}
|
|
117178
|
-
function getAssumedCommonSourceDirectory() {
|
|
117179
|
-
return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
|
|
117180
|
-
}
|
|
117181
117132
|
function getClassifiableNames() {
|
|
117182
117133
|
var _a2;
|
|
117183
117134
|
if (!classifiableNames) {
|
|
@@ -117401,7 +117352,7 @@ ${lanes.join("\n")}
|
|
|
117401
117352
|
})(SeenPackageName || (SeenPackageName = {}));
|
|
117402
117353
|
const seenPackageNames = /* @__PURE__ */ new Map();
|
|
117403
117354
|
for (const oldSourceFile of oldSourceFiles) {
|
|
117404
|
-
const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
|
|
117355
|
+
const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
117405
117356
|
let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
|
|
117406
117357
|
oldSourceFile.fileName,
|
|
117407
117358
|
oldSourceFile.resolvedPath,
|
|
@@ -118363,48 +118314,10 @@ ${lanes.join("\n")}
|
|
|
118363
118314
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
118364
118315
|
return result;
|
|
118365
118316
|
}
|
|
118366
|
-
function
|
|
118367
|
-
|
|
118368
|
-
|
|
118369
|
-
|
|
118370
|
-
if (projectReference) {
|
|
118371
|
-
Debug.assert(useSourceOfProjectReferenceRedirect);
|
|
118372
|
-
fileNameForModuleFormatDetection = getOutputDeclarationFileName(
|
|
118373
|
-
fileNameForModuleFormatDetection,
|
|
118374
|
-
projectReference.commandLine,
|
|
118375
|
-
!host.useCaseSensitiveFileNames()
|
|
118376
|
-
) || getOutputJSFileName(
|
|
118377
|
-
fileNameForModuleFormatDetection,
|
|
118378
|
-
projectReference.commandLine,
|
|
118379
|
-
!host.useCaseSensitiveFileNames()
|
|
118380
|
-
) || fileNameForModuleFormatDetection;
|
|
118381
|
-
} else {
|
|
118382
|
-
fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
|
|
118383
|
-
fileNameForModuleFormatDetection,
|
|
118384
|
-
options,
|
|
118385
|
-
!host.useCaseSensitiveFileNames(),
|
|
118386
|
-
currentDirectory,
|
|
118387
|
-
getAssumedCommonSourceDirectory
|
|
118388
|
-
) || getOutputJSFileNameWithoutConfigFile(
|
|
118389
|
-
fileNameForModuleFormatDetection,
|
|
118390
|
-
options,
|
|
118391
|
-
!host.useCaseSensitiveFileNames(),
|
|
118392
|
-
currentDirectory,
|
|
118393
|
-
getAssumedCommonSourceDirectory
|
|
118394
|
-
) || fileNameForModuleFormatDetection;
|
|
118395
|
-
}
|
|
118396
|
-
}
|
|
118397
|
-
return getImpliedNodeFormatForFileWorker(
|
|
118398
|
-
fileNameForModuleFormatDetection,
|
|
118399
|
-
moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
|
|
118400
|
-
host,
|
|
118401
|
-
options
|
|
118402
|
-
);
|
|
118403
|
-
}
|
|
118404
|
-
function getCreateSourceFileOptions(fileName) {
|
|
118405
|
-
const result = getImpliedNodeFormatForFile2(fileName);
|
|
118406
|
-
const languageVersion = getEmitScriptTarget(options);
|
|
118407
|
-
const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
|
|
118317
|
+
function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
|
|
118318
|
+
const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
|
|
118319
|
+
const languageVersion = getEmitScriptTarget(options2);
|
|
118320
|
+
const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
|
|
118408
118321
|
return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
|
|
118409
118322
|
}
|
|
118410
118323
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
@@ -118476,7 +118389,7 @@ ${lanes.join("\n")}
|
|
|
118476
118389
|
redirectedPath = toPath3(redirect);
|
|
118477
118390
|
}
|
|
118478
118391
|
}
|
|
118479
|
-
const sourceFileOptions = getCreateSourceFileOptions(fileName);
|
|
118392
|
+
const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
118480
118393
|
const file = host.getSourceFile(
|
|
118481
118394
|
fileName,
|
|
118482
118395
|
sourceFileOptions,
|
|
@@ -119099,9 +119012,6 @@ ${lanes.join("\n")}
|
|
|
119099
119012
|
createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
|
|
119100
119013
|
}
|
|
119101
119014
|
}
|
|
119102
|
-
if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
|
|
119103
|
-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate));
|
|
119104
|
-
}
|
|
119105
119015
|
if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
|
|
119106
119016
|
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
|
|
119107
119017
|
}
|
|
@@ -134100,8 +134010,8 @@ ${lanes.join("\n")}
|
|
|
134100
134010
|
return context.cancellationToken && context.cancellationToken.isCancellationRequested() || !((_a = refactor.kinds) == null ? void 0 : _a.some((kind) => refactorKindBeginsWith(kind, context.kind))) ? void 0 : refactor.getAvailableActions(context, includeInteractiveActions);
|
|
134101
134011
|
}));
|
|
134102
134012
|
}
|
|
134103
|
-
function getEditsForRefactor(context,
|
|
134104
|
-
const refactor = refactors.get(
|
|
134013
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134014
|
+
const refactor = refactors.get(refactorName14);
|
|
134105
134015
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134106
134016
|
}
|
|
134107
134017
|
var refactors;
|
|
@@ -134907,6 +134817,137 @@ ${lanes.join("\n")}
|
|
|
134907
134817
|
}
|
|
134908
134818
|
});
|
|
134909
134819
|
|
|
134820
|
+
// src/services/refactors/inlineVariable.ts
|
|
134821
|
+
function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
|
|
134822
|
+
var _a, _b;
|
|
134823
|
+
const checker = program.getTypeChecker();
|
|
134824
|
+
const token = getTokenAtPosition(file, startPosition);
|
|
134825
|
+
const parent2 = token.parent;
|
|
134826
|
+
if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
|
|
134827
|
+
if (((_a = parent2.symbol.declarations) == null ? void 0 : _a.length) !== 1) {
|
|
134828
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
134829
|
+
}
|
|
134830
|
+
if (findAncestor(parent2, (node) => canHaveModifiers(node) && some(node.modifiers, isExportModifier))) {
|
|
134831
|
+
return void 0;
|
|
134832
|
+
}
|
|
134833
|
+
const references = getReferenceNodes(parent2, checker, file);
|
|
134834
|
+
return references && { references, declaration: parent2, replacement: parent2.initializer };
|
|
134835
|
+
}
|
|
134836
|
+
if (tryWithReferenceToken && isIdentifier(token)) {
|
|
134837
|
+
const definition = checker.resolveName(
|
|
134838
|
+
token.text,
|
|
134839
|
+
token,
|
|
134840
|
+
111551 /* Value */,
|
|
134841
|
+
/*excludeGlobals*/
|
|
134842
|
+
false
|
|
134843
|
+
);
|
|
134844
|
+
if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
|
|
134845
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
134846
|
+
}
|
|
134847
|
+
const declaration = definition.declarations[0];
|
|
134848
|
+
if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
|
|
134849
|
+
return void 0;
|
|
134850
|
+
}
|
|
134851
|
+
const references = getReferenceNodes(declaration, checker, file);
|
|
134852
|
+
return references && { references, declaration, replacement: declaration.initializer };
|
|
134853
|
+
}
|
|
134854
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
|
|
134855
|
+
}
|
|
134856
|
+
function getReferenceNodes(declaration, checker, file) {
|
|
134857
|
+
const references = [];
|
|
134858
|
+
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
134859
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
134860
|
+
return true;
|
|
134861
|
+
}
|
|
134862
|
+
if (isTypeQueryNode(ref.parent)) {
|
|
134863
|
+
return true;
|
|
134864
|
+
}
|
|
134865
|
+
if (findAncestor(ref, (node) => node === declaration.initializer)) {
|
|
134866
|
+
return true;
|
|
134867
|
+
}
|
|
134868
|
+
references.push(ref);
|
|
134869
|
+
});
|
|
134870
|
+
return references.length === 0 || cannotInline ? void 0 : references;
|
|
134871
|
+
}
|
|
134872
|
+
function getReplacementExpression(reference, replacement) {
|
|
134873
|
+
const { parent: parent2 } = reference;
|
|
134874
|
+
if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
|
|
134875
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134876
|
+
}
|
|
134877
|
+
return replacement;
|
|
134878
|
+
}
|
|
134879
|
+
var refactorName4, refactorDescription, inlineVariableAction;
|
|
134880
|
+
var init_inlineVariable = __esm({
|
|
134881
|
+
"src/services/refactors/inlineVariable.ts"() {
|
|
134882
|
+
"use strict";
|
|
134883
|
+
init_ts4();
|
|
134884
|
+
init_ts_refactor();
|
|
134885
|
+
refactorName4 = "Inline variable";
|
|
134886
|
+
refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
|
|
134887
|
+
inlineVariableAction = {
|
|
134888
|
+
name: refactorName4,
|
|
134889
|
+
description: refactorDescription,
|
|
134890
|
+
kind: "refactor.inline.variable"
|
|
134891
|
+
};
|
|
134892
|
+
registerRefactor(refactorName4, {
|
|
134893
|
+
kinds: [inlineVariableAction.kind],
|
|
134894
|
+
getAvailableActions(context) {
|
|
134895
|
+
const {
|
|
134896
|
+
file,
|
|
134897
|
+
program,
|
|
134898
|
+
preferences,
|
|
134899
|
+
startPosition,
|
|
134900
|
+
triggerReason
|
|
134901
|
+
} = context;
|
|
134902
|
+
const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
|
|
134903
|
+
if (!info) {
|
|
134904
|
+
return emptyArray;
|
|
134905
|
+
}
|
|
134906
|
+
if (ts_refactor_exports.isRefactorErrorInfo(info) && preferences.provideRefactorNotApplicableReason) {
|
|
134907
|
+
return [{
|
|
134908
|
+
name: refactorName4,
|
|
134909
|
+
description: refactorDescription,
|
|
134910
|
+
actions: [{
|
|
134911
|
+
...inlineVariableAction,
|
|
134912
|
+
notApplicableReason: info.error
|
|
134913
|
+
}]
|
|
134914
|
+
}];
|
|
134915
|
+
}
|
|
134916
|
+
if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134917
|
+
return [{
|
|
134918
|
+
name: refactorName4,
|
|
134919
|
+
description: refactorDescription,
|
|
134920
|
+
actions: [inlineVariableAction]
|
|
134921
|
+
}];
|
|
134922
|
+
}
|
|
134923
|
+
return emptyArray;
|
|
134924
|
+
},
|
|
134925
|
+
getEditsForAction(context, actionName2) {
|
|
134926
|
+
Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
|
|
134927
|
+
const { file, program, startPosition } = context;
|
|
134928
|
+
const info = getInliningInfo(
|
|
134929
|
+
file,
|
|
134930
|
+
startPosition,
|
|
134931
|
+
/*tryWithReferenceToken*/
|
|
134932
|
+
true,
|
|
134933
|
+
program
|
|
134934
|
+
);
|
|
134935
|
+
if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134936
|
+
return void 0;
|
|
134937
|
+
}
|
|
134938
|
+
const { references, declaration, replacement } = info;
|
|
134939
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
134940
|
+
for (const node of references) {
|
|
134941
|
+
tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
|
|
134942
|
+
}
|
|
134943
|
+
tracker.delete(file, declaration);
|
|
134944
|
+
});
|
|
134945
|
+
return { edits };
|
|
134946
|
+
}
|
|
134947
|
+
});
|
|
134948
|
+
}
|
|
134949
|
+
});
|
|
134950
|
+
|
|
134910
134951
|
// src/services/refactors/moveToNewFile.ts
|
|
134911
134952
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134912
134953
|
const checker = program.getTypeChecker();
|
|
@@ -134988,29 +135029,29 @@ ${lanes.join("\n")}
|
|
|
134988
135029
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
134989
135030
|
return copiedOldImports;
|
|
134990
135031
|
}
|
|
134991
|
-
var
|
|
135032
|
+
var refactorName5, description, moveToNewFileAction;
|
|
134992
135033
|
var init_moveToNewFile = __esm({
|
|
134993
135034
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
134994
135035
|
"use strict";
|
|
134995
135036
|
init_ts4();
|
|
134996
135037
|
init_ts_refactor();
|
|
134997
|
-
|
|
135038
|
+
refactorName5 = "Move to a new file";
|
|
134998
135039
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
134999
135040
|
moveToNewFileAction = {
|
|
135000
|
-
name:
|
|
135041
|
+
name: refactorName5,
|
|
135001
135042
|
description,
|
|
135002
135043
|
kind: "refactor.move.newFile"
|
|
135003
135044
|
};
|
|
135004
|
-
registerRefactor(
|
|
135045
|
+
registerRefactor(refactorName5, {
|
|
135005
135046
|
kinds: [moveToNewFileAction.kind],
|
|
135006
135047
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
135007
135048
|
const statements = getStatementsToMove(context);
|
|
135008
135049
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
135009
|
-
return [{ name:
|
|
135050
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
135010
135051
|
}
|
|
135011
135052
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
135012
135053
|
return [{
|
|
135013
|
-
name:
|
|
135054
|
+
name: refactorName5,
|
|
135014
135055
|
description,
|
|
135015
135056
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
135016
135057
|
}];
|
|
@@ -135018,7 +135059,7 @@ ${lanes.join("\n")}
|
|
|
135018
135059
|
return emptyArray;
|
|
135019
135060
|
},
|
|
135020
135061
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
135021
|
-
Debug.assert(actionName2 ===
|
|
135062
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
135022
135063
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
135023
135064
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
135024
135065
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135929,8 +135970,8 @@ ${lanes.join("\n")}
|
|
|
135929
135970
|
if (!info)
|
|
135930
135971
|
return emptyArray;
|
|
135931
135972
|
return [{
|
|
135932
|
-
name:
|
|
135933
|
-
description:
|
|
135973
|
+
name: refactorName6,
|
|
135974
|
+
description: refactorDescription2,
|
|
135934
135975
|
actions: [functionOverloadAction]
|
|
135935
135976
|
}];
|
|
135936
135977
|
}
|
|
@@ -136121,20 +136162,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136121
136162
|
}
|
|
136122
136163
|
return signatureDecls;
|
|
136123
136164
|
}
|
|
136124
|
-
var
|
|
136165
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136125
136166
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136126
136167
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136127
136168
|
"use strict";
|
|
136128
136169
|
init_ts4();
|
|
136129
136170
|
init_ts_refactor();
|
|
136130
|
-
|
|
136131
|
-
|
|
136171
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136172
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136132
136173
|
functionOverloadAction = {
|
|
136133
|
-
name:
|
|
136134
|
-
description:
|
|
136174
|
+
name: refactorName6,
|
|
136175
|
+
description: refactorDescription2,
|
|
136135
136176
|
kind: "refactor.rewrite.function.overloadList"
|
|
136136
136177
|
};
|
|
136137
|
-
registerRefactor(
|
|
136178
|
+
registerRefactor(refactorName6, {
|
|
136138
136179
|
kinds: [functionOverloadAction.kind],
|
|
136139
136180
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136140
136181
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136150,8 +136191,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136150
136191
|
return emptyArray;
|
|
136151
136192
|
if (!isRefactorErrorInfo(info)) {
|
|
136152
136193
|
return [{
|
|
136153
|
-
name:
|
|
136154
|
-
description:
|
|
136194
|
+
name: refactorName7,
|
|
136195
|
+
description: refactorDescription3,
|
|
136155
136196
|
actions: [
|
|
136156
136197
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136157
136198
|
]
|
|
@@ -136159,8 +136200,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136159
136200
|
}
|
|
136160
136201
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136161
136202
|
return [{
|
|
136162
|
-
name:
|
|
136163
|
-
description:
|
|
136203
|
+
name: refactorName7,
|
|
136204
|
+
description: refactorDescription3,
|
|
136164
136205
|
actions: [
|
|
136165
136206
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136166
136207
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136251,14 +136292,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136251
136292
|
}
|
|
136252
136293
|
return void 0;
|
|
136253
136294
|
}
|
|
136254
|
-
var
|
|
136295
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136255
136296
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136256
136297
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136257
136298
|
"use strict";
|
|
136258
136299
|
init_ts4();
|
|
136259
136300
|
init_ts_refactor();
|
|
136260
|
-
|
|
136261
|
-
|
|
136301
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136302
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136262
136303
|
addBracesAction = {
|
|
136263
136304
|
name: "Add braces to arrow function",
|
|
136264
136305
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136269,7 +136310,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136269
136310
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136270
136311
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136271
136312
|
};
|
|
136272
|
-
registerRefactor(
|
|
136313
|
+
registerRefactor(refactorName7, {
|
|
136273
136314
|
kinds: [removeBracesAction.kind],
|
|
136274
136315
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136275
136316
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136321,8 +136362,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136321
136362
|
}
|
|
136322
136363
|
}
|
|
136323
136364
|
return [{
|
|
136324
|
-
name:
|
|
136325
|
-
description:
|
|
136365
|
+
name: refactorName8,
|
|
136366
|
+
description: refactorDescription4,
|
|
136326
136367
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136327
136368
|
}];
|
|
136328
136369
|
}
|
|
@@ -136482,14 +136523,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136482
136523
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136483
136524
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136484
136525
|
}
|
|
136485
|
-
var
|
|
136526
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136486
136527
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136487
136528
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136488
136529
|
"use strict";
|
|
136489
136530
|
init_ts4();
|
|
136490
136531
|
init_ts_refactor();
|
|
136491
|
-
|
|
136492
|
-
|
|
136532
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136533
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136493
136534
|
toAnonymousFunctionAction = {
|
|
136494
136535
|
name: "Convert to anonymous function",
|
|
136495
136536
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136505,7 +136546,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136505
136546
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136506
136547
|
kind: "refactor.rewrite.function.arrow"
|
|
136507
136548
|
};
|
|
136508
|
-
registerRefactor(
|
|
136549
|
+
registerRefactor(refactorName8, {
|
|
136509
136550
|
kinds: [
|
|
136510
136551
|
toAnonymousFunctionAction.kind,
|
|
136511
136552
|
toNamedFunctionAction.kind,
|
|
@@ -136536,13 +136577,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136536
136577
|
if (!functionDeclaration)
|
|
136537
136578
|
return emptyArray;
|
|
136538
136579
|
return [{
|
|
136539
|
-
name:
|
|
136540
|
-
description:
|
|
136580
|
+
name: refactorName9,
|
|
136581
|
+
description: refactorDescription5,
|
|
136541
136582
|
actions: [toDestructuredAction]
|
|
136542
136583
|
}];
|
|
136543
136584
|
}
|
|
136544
136585
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136545
|
-
Debug.assert(actionName2 ===
|
|
136586
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136546
136587
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136547
136588
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136548
136589
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -137052,21 +137093,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137052
137093
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
137053
137094
|
}
|
|
137054
137095
|
}
|
|
137055
|
-
var
|
|
137096
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
137056
137097
|
var init_convertParamsToDestructuredObject = __esm({
|
|
137057
137098
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
137058
137099
|
"use strict";
|
|
137059
137100
|
init_ts4();
|
|
137060
137101
|
init_ts_refactor();
|
|
137061
|
-
|
|
137102
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
137062
137103
|
minimumParameterLength = 1;
|
|
137063
|
-
|
|
137104
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
137064
137105
|
toDestructuredAction = {
|
|
137065
|
-
name:
|
|
137066
|
-
description:
|
|
137106
|
+
name: refactorName9,
|
|
137107
|
+
description: refactorDescription5,
|
|
137067
137108
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
137068
137109
|
};
|
|
137069
|
-
registerRefactor(
|
|
137110
|
+
registerRefactor(refactorName9, {
|
|
137070
137111
|
kinds: [toDestructuredAction.kind],
|
|
137071
137112
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
137072
137113
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137088,7 +137129,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137088
137129
|
const { file, startPosition } = context;
|
|
137089
137130
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137090
137131
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137091
|
-
const refactorInfo = { name:
|
|
137132
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137092
137133
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137093
137134
|
refactorInfo.actions.push(convertStringAction);
|
|
137094
137135
|
return [refactorInfo];
|
|
@@ -137114,7 +137155,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137114
137155
|
const { file, startPosition } = context;
|
|
137115
137156
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137116
137157
|
switch (actionName2) {
|
|
137117
|
-
case
|
|
137158
|
+
case refactorDescription6:
|
|
137118
137159
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137119
137160
|
default:
|
|
137120
137161
|
return Debug.fail("invalid action");
|
|
@@ -137265,20 +137306,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137265
137306
|
}
|
|
137266
137307
|
return node;
|
|
137267
137308
|
}
|
|
137268
|
-
var
|
|
137309
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137269
137310
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137270
137311
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137271
137312
|
"use strict";
|
|
137272
137313
|
init_ts4();
|
|
137273
137314
|
init_ts_refactor();
|
|
137274
|
-
|
|
137275
|
-
|
|
137315
|
+
refactorName10 = "Convert to template string";
|
|
137316
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137276
137317
|
convertStringAction = {
|
|
137277
|
-
name:
|
|
137278
|
-
description:
|
|
137318
|
+
name: refactorName10,
|
|
137319
|
+
description: refactorDescription6,
|
|
137279
137320
|
kind: "refactor.rewrite.string"
|
|
137280
137321
|
};
|
|
137281
|
-
registerRefactor(
|
|
137322
|
+
registerRefactor(refactorName10, {
|
|
137282
137323
|
kinds: [convertStringAction.kind],
|
|
137283
137324
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137284
137325
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137328,14 +137369,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137328
137369
|
return emptyArray;
|
|
137329
137370
|
if (!isRefactorErrorInfo(info)) {
|
|
137330
137371
|
return [{
|
|
137331
|
-
name:
|
|
137372
|
+
name: refactorName11,
|
|
137332
137373
|
description: convertToOptionalChainExpressionMessage,
|
|
137333
137374
|
actions: [toOptionalChainAction]
|
|
137334
137375
|
}];
|
|
137335
137376
|
}
|
|
137336
137377
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137337
137378
|
return [{
|
|
137338
|
-
name:
|
|
137379
|
+
name: refactorName11,
|
|
137339
137380
|
description: convertToOptionalChainExpressionMessage,
|
|
137340
137381
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137341
137382
|
}];
|
|
@@ -137519,20 +137560,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137519
137560
|
}
|
|
137520
137561
|
}
|
|
137521
137562
|
}
|
|
137522
|
-
var
|
|
137563
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137523
137564
|
var init_convertToOptionalChainExpression = __esm({
|
|
137524
137565
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137525
137566
|
"use strict";
|
|
137526
137567
|
init_ts4();
|
|
137527
137568
|
init_ts_refactor();
|
|
137528
|
-
|
|
137569
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137529
137570
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137530
137571
|
toOptionalChainAction = {
|
|
137531
|
-
name:
|
|
137572
|
+
name: refactorName11,
|
|
137532
137573
|
description: convertToOptionalChainExpressionMessage,
|
|
137533
137574
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137534
137575
|
};
|
|
137535
|
-
registerRefactor(
|
|
137576
|
+
registerRefactor(refactorName11, {
|
|
137536
137577
|
kinds: [toOptionalChainAction.kind],
|
|
137537
137578
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137538
137579
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137561,14 +137602,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137561
137602
|
const errors = [];
|
|
137562
137603
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137563
137604
|
errors.push({
|
|
137564
|
-
name:
|
|
137605
|
+
name: refactorName12,
|
|
137565
137606
|
description: extractFunctionAction.description,
|
|
137566
137607
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137567
137608
|
});
|
|
137568
137609
|
}
|
|
137569
137610
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137570
137611
|
errors.push({
|
|
137571
|
-
name:
|
|
137612
|
+
name: refactorName12,
|
|
137572
137613
|
description: extractConstantAction.description,
|
|
137573
137614
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137574
137615
|
});
|
|
@@ -137632,26 +137673,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137632
137673
|
const infos = [];
|
|
137633
137674
|
if (functionActions.length) {
|
|
137634
137675
|
infos.push({
|
|
137635
|
-
name:
|
|
137676
|
+
name: refactorName12,
|
|
137636
137677
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137637
137678
|
actions: functionActions
|
|
137638
137679
|
});
|
|
137639
137680
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137640
137681
|
infos.push({
|
|
137641
|
-
name:
|
|
137682
|
+
name: refactorName12,
|
|
137642
137683
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137643
137684
|
actions: [innermostErrorFunctionAction]
|
|
137644
137685
|
});
|
|
137645
137686
|
}
|
|
137646
137687
|
if (constantActions.length) {
|
|
137647
137688
|
infos.push({
|
|
137648
|
-
name:
|
|
137689
|
+
name: refactorName12,
|
|
137649
137690
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137650
137691
|
actions: constantActions
|
|
137651
137692
|
});
|
|
137652
137693
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137653
137694
|
infos.push({
|
|
137654
|
-
name:
|
|
137695
|
+
name: refactorName12,
|
|
137655
137696
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137656
137697
|
actions: [innermostErrorConstantAction]
|
|
137657
137698
|
});
|
|
@@ -139082,13 +139123,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139082
139123
|
function isStringLiteralJsxAttribute(node) {
|
|
139083
139124
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139084
139125
|
}
|
|
139085
|
-
var
|
|
139126
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139086
139127
|
var init_extractSymbol = __esm({
|
|
139087
139128
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139088
139129
|
"use strict";
|
|
139089
139130
|
init_ts4();
|
|
139090
139131
|
init_ts_refactor();
|
|
139091
|
-
|
|
139132
|
+
refactorName12 = "Extract Symbol";
|
|
139092
139133
|
extractConstantAction = {
|
|
139093
139134
|
name: "Extract Constant",
|
|
139094
139135
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139099,7 +139140,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139099
139140
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139100
139141
|
kind: "refactor.extract.function"
|
|
139101
139142
|
};
|
|
139102
|
-
registerRefactor(
|
|
139143
|
+
registerRefactor(refactorName12, {
|
|
139103
139144
|
kinds: [
|
|
139104
139145
|
extractConstantAction.kind,
|
|
139105
139146
|
extractFunctionAction.kind
|
|
@@ -139250,15 +139291,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139250
139291
|
return emptyArray;
|
|
139251
139292
|
if (!isRefactorErrorInfo(info)) {
|
|
139252
139293
|
return [{
|
|
139253
|
-
name:
|
|
139254
|
-
description:
|
|
139294
|
+
name: refactorName13,
|
|
139295
|
+
description: refactorDescription7,
|
|
139255
139296
|
actions: [inferReturnTypeAction]
|
|
139256
139297
|
}];
|
|
139257
139298
|
}
|
|
139258
139299
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139259
139300
|
return [{
|
|
139260
|
-
name:
|
|
139261
|
-
description:
|
|
139301
|
+
name: refactorName13,
|
|
139302
|
+
description: refactorDescription7,
|
|
139262
139303
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139263
139304
|
}];
|
|
139264
139305
|
}
|
|
@@ -139317,20 +139358,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139317
139358
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139318
139359
|
}
|
|
139319
139360
|
}
|
|
139320
|
-
var
|
|
139361
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139321
139362
|
var init_inferFunctionReturnType = __esm({
|
|
139322
139363
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139323
139364
|
"use strict";
|
|
139324
139365
|
init_ts4();
|
|
139325
139366
|
init_ts_refactor();
|
|
139326
|
-
|
|
139327
|
-
|
|
139367
|
+
refactorName13 = "Infer function return type";
|
|
139368
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139328
139369
|
inferReturnTypeAction = {
|
|
139329
|
-
name:
|
|
139330
|
-
description:
|
|
139370
|
+
name: refactorName13,
|
|
139371
|
+
description: refactorDescription7,
|
|
139331
139372
|
kind: "refactor.rewrite.function.returnType"
|
|
139332
139373
|
};
|
|
139333
|
-
registerRefactor(
|
|
139374
|
+
registerRefactor(refactorName13, {
|
|
139334
139375
|
kinds: [inferReturnTypeAction.kind],
|
|
139335
139376
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139336
139377
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139391,6 +139432,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139391
139432
|
init_convertImport();
|
|
139392
139433
|
init_extractType();
|
|
139393
139434
|
init_helpers();
|
|
139435
|
+
init_inlineVariable();
|
|
139394
139436
|
init_moveToNewFile();
|
|
139395
139437
|
init_moveToFile();
|
|
139396
139438
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140929,10 +140971,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140929
140971
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140930
140972
|
return { newFileName, files };
|
|
140931
140973
|
}
|
|
140932
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
140974
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140933
140975
|
synchronizeHostData();
|
|
140934
140976
|
const file = getValidSourceFile(fileName);
|
|
140935
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
140977
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140936
140978
|
}
|
|
140937
140979
|
function toLineColumnOffset(fileName, position) {
|
|
140938
140980
|
if (position === 0) {
|
|
@@ -146438,27 +146480,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146438
146480
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
146439
146481
|
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
146440
146482
|
}
|
|
146441
|
-
function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program) {
|
|
146442
|
-
if (specifier.parent.parent.name) {
|
|
146443
|
-
return false;
|
|
146444
|
-
}
|
|
146445
|
-
const nonTypeOnlySpecifiers = specifier.parent.elements.filter((e) => !e.isTypeOnly);
|
|
146446
|
-
if (nonTypeOnlySpecifiers.length === 1) {
|
|
146447
|
-
return true;
|
|
146448
|
-
}
|
|
146449
|
-
const checker = program.getTypeChecker();
|
|
146450
|
-
for (const specifier2 of nonTypeOnlySpecifiers) {
|
|
146451
|
-
const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
|
|
146452
|
-
return !isValidTypeOnlyAliasUseSite(usage);
|
|
146453
|
-
});
|
|
146454
|
-
if (isUsedAsValue) {
|
|
146455
|
-
return false;
|
|
146456
|
-
}
|
|
146457
|
-
}
|
|
146458
|
-
return true;
|
|
146459
|
-
}
|
|
146460
146483
|
function doChange11(changes, sourceFile, declaration) {
|
|
146461
|
-
var _a;
|
|
146462
146484
|
if (isImportSpecifier(declaration)) {
|
|
146463
146485
|
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
146464
146486
|
declaration,
|
|
@@ -146529,16 +146551,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146529
146551
|
)
|
|
146530
146552
|
]);
|
|
146531
146553
|
} else {
|
|
146532
|
-
const newNamedBindings = ((_a = importClause.namedBindings) == null ? void 0 : _a.kind) === 274 /* NamedImports */ ? factory.updateNamedImports(
|
|
146533
|
-
importClause.namedBindings,
|
|
146534
|
-
sameMap(importClause.namedBindings.elements, (e) => factory.updateImportSpecifier(
|
|
146535
|
-
e,
|
|
146536
|
-
/*isTypeOnly*/
|
|
146537
|
-
false,
|
|
146538
|
-
e.propertyName,
|
|
146539
|
-
e.name
|
|
146540
|
-
))
|
|
146541
|
-
) : importClause.namedBindings;
|
|
146542
146554
|
const importDeclaration = factory.updateImportDeclaration(
|
|
146543
146555
|
declaration,
|
|
146544
146556
|
declaration.modifiers,
|
|
@@ -146547,7 +146559,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146547
146559
|
/*isTypeOnly*/
|
|
146548
146560
|
true,
|
|
146549
146561
|
importClause.name,
|
|
146550
|
-
|
|
146562
|
+
importClause.namedBindings
|
|
146551
146563
|
),
|
|
146552
146564
|
declaration.moduleSpecifier,
|
|
146553
146565
|
declaration.assertClause
|
|
@@ -146570,41 +146582,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146570
146582
|
registerCodeFix({
|
|
146571
146583
|
errorCodes: errorCodes14,
|
|
146572
146584
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146573
|
-
var _a;
|
|
146574
146585
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
146575
146586
|
if (declaration) {
|
|
146576
146587
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
146577
|
-
|
|
146578
|
-
const mainAction = createCodeFixAction(
|
|
146579
|
-
fixId13,
|
|
146580
|
-
changes,
|
|
146581
|
-
declaration.kind === 275 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
146582
|
-
fixId13,
|
|
146583
|
-
Diagnostics.Fix_all_with_type_only_imports
|
|
146584
|
-
);
|
|
146585
|
-
if (some(importDeclarationChanges)) {
|
|
146586
|
-
return [
|
|
146587
|
-
createCodeFixActionWithoutFixAll(fixId13, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
146588
|
-
mainAction
|
|
146589
|
-
];
|
|
146590
|
-
}
|
|
146591
|
-
return [mainAction];
|
|
146588
|
+
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
146592
146589
|
}
|
|
146593
146590
|
return void 0;
|
|
146594
146591
|
},
|
|
146595
146592
|
fixIds: [fixId13],
|
|
146596
146593
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146597
|
-
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
146598
146594
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
146599
|
-
const
|
|
146600
|
-
if (
|
|
146601
|
-
doChange11(changes, diag2.file,
|
|
146602
|
-
fixedImportDeclarations.add(errorDeclaration);
|
|
146603
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */ && !fixedImportDeclarations.has(errorDeclaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(errorDeclaration, diag2.file, context.program)) {
|
|
146604
|
-
doChange11(changes, diag2.file, errorDeclaration.parent.parent.parent);
|
|
146605
|
-
fixedImportDeclarations.add(errorDeclaration.parent.parent.parent);
|
|
146606
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */) {
|
|
146607
|
-
doChange11(changes, diag2.file, errorDeclaration);
|
|
146595
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
146596
|
+
if (declaration) {
|
|
146597
|
+
doChange11(changes, diag2.file, declaration);
|
|
146608
146598
|
}
|
|
146609
146599
|
});
|
|
146610
146600
|
}
|
|
@@ -150534,7 +150524,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
150534
150524
|
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
150535
150525
|
}
|
|
150536
150526
|
if (typeOnlyChanges.length) {
|
|
150537
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.
|
|
150527
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
150538
150528
|
}
|
|
150539
150529
|
return actions2;
|
|
150540
150530
|
},
|
|
@@ -158741,7 +158731,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158741
158731
|
}
|
|
158742
158732
|
const keys = getOwnKeys(exports);
|
|
158743
158733
|
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
158744
|
-
const conditions =
|
|
158734
|
+
const conditions = mode === 99 /* ESNext */ ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
158745
158735
|
addCompletionEntriesFromPathsOrExports(
|
|
158746
158736
|
result,
|
|
158747
158737
|
fragmentSubpath,
|
|
@@ -161496,6 +161486,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161496
161486
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161497
161487
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161498
161488
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161489
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161499
161490
|
nodeEntry: () => nodeEntry,
|
|
161500
161491
|
toContextSpan: () => toContextSpan,
|
|
161501
161492
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -162178,29 +162169,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162178
162169
|
if (!signature || !candidates.length) {
|
|
162179
162170
|
return;
|
|
162180
162171
|
}
|
|
162181
|
-
let
|
|
162182
|
-
|
|
162172
|
+
for (let i = 0; i < args.length; ++i) {
|
|
162173
|
+
const originalArg = args[i];
|
|
162183
162174
|
const arg = skipParentheses(originalArg);
|
|
162184
162175
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162185
162176
|
continue;
|
|
162186
162177
|
}
|
|
162187
|
-
|
|
162188
|
-
if (isSpreadElement(arg)) {
|
|
162189
|
-
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162190
|
-
if (checker.isTupleType(spreadType)) {
|
|
162191
|
-
const { elementFlags, fixedLength } = spreadType.target;
|
|
162192
|
-
if (fixedLength === 0) {
|
|
162193
|
-
continue;
|
|
162194
|
-
}
|
|
162195
|
-
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162196
|
-
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162197
|
-
if (requiredArgs > 0) {
|
|
162198
|
-
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162199
|
-
}
|
|
162200
|
-
}
|
|
162201
|
-
}
|
|
162202
|
-
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162203
|
-
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162178
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
|
|
162204
162179
|
if (identifierNameInfo) {
|
|
162205
162180
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162206
162181
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -169702,9 +169677,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169702
169677
|
init_ts5();
|
|
169703
169678
|
init_deprecate();
|
|
169704
169679
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169705
|
-
const
|
|
169706
|
-
if (!hasProperty(
|
|
169707
|
-
Object.defineProperty(
|
|
169680
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169681
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169682
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169708
169683
|
get: deprecate(function() {
|
|
169709
169684
|
return identifierToKeywordKind(this);
|
|
169710
169685
|
}, {
|
|
@@ -169716,8 +169691,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169716
169691
|
})
|
|
169717
169692
|
});
|
|
169718
169693
|
}
|
|
169719
|
-
if (!hasProperty(
|
|
169720
|
-
Object.defineProperty(
|
|
169694
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169695
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169721
169696
|
get: deprecate(function() {
|
|
169722
169697
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169723
169698
|
}, {
|
|
@@ -182006,11 +181981,8 @@ ${e.message}`;
|
|
|
182006
181981
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
182007
181982
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
182008
181983
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
182009
|
-
getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
|
|
182010
181984
|
getOutputExtension: () => getOutputExtension,
|
|
182011
181985
|
getOutputFileNames: () => getOutputFileNames,
|
|
182012
|
-
getOutputJSFileName: () => getOutputJSFileName,
|
|
182013
|
-
getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
|
|
182014
181986
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
182015
181987
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
182016
181988
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -184388,11 +184360,8 @@ ${e.message}`;
|
|
|
184388
184360
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
184389
184361
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
184390
184362
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
184391
|
-
getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
|
|
184392
184363
|
getOutputExtension: () => getOutputExtension,
|
|
184393
184364
|
getOutputFileNames: () => getOutputFileNames,
|
|
184394
|
-
getOutputJSFileName: () => getOutputJSFileName,
|
|
184395
|
-
getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
|
|
184396
184365
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
184397
184366
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
184398
184367
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|