@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/typescript.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
|
}
|
|
@@ -134115,8 +134025,8 @@ ${lanes.join("\n")}
|
|
|
134115
134025
|
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);
|
|
134116
134026
|
}));
|
|
134117
134027
|
}
|
|
134118
|
-
function getEditsForRefactor(context,
|
|
134119
|
-
const refactor = refactors.get(
|
|
134028
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134029
|
+
const refactor = refactors.get(refactorName14);
|
|
134120
134030
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134121
134031
|
}
|
|
134122
134032
|
var refactors;
|
|
@@ -134922,6 +134832,137 @@ ${lanes.join("\n")}
|
|
|
134922
134832
|
}
|
|
134923
134833
|
});
|
|
134924
134834
|
|
|
134835
|
+
// src/services/refactors/inlineVariable.ts
|
|
134836
|
+
function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
|
|
134837
|
+
var _a, _b;
|
|
134838
|
+
const checker = program.getTypeChecker();
|
|
134839
|
+
const token = getTokenAtPosition(file, startPosition);
|
|
134840
|
+
const parent2 = token.parent;
|
|
134841
|
+
if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
|
|
134842
|
+
if (((_a = parent2.symbol.declarations) == null ? void 0 : _a.length) !== 1) {
|
|
134843
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
134844
|
+
}
|
|
134845
|
+
if (findAncestor(parent2, (node) => canHaveModifiers(node) && some(node.modifiers, isExportModifier))) {
|
|
134846
|
+
return void 0;
|
|
134847
|
+
}
|
|
134848
|
+
const references = getReferenceNodes(parent2, checker, file);
|
|
134849
|
+
return references && { references, declaration: parent2, replacement: parent2.initializer };
|
|
134850
|
+
}
|
|
134851
|
+
if (tryWithReferenceToken && isIdentifier(token)) {
|
|
134852
|
+
const definition = checker.resolveName(
|
|
134853
|
+
token.text,
|
|
134854
|
+
token,
|
|
134855
|
+
111551 /* Value */,
|
|
134856
|
+
/*excludeGlobals*/
|
|
134857
|
+
false
|
|
134858
|
+
);
|
|
134859
|
+
if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
|
|
134860
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
134861
|
+
}
|
|
134862
|
+
const declaration = definition.declarations[0];
|
|
134863
|
+
if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
|
|
134864
|
+
return void 0;
|
|
134865
|
+
}
|
|
134866
|
+
const references = getReferenceNodes(declaration, checker, file);
|
|
134867
|
+
return references && { references, declaration, replacement: declaration.initializer };
|
|
134868
|
+
}
|
|
134869
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
|
|
134870
|
+
}
|
|
134871
|
+
function getReferenceNodes(declaration, checker, file) {
|
|
134872
|
+
const references = [];
|
|
134873
|
+
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
134874
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
134875
|
+
return true;
|
|
134876
|
+
}
|
|
134877
|
+
if (isTypeQueryNode(ref.parent)) {
|
|
134878
|
+
return true;
|
|
134879
|
+
}
|
|
134880
|
+
if (findAncestor(ref, (node) => node === declaration.initializer)) {
|
|
134881
|
+
return true;
|
|
134882
|
+
}
|
|
134883
|
+
references.push(ref);
|
|
134884
|
+
});
|
|
134885
|
+
return references.length === 0 || cannotInline ? void 0 : references;
|
|
134886
|
+
}
|
|
134887
|
+
function getReplacementExpression(reference, replacement) {
|
|
134888
|
+
const { parent: parent2 } = reference;
|
|
134889
|
+
if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
|
|
134890
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134891
|
+
}
|
|
134892
|
+
return replacement;
|
|
134893
|
+
}
|
|
134894
|
+
var refactorName4, refactorDescription, inlineVariableAction;
|
|
134895
|
+
var init_inlineVariable = __esm({
|
|
134896
|
+
"src/services/refactors/inlineVariable.ts"() {
|
|
134897
|
+
"use strict";
|
|
134898
|
+
init_ts4();
|
|
134899
|
+
init_ts_refactor();
|
|
134900
|
+
refactorName4 = "Inline variable";
|
|
134901
|
+
refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
|
|
134902
|
+
inlineVariableAction = {
|
|
134903
|
+
name: refactorName4,
|
|
134904
|
+
description: refactorDescription,
|
|
134905
|
+
kind: "refactor.inline.variable"
|
|
134906
|
+
};
|
|
134907
|
+
registerRefactor(refactorName4, {
|
|
134908
|
+
kinds: [inlineVariableAction.kind],
|
|
134909
|
+
getAvailableActions(context) {
|
|
134910
|
+
const {
|
|
134911
|
+
file,
|
|
134912
|
+
program,
|
|
134913
|
+
preferences,
|
|
134914
|
+
startPosition,
|
|
134915
|
+
triggerReason
|
|
134916
|
+
} = context;
|
|
134917
|
+
const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
|
|
134918
|
+
if (!info) {
|
|
134919
|
+
return emptyArray;
|
|
134920
|
+
}
|
|
134921
|
+
if (ts_refactor_exports.isRefactorErrorInfo(info) && preferences.provideRefactorNotApplicableReason) {
|
|
134922
|
+
return [{
|
|
134923
|
+
name: refactorName4,
|
|
134924
|
+
description: refactorDescription,
|
|
134925
|
+
actions: [{
|
|
134926
|
+
...inlineVariableAction,
|
|
134927
|
+
notApplicableReason: info.error
|
|
134928
|
+
}]
|
|
134929
|
+
}];
|
|
134930
|
+
}
|
|
134931
|
+
if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134932
|
+
return [{
|
|
134933
|
+
name: refactorName4,
|
|
134934
|
+
description: refactorDescription,
|
|
134935
|
+
actions: [inlineVariableAction]
|
|
134936
|
+
}];
|
|
134937
|
+
}
|
|
134938
|
+
return emptyArray;
|
|
134939
|
+
},
|
|
134940
|
+
getEditsForAction(context, actionName2) {
|
|
134941
|
+
Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
|
|
134942
|
+
const { file, program, startPosition } = context;
|
|
134943
|
+
const info = getInliningInfo(
|
|
134944
|
+
file,
|
|
134945
|
+
startPosition,
|
|
134946
|
+
/*tryWithReferenceToken*/
|
|
134947
|
+
true,
|
|
134948
|
+
program
|
|
134949
|
+
);
|
|
134950
|
+
if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134951
|
+
return void 0;
|
|
134952
|
+
}
|
|
134953
|
+
const { references, declaration, replacement } = info;
|
|
134954
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
134955
|
+
for (const node of references) {
|
|
134956
|
+
tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
|
|
134957
|
+
}
|
|
134958
|
+
tracker.delete(file, declaration);
|
|
134959
|
+
});
|
|
134960
|
+
return { edits };
|
|
134961
|
+
}
|
|
134962
|
+
});
|
|
134963
|
+
}
|
|
134964
|
+
});
|
|
134965
|
+
|
|
134925
134966
|
// src/services/refactors/moveToNewFile.ts
|
|
134926
134967
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134927
134968
|
const checker = program.getTypeChecker();
|
|
@@ -135003,29 +135044,29 @@ ${lanes.join("\n")}
|
|
|
135003
135044
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
135004
135045
|
return copiedOldImports;
|
|
135005
135046
|
}
|
|
135006
|
-
var
|
|
135047
|
+
var refactorName5, description, moveToNewFileAction;
|
|
135007
135048
|
var init_moveToNewFile = __esm({
|
|
135008
135049
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
135009
135050
|
"use strict";
|
|
135010
135051
|
init_ts4();
|
|
135011
135052
|
init_ts_refactor();
|
|
135012
|
-
|
|
135053
|
+
refactorName5 = "Move to a new file";
|
|
135013
135054
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
135014
135055
|
moveToNewFileAction = {
|
|
135015
|
-
name:
|
|
135056
|
+
name: refactorName5,
|
|
135016
135057
|
description,
|
|
135017
135058
|
kind: "refactor.move.newFile"
|
|
135018
135059
|
};
|
|
135019
|
-
registerRefactor(
|
|
135060
|
+
registerRefactor(refactorName5, {
|
|
135020
135061
|
kinds: [moveToNewFileAction.kind],
|
|
135021
135062
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
135022
135063
|
const statements = getStatementsToMove(context);
|
|
135023
135064
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
135024
|
-
return [{ name:
|
|
135065
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
135025
135066
|
}
|
|
135026
135067
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
135027
135068
|
return [{
|
|
135028
|
-
name:
|
|
135069
|
+
name: refactorName5,
|
|
135029
135070
|
description,
|
|
135030
135071
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
135031
135072
|
}];
|
|
@@ -135033,7 +135074,7 @@ ${lanes.join("\n")}
|
|
|
135033
135074
|
return emptyArray;
|
|
135034
135075
|
},
|
|
135035
135076
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
135036
|
-
Debug.assert(actionName2 ===
|
|
135077
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
135037
135078
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
135038
135079
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
135039
135080
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135944,8 +135985,8 @@ ${lanes.join("\n")}
|
|
|
135944
135985
|
if (!info)
|
|
135945
135986
|
return emptyArray;
|
|
135946
135987
|
return [{
|
|
135947
|
-
name:
|
|
135948
|
-
description:
|
|
135988
|
+
name: refactorName6,
|
|
135989
|
+
description: refactorDescription2,
|
|
135949
135990
|
actions: [functionOverloadAction]
|
|
135950
135991
|
}];
|
|
135951
135992
|
}
|
|
@@ -136136,20 +136177,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136136
136177
|
}
|
|
136137
136178
|
return signatureDecls;
|
|
136138
136179
|
}
|
|
136139
|
-
var
|
|
136180
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136140
136181
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136141
136182
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136142
136183
|
"use strict";
|
|
136143
136184
|
init_ts4();
|
|
136144
136185
|
init_ts_refactor();
|
|
136145
|
-
|
|
136146
|
-
|
|
136186
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136187
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136147
136188
|
functionOverloadAction = {
|
|
136148
|
-
name:
|
|
136149
|
-
description:
|
|
136189
|
+
name: refactorName6,
|
|
136190
|
+
description: refactorDescription2,
|
|
136150
136191
|
kind: "refactor.rewrite.function.overloadList"
|
|
136151
136192
|
};
|
|
136152
|
-
registerRefactor(
|
|
136193
|
+
registerRefactor(refactorName6, {
|
|
136153
136194
|
kinds: [functionOverloadAction.kind],
|
|
136154
136195
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136155
136196
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136165,8 +136206,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136165
136206
|
return emptyArray;
|
|
136166
136207
|
if (!isRefactorErrorInfo(info)) {
|
|
136167
136208
|
return [{
|
|
136168
|
-
name:
|
|
136169
|
-
description:
|
|
136209
|
+
name: refactorName7,
|
|
136210
|
+
description: refactorDescription3,
|
|
136170
136211
|
actions: [
|
|
136171
136212
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136172
136213
|
]
|
|
@@ -136174,8 +136215,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136174
136215
|
}
|
|
136175
136216
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136176
136217
|
return [{
|
|
136177
|
-
name:
|
|
136178
|
-
description:
|
|
136218
|
+
name: refactorName7,
|
|
136219
|
+
description: refactorDescription3,
|
|
136179
136220
|
actions: [
|
|
136180
136221
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136181
136222
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136266,14 +136307,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136266
136307
|
}
|
|
136267
136308
|
return void 0;
|
|
136268
136309
|
}
|
|
136269
|
-
var
|
|
136310
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136270
136311
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136271
136312
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136272
136313
|
"use strict";
|
|
136273
136314
|
init_ts4();
|
|
136274
136315
|
init_ts_refactor();
|
|
136275
|
-
|
|
136276
|
-
|
|
136316
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136317
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136277
136318
|
addBracesAction = {
|
|
136278
136319
|
name: "Add braces to arrow function",
|
|
136279
136320
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136284,7 +136325,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136284
136325
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136285
136326
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136286
136327
|
};
|
|
136287
|
-
registerRefactor(
|
|
136328
|
+
registerRefactor(refactorName7, {
|
|
136288
136329
|
kinds: [removeBracesAction.kind],
|
|
136289
136330
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136290
136331
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136336,8 +136377,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136336
136377
|
}
|
|
136337
136378
|
}
|
|
136338
136379
|
return [{
|
|
136339
|
-
name:
|
|
136340
|
-
description:
|
|
136380
|
+
name: refactorName8,
|
|
136381
|
+
description: refactorDescription4,
|
|
136341
136382
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136342
136383
|
}];
|
|
136343
136384
|
}
|
|
@@ -136497,14 +136538,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136497
136538
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136498
136539
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136499
136540
|
}
|
|
136500
|
-
var
|
|
136541
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136501
136542
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136502
136543
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136503
136544
|
"use strict";
|
|
136504
136545
|
init_ts4();
|
|
136505
136546
|
init_ts_refactor();
|
|
136506
|
-
|
|
136507
|
-
|
|
136547
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136548
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136508
136549
|
toAnonymousFunctionAction = {
|
|
136509
136550
|
name: "Convert to anonymous function",
|
|
136510
136551
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136520,7 +136561,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136520
136561
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136521
136562
|
kind: "refactor.rewrite.function.arrow"
|
|
136522
136563
|
};
|
|
136523
|
-
registerRefactor(
|
|
136564
|
+
registerRefactor(refactorName8, {
|
|
136524
136565
|
kinds: [
|
|
136525
136566
|
toAnonymousFunctionAction.kind,
|
|
136526
136567
|
toNamedFunctionAction.kind,
|
|
@@ -136551,13 +136592,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136551
136592
|
if (!functionDeclaration)
|
|
136552
136593
|
return emptyArray;
|
|
136553
136594
|
return [{
|
|
136554
|
-
name:
|
|
136555
|
-
description:
|
|
136595
|
+
name: refactorName9,
|
|
136596
|
+
description: refactorDescription5,
|
|
136556
136597
|
actions: [toDestructuredAction]
|
|
136557
136598
|
}];
|
|
136558
136599
|
}
|
|
136559
136600
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136560
|
-
Debug.assert(actionName2 ===
|
|
136601
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136561
136602
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136562
136603
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136563
136604
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -137067,21 +137108,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137067
137108
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
137068
137109
|
}
|
|
137069
137110
|
}
|
|
137070
|
-
var
|
|
137111
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
137071
137112
|
var init_convertParamsToDestructuredObject = __esm({
|
|
137072
137113
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
137073
137114
|
"use strict";
|
|
137074
137115
|
init_ts4();
|
|
137075
137116
|
init_ts_refactor();
|
|
137076
|
-
|
|
137117
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
137077
137118
|
minimumParameterLength = 1;
|
|
137078
|
-
|
|
137119
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
137079
137120
|
toDestructuredAction = {
|
|
137080
|
-
name:
|
|
137081
|
-
description:
|
|
137121
|
+
name: refactorName9,
|
|
137122
|
+
description: refactorDescription5,
|
|
137082
137123
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
137083
137124
|
};
|
|
137084
|
-
registerRefactor(
|
|
137125
|
+
registerRefactor(refactorName9, {
|
|
137085
137126
|
kinds: [toDestructuredAction.kind],
|
|
137086
137127
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
137087
137128
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137103,7 +137144,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137103
137144
|
const { file, startPosition } = context;
|
|
137104
137145
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137105
137146
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137106
|
-
const refactorInfo = { name:
|
|
137147
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137107
137148
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137108
137149
|
refactorInfo.actions.push(convertStringAction);
|
|
137109
137150
|
return [refactorInfo];
|
|
@@ -137129,7 +137170,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137129
137170
|
const { file, startPosition } = context;
|
|
137130
137171
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137131
137172
|
switch (actionName2) {
|
|
137132
|
-
case
|
|
137173
|
+
case refactorDescription6:
|
|
137133
137174
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137134
137175
|
default:
|
|
137135
137176
|
return Debug.fail("invalid action");
|
|
@@ -137280,20 +137321,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137280
137321
|
}
|
|
137281
137322
|
return node;
|
|
137282
137323
|
}
|
|
137283
|
-
var
|
|
137324
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137284
137325
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137285
137326
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137286
137327
|
"use strict";
|
|
137287
137328
|
init_ts4();
|
|
137288
137329
|
init_ts_refactor();
|
|
137289
|
-
|
|
137290
|
-
|
|
137330
|
+
refactorName10 = "Convert to template string";
|
|
137331
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137291
137332
|
convertStringAction = {
|
|
137292
|
-
name:
|
|
137293
|
-
description:
|
|
137333
|
+
name: refactorName10,
|
|
137334
|
+
description: refactorDescription6,
|
|
137294
137335
|
kind: "refactor.rewrite.string"
|
|
137295
137336
|
};
|
|
137296
|
-
registerRefactor(
|
|
137337
|
+
registerRefactor(refactorName10, {
|
|
137297
137338
|
kinds: [convertStringAction.kind],
|
|
137298
137339
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137299
137340
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137343,14 +137384,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137343
137384
|
return emptyArray;
|
|
137344
137385
|
if (!isRefactorErrorInfo(info)) {
|
|
137345
137386
|
return [{
|
|
137346
|
-
name:
|
|
137387
|
+
name: refactorName11,
|
|
137347
137388
|
description: convertToOptionalChainExpressionMessage,
|
|
137348
137389
|
actions: [toOptionalChainAction]
|
|
137349
137390
|
}];
|
|
137350
137391
|
}
|
|
137351
137392
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137352
137393
|
return [{
|
|
137353
|
-
name:
|
|
137394
|
+
name: refactorName11,
|
|
137354
137395
|
description: convertToOptionalChainExpressionMessage,
|
|
137355
137396
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137356
137397
|
}];
|
|
@@ -137534,20 +137575,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137534
137575
|
}
|
|
137535
137576
|
}
|
|
137536
137577
|
}
|
|
137537
|
-
var
|
|
137578
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137538
137579
|
var init_convertToOptionalChainExpression = __esm({
|
|
137539
137580
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137540
137581
|
"use strict";
|
|
137541
137582
|
init_ts4();
|
|
137542
137583
|
init_ts_refactor();
|
|
137543
|
-
|
|
137584
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137544
137585
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137545
137586
|
toOptionalChainAction = {
|
|
137546
|
-
name:
|
|
137587
|
+
name: refactorName11,
|
|
137547
137588
|
description: convertToOptionalChainExpressionMessage,
|
|
137548
137589
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137549
137590
|
};
|
|
137550
|
-
registerRefactor(
|
|
137591
|
+
registerRefactor(refactorName11, {
|
|
137551
137592
|
kinds: [toOptionalChainAction.kind],
|
|
137552
137593
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137553
137594
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137576,14 +137617,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137576
137617
|
const errors = [];
|
|
137577
137618
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137578
137619
|
errors.push({
|
|
137579
|
-
name:
|
|
137620
|
+
name: refactorName12,
|
|
137580
137621
|
description: extractFunctionAction.description,
|
|
137581
137622
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137582
137623
|
});
|
|
137583
137624
|
}
|
|
137584
137625
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137585
137626
|
errors.push({
|
|
137586
|
-
name:
|
|
137627
|
+
name: refactorName12,
|
|
137587
137628
|
description: extractConstantAction.description,
|
|
137588
137629
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137589
137630
|
});
|
|
@@ -137647,26 +137688,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137647
137688
|
const infos = [];
|
|
137648
137689
|
if (functionActions.length) {
|
|
137649
137690
|
infos.push({
|
|
137650
|
-
name:
|
|
137691
|
+
name: refactorName12,
|
|
137651
137692
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137652
137693
|
actions: functionActions
|
|
137653
137694
|
});
|
|
137654
137695
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137655
137696
|
infos.push({
|
|
137656
|
-
name:
|
|
137697
|
+
name: refactorName12,
|
|
137657
137698
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137658
137699
|
actions: [innermostErrorFunctionAction]
|
|
137659
137700
|
});
|
|
137660
137701
|
}
|
|
137661
137702
|
if (constantActions.length) {
|
|
137662
137703
|
infos.push({
|
|
137663
|
-
name:
|
|
137704
|
+
name: refactorName12,
|
|
137664
137705
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137665
137706
|
actions: constantActions
|
|
137666
137707
|
});
|
|
137667
137708
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137668
137709
|
infos.push({
|
|
137669
|
-
name:
|
|
137710
|
+
name: refactorName12,
|
|
137670
137711
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137671
137712
|
actions: [innermostErrorConstantAction]
|
|
137672
137713
|
});
|
|
@@ -139097,13 +139138,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139097
139138
|
function isStringLiteralJsxAttribute(node) {
|
|
139098
139139
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139099
139140
|
}
|
|
139100
|
-
var
|
|
139141
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139101
139142
|
var init_extractSymbol = __esm({
|
|
139102
139143
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139103
139144
|
"use strict";
|
|
139104
139145
|
init_ts4();
|
|
139105
139146
|
init_ts_refactor();
|
|
139106
|
-
|
|
139147
|
+
refactorName12 = "Extract Symbol";
|
|
139107
139148
|
extractConstantAction = {
|
|
139108
139149
|
name: "Extract Constant",
|
|
139109
139150
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139114,7 +139155,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139114
139155
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139115
139156
|
kind: "refactor.extract.function"
|
|
139116
139157
|
};
|
|
139117
|
-
registerRefactor(
|
|
139158
|
+
registerRefactor(refactorName12, {
|
|
139118
139159
|
kinds: [
|
|
139119
139160
|
extractConstantAction.kind,
|
|
139120
139161
|
extractFunctionAction.kind
|
|
@@ -139265,15 +139306,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139265
139306
|
return emptyArray;
|
|
139266
139307
|
if (!isRefactorErrorInfo(info)) {
|
|
139267
139308
|
return [{
|
|
139268
|
-
name:
|
|
139269
|
-
description:
|
|
139309
|
+
name: refactorName13,
|
|
139310
|
+
description: refactorDescription7,
|
|
139270
139311
|
actions: [inferReturnTypeAction]
|
|
139271
139312
|
}];
|
|
139272
139313
|
}
|
|
139273
139314
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139274
139315
|
return [{
|
|
139275
|
-
name:
|
|
139276
|
-
description:
|
|
139316
|
+
name: refactorName13,
|
|
139317
|
+
description: refactorDescription7,
|
|
139277
139318
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139278
139319
|
}];
|
|
139279
139320
|
}
|
|
@@ -139332,20 +139373,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139332
139373
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139333
139374
|
}
|
|
139334
139375
|
}
|
|
139335
|
-
var
|
|
139376
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139336
139377
|
var init_inferFunctionReturnType = __esm({
|
|
139337
139378
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139338
139379
|
"use strict";
|
|
139339
139380
|
init_ts4();
|
|
139340
139381
|
init_ts_refactor();
|
|
139341
|
-
|
|
139342
|
-
|
|
139382
|
+
refactorName13 = "Infer function return type";
|
|
139383
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139343
139384
|
inferReturnTypeAction = {
|
|
139344
|
-
name:
|
|
139345
|
-
description:
|
|
139385
|
+
name: refactorName13,
|
|
139386
|
+
description: refactorDescription7,
|
|
139346
139387
|
kind: "refactor.rewrite.function.returnType"
|
|
139347
139388
|
};
|
|
139348
|
-
registerRefactor(
|
|
139389
|
+
registerRefactor(refactorName13, {
|
|
139349
139390
|
kinds: [inferReturnTypeAction.kind],
|
|
139350
139391
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139351
139392
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139406,6 +139447,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139406
139447
|
init_convertImport();
|
|
139407
139448
|
init_extractType();
|
|
139408
139449
|
init_helpers();
|
|
139450
|
+
init_inlineVariable();
|
|
139409
139451
|
init_moveToNewFile();
|
|
139410
139452
|
init_moveToFile();
|
|
139411
139453
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140944,10 +140986,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140944
140986
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140945
140987
|
return { newFileName, files };
|
|
140946
140988
|
}
|
|
140947
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
140989
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140948
140990
|
synchronizeHostData();
|
|
140949
140991
|
const file = getValidSourceFile(fileName);
|
|
140950
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
140992
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140951
140993
|
}
|
|
140952
140994
|
function toLineColumnOffset(fileName, position) {
|
|
140953
140995
|
if (position === 0) {
|
|
@@ -146453,27 +146495,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146453
146495
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
146454
146496
|
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
146455
146497
|
}
|
|
146456
|
-
function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program) {
|
|
146457
|
-
if (specifier.parent.parent.name) {
|
|
146458
|
-
return false;
|
|
146459
|
-
}
|
|
146460
|
-
const nonTypeOnlySpecifiers = specifier.parent.elements.filter((e) => !e.isTypeOnly);
|
|
146461
|
-
if (nonTypeOnlySpecifiers.length === 1) {
|
|
146462
|
-
return true;
|
|
146463
|
-
}
|
|
146464
|
-
const checker = program.getTypeChecker();
|
|
146465
|
-
for (const specifier2 of nonTypeOnlySpecifiers) {
|
|
146466
|
-
const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
|
|
146467
|
-
return !isValidTypeOnlyAliasUseSite(usage);
|
|
146468
|
-
});
|
|
146469
|
-
if (isUsedAsValue) {
|
|
146470
|
-
return false;
|
|
146471
|
-
}
|
|
146472
|
-
}
|
|
146473
|
-
return true;
|
|
146474
|
-
}
|
|
146475
146498
|
function doChange11(changes, sourceFile, declaration) {
|
|
146476
|
-
var _a;
|
|
146477
146499
|
if (isImportSpecifier(declaration)) {
|
|
146478
146500
|
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
146479
146501
|
declaration,
|
|
@@ -146544,16 +146566,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146544
146566
|
)
|
|
146545
146567
|
]);
|
|
146546
146568
|
} else {
|
|
146547
|
-
const newNamedBindings = ((_a = importClause.namedBindings) == null ? void 0 : _a.kind) === 274 /* NamedImports */ ? factory.updateNamedImports(
|
|
146548
|
-
importClause.namedBindings,
|
|
146549
|
-
sameMap(importClause.namedBindings.elements, (e) => factory.updateImportSpecifier(
|
|
146550
|
-
e,
|
|
146551
|
-
/*isTypeOnly*/
|
|
146552
|
-
false,
|
|
146553
|
-
e.propertyName,
|
|
146554
|
-
e.name
|
|
146555
|
-
))
|
|
146556
|
-
) : importClause.namedBindings;
|
|
146557
146569
|
const importDeclaration = factory.updateImportDeclaration(
|
|
146558
146570
|
declaration,
|
|
146559
146571
|
declaration.modifiers,
|
|
@@ -146562,7 +146574,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146562
146574
|
/*isTypeOnly*/
|
|
146563
146575
|
true,
|
|
146564
146576
|
importClause.name,
|
|
146565
|
-
|
|
146577
|
+
importClause.namedBindings
|
|
146566
146578
|
),
|
|
146567
146579
|
declaration.moduleSpecifier,
|
|
146568
146580
|
declaration.assertClause
|
|
@@ -146585,41 +146597,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146585
146597
|
registerCodeFix({
|
|
146586
146598
|
errorCodes: errorCodes14,
|
|
146587
146599
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146588
|
-
var _a;
|
|
146589
146600
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
146590
146601
|
if (declaration) {
|
|
146591
146602
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
146592
|
-
|
|
146593
|
-
const mainAction = createCodeFixAction(
|
|
146594
|
-
fixId13,
|
|
146595
|
-
changes,
|
|
146596
|
-
declaration.kind === 275 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
146597
|
-
fixId13,
|
|
146598
|
-
Diagnostics.Fix_all_with_type_only_imports
|
|
146599
|
-
);
|
|
146600
|
-
if (some(importDeclarationChanges)) {
|
|
146601
|
-
return [
|
|
146602
|
-
createCodeFixActionWithoutFixAll(fixId13, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
146603
|
-
mainAction
|
|
146604
|
-
];
|
|
146605
|
-
}
|
|
146606
|
-
return [mainAction];
|
|
146603
|
+
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
146607
146604
|
}
|
|
146608
146605
|
return void 0;
|
|
146609
146606
|
},
|
|
146610
146607
|
fixIds: [fixId13],
|
|
146611
146608
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146612
|
-
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
146613
146609
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
146614
|
-
const
|
|
146615
|
-
if (
|
|
146616
|
-
doChange11(changes, diag2.file,
|
|
146617
|
-
fixedImportDeclarations.add(errorDeclaration);
|
|
146618
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */ && !fixedImportDeclarations.has(errorDeclaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(errorDeclaration, diag2.file, context.program)) {
|
|
146619
|
-
doChange11(changes, diag2.file, errorDeclaration.parent.parent.parent);
|
|
146620
|
-
fixedImportDeclarations.add(errorDeclaration.parent.parent.parent);
|
|
146621
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */) {
|
|
146622
|
-
doChange11(changes, diag2.file, errorDeclaration);
|
|
146610
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
146611
|
+
if (declaration) {
|
|
146612
|
+
doChange11(changes, diag2.file, declaration);
|
|
146623
146613
|
}
|
|
146624
146614
|
});
|
|
146625
146615
|
}
|
|
@@ -150549,7 +150539,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
150549
150539
|
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
150550
150540
|
}
|
|
150551
150541
|
if (typeOnlyChanges.length) {
|
|
150552
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.
|
|
150542
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
150553
150543
|
}
|
|
150554
150544
|
return actions2;
|
|
150555
150545
|
},
|
|
@@ -158756,7 +158746,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158756
158746
|
}
|
|
158757
158747
|
const keys = getOwnKeys(exports);
|
|
158758
158748
|
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
158759
|
-
const conditions =
|
|
158749
|
+
const conditions = mode === 99 /* ESNext */ ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
158760
158750
|
addCompletionEntriesFromPathsOrExports(
|
|
158761
158751
|
result,
|
|
158762
158752
|
fragmentSubpath,
|
|
@@ -161511,6 +161501,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161511
161501
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161512
161502
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161513
161503
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161504
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161514
161505
|
nodeEntry: () => nodeEntry,
|
|
161515
161506
|
toContextSpan: () => toContextSpan,
|
|
161516
161507
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -162193,29 +162184,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162193
162184
|
if (!signature || !candidates.length) {
|
|
162194
162185
|
return;
|
|
162195
162186
|
}
|
|
162196
|
-
let
|
|
162197
|
-
|
|
162187
|
+
for (let i = 0; i < args.length; ++i) {
|
|
162188
|
+
const originalArg = args[i];
|
|
162198
162189
|
const arg = skipParentheses(originalArg);
|
|
162199
162190
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162200
162191
|
continue;
|
|
162201
162192
|
}
|
|
162202
|
-
|
|
162203
|
-
if (isSpreadElement(arg)) {
|
|
162204
|
-
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162205
|
-
if (checker.isTupleType(spreadType)) {
|
|
162206
|
-
const { elementFlags, fixedLength } = spreadType.target;
|
|
162207
|
-
if (fixedLength === 0) {
|
|
162208
|
-
continue;
|
|
162209
|
-
}
|
|
162210
|
-
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162211
|
-
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162212
|
-
if (requiredArgs > 0) {
|
|
162213
|
-
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162214
|
-
}
|
|
162215
|
-
}
|
|
162216
|
-
}
|
|
162217
|
-
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162218
|
-
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162193
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
|
|
162219
162194
|
if (identifierNameInfo) {
|
|
162220
162195
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162221
162196
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -169717,9 +169692,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169717
169692
|
init_ts5();
|
|
169718
169693
|
init_deprecate();
|
|
169719
169694
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169720
|
-
const
|
|
169721
|
-
if (!hasProperty(
|
|
169722
|
-
Object.defineProperty(
|
|
169695
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169696
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169697
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169723
169698
|
get: deprecate(function() {
|
|
169724
169699
|
return identifierToKeywordKind(this);
|
|
169725
169700
|
}, {
|
|
@@ -169731,8 +169706,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169731
169706
|
})
|
|
169732
169707
|
});
|
|
169733
169708
|
}
|
|
169734
|
-
if (!hasProperty(
|
|
169735
|
-
Object.defineProperty(
|
|
169709
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169710
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169736
169711
|
get: deprecate(function() {
|
|
169737
169712
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169738
169713
|
}, {
|
|
@@ -170644,11 +170619,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
170644
170619
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
170645
170620
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
170646
170621
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
170647
|
-
getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
|
|
170648
170622
|
getOutputExtension: () => getOutputExtension,
|
|
170649
170623
|
getOutputFileNames: () => getOutputFileNames,
|
|
170650
|
-
getOutputJSFileName: () => getOutputJSFileName,
|
|
170651
|
-
getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
|
|
170652
170624
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
170653
170625
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
170654
170626
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|