@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/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."),
|
|
@@ -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));
|
|
@@ -134031,8 +134025,8 @@ ${lanes.join("\n")}
|
|
|
134031
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);
|
|
134032
134026
|
}));
|
|
134033
134027
|
}
|
|
134034
|
-
function getEditsForRefactor(context,
|
|
134035
|
-
const refactor = refactors.get(
|
|
134028
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134029
|
+
const refactor = refactors.get(refactorName14);
|
|
134036
134030
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134037
134031
|
}
|
|
134038
134032
|
var refactors;
|
|
@@ -134838,6 +134832,137 @@ ${lanes.join("\n")}
|
|
|
134838
134832
|
}
|
|
134839
134833
|
});
|
|
134840
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
|
+
|
|
134841
134966
|
// src/services/refactors/moveToNewFile.ts
|
|
134842
134967
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134843
134968
|
const checker = program.getTypeChecker();
|
|
@@ -134919,29 +135044,29 @@ ${lanes.join("\n")}
|
|
|
134919
135044
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
134920
135045
|
return copiedOldImports;
|
|
134921
135046
|
}
|
|
134922
|
-
var
|
|
135047
|
+
var refactorName5, description, moveToNewFileAction;
|
|
134923
135048
|
var init_moveToNewFile = __esm({
|
|
134924
135049
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
134925
135050
|
"use strict";
|
|
134926
135051
|
init_ts4();
|
|
134927
135052
|
init_ts_refactor();
|
|
134928
|
-
|
|
135053
|
+
refactorName5 = "Move to a new file";
|
|
134929
135054
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
134930
135055
|
moveToNewFileAction = {
|
|
134931
|
-
name:
|
|
135056
|
+
name: refactorName5,
|
|
134932
135057
|
description,
|
|
134933
135058
|
kind: "refactor.move.newFile"
|
|
134934
135059
|
};
|
|
134935
|
-
registerRefactor(
|
|
135060
|
+
registerRefactor(refactorName5, {
|
|
134936
135061
|
kinds: [moveToNewFileAction.kind],
|
|
134937
135062
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
134938
135063
|
const statements = getStatementsToMove(context);
|
|
134939
135064
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
134940
|
-
return [{ name:
|
|
135065
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
134941
135066
|
}
|
|
134942
135067
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
134943
135068
|
return [{
|
|
134944
|
-
name:
|
|
135069
|
+
name: refactorName5,
|
|
134945
135070
|
description,
|
|
134946
135071
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
134947
135072
|
}];
|
|
@@ -134949,7 +135074,7 @@ ${lanes.join("\n")}
|
|
|
134949
135074
|
return emptyArray;
|
|
134950
135075
|
},
|
|
134951
135076
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
134952
|
-
Debug.assert(actionName2 ===
|
|
135077
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
134953
135078
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
134954
135079
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
134955
135080
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135860,8 +135985,8 @@ ${lanes.join("\n")}
|
|
|
135860
135985
|
if (!info)
|
|
135861
135986
|
return emptyArray;
|
|
135862
135987
|
return [{
|
|
135863
|
-
name:
|
|
135864
|
-
description:
|
|
135988
|
+
name: refactorName6,
|
|
135989
|
+
description: refactorDescription2,
|
|
135865
135990
|
actions: [functionOverloadAction]
|
|
135866
135991
|
}];
|
|
135867
135992
|
}
|
|
@@ -136052,20 +136177,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136052
136177
|
}
|
|
136053
136178
|
return signatureDecls;
|
|
136054
136179
|
}
|
|
136055
|
-
var
|
|
136180
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136056
136181
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136057
136182
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136058
136183
|
"use strict";
|
|
136059
136184
|
init_ts4();
|
|
136060
136185
|
init_ts_refactor();
|
|
136061
|
-
|
|
136062
|
-
|
|
136186
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136187
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136063
136188
|
functionOverloadAction = {
|
|
136064
|
-
name:
|
|
136065
|
-
description:
|
|
136189
|
+
name: refactorName6,
|
|
136190
|
+
description: refactorDescription2,
|
|
136066
136191
|
kind: "refactor.rewrite.function.overloadList"
|
|
136067
136192
|
};
|
|
136068
|
-
registerRefactor(
|
|
136193
|
+
registerRefactor(refactorName6, {
|
|
136069
136194
|
kinds: [functionOverloadAction.kind],
|
|
136070
136195
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136071
136196
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136081,8 +136206,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136081
136206
|
return emptyArray;
|
|
136082
136207
|
if (!isRefactorErrorInfo(info)) {
|
|
136083
136208
|
return [{
|
|
136084
|
-
name:
|
|
136085
|
-
description:
|
|
136209
|
+
name: refactorName7,
|
|
136210
|
+
description: refactorDescription3,
|
|
136086
136211
|
actions: [
|
|
136087
136212
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136088
136213
|
]
|
|
@@ -136090,8 +136215,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136090
136215
|
}
|
|
136091
136216
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136092
136217
|
return [{
|
|
136093
|
-
name:
|
|
136094
|
-
description:
|
|
136218
|
+
name: refactorName7,
|
|
136219
|
+
description: refactorDescription3,
|
|
136095
136220
|
actions: [
|
|
136096
136221
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136097
136222
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136182,14 +136307,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136182
136307
|
}
|
|
136183
136308
|
return void 0;
|
|
136184
136309
|
}
|
|
136185
|
-
var
|
|
136310
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136186
136311
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136187
136312
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136188
136313
|
"use strict";
|
|
136189
136314
|
init_ts4();
|
|
136190
136315
|
init_ts_refactor();
|
|
136191
|
-
|
|
136192
|
-
|
|
136316
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136317
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136193
136318
|
addBracesAction = {
|
|
136194
136319
|
name: "Add braces to arrow function",
|
|
136195
136320
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136200,7 +136325,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136200
136325
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136201
136326
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136202
136327
|
};
|
|
136203
|
-
registerRefactor(
|
|
136328
|
+
registerRefactor(refactorName7, {
|
|
136204
136329
|
kinds: [removeBracesAction.kind],
|
|
136205
136330
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136206
136331
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136252,8 +136377,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136252
136377
|
}
|
|
136253
136378
|
}
|
|
136254
136379
|
return [{
|
|
136255
|
-
name:
|
|
136256
|
-
description:
|
|
136380
|
+
name: refactorName8,
|
|
136381
|
+
description: refactorDescription4,
|
|
136257
136382
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136258
136383
|
}];
|
|
136259
136384
|
}
|
|
@@ -136413,14 +136538,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136413
136538
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136414
136539
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136415
136540
|
}
|
|
136416
|
-
var
|
|
136541
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136417
136542
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136418
136543
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136419
136544
|
"use strict";
|
|
136420
136545
|
init_ts4();
|
|
136421
136546
|
init_ts_refactor();
|
|
136422
|
-
|
|
136423
|
-
|
|
136547
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136548
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136424
136549
|
toAnonymousFunctionAction = {
|
|
136425
136550
|
name: "Convert to anonymous function",
|
|
136426
136551
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136436,7 +136561,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136436
136561
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136437
136562
|
kind: "refactor.rewrite.function.arrow"
|
|
136438
136563
|
};
|
|
136439
|
-
registerRefactor(
|
|
136564
|
+
registerRefactor(refactorName8, {
|
|
136440
136565
|
kinds: [
|
|
136441
136566
|
toAnonymousFunctionAction.kind,
|
|
136442
136567
|
toNamedFunctionAction.kind,
|
|
@@ -136467,13 +136592,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136467
136592
|
if (!functionDeclaration)
|
|
136468
136593
|
return emptyArray;
|
|
136469
136594
|
return [{
|
|
136470
|
-
name:
|
|
136471
|
-
description:
|
|
136595
|
+
name: refactorName9,
|
|
136596
|
+
description: refactorDescription5,
|
|
136472
136597
|
actions: [toDestructuredAction]
|
|
136473
136598
|
}];
|
|
136474
136599
|
}
|
|
136475
136600
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136476
|
-
Debug.assert(actionName2 ===
|
|
136601
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136477
136602
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136478
136603
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136479
136604
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -136983,21 +137108,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136983
137108
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
136984
137109
|
}
|
|
136985
137110
|
}
|
|
136986
|
-
var
|
|
137111
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
136987
137112
|
var init_convertParamsToDestructuredObject = __esm({
|
|
136988
137113
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
136989
137114
|
"use strict";
|
|
136990
137115
|
init_ts4();
|
|
136991
137116
|
init_ts_refactor();
|
|
136992
|
-
|
|
137117
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
136993
137118
|
minimumParameterLength = 1;
|
|
136994
|
-
|
|
137119
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
136995
137120
|
toDestructuredAction = {
|
|
136996
|
-
name:
|
|
136997
|
-
description:
|
|
137121
|
+
name: refactorName9,
|
|
137122
|
+
description: refactorDescription5,
|
|
136998
137123
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
136999
137124
|
};
|
|
137000
|
-
registerRefactor(
|
|
137125
|
+
registerRefactor(refactorName9, {
|
|
137001
137126
|
kinds: [toDestructuredAction.kind],
|
|
137002
137127
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
137003
137128
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137019,7 +137144,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137019
137144
|
const { file, startPosition } = context;
|
|
137020
137145
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137021
137146
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137022
|
-
const refactorInfo = { name:
|
|
137147
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137023
137148
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137024
137149
|
refactorInfo.actions.push(convertStringAction);
|
|
137025
137150
|
return [refactorInfo];
|
|
@@ -137045,7 +137170,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137045
137170
|
const { file, startPosition } = context;
|
|
137046
137171
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137047
137172
|
switch (actionName2) {
|
|
137048
|
-
case
|
|
137173
|
+
case refactorDescription6:
|
|
137049
137174
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137050
137175
|
default:
|
|
137051
137176
|
return Debug.fail("invalid action");
|
|
@@ -137196,20 +137321,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137196
137321
|
}
|
|
137197
137322
|
return node;
|
|
137198
137323
|
}
|
|
137199
|
-
var
|
|
137324
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137200
137325
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137201
137326
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137202
137327
|
"use strict";
|
|
137203
137328
|
init_ts4();
|
|
137204
137329
|
init_ts_refactor();
|
|
137205
|
-
|
|
137206
|
-
|
|
137330
|
+
refactorName10 = "Convert to template string";
|
|
137331
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137207
137332
|
convertStringAction = {
|
|
137208
|
-
name:
|
|
137209
|
-
description:
|
|
137333
|
+
name: refactorName10,
|
|
137334
|
+
description: refactorDescription6,
|
|
137210
137335
|
kind: "refactor.rewrite.string"
|
|
137211
137336
|
};
|
|
137212
|
-
registerRefactor(
|
|
137337
|
+
registerRefactor(refactorName10, {
|
|
137213
137338
|
kinds: [convertStringAction.kind],
|
|
137214
137339
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137215
137340
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137259,14 +137384,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137259
137384
|
return emptyArray;
|
|
137260
137385
|
if (!isRefactorErrorInfo(info)) {
|
|
137261
137386
|
return [{
|
|
137262
|
-
name:
|
|
137387
|
+
name: refactorName11,
|
|
137263
137388
|
description: convertToOptionalChainExpressionMessage,
|
|
137264
137389
|
actions: [toOptionalChainAction]
|
|
137265
137390
|
}];
|
|
137266
137391
|
}
|
|
137267
137392
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137268
137393
|
return [{
|
|
137269
|
-
name:
|
|
137394
|
+
name: refactorName11,
|
|
137270
137395
|
description: convertToOptionalChainExpressionMessage,
|
|
137271
137396
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137272
137397
|
}];
|
|
@@ -137450,20 +137575,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137450
137575
|
}
|
|
137451
137576
|
}
|
|
137452
137577
|
}
|
|
137453
|
-
var
|
|
137578
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137454
137579
|
var init_convertToOptionalChainExpression = __esm({
|
|
137455
137580
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137456
137581
|
"use strict";
|
|
137457
137582
|
init_ts4();
|
|
137458
137583
|
init_ts_refactor();
|
|
137459
|
-
|
|
137584
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137460
137585
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137461
137586
|
toOptionalChainAction = {
|
|
137462
|
-
name:
|
|
137587
|
+
name: refactorName11,
|
|
137463
137588
|
description: convertToOptionalChainExpressionMessage,
|
|
137464
137589
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137465
137590
|
};
|
|
137466
|
-
registerRefactor(
|
|
137591
|
+
registerRefactor(refactorName11, {
|
|
137467
137592
|
kinds: [toOptionalChainAction.kind],
|
|
137468
137593
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137469
137594
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137492,14 +137617,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137492
137617
|
const errors = [];
|
|
137493
137618
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137494
137619
|
errors.push({
|
|
137495
|
-
name:
|
|
137620
|
+
name: refactorName12,
|
|
137496
137621
|
description: extractFunctionAction.description,
|
|
137497
137622
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137498
137623
|
});
|
|
137499
137624
|
}
|
|
137500
137625
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137501
137626
|
errors.push({
|
|
137502
|
-
name:
|
|
137627
|
+
name: refactorName12,
|
|
137503
137628
|
description: extractConstantAction.description,
|
|
137504
137629
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137505
137630
|
});
|
|
@@ -137563,26 +137688,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137563
137688
|
const infos = [];
|
|
137564
137689
|
if (functionActions.length) {
|
|
137565
137690
|
infos.push({
|
|
137566
|
-
name:
|
|
137691
|
+
name: refactorName12,
|
|
137567
137692
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137568
137693
|
actions: functionActions
|
|
137569
137694
|
});
|
|
137570
137695
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137571
137696
|
infos.push({
|
|
137572
|
-
name:
|
|
137697
|
+
name: refactorName12,
|
|
137573
137698
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137574
137699
|
actions: [innermostErrorFunctionAction]
|
|
137575
137700
|
});
|
|
137576
137701
|
}
|
|
137577
137702
|
if (constantActions.length) {
|
|
137578
137703
|
infos.push({
|
|
137579
|
-
name:
|
|
137704
|
+
name: refactorName12,
|
|
137580
137705
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137581
137706
|
actions: constantActions
|
|
137582
137707
|
});
|
|
137583
137708
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137584
137709
|
infos.push({
|
|
137585
|
-
name:
|
|
137710
|
+
name: refactorName12,
|
|
137586
137711
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137587
137712
|
actions: [innermostErrorConstantAction]
|
|
137588
137713
|
});
|
|
@@ -139013,13 +139138,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139013
139138
|
function isStringLiteralJsxAttribute(node) {
|
|
139014
139139
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139015
139140
|
}
|
|
139016
|
-
var
|
|
139141
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139017
139142
|
var init_extractSymbol = __esm({
|
|
139018
139143
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139019
139144
|
"use strict";
|
|
139020
139145
|
init_ts4();
|
|
139021
139146
|
init_ts_refactor();
|
|
139022
|
-
|
|
139147
|
+
refactorName12 = "Extract Symbol";
|
|
139023
139148
|
extractConstantAction = {
|
|
139024
139149
|
name: "Extract Constant",
|
|
139025
139150
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139030,7 +139155,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139030
139155
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139031
139156
|
kind: "refactor.extract.function"
|
|
139032
139157
|
};
|
|
139033
|
-
registerRefactor(
|
|
139158
|
+
registerRefactor(refactorName12, {
|
|
139034
139159
|
kinds: [
|
|
139035
139160
|
extractConstantAction.kind,
|
|
139036
139161
|
extractFunctionAction.kind
|
|
@@ -139181,15 +139306,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139181
139306
|
return emptyArray;
|
|
139182
139307
|
if (!isRefactorErrorInfo(info)) {
|
|
139183
139308
|
return [{
|
|
139184
|
-
name:
|
|
139185
|
-
description:
|
|
139309
|
+
name: refactorName13,
|
|
139310
|
+
description: refactorDescription7,
|
|
139186
139311
|
actions: [inferReturnTypeAction]
|
|
139187
139312
|
}];
|
|
139188
139313
|
}
|
|
139189
139314
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139190
139315
|
return [{
|
|
139191
|
-
name:
|
|
139192
|
-
description:
|
|
139316
|
+
name: refactorName13,
|
|
139317
|
+
description: refactorDescription7,
|
|
139193
139318
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139194
139319
|
}];
|
|
139195
139320
|
}
|
|
@@ -139248,20 +139373,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139248
139373
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139249
139374
|
}
|
|
139250
139375
|
}
|
|
139251
|
-
var
|
|
139376
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139252
139377
|
var init_inferFunctionReturnType = __esm({
|
|
139253
139378
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139254
139379
|
"use strict";
|
|
139255
139380
|
init_ts4();
|
|
139256
139381
|
init_ts_refactor();
|
|
139257
|
-
|
|
139258
|
-
|
|
139382
|
+
refactorName13 = "Infer function return type";
|
|
139383
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139259
139384
|
inferReturnTypeAction = {
|
|
139260
|
-
name:
|
|
139261
|
-
description:
|
|
139385
|
+
name: refactorName13,
|
|
139386
|
+
description: refactorDescription7,
|
|
139262
139387
|
kind: "refactor.rewrite.function.returnType"
|
|
139263
139388
|
};
|
|
139264
|
-
registerRefactor(
|
|
139389
|
+
registerRefactor(refactorName13, {
|
|
139265
139390
|
kinds: [inferReturnTypeAction.kind],
|
|
139266
139391
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139267
139392
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139322,6 +139447,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139322
139447
|
init_convertImport();
|
|
139323
139448
|
init_extractType();
|
|
139324
139449
|
init_helpers();
|
|
139450
|
+
init_inlineVariable();
|
|
139325
139451
|
init_moveToNewFile();
|
|
139326
139452
|
init_moveToFile();
|
|
139327
139453
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140860,10 +140986,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140860
140986
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140861
140987
|
return { newFileName, files };
|
|
140862
140988
|
}
|
|
140863
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
140989
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140864
140990
|
synchronizeHostData();
|
|
140865
140991
|
const file = getValidSourceFile(fileName);
|
|
140866
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
140992
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140867
140993
|
}
|
|
140868
140994
|
function toLineColumnOffset(fileName, position) {
|
|
140869
140995
|
if (position === 0) {
|
|
@@ -146369,27 +146495,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146369
146495
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
146370
146496
|
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
146371
146497
|
}
|
|
146372
|
-
function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program) {
|
|
146373
|
-
if (specifier.parent.parent.name) {
|
|
146374
|
-
return false;
|
|
146375
|
-
}
|
|
146376
|
-
const nonTypeOnlySpecifiers = specifier.parent.elements.filter((e) => !e.isTypeOnly);
|
|
146377
|
-
if (nonTypeOnlySpecifiers.length === 1) {
|
|
146378
|
-
return true;
|
|
146379
|
-
}
|
|
146380
|
-
const checker = program.getTypeChecker();
|
|
146381
|
-
for (const specifier2 of nonTypeOnlySpecifiers) {
|
|
146382
|
-
const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
|
|
146383
|
-
return !isValidTypeOnlyAliasUseSite(usage);
|
|
146384
|
-
});
|
|
146385
|
-
if (isUsedAsValue) {
|
|
146386
|
-
return false;
|
|
146387
|
-
}
|
|
146388
|
-
}
|
|
146389
|
-
return true;
|
|
146390
|
-
}
|
|
146391
146498
|
function doChange11(changes, sourceFile, declaration) {
|
|
146392
|
-
var _a;
|
|
146393
146499
|
if (isImportSpecifier(declaration)) {
|
|
146394
146500
|
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
146395
146501
|
declaration,
|
|
@@ -146460,16 +146566,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146460
146566
|
)
|
|
146461
146567
|
]);
|
|
146462
146568
|
} else {
|
|
146463
|
-
const newNamedBindings = ((_a = importClause.namedBindings) == null ? void 0 : _a.kind) === 274 /* NamedImports */ ? factory.updateNamedImports(
|
|
146464
|
-
importClause.namedBindings,
|
|
146465
|
-
sameMap(importClause.namedBindings.elements, (e) => factory.updateImportSpecifier(
|
|
146466
|
-
e,
|
|
146467
|
-
/*isTypeOnly*/
|
|
146468
|
-
false,
|
|
146469
|
-
e.propertyName,
|
|
146470
|
-
e.name
|
|
146471
|
-
))
|
|
146472
|
-
) : importClause.namedBindings;
|
|
146473
146569
|
const importDeclaration = factory.updateImportDeclaration(
|
|
146474
146570
|
declaration,
|
|
146475
146571
|
declaration.modifiers,
|
|
@@ -146478,7 +146574,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146478
146574
|
/*isTypeOnly*/
|
|
146479
146575
|
true,
|
|
146480
146576
|
importClause.name,
|
|
146481
|
-
|
|
146577
|
+
importClause.namedBindings
|
|
146482
146578
|
),
|
|
146483
146579
|
declaration.moduleSpecifier,
|
|
146484
146580
|
declaration.assertClause
|
|
@@ -146501,41 +146597,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
146501
146597
|
registerCodeFix({
|
|
146502
146598
|
errorCodes: errorCodes14,
|
|
146503
146599
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146504
|
-
var _a;
|
|
146505
146600
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
146506
146601
|
if (declaration) {
|
|
146507
146602
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
146508
|
-
|
|
146509
|
-
const mainAction = createCodeFixAction(
|
|
146510
|
-
fixId13,
|
|
146511
|
-
changes,
|
|
146512
|
-
declaration.kind === 275 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
146513
|
-
fixId13,
|
|
146514
|
-
Diagnostics.Fix_all_with_type_only_imports
|
|
146515
|
-
);
|
|
146516
|
-
if (some(importDeclarationChanges)) {
|
|
146517
|
-
return [
|
|
146518
|
-
createCodeFixActionWithoutFixAll(fixId13, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
146519
|
-
mainAction
|
|
146520
|
-
];
|
|
146521
|
-
}
|
|
146522
|
-
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)];
|
|
146523
146604
|
}
|
|
146524
146605
|
return void 0;
|
|
146525
146606
|
},
|
|
146526
146607
|
fixIds: [fixId13],
|
|
146527
146608
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
146528
|
-
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
146529
146609
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
146530
|
-
const
|
|
146531
|
-
if (
|
|
146532
|
-
doChange11(changes, diag2.file,
|
|
146533
|
-
fixedImportDeclarations.add(errorDeclaration);
|
|
146534
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */ && !fixedImportDeclarations.has(errorDeclaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(errorDeclaration, diag2.file, context.program)) {
|
|
146535
|
-
doChange11(changes, diag2.file, errorDeclaration.parent.parent.parent);
|
|
146536
|
-
fixedImportDeclarations.add(errorDeclaration.parent.parent.parent);
|
|
146537
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */) {
|
|
146538
|
-
doChange11(changes, diag2.file, errorDeclaration);
|
|
146610
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
146611
|
+
if (declaration) {
|
|
146612
|
+
doChange11(changes, diag2.file, declaration);
|
|
146539
146613
|
}
|
|
146540
146614
|
});
|
|
146541
146615
|
}
|
|
@@ -150465,7 +150539,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
150465
150539
|
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
150466
150540
|
}
|
|
150467
150541
|
if (typeOnlyChanges.length) {
|
|
150468
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.
|
|
150542
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
150469
150543
|
}
|
|
150470
150544
|
return actions2;
|
|
150471
150545
|
},
|
|
@@ -158672,7 +158746,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158672
158746
|
}
|
|
158673
158747
|
const keys = getOwnKeys(exports);
|
|
158674
158748
|
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
158675
|
-
const conditions =
|
|
158749
|
+
const conditions = mode === 99 /* ESNext */ ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
158676
158750
|
addCompletionEntriesFromPathsOrExports(
|
|
158677
158751
|
result,
|
|
158678
158752
|
fragmentSubpath,
|
|
@@ -161427,6 +161501,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161427
161501
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161428
161502
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161429
161503
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161504
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161430
161505
|
nodeEntry: () => nodeEntry,
|
|
161431
161506
|
toContextSpan: () => toContextSpan,
|
|
161432
161507
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -162109,29 +162184,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162109
162184
|
if (!signature || !candidates.length) {
|
|
162110
162185
|
return;
|
|
162111
162186
|
}
|
|
162112
|
-
let
|
|
162113
|
-
|
|
162187
|
+
for (let i = 0; i < args.length; ++i) {
|
|
162188
|
+
const originalArg = args[i];
|
|
162114
162189
|
const arg = skipParentheses(originalArg);
|
|
162115
162190
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162116
162191
|
continue;
|
|
162117
162192
|
}
|
|
162118
|
-
|
|
162119
|
-
if (isSpreadElement(arg)) {
|
|
162120
|
-
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162121
|
-
if (checker.isTupleType(spreadType)) {
|
|
162122
|
-
const { elementFlags, fixedLength } = spreadType.target;
|
|
162123
|
-
if (fixedLength === 0) {
|
|
162124
|
-
continue;
|
|
162125
|
-
}
|
|
162126
|
-
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162127
|
-
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162128
|
-
if (requiredArgs > 0) {
|
|
162129
|
-
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162130
|
-
}
|
|
162131
|
-
}
|
|
162132
|
-
}
|
|
162133
|
-
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162134
|
-
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162193
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
|
|
162135
162194
|
if (identifierNameInfo) {
|
|
162136
162195
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162137
162196
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -169633,9 +169692,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169633
169692
|
init_ts5();
|
|
169634
169693
|
init_deprecate();
|
|
169635
169694
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169636
|
-
const
|
|
169637
|
-
if (!hasProperty(
|
|
169638
|
-
Object.defineProperty(
|
|
169695
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169696
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169697
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169639
169698
|
get: deprecate(function() {
|
|
169640
169699
|
return identifierToKeywordKind(this);
|
|
169641
169700
|
}, {
|
|
@@ -169647,8 +169706,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169647
169706
|
})
|
|
169648
169707
|
});
|
|
169649
169708
|
}
|
|
169650
|
-
if (!hasProperty(
|
|
169651
|
-
Object.defineProperty(
|
|
169709
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169710
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169652
169711
|
get: deprecate(function() {
|
|
169653
169712
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169654
169713
|
}, {
|