@typescript-deploys/pr-build 5.2.0-pr-54536-13 → 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 +45 -51
- package/lib/tsserver.js +250 -200
- package/lib/tsserverlibrary.js +268 -209
- package/lib/typescript.js +268 -209
- package/lib/typingsInstaller.js +10 -13
- 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."),
|
|
@@ -8505,8 +8507,6 @@ ${lanes.join("\n")}
|
|
|
8505
8507
|
Resolved_under_condition_0: diag(6414, 3 /* Message */, "Resolved_under_condition_0_6414", "Resolved under condition '{0}'."),
|
|
8506
8508
|
Failed_to_resolve_under_condition_0: diag(6415, 3 /* Message */, "Failed_to_resolve_under_condition_0_6415", "Failed to resolve under condition '{0}'."),
|
|
8507
8509
|
Exiting_conditional_exports: diag(6416, 3 /* Message */, "Exiting_conditional_exports_6416", "Exiting conditional exports."),
|
|
8508
|
-
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}."),
|
|
8509
|
-
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}."),
|
|
8510
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}'"),
|
|
8511
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."),
|
|
8512
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."),
|
|
@@ -9019,9 +9019,9 @@ ${lanes.join("\n")}
|
|
|
9019
9019
|
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
9020
9020
|
Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
|
|
9021
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"),
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
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."),
|
|
9025
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."),
|
|
9026
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'."),
|
|
9027
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?"),
|
|
@@ -40951,13 +40951,11 @@ ${lanes.join("\n")}
|
|
|
40951
40951
|
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
40952
40952
|
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
40953
40953
|
if (priorityExtensions) {
|
|
40954
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0, formatExtensions(priorityExtensions));
|
|
40955
40954
|
const result = lookup(priorityExtensions);
|
|
40956
40955
|
if (result)
|
|
40957
40956
|
return result;
|
|
40958
40957
|
}
|
|
40959
40958
|
if (secondaryExtensions && !typesScopeOnly) {
|
|
40960
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0, formatExtensions(secondaryExtensions));
|
|
40961
40959
|
return lookup(secondaryExtensions);
|
|
40962
40960
|
}
|
|
40963
40961
|
function lookup(extensions2) {
|
|
@@ -45382,9 +45380,9 @@ ${lanes.join("\n")}
|
|
|
45382
45380
|
candidatesOutArray,
|
|
45383
45381
|
/*argumentCount*/
|
|
45384
45382
|
void 0,
|
|
45385
|
-
|
|
45383
|
+
32 /* IsForStringLiteralArgumentCompletions */
|
|
45386
45384
|
)),
|
|
45387
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
45385
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
45388
45386
|
getExpandedParameters,
|
|
45389
45387
|
hasEffectiveRestParameter,
|
|
45390
45388
|
containsArgumentsReference,
|
|
@@ -53339,7 +53337,7 @@ ${lanes.join("\n")}
|
|
|
53339
53337
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53340
53338
|
}
|
|
53341
53339
|
function getTypeForBindingElement(declaration) {
|
|
53342
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53340
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
53343
53341
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53344
53342
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53345
53343
|
}
|
|
@@ -55096,13 +55094,19 @@ ${lanes.join("\n")}
|
|
|
55096
55094
|
if (getObjectFlags(type) & 4 /* Reference */) {
|
|
55097
55095
|
const target = type.target;
|
|
55098
55096
|
const typeArguments = getTypeArguments(type);
|
|
55099
|
-
|
|
55097
|
+
if (length(target.typeParameters) === length(typeArguments)) {
|
|
55098
|
+
const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
|
|
55099
|
+
return needApparentType ? getApparentType(ref) : ref;
|
|
55100
|
+
}
|
|
55100
55101
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
55101
55102
|
const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
|
|
55102
55103
|
return types !== type.types ? getIntersectionType(types) : type;
|
|
55103
55104
|
}
|
|
55104
55105
|
return needApparentType ? getApparentType(type) : type;
|
|
55105
55106
|
}
|
|
55107
|
+
function getThisArgument(type) {
|
|
55108
|
+
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
55109
|
+
}
|
|
55106
55110
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
55107
55111
|
let mapper;
|
|
55108
55112
|
let members;
|
|
@@ -56168,7 +56172,7 @@ ${lanes.join("\n")}
|
|
|
56168
56172
|
return type.resolvedBaseConstraint;
|
|
56169
56173
|
}
|
|
56170
56174
|
const stack = [];
|
|
56171
|
-
return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
|
|
56175
|
+
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
|
|
56172
56176
|
function getImmediateBaseConstraint(t) {
|
|
56173
56177
|
if (!t.immediateBaseConstraint) {
|
|
56174
56178
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -56260,18 +56264,18 @@ ${lanes.join("\n")}
|
|
|
56260
56264
|
}
|
|
56261
56265
|
if (isGenericTupleType(t)) {
|
|
56262
56266
|
const newElements = map(getElementTypes(t), (v, i) => {
|
|
56263
|
-
const constraint =
|
|
56264
|
-
return constraint
|
|
56267
|
+
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
56268
|
+
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
56265
56269
|
});
|
|
56266
56270
|
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
56267
56271
|
}
|
|
56268
56272
|
return t;
|
|
56269
56273
|
}
|
|
56270
56274
|
}
|
|
56271
|
-
function getApparentTypeOfIntersectionType(type
|
|
56275
|
+
function getApparentTypeOfIntersectionType(type) {
|
|
56272
56276
|
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
|
|
56273
56277
|
type,
|
|
56274
|
-
|
|
56278
|
+
type,
|
|
56275
56279
|
/*needApparentType*/
|
|
56276
56280
|
true
|
|
56277
56281
|
));
|
|
@@ -56322,9 +56326,8 @@ ${lanes.join("\n")}
|
|
|
56322
56326
|
return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
|
|
56323
56327
|
}
|
|
56324
56328
|
function getApparentType(type) {
|
|
56325
|
-
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType
|
|
56326
|
-
|
|
56327
|
-
return objectFlags & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : objectFlags & 4 /* Reference */ && t !== type ? getTypeWithThisArgument(t, type) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t, type) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
|
|
56329
|
+
const t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
|
|
56330
|
+
return getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 402653316 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : t.flags & 4194304 /* Index */ ? keyofConstraintType : t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t;
|
|
56328
56331
|
}
|
|
56329
56332
|
function getReducedApparentType(type) {
|
|
56330
56333
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -63145,7 +63148,7 @@ ${lanes.join("\n")}
|
|
|
63145
63148
|
return 3 /* Maybe */;
|
|
63146
63149
|
}
|
|
63147
63150
|
const c = target2;
|
|
63148
|
-
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)
|
|
63151
|
+
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
|
|
63149
63152
|
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
|
|
63150
63153
|
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
|
|
63151
63154
|
if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
|
|
@@ -67155,8 +67158,6 @@ ${lanes.join("\n")}
|
|
|
67155
67158
|
}
|
|
67156
67159
|
function isConstantReference(node) {
|
|
67157
67160
|
switch (node.kind) {
|
|
67158
|
-
case 110 /* ThisKeyword */:
|
|
67159
|
-
return true;
|
|
67160
67161
|
case 80 /* Identifier */:
|
|
67161
67162
|
if (!isThisInTypeQuery(node)) {
|
|
67162
67163
|
const symbol = getResolvedSymbol(node);
|
|
@@ -68231,7 +68232,7 @@ ${lanes.join("\n")}
|
|
|
68231
68232
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68232
68233
|
}
|
|
68233
68234
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68234
|
-
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(
|
|
68235
68236
|
node,
|
|
68236
68237
|
/*contextFlags*/
|
|
68237
68238
|
void 0
|
|
@@ -68988,7 +68989,7 @@ ${lanes.join("\n")}
|
|
|
68988
68989
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
68989
68990
|
const parent2 = declaration.parent.parent;
|
|
68990
68991
|
const name = declaration.propertyName || declaration.name;
|
|
68991
|
-
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 */);
|
|
68992
68993
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
68993
68994
|
return void 0;
|
|
68994
68995
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -70037,9 +70038,7 @@ ${lanes.join("\n")}
|
|
|
70037
70038
|
elementTypes.push(undefinedOrMissingType);
|
|
70038
70039
|
elementFlags.push(2 /* Optional */);
|
|
70039
70040
|
} else {
|
|
70040
|
-
const
|
|
70041
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70042
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70041
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
70043
70042
|
elementTypes.push(addOptionality(
|
|
70044
70043
|
type,
|
|
70045
70044
|
/*isProperty*/
|
|
@@ -70047,7 +70046,7 @@ ${lanes.join("\n")}
|
|
|
70047
70046
|
hasOmittedExpression
|
|
70048
70047
|
));
|
|
70049
70048
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70050
|
-
if (
|
|
70049
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
70051
70050
|
const inferenceContext = getInferenceContext(node);
|
|
70052
70051
|
Debug.assert(inferenceContext);
|
|
70053
70052
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70188,13 +70187,11 @@ ${lanes.join("\n")}
|
|
|
70188
70187
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70189
70188
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70190
70189
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70191
|
-
|
|
70192
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70193
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70190
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
70194
70191
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70195
70192
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70196
70193
|
// we don't want to say "could not find 'a'".
|
|
70197
|
-
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)
|
|
70198
70195
|
);
|
|
70199
70196
|
if (isInJavascript) {
|
|
70200
70197
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70238,7 +70235,7 @@ ${lanes.join("\n")}
|
|
|
70238
70235
|
prop.links.target = member;
|
|
70239
70236
|
member = prop;
|
|
70240
70237
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70241
|
-
if (
|
|
70238
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
70242
70239
|
const inferenceContext = getInferenceContext(node);
|
|
70243
70240
|
Debug.assert(inferenceContext);
|
|
70244
70241
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70411,9 +70408,7 @@ ${lanes.join("\n")}
|
|
|
70411
70408
|
for (const attributeDecl of attributes.properties) {
|
|
70412
70409
|
const member = attributeDecl.symbol;
|
|
70413
70410
|
if (isJsxAttribute(attributeDecl)) {
|
|
70414
|
-
const
|
|
70415
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70416
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70411
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
70417
70412
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70418
70413
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70419
70414
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70434,7 +70429,7 @@ ${lanes.join("\n")}
|
|
|
70434
70429
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70435
70430
|
}
|
|
70436
70431
|
}
|
|
70437
|
-
if (
|
|
70432
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
70438
70433
|
const inferenceContext = getInferenceContext(attributes);
|
|
70439
70434
|
Debug.assert(inferenceContext);
|
|
70440
70435
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72052,7 +72047,7 @@ ${lanes.join("\n")}
|
|
|
72052
72047
|
}
|
|
72053
72048
|
for (let i = 0; i < argCount; i++) {
|
|
72054
72049
|
const arg = args[i];
|
|
72055
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
72050
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
72056
72051
|
const paramType = getTypeAtPosition(signature, i);
|
|
72057
72052
|
if (couldContainTypeVariables(paramType)) {
|
|
72058
72053
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72665,12 +72660,12 @@ ${lanes.join("\n")}
|
|
|
72665
72660
|
const args = getEffectiveCallArguments(node);
|
|
72666
72661
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72667
72662
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72668
|
-
argCheckMode |= checkMode &
|
|
72663
|
+
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72669
72664
|
let candidatesForArgumentError;
|
|
72670
72665
|
let candidateForArgumentArityError;
|
|
72671
72666
|
let candidateForTypeArgumentError;
|
|
72672
72667
|
let result;
|
|
72673
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72668
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72674
72669
|
if (candidates.length > 1) {
|
|
72675
72670
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72676
72671
|
}
|
|
@@ -72889,7 +72884,7 @@ ${lanes.join("\n")}
|
|
|
72889
72884
|
continue;
|
|
72890
72885
|
}
|
|
72891
72886
|
if (argCheckMode) {
|
|
72892
|
-
argCheckMode = checkMode &
|
|
72887
|
+
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
72893
72888
|
if (inferenceContext) {
|
|
72894
72889
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72895
72890
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75967,7 +75962,7 @@ ${lanes.join("\n")}
|
|
|
75967
75962
|
case 36 /* ExclamationEqualsToken */:
|
|
75968
75963
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75969
75964
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75970
|
-
if (!(checkMode && checkMode &
|
|
75965
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
75971
75966
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
75972
75967
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75973
75968
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -76626,7 +76621,7 @@ ${lanes.join("\n")}
|
|
|
76626
76621
|
}
|
|
76627
76622
|
}
|
|
76628
76623
|
const startInvocationCount = flowInvocationCount;
|
|
76629
|
-
const type = checkExpression(node,
|
|
76624
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
76630
76625
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76631
76626
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76632
76627
|
cache[getNodeId(node)] = type;
|
|
@@ -79097,7 +79092,7 @@ ${lanes.join("\n")}
|
|
|
79097
79092
|
checkComputedPropertyName(node.propertyName);
|
|
79098
79093
|
}
|
|
79099
79094
|
const parent2 = node.parent.parent;
|
|
79100
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79095
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
79101
79096
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79102
79097
|
const name = node.propertyName || node.name;
|
|
79103
79098
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -85833,11 +85828,10 @@ ${lanes.join("\n")}
|
|
|
85833
85828
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85834
85829
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85835
85830
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85836
|
-
CheckMode3[CheckMode3["
|
|
85837
|
-
CheckMode3[CheckMode3["
|
|
85838
|
-
CheckMode3[CheckMode3["
|
|
85839
|
-
CheckMode3[CheckMode3["
|
|
85840
|
-
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";
|
|
85841
85835
|
return CheckMode3;
|
|
85842
85836
|
})(CheckMode || {});
|
|
85843
85837
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -98256,7 +98250,7 @@ ${lanes.join("\n")}
|
|
|
98256
98250
|
continue;
|
|
98257
98251
|
}
|
|
98258
98252
|
finishObjectLiteralIfNeeded();
|
|
98259
|
-
expressions.push(
|
|
98253
|
+
expressions.push(attr.expression);
|
|
98260
98254
|
continue;
|
|
98261
98255
|
}
|
|
98262
98256
|
properties.push(transformJsxAttributeToObjectLiteralElement(attr));
|
|
@@ -134016,8 +134010,8 @@ ${lanes.join("\n")}
|
|
|
134016
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);
|
|
134017
134011
|
}));
|
|
134018
134012
|
}
|
|
134019
|
-
function getEditsForRefactor(context,
|
|
134020
|
-
const refactor = refactors.get(
|
|
134013
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134014
|
+
const refactor = refactors.get(refactorName14);
|
|
134021
134015
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134022
134016
|
}
|
|
134023
134017
|
var refactors;
|
|
@@ -134823,6 +134817,137 @@ ${lanes.join("\n")}
|
|
|
134823
134817
|
}
|
|
134824
134818
|
});
|
|
134825
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
|
+
|
|
134826
134951
|
// src/services/refactors/moveToNewFile.ts
|
|
134827
134952
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134828
134953
|
const checker = program.getTypeChecker();
|
|
@@ -134904,29 +135029,29 @@ ${lanes.join("\n")}
|
|
|
134904
135029
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
134905
135030
|
return copiedOldImports;
|
|
134906
135031
|
}
|
|
134907
|
-
var
|
|
135032
|
+
var refactorName5, description, moveToNewFileAction;
|
|
134908
135033
|
var init_moveToNewFile = __esm({
|
|
134909
135034
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
134910
135035
|
"use strict";
|
|
134911
135036
|
init_ts4();
|
|
134912
135037
|
init_ts_refactor();
|
|
134913
|
-
|
|
135038
|
+
refactorName5 = "Move to a new file";
|
|
134914
135039
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
134915
135040
|
moveToNewFileAction = {
|
|
134916
|
-
name:
|
|
135041
|
+
name: refactorName5,
|
|
134917
135042
|
description,
|
|
134918
135043
|
kind: "refactor.move.newFile"
|
|
134919
135044
|
};
|
|
134920
|
-
registerRefactor(
|
|
135045
|
+
registerRefactor(refactorName5, {
|
|
134921
135046
|
kinds: [moveToNewFileAction.kind],
|
|
134922
135047
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
134923
135048
|
const statements = getStatementsToMove(context);
|
|
134924
135049
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
134925
|
-
return [{ name:
|
|
135050
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
134926
135051
|
}
|
|
134927
135052
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
134928
135053
|
return [{
|
|
134929
|
-
name:
|
|
135054
|
+
name: refactorName5,
|
|
134930
135055
|
description,
|
|
134931
135056
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
134932
135057
|
}];
|
|
@@ -134934,7 +135059,7 @@ ${lanes.join("\n")}
|
|
|
134934
135059
|
return emptyArray;
|
|
134935
135060
|
},
|
|
134936
135061
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
134937
|
-
Debug.assert(actionName2 ===
|
|
135062
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
134938
135063
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
134939
135064
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
134940
135065
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135845,8 +135970,8 @@ ${lanes.join("\n")}
|
|
|
135845
135970
|
if (!info)
|
|
135846
135971
|
return emptyArray;
|
|
135847
135972
|
return [{
|
|
135848
|
-
name:
|
|
135849
|
-
description:
|
|
135973
|
+
name: refactorName6,
|
|
135974
|
+
description: refactorDescription2,
|
|
135850
135975
|
actions: [functionOverloadAction]
|
|
135851
135976
|
}];
|
|
135852
135977
|
}
|
|
@@ -136037,20 +136162,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136037
136162
|
}
|
|
136038
136163
|
return signatureDecls;
|
|
136039
136164
|
}
|
|
136040
|
-
var
|
|
136165
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136041
136166
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136042
136167
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136043
136168
|
"use strict";
|
|
136044
136169
|
init_ts4();
|
|
136045
136170
|
init_ts_refactor();
|
|
136046
|
-
|
|
136047
|
-
|
|
136171
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136172
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136048
136173
|
functionOverloadAction = {
|
|
136049
|
-
name:
|
|
136050
|
-
description:
|
|
136174
|
+
name: refactorName6,
|
|
136175
|
+
description: refactorDescription2,
|
|
136051
136176
|
kind: "refactor.rewrite.function.overloadList"
|
|
136052
136177
|
};
|
|
136053
|
-
registerRefactor(
|
|
136178
|
+
registerRefactor(refactorName6, {
|
|
136054
136179
|
kinds: [functionOverloadAction.kind],
|
|
136055
136180
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136056
136181
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136066,8 +136191,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136066
136191
|
return emptyArray;
|
|
136067
136192
|
if (!isRefactorErrorInfo(info)) {
|
|
136068
136193
|
return [{
|
|
136069
|
-
name:
|
|
136070
|
-
description:
|
|
136194
|
+
name: refactorName7,
|
|
136195
|
+
description: refactorDescription3,
|
|
136071
136196
|
actions: [
|
|
136072
136197
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136073
136198
|
]
|
|
@@ -136075,8 +136200,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136075
136200
|
}
|
|
136076
136201
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136077
136202
|
return [{
|
|
136078
|
-
name:
|
|
136079
|
-
description:
|
|
136203
|
+
name: refactorName7,
|
|
136204
|
+
description: refactorDescription3,
|
|
136080
136205
|
actions: [
|
|
136081
136206
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136082
136207
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136167,14 +136292,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136167
136292
|
}
|
|
136168
136293
|
return void 0;
|
|
136169
136294
|
}
|
|
136170
|
-
var
|
|
136295
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136171
136296
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136172
136297
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136173
136298
|
"use strict";
|
|
136174
136299
|
init_ts4();
|
|
136175
136300
|
init_ts_refactor();
|
|
136176
|
-
|
|
136177
|
-
|
|
136301
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136302
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136178
136303
|
addBracesAction = {
|
|
136179
136304
|
name: "Add braces to arrow function",
|
|
136180
136305
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136185,7 +136310,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136185
136310
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136186
136311
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136187
136312
|
};
|
|
136188
|
-
registerRefactor(
|
|
136313
|
+
registerRefactor(refactorName7, {
|
|
136189
136314
|
kinds: [removeBracesAction.kind],
|
|
136190
136315
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136191
136316
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136237,8 +136362,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136237
136362
|
}
|
|
136238
136363
|
}
|
|
136239
136364
|
return [{
|
|
136240
|
-
name:
|
|
136241
|
-
description:
|
|
136365
|
+
name: refactorName8,
|
|
136366
|
+
description: refactorDescription4,
|
|
136242
136367
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136243
136368
|
}];
|
|
136244
136369
|
}
|
|
@@ -136398,14 +136523,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136398
136523
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136399
136524
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136400
136525
|
}
|
|
136401
|
-
var
|
|
136526
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136402
136527
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136403
136528
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136404
136529
|
"use strict";
|
|
136405
136530
|
init_ts4();
|
|
136406
136531
|
init_ts_refactor();
|
|
136407
|
-
|
|
136408
|
-
|
|
136532
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136533
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136409
136534
|
toAnonymousFunctionAction = {
|
|
136410
136535
|
name: "Convert to anonymous function",
|
|
136411
136536
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136421,7 +136546,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136421
136546
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136422
136547
|
kind: "refactor.rewrite.function.arrow"
|
|
136423
136548
|
};
|
|
136424
|
-
registerRefactor(
|
|
136549
|
+
registerRefactor(refactorName8, {
|
|
136425
136550
|
kinds: [
|
|
136426
136551
|
toAnonymousFunctionAction.kind,
|
|
136427
136552
|
toNamedFunctionAction.kind,
|
|
@@ -136452,13 +136577,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136452
136577
|
if (!functionDeclaration)
|
|
136453
136578
|
return emptyArray;
|
|
136454
136579
|
return [{
|
|
136455
|
-
name:
|
|
136456
|
-
description:
|
|
136580
|
+
name: refactorName9,
|
|
136581
|
+
description: refactorDescription5,
|
|
136457
136582
|
actions: [toDestructuredAction]
|
|
136458
136583
|
}];
|
|
136459
136584
|
}
|
|
136460
136585
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136461
|
-
Debug.assert(actionName2 ===
|
|
136586
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136462
136587
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136463
136588
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136464
136589
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -136968,21 +137093,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136968
137093
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
136969
137094
|
}
|
|
136970
137095
|
}
|
|
136971
|
-
var
|
|
137096
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
136972
137097
|
var init_convertParamsToDestructuredObject = __esm({
|
|
136973
137098
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
136974
137099
|
"use strict";
|
|
136975
137100
|
init_ts4();
|
|
136976
137101
|
init_ts_refactor();
|
|
136977
|
-
|
|
137102
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
136978
137103
|
minimumParameterLength = 1;
|
|
136979
|
-
|
|
137104
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
136980
137105
|
toDestructuredAction = {
|
|
136981
|
-
name:
|
|
136982
|
-
description:
|
|
137106
|
+
name: refactorName9,
|
|
137107
|
+
description: refactorDescription5,
|
|
136983
137108
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
136984
137109
|
};
|
|
136985
|
-
registerRefactor(
|
|
137110
|
+
registerRefactor(refactorName9, {
|
|
136986
137111
|
kinds: [toDestructuredAction.kind],
|
|
136987
137112
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
136988
137113
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137004,7 +137129,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137004
137129
|
const { file, startPosition } = context;
|
|
137005
137130
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137006
137131
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137007
|
-
const refactorInfo = { name:
|
|
137132
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137008
137133
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137009
137134
|
refactorInfo.actions.push(convertStringAction);
|
|
137010
137135
|
return [refactorInfo];
|
|
@@ -137030,7 +137155,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137030
137155
|
const { file, startPosition } = context;
|
|
137031
137156
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137032
137157
|
switch (actionName2) {
|
|
137033
|
-
case
|
|
137158
|
+
case refactorDescription6:
|
|
137034
137159
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137035
137160
|
default:
|
|
137036
137161
|
return Debug.fail("invalid action");
|
|
@@ -137181,20 +137306,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137181
137306
|
}
|
|
137182
137307
|
return node;
|
|
137183
137308
|
}
|
|
137184
|
-
var
|
|
137309
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137185
137310
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137186
137311
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137187
137312
|
"use strict";
|
|
137188
137313
|
init_ts4();
|
|
137189
137314
|
init_ts_refactor();
|
|
137190
|
-
|
|
137191
|
-
|
|
137315
|
+
refactorName10 = "Convert to template string";
|
|
137316
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137192
137317
|
convertStringAction = {
|
|
137193
|
-
name:
|
|
137194
|
-
description:
|
|
137318
|
+
name: refactorName10,
|
|
137319
|
+
description: refactorDescription6,
|
|
137195
137320
|
kind: "refactor.rewrite.string"
|
|
137196
137321
|
};
|
|
137197
|
-
registerRefactor(
|
|
137322
|
+
registerRefactor(refactorName10, {
|
|
137198
137323
|
kinds: [convertStringAction.kind],
|
|
137199
137324
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137200
137325
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137244,14 +137369,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137244
137369
|
return emptyArray;
|
|
137245
137370
|
if (!isRefactorErrorInfo(info)) {
|
|
137246
137371
|
return [{
|
|
137247
|
-
name:
|
|
137372
|
+
name: refactorName11,
|
|
137248
137373
|
description: convertToOptionalChainExpressionMessage,
|
|
137249
137374
|
actions: [toOptionalChainAction]
|
|
137250
137375
|
}];
|
|
137251
137376
|
}
|
|
137252
137377
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137253
137378
|
return [{
|
|
137254
|
-
name:
|
|
137379
|
+
name: refactorName11,
|
|
137255
137380
|
description: convertToOptionalChainExpressionMessage,
|
|
137256
137381
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137257
137382
|
}];
|
|
@@ -137435,20 +137560,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137435
137560
|
}
|
|
137436
137561
|
}
|
|
137437
137562
|
}
|
|
137438
|
-
var
|
|
137563
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137439
137564
|
var init_convertToOptionalChainExpression = __esm({
|
|
137440
137565
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137441
137566
|
"use strict";
|
|
137442
137567
|
init_ts4();
|
|
137443
137568
|
init_ts_refactor();
|
|
137444
|
-
|
|
137569
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137445
137570
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137446
137571
|
toOptionalChainAction = {
|
|
137447
|
-
name:
|
|
137572
|
+
name: refactorName11,
|
|
137448
137573
|
description: convertToOptionalChainExpressionMessage,
|
|
137449
137574
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137450
137575
|
};
|
|
137451
|
-
registerRefactor(
|
|
137576
|
+
registerRefactor(refactorName11, {
|
|
137452
137577
|
kinds: [toOptionalChainAction.kind],
|
|
137453
137578
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137454
137579
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137477,14 +137602,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137477
137602
|
const errors = [];
|
|
137478
137603
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137479
137604
|
errors.push({
|
|
137480
|
-
name:
|
|
137605
|
+
name: refactorName12,
|
|
137481
137606
|
description: extractFunctionAction.description,
|
|
137482
137607
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137483
137608
|
});
|
|
137484
137609
|
}
|
|
137485
137610
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137486
137611
|
errors.push({
|
|
137487
|
-
name:
|
|
137612
|
+
name: refactorName12,
|
|
137488
137613
|
description: extractConstantAction.description,
|
|
137489
137614
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137490
137615
|
});
|
|
@@ -137548,26 +137673,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137548
137673
|
const infos = [];
|
|
137549
137674
|
if (functionActions.length) {
|
|
137550
137675
|
infos.push({
|
|
137551
|
-
name:
|
|
137676
|
+
name: refactorName12,
|
|
137552
137677
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137553
137678
|
actions: functionActions
|
|
137554
137679
|
});
|
|
137555
137680
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137556
137681
|
infos.push({
|
|
137557
|
-
name:
|
|
137682
|
+
name: refactorName12,
|
|
137558
137683
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137559
137684
|
actions: [innermostErrorFunctionAction]
|
|
137560
137685
|
});
|
|
137561
137686
|
}
|
|
137562
137687
|
if (constantActions.length) {
|
|
137563
137688
|
infos.push({
|
|
137564
|
-
name:
|
|
137689
|
+
name: refactorName12,
|
|
137565
137690
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137566
137691
|
actions: constantActions
|
|
137567
137692
|
});
|
|
137568
137693
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137569
137694
|
infos.push({
|
|
137570
|
-
name:
|
|
137695
|
+
name: refactorName12,
|
|
137571
137696
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137572
137697
|
actions: [innermostErrorConstantAction]
|
|
137573
137698
|
});
|
|
@@ -138998,13 +139123,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
138998
139123
|
function isStringLiteralJsxAttribute(node) {
|
|
138999
139124
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139000
139125
|
}
|
|
139001
|
-
var
|
|
139126
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139002
139127
|
var init_extractSymbol = __esm({
|
|
139003
139128
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139004
139129
|
"use strict";
|
|
139005
139130
|
init_ts4();
|
|
139006
139131
|
init_ts_refactor();
|
|
139007
|
-
|
|
139132
|
+
refactorName12 = "Extract Symbol";
|
|
139008
139133
|
extractConstantAction = {
|
|
139009
139134
|
name: "Extract Constant",
|
|
139010
139135
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139015,7 +139140,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139015
139140
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139016
139141
|
kind: "refactor.extract.function"
|
|
139017
139142
|
};
|
|
139018
|
-
registerRefactor(
|
|
139143
|
+
registerRefactor(refactorName12, {
|
|
139019
139144
|
kinds: [
|
|
139020
139145
|
extractConstantAction.kind,
|
|
139021
139146
|
extractFunctionAction.kind
|
|
@@ -139166,15 +139291,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139166
139291
|
return emptyArray;
|
|
139167
139292
|
if (!isRefactorErrorInfo(info)) {
|
|
139168
139293
|
return [{
|
|
139169
|
-
name:
|
|
139170
|
-
description:
|
|
139294
|
+
name: refactorName13,
|
|
139295
|
+
description: refactorDescription7,
|
|
139171
139296
|
actions: [inferReturnTypeAction]
|
|
139172
139297
|
}];
|
|
139173
139298
|
}
|
|
139174
139299
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139175
139300
|
return [{
|
|
139176
|
-
name:
|
|
139177
|
-
description:
|
|
139301
|
+
name: refactorName13,
|
|
139302
|
+
description: refactorDescription7,
|
|
139178
139303
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139179
139304
|
}];
|
|
139180
139305
|
}
|
|
@@ -139233,20 +139358,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139233
139358
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139234
139359
|
}
|
|
139235
139360
|
}
|
|
139236
|
-
var
|
|
139361
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139237
139362
|
var init_inferFunctionReturnType = __esm({
|
|
139238
139363
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139239
139364
|
"use strict";
|
|
139240
139365
|
init_ts4();
|
|
139241
139366
|
init_ts_refactor();
|
|
139242
|
-
|
|
139243
|
-
|
|
139367
|
+
refactorName13 = "Infer function return type";
|
|
139368
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139244
139369
|
inferReturnTypeAction = {
|
|
139245
|
-
name:
|
|
139246
|
-
description:
|
|
139370
|
+
name: refactorName13,
|
|
139371
|
+
description: refactorDescription7,
|
|
139247
139372
|
kind: "refactor.rewrite.function.returnType"
|
|
139248
139373
|
};
|
|
139249
|
-
registerRefactor(
|
|
139374
|
+
registerRefactor(refactorName13, {
|
|
139250
139375
|
kinds: [inferReturnTypeAction.kind],
|
|
139251
139376
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139252
139377
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139307,6 +139432,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139307
139432
|
init_convertImport();
|
|
139308
139433
|
init_extractType();
|
|
139309
139434
|
init_helpers();
|
|
139435
|
+
init_inlineVariable();
|
|
139310
139436
|
init_moveToNewFile();
|
|
139311
139437
|
init_moveToFile();
|
|
139312
139438
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140845,10 +140971,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140845
140971
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140846
140972
|
return { newFileName, files };
|
|
140847
140973
|
}
|
|
140848
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
140974
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140849
140975
|
synchronizeHostData();
|
|
140850
140976
|
const file = getValidSourceFile(fileName);
|
|
140851
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
140977
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140852
140978
|
}
|
|
140853
140979
|
function toLineColumnOffset(fileName, position) {
|
|
140854
140980
|
if (position === 0) {
|
|
@@ -146354,27 +146480,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146354
146480
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
146355
146481
|
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
146356
146482
|
}
|
|
146357
|
-
function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program) {
|
|
146358
|
-
if (specifier.parent.parent.name) {
|
|
146359
|
-
return false;
|
|
146360
|
-
}
|
|
146361
|
-
const nonTypeOnlySpecifiers = specifier.parent.elements.filter((e) => !e.isTypeOnly);
|
|
146362
|
-
if (nonTypeOnlySpecifiers.length === 1) {
|
|
146363
|
-
return true;
|
|
146364
|
-
}
|
|
146365
|
-
const checker = program.getTypeChecker();
|
|
146366
|
-
for (const specifier2 of nonTypeOnlySpecifiers) {
|
|
146367
|
-
const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
|
|
146368
|
-
return !isValidTypeOnlyAliasUseSite(usage);
|
|
146369
|
-
});
|
|
146370
|
-
if (isUsedAsValue) {
|
|
146371
|
-
return false;
|
|
146372
|
-
}
|
|
146373
|
-
}
|
|
146374
|
-
return true;
|
|
146375
|
-
}
|
|
146376
146483
|
function doChange11(changes, sourceFile, declaration) {
|
|
146377
|
-
var _a;
|
|
146378
146484
|
if (isImportSpecifier(declaration)) {
|
|
146379
146485
|
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
146380
146486
|
declaration,
|
|
@@ -146445,16 +146551,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146445
146551
|
)
|
|
146446
146552
|
]);
|
|
146447
146553
|
} else {
|
|
146448
|
-
const newNamedBindings = ((_a = importClause.namedBindings) == null ? void 0 : _a.kind) === 274 /* NamedImports */ ? factory.updateNamedImports(
|
|
146449
|
-
importClause.namedBindings,
|
|
146450
|
-
sameMap(importClause.namedBindings.elements, (e) => factory.updateImportSpecifier(
|
|
146451
|
-
e,
|
|
146452
|
-
/*isTypeOnly*/
|
|
146453
|
-
false,
|
|
146454
|
-
e.propertyName,
|
|
146455
|
-
e.name
|
|
146456
|
-
))
|
|
146457
|
-
) : importClause.namedBindings;
|
|
146458
146554
|
const importDeclaration = factory.updateImportDeclaration(
|
|
146459
146555
|
declaration,
|
|
146460
146556
|
declaration.modifiers,
|
|
@@ -146463,7 +146559,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146463
146559
|
/*isTypeOnly*/
|
|
146464
146560
|
true,
|
|
146465
146561
|
importClause.name,
|
|
146466
|
-
|
|
146562
|
+
importClause.namedBindings
|
|
146467
146563
|
),
|
|
146468
146564
|
declaration.moduleSpecifier,
|
|
146469
146565
|
declaration.assertClause
|
|
@@ -146486,41 +146582,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146486
146582
|
registerCodeFix({
|
|
146487
146583
|
errorCodes: errorCodes14,
|
|
146488
146584
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146489
|
-
var _a;
|
|
146490
146585
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
146491
146586
|
if (declaration) {
|
|
146492
146587
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
146493
|
-
|
|
146494
|
-
const mainAction = createCodeFixAction(
|
|
146495
|
-
fixId13,
|
|
146496
|
-
changes,
|
|
146497
|
-
declaration.kind === 275 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
146498
|
-
fixId13,
|
|
146499
|
-
Diagnostics.Fix_all_with_type_only_imports
|
|
146500
|
-
);
|
|
146501
|
-
if (some(importDeclarationChanges)) {
|
|
146502
|
-
return [
|
|
146503
|
-
createCodeFixActionWithoutFixAll(fixId13, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
146504
|
-
mainAction
|
|
146505
|
-
];
|
|
146506
|
-
}
|
|
146507
|
-
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)];
|
|
146508
146589
|
}
|
|
146509
146590
|
return void 0;
|
|
146510
146591
|
},
|
|
146511
146592
|
fixIds: [fixId13],
|
|
146512
146593
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146513
|
-
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
146514
146594
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
146515
|
-
const
|
|
146516
|
-
if (
|
|
146517
|
-
doChange11(changes, diag2.file,
|
|
146518
|
-
fixedImportDeclarations.add(errorDeclaration);
|
|
146519
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */ && !fixedImportDeclarations.has(errorDeclaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(errorDeclaration, diag2.file, context.program)) {
|
|
146520
|
-
doChange11(changes, diag2.file, errorDeclaration.parent.parent.parent);
|
|
146521
|
-
fixedImportDeclarations.add(errorDeclaration.parent.parent.parent);
|
|
146522
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */) {
|
|
146523
|
-
doChange11(changes, diag2.file, errorDeclaration);
|
|
146595
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
146596
|
+
if (declaration) {
|
|
146597
|
+
doChange11(changes, diag2.file, declaration);
|
|
146524
146598
|
}
|
|
146525
146599
|
});
|
|
146526
146600
|
}
|
|
@@ -150450,7 +150524,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
150450
150524
|
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
150451
150525
|
}
|
|
150452
150526
|
if (typeOnlyChanges.length) {
|
|
150453
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.
|
|
150527
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
150454
150528
|
}
|
|
150455
150529
|
return actions2;
|
|
150456
150530
|
},
|
|
@@ -158657,7 +158731,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158657
158731
|
}
|
|
158658
158732
|
const keys = getOwnKeys(exports);
|
|
158659
158733
|
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
158660
|
-
const conditions =
|
|
158734
|
+
const conditions = mode === 99 /* ESNext */ ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
158661
158735
|
addCompletionEntriesFromPathsOrExports(
|
|
158662
158736
|
result,
|
|
158663
158737
|
fragmentSubpath,
|
|
@@ -161412,6 +161486,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161412
161486
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161413
161487
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161414
161488
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161489
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161415
161490
|
nodeEntry: () => nodeEntry,
|
|
161416
161491
|
toContextSpan: () => toContextSpan,
|
|
161417
161492
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -162094,29 +162169,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162094
162169
|
if (!signature || !candidates.length) {
|
|
162095
162170
|
return;
|
|
162096
162171
|
}
|
|
162097
|
-
let
|
|
162098
|
-
|
|
162172
|
+
for (let i = 0; i < args.length; ++i) {
|
|
162173
|
+
const originalArg = args[i];
|
|
162099
162174
|
const arg = skipParentheses(originalArg);
|
|
162100
162175
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162101
162176
|
continue;
|
|
162102
162177
|
}
|
|
162103
|
-
|
|
162104
|
-
if (isSpreadElement(arg)) {
|
|
162105
|
-
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162106
|
-
if (checker.isTupleType(spreadType)) {
|
|
162107
|
-
const { elementFlags, fixedLength } = spreadType.target;
|
|
162108
|
-
if (fixedLength === 0) {
|
|
162109
|
-
continue;
|
|
162110
|
-
}
|
|
162111
|
-
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162112
|
-
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162113
|
-
if (requiredArgs > 0) {
|
|
162114
|
-
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162115
|
-
}
|
|
162116
|
-
}
|
|
162117
|
-
}
|
|
162118
|
-
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162119
|
-
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162178
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
|
|
162120
162179
|
if (identifierNameInfo) {
|
|
162121
162180
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162122
162181
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -169618,9 +169677,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169618
169677
|
init_ts5();
|
|
169619
169678
|
init_deprecate();
|
|
169620
169679
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169621
|
-
const
|
|
169622
|
-
if (!hasProperty(
|
|
169623
|
-
Object.defineProperty(
|
|
169680
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169681
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169682
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169624
169683
|
get: deprecate(function() {
|
|
169625
169684
|
return identifierToKeywordKind(this);
|
|
169626
169685
|
}, {
|
|
@@ -169632,8 +169691,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169632
169691
|
})
|
|
169633
169692
|
});
|
|
169634
169693
|
}
|
|
169635
|
-
if (!hasProperty(
|
|
169636
|
-
Object.defineProperty(
|
|
169694
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169695
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169637
169696
|
get: deprecate(function() {
|
|
169638
169697
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169639
169698
|
}, {
|