typescript 5.2.0-dev.20230612 → 5.2.0-dev.20230614
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +103 -77
- package/lib/tsserver.js +319 -151
- package/lib/tsserverlibrary.js +337 -160
- package/lib/typescript.js +337 -160
- package/lib/typingsInstaller.js +11 -7
- package/package.json +3 -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-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230614`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9032,6 +9032,9 @@ ${lanes.join("\n")}
|
|
|
9032
9032
|
Use_type_0: diag(95181, 3 /* Message */, "Use_type_0_95181", "Use 'type {0}'"),
|
|
9033
9033
|
Fix_all_with_type_only_imports: diag(95182, 3 /* Message */, "Fix_all_with_type_only_imports_95182", "Fix all with type-only imports"),
|
|
9034
9034
|
Cannot_move_statements_to_the_selected_file: diag(95183, 3 /* Message */, "Cannot_move_statements_to_the_selected_file_95183", "Cannot move statements to the selected file"),
|
|
9035
|
+
Inline_variable: diag(95184, 3 /* Message */, "Inline_variable_95184", "Inline variable"),
|
|
9036
|
+
Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
|
|
9037
|
+
Variables_with_multiple_declarations_cannot_be_inlined: diag(95186, 3 /* Message */, "Variables_with_multiple_declarations_cannot_be_inlined_95186", "Variables with multiple declarations cannot be inlined."),
|
|
9035
9038
|
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."),
|
|
9036
9039
|
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'."),
|
|
9037
9040
|
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?"),
|
|
@@ -45389,14 +45392,25 @@ ${lanes.join("\n")}
|
|
|
45389
45392
|
getTypeOfPropertyOfContextualType,
|
|
45390
45393
|
getFullyQualifiedName,
|
|
45391
45394
|
getResolvedSignature: (node, candidatesOutArray, argumentCount) => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */),
|
|
45392
|
-
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray
|
|
45393
|
-
|
|
45394
|
-
|
|
45395
|
-
|
|
45396
|
-
|
|
45397
|
-
|
|
45398
|
-
|
|
45399
|
-
|
|
45395
|
+
getResolvedSignatureForStringLiteralCompletions: (call, editingArgument, candidatesOutArray, checkMode = 32 /* IsForStringLiteralArgumentCompletions */) => {
|
|
45396
|
+
if (checkMode & 32 /* IsForStringLiteralArgumentCompletions */) {
|
|
45397
|
+
return runWithInferenceBlockedFromSourceNode(editingArgument, () => getResolvedSignatureWorker(
|
|
45398
|
+
call,
|
|
45399
|
+
candidatesOutArray,
|
|
45400
|
+
/*argumentCount*/
|
|
45401
|
+
void 0,
|
|
45402
|
+
checkMode & ~32 /* IsForStringLiteralArgumentCompletions */
|
|
45403
|
+
));
|
|
45404
|
+
}
|
|
45405
|
+
return runWithoutResolvedSignatureCaching(editingArgument, () => getResolvedSignatureWorker(
|
|
45406
|
+
call,
|
|
45407
|
+
candidatesOutArray,
|
|
45408
|
+
/*argumentCount*/
|
|
45409
|
+
void 0,
|
|
45410
|
+
checkMode & ~32 /* IsForStringLiteralArgumentCompletions */
|
|
45411
|
+
));
|
|
45412
|
+
},
|
|
45413
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
45400
45414
|
getExpandedParameters,
|
|
45401
45415
|
hasEffectiveRestParameter,
|
|
45402
45416
|
containsArgumentsReference,
|
|
@@ -53222,9 +53236,15 @@ ${lanes.join("\n")}
|
|
|
53222
53236
|
const prop = getPropertyOfType(type, name);
|
|
53223
53237
|
return prop ? getTypeOfSymbol(prop) : void 0;
|
|
53224
53238
|
}
|
|
53225
|
-
function getTypeOfPropertyOrIndexSignature(type, name) {
|
|
53239
|
+
function getTypeOfPropertyOrIndexSignature(type, name, addOptionalityToIndex) {
|
|
53226
53240
|
var _a;
|
|
53227
|
-
|
|
53241
|
+
let propType;
|
|
53242
|
+
return getTypeOfPropertyOfType(type, name) || (propType = (_a = getApplicableIndexInfoForName(type, name)) == null ? void 0 : _a.type) && addOptionality(
|
|
53243
|
+
propType,
|
|
53244
|
+
/*isProperty*/
|
|
53245
|
+
true,
|
|
53246
|
+
addOptionalityToIndex
|
|
53247
|
+
) || unknownType;
|
|
53228
53248
|
}
|
|
53229
53249
|
function isTypeAny(type) {
|
|
53230
53250
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
@@ -53351,7 +53371,7 @@ ${lanes.join("\n")}
|
|
|
53351
53371
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
53352
53372
|
}
|
|
53353
53373
|
function getTypeForBindingElement(declaration) {
|
|
53354
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
53374
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
53355
53375
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
53356
53376
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
53357
53377
|
}
|
|
@@ -55108,19 +55128,13 @@ ${lanes.join("\n")}
|
|
|
55108
55128
|
if (getObjectFlags(type) & 4 /* Reference */) {
|
|
55109
55129
|
const target = type.target;
|
|
55110
55130
|
const typeArguments = getTypeArguments(type);
|
|
55111
|
-
|
|
55112
|
-
const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType]));
|
|
55113
|
-
return needApparentType ? getApparentType(ref) : ref;
|
|
55114
|
-
}
|
|
55131
|
+
return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType])) : type;
|
|
55115
55132
|
} else if (type.flags & 2097152 /* Intersection */) {
|
|
55116
55133
|
const types = sameMap(type.types, (t) => getTypeWithThisArgument(t, thisArgument, needApparentType));
|
|
55117
55134
|
return types !== type.types ? getIntersectionType(types) : type;
|
|
55118
55135
|
}
|
|
55119
55136
|
return needApparentType ? getApparentType(type) : type;
|
|
55120
55137
|
}
|
|
55121
|
-
function getThisArgument(type) {
|
|
55122
|
-
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
55123
|
-
}
|
|
55124
55138
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
55125
55139
|
let mapper;
|
|
55126
55140
|
let members;
|
|
@@ -56186,7 +56200,7 @@ ${lanes.join("\n")}
|
|
|
56186
56200
|
return type.resolvedBaseConstraint;
|
|
56187
56201
|
}
|
|
56188
56202
|
const stack = [];
|
|
56189
|
-
return type.resolvedBaseConstraint =
|
|
56203
|
+
return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
|
|
56190
56204
|
function getImmediateBaseConstraint(t) {
|
|
56191
56205
|
if (!t.immediateBaseConstraint) {
|
|
56192
56206
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -56278,18 +56292,18 @@ ${lanes.join("\n")}
|
|
|
56278
56292
|
}
|
|
56279
56293
|
if (isGenericTupleType(t)) {
|
|
56280
56294
|
const newElements = map(getElementTypes(t), (v, i) => {
|
|
56281
|
-
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
56282
|
-
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
56295
|
+
const constraint = v.flags & 262144 /* TypeParameter */ && t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
56296
|
+
return constraint !== v && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
56283
56297
|
});
|
|
56284
56298
|
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
56285
56299
|
}
|
|
56286
56300
|
return t;
|
|
56287
56301
|
}
|
|
56288
56302
|
}
|
|
56289
|
-
function getApparentTypeOfIntersectionType(type) {
|
|
56303
|
+
function getApparentTypeOfIntersectionType(type, thisArgument) {
|
|
56290
56304
|
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(
|
|
56291
56305
|
type,
|
|
56292
|
-
|
|
56306
|
+
thisArgument,
|
|
56293
56307
|
/*needApparentType*/
|
|
56294
56308
|
true
|
|
56295
56309
|
));
|
|
@@ -56340,8 +56354,9 @@ ${lanes.join("\n")}
|
|
|
56340
56354
|
return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
|
|
56341
56355
|
}
|
|
56342
56356
|
function getApparentType(type) {
|
|
56343
|
-
const t =
|
|
56344
|
-
|
|
56357
|
+
const t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
|
|
56358
|
+
const objectFlags = getObjectFlags(t);
|
|
56359
|
+
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;
|
|
56345
56360
|
}
|
|
56346
56361
|
function getReducedApparentType(type) {
|
|
56347
56362
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
@@ -63170,7 +63185,7 @@ ${lanes.join("\n")}
|
|
|
63170
63185
|
return 3 /* Maybe */;
|
|
63171
63186
|
}
|
|
63172
63187
|
const c = target2;
|
|
63173
|
-
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
|
|
63188
|
+
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source2.flags & 16777216 /* Conditional */ && source2.root === c.root)) {
|
|
63174
63189
|
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
|
|
63175
63190
|
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
|
|
63176
63191
|
if (result2 = skipTrue ? -1 /* True */ : isRelatedTo(
|
|
@@ -64231,7 +64246,12 @@ ${lanes.join("\n")}
|
|
|
64231
64246
|
let matched = false;
|
|
64232
64247
|
for (let i = 0; i < types.length; i++) {
|
|
64233
64248
|
if (include[i]) {
|
|
64234
|
-
const targetType =
|
|
64249
|
+
const targetType = getTypeOfPropertyOrIndexSignature(
|
|
64250
|
+
types[i],
|
|
64251
|
+
propertyName,
|
|
64252
|
+
/*addOptionalityToIndex*/
|
|
64253
|
+
true
|
|
64254
|
+
);
|
|
64235
64255
|
if (targetType && related(getDiscriminatingType(), targetType)) {
|
|
64236
64256
|
matched = true;
|
|
64237
64257
|
} else {
|
|
@@ -66162,7 +66182,7 @@ ${lanes.join("\n")}
|
|
|
66162
66182
|
const constraint = getConstraintOfTypeParameter(inference.typeParameter);
|
|
66163
66183
|
if (constraint) {
|
|
66164
66184
|
const instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
|
|
66165
|
-
if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
66185
|
+
if (!inferredType || inferredType === wildcardType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
|
66166
66186
|
inference.inferredType = fallbackType && context.compareTypes(fallbackType, getTypeWithThisArgument(instantiatedConstraint, fallbackType)) ? fallbackType : instantiatedConstraint;
|
|
66167
66187
|
}
|
|
66168
66188
|
}
|
|
@@ -67629,7 +67649,12 @@ ${lanes.join("\n")}
|
|
|
67629
67649
|
propType = removeNullable && optionalChain ? getOptionalType(propType) : propType;
|
|
67630
67650
|
const narrowedPropType = narrowType2(propType);
|
|
67631
67651
|
return filterType(type, (t) => {
|
|
67632
|
-
const discriminantType = getTypeOfPropertyOrIndexSignature(
|
|
67652
|
+
const discriminantType = getTypeOfPropertyOrIndexSignature(
|
|
67653
|
+
t,
|
|
67654
|
+
propName,
|
|
67655
|
+
/*addOptionalityToIndex*/
|
|
67656
|
+
false
|
|
67657
|
+
);
|
|
67633
67658
|
return !(discriminantType.flags & 131072 /* Never */) && !(narrowedPropType.flags & 131072 /* Never */) && areTypesComparable(narrowedPropType, discriminantType);
|
|
67634
67659
|
});
|
|
67635
67660
|
}
|
|
@@ -68256,7 +68281,7 @@ ${lanes.join("\n")}
|
|
|
68256
68281
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
68257
68282
|
}
|
|
68258
68283
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
68259
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
68284
|
+
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(
|
|
68260
68285
|
node,
|
|
68261
68286
|
/*contextFlags*/
|
|
68262
68287
|
void 0
|
|
@@ -68903,6 +68928,25 @@ ${lanes.join("\n")}
|
|
|
68903
68928
|
return t.flags & 2097152 /* Intersection */ ? forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
|
|
68904
68929
|
});
|
|
68905
68930
|
}
|
|
68931
|
+
function getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType) {
|
|
68932
|
+
let literal = containingLiteral;
|
|
68933
|
+
let type = contextualType;
|
|
68934
|
+
while (type) {
|
|
68935
|
+
const thisType = getThisTypeFromContextualType(type);
|
|
68936
|
+
if (thisType) {
|
|
68937
|
+
return thisType;
|
|
68938
|
+
}
|
|
68939
|
+
if (literal.parent.kind !== 302 /* PropertyAssignment */) {
|
|
68940
|
+
break;
|
|
68941
|
+
}
|
|
68942
|
+
literal = literal.parent.parent;
|
|
68943
|
+
type = getApparentTypeOfContextualType(
|
|
68944
|
+
literal,
|
|
68945
|
+
/*contextFlags*/
|
|
68946
|
+
void 0
|
|
68947
|
+
);
|
|
68948
|
+
}
|
|
68949
|
+
}
|
|
68906
68950
|
function getContextualThisParameterType(func) {
|
|
68907
68951
|
if (func.kind === 218 /* ArrowFunction */) {
|
|
68908
68952
|
return void 0;
|
|
@@ -68925,22 +68969,9 @@ ${lanes.join("\n")}
|
|
|
68925
68969
|
/*contextFlags*/
|
|
68926
68970
|
void 0
|
|
68927
68971
|
);
|
|
68928
|
-
|
|
68929
|
-
|
|
68930
|
-
|
|
68931
|
-
const thisType = getThisTypeFromContextualType(type);
|
|
68932
|
-
if (thisType) {
|
|
68933
|
-
return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
|
|
68934
|
-
}
|
|
68935
|
-
if (literal.parent.kind !== 302 /* PropertyAssignment */) {
|
|
68936
|
-
break;
|
|
68937
|
-
}
|
|
68938
|
-
literal = literal.parent.parent;
|
|
68939
|
-
type = getApparentTypeOfContextualType(
|
|
68940
|
-
literal,
|
|
68941
|
-
/*contextFlags*/
|
|
68942
|
-
void 0
|
|
68943
|
-
);
|
|
68972
|
+
const thisType = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
|
|
68973
|
+
if (thisType) {
|
|
68974
|
+
return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
|
|
68944
68975
|
}
|
|
68945
68976
|
return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
|
|
68946
68977
|
}
|
|
@@ -69013,7 +69044,7 @@ ${lanes.join("\n")}
|
|
|
69013
69044
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
69014
69045
|
const parent2 = declaration.parent.parent;
|
|
69015
69046
|
const name = declaration.propertyName || declaration.name;
|
|
69016
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
69047
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
69017
69048
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
69018
69049
|
return void 0;
|
|
69019
69050
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -70062,9 +70093,7 @@ ${lanes.join("\n")}
|
|
|
70062
70093
|
elementTypes.push(undefinedOrMissingType);
|
|
70063
70094
|
elementFlags.push(2 /* Optional */);
|
|
70064
70095
|
} else {
|
|
70065
|
-
const
|
|
70066
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70067
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
70096
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
70068
70097
|
elementTypes.push(addOptionality(
|
|
70069
70098
|
type,
|
|
70070
70099
|
/*isProperty*/
|
|
@@ -70072,7 +70101,7 @@ ${lanes.join("\n")}
|
|
|
70072
70101
|
hasOmittedExpression
|
|
70073
70102
|
));
|
|
70074
70103
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
70075
|
-
if (
|
|
70104
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
70076
70105
|
const inferenceContext = getInferenceContext(node);
|
|
70077
70106
|
Debug.assert(inferenceContext);
|
|
70078
70107
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -70213,13 +70242,11 @@ ${lanes.join("\n")}
|
|
|
70213
70242
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
70214
70243
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
70215
70244
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
70216
|
-
|
|
70217
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70218
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
70245
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
70219
70246
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
70220
70247
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
70221
70248
|
// we don't want to say "could not find 'a'".
|
|
70222
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
70249
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
70223
70250
|
);
|
|
70224
70251
|
if (isInJavascript) {
|
|
70225
70252
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -70263,7 +70290,7 @@ ${lanes.join("\n")}
|
|
|
70263
70290
|
prop.links.target = member;
|
|
70264
70291
|
member = prop;
|
|
70265
70292
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
70266
|
-
if (
|
|
70293
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
70267
70294
|
const inferenceContext = getInferenceContext(node);
|
|
70268
70295
|
Debug.assert(inferenceContext);
|
|
70269
70296
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -70436,9 +70463,7 @@ ${lanes.join("\n")}
|
|
|
70436
70463
|
for (const attributeDecl of attributes.properties) {
|
|
70437
70464
|
const member = attributeDecl.symbol;
|
|
70438
70465
|
if (isJsxAttribute(attributeDecl)) {
|
|
70439
|
-
const
|
|
70440
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
70441
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
70466
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
70442
70467
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
70443
70468
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
70444
70469
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -70459,7 +70484,7 @@ ${lanes.join("\n")}
|
|
|
70459
70484
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
70460
70485
|
}
|
|
70461
70486
|
}
|
|
70462
|
-
if (
|
|
70487
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
70463
70488
|
const inferenceContext = getInferenceContext(attributes);
|
|
70464
70489
|
Debug.assert(inferenceContext);
|
|
70465
70490
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -72077,7 +72102,7 @@ ${lanes.join("\n")}
|
|
|
72077
72102
|
}
|
|
72078
72103
|
for (let i = 0; i < argCount; i++) {
|
|
72079
72104
|
const arg = args[i];
|
|
72080
|
-
if (arg.kind !== 231 /* OmittedExpression */
|
|
72105
|
+
if (arg.kind !== 231 /* OmittedExpression */) {
|
|
72081
72106
|
const paramType = getTypeAtPosition(signature, i);
|
|
72082
72107
|
if (couldContainTypeVariables(paramType)) {
|
|
72083
72108
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -72690,12 +72715,11 @@ ${lanes.join("\n")}
|
|
|
72690
72715
|
const args = getEffectiveCallArguments(node);
|
|
72691
72716
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
72692
72717
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
72693
|
-
argCheckMode |= checkMode & 64 /* IsForStringLiteralArgumentCompletions */;
|
|
72694
72718
|
let candidatesForArgumentError;
|
|
72695
72719
|
let candidateForArgumentArityError;
|
|
72696
72720
|
let candidateForTypeArgumentError;
|
|
72697
72721
|
let result;
|
|
72698
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
72722
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
72699
72723
|
if (candidates.length > 1) {
|
|
72700
72724
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
72701
72725
|
}
|
|
@@ -72914,7 +72938,7 @@ ${lanes.join("\n")}
|
|
|
72914
72938
|
continue;
|
|
72915
72939
|
}
|
|
72916
72940
|
if (argCheckMode) {
|
|
72917
|
-
argCheckMode =
|
|
72941
|
+
argCheckMode = 0 /* Normal */;
|
|
72918
72942
|
if (inferenceContext) {
|
|
72919
72943
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72920
72944
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -75992,8 +76016,9 @@ ${lanes.join("\n")}
|
|
|
75992
76016
|
case 36 /* ExclamationEqualsToken */:
|
|
75993
76017
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
75994
76018
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
75995
|
-
if (!(checkMode && checkMode &
|
|
75996
|
-
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right))
|
|
76019
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
76020
|
+
if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
|
|
76021
|
+
(!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
|
|
75997
76022
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
75998
76023
|
error2(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
75999
76024
|
}
|
|
@@ -76651,7 +76676,7 @@ ${lanes.join("\n")}
|
|
|
76651
76676
|
}
|
|
76652
76677
|
}
|
|
76653
76678
|
const startInvocationCount = flowInvocationCount;
|
|
76654
|
-
const type = checkExpression(node,
|
|
76679
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
76655
76680
|
if (flowInvocationCount !== startInvocationCount) {
|
|
76656
76681
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
76657
76682
|
cache[getNodeId(node)] = type;
|
|
@@ -76766,7 +76791,7 @@ ${lanes.join("\n")}
|
|
|
76766
76791
|
return nullWideningType;
|
|
76767
76792
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
76768
76793
|
case 11 /* StringLiteral */:
|
|
76769
|
-
return hasSkipDirectInferenceFlag(node) ?
|
|
76794
|
+
return hasSkipDirectInferenceFlag(node) ? wildcardType : getFreshTypeOfLiteralType(getStringLiteralType(node.text));
|
|
76770
76795
|
case 9 /* NumericLiteral */:
|
|
76771
76796
|
checkGrammarNumericLiteral(node);
|
|
76772
76797
|
return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text));
|
|
@@ -79122,7 +79147,7 @@ ${lanes.join("\n")}
|
|
|
79122
79147
|
checkComputedPropertyName(node.propertyName);
|
|
79123
79148
|
}
|
|
79124
79149
|
const parent2 = node.parent.parent;
|
|
79125
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
79150
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
79126
79151
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
79127
79152
|
const name = node.propertyName || node.name;
|
|
79128
79153
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -82712,7 +82737,7 @@ ${lanes.join("\n")}
|
|
|
82712
82737
|
/*contextFlags*/
|
|
82713
82738
|
void 0
|
|
82714
82739
|
);
|
|
82715
|
-
const type =
|
|
82740
|
+
const type = getThisTypeOfObjectLiteralFromContextualType(containingLiteral, contextualType);
|
|
82716
82741
|
return type && !isTypeAny(type);
|
|
82717
82742
|
}
|
|
82718
82743
|
}
|
|
@@ -85858,11 +85883,10 @@ ${lanes.join("\n")}
|
|
|
85858
85883
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
85859
85884
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
85860
85885
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
85861
|
-
CheckMode3[CheckMode3["
|
|
85862
|
-
CheckMode3[CheckMode3["
|
|
85863
|
-
CheckMode3[CheckMode3["
|
|
85864
|
-
CheckMode3[CheckMode3["
|
|
85865
|
-
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
85886
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
85887
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
85888
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
85889
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
85866
85890
|
return CheckMode3;
|
|
85867
85891
|
})(CheckMode || {});
|
|
85868
85892
|
SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -120027,7 +120051,9 @@ ${lanes.join("\n")}
|
|
|
120027
120051
|
Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
120028
120052
|
Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
120029
120053
|
Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
120030
|
-
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code
|
|
120054
|
+
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
120055
|
+
// Type errors
|
|
120056
|
+
Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value.code
|
|
120031
120057
|
]);
|
|
120032
120058
|
emitSkippedWithNoDiagnostics = { diagnostics: emptyArray, sourceMaps: void 0, emittedFiles: void 0, emitSkipped: true };
|
|
120033
120059
|
}
|
|
@@ -134036,8 +134062,8 @@ ${lanes.join("\n")}
|
|
|
134036
134062
|
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);
|
|
134037
134063
|
}));
|
|
134038
134064
|
}
|
|
134039
|
-
function getEditsForRefactor(context,
|
|
134040
|
-
const refactor = refactors.get(
|
|
134065
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134066
|
+
const refactor = refactors.get(refactorName14);
|
|
134041
134067
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134042
134068
|
}
|
|
134043
134069
|
var refactors;
|
|
@@ -134843,6 +134869,155 @@ ${lanes.join("\n")}
|
|
|
134843
134869
|
}
|
|
134844
134870
|
});
|
|
134845
134871
|
|
|
134872
|
+
// src/services/refactors/inlineVariable.ts
|
|
134873
|
+
function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
|
|
134874
|
+
var _a, _b;
|
|
134875
|
+
const checker = program.getTypeChecker();
|
|
134876
|
+
const token = getTouchingPropertyName(file, startPosition);
|
|
134877
|
+
const parent2 = token.parent;
|
|
134878
|
+
if (!isIdentifier(token)) {
|
|
134879
|
+
return void 0;
|
|
134880
|
+
}
|
|
134881
|
+
if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2)) {
|
|
134882
|
+
if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
|
|
134883
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
|
|
134884
|
+
}
|
|
134885
|
+
if (isDeclarationExported(parent2)) {
|
|
134886
|
+
return void 0;
|
|
134887
|
+
}
|
|
134888
|
+
const references = getReferenceNodes(parent2, checker, file);
|
|
134889
|
+
return references && { references, declaration: parent2, replacement: parent2.initializer };
|
|
134890
|
+
}
|
|
134891
|
+
if (tryWithReferenceToken) {
|
|
134892
|
+
let definition = checker.resolveName(
|
|
134893
|
+
token.text,
|
|
134894
|
+
token,
|
|
134895
|
+
111551 /* Value */,
|
|
134896
|
+
/*excludeGlobals*/
|
|
134897
|
+
false
|
|
134898
|
+
);
|
|
134899
|
+
definition = definition && checker.getMergedSymbol(definition);
|
|
134900
|
+
if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
|
|
134901
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
|
|
134902
|
+
}
|
|
134903
|
+
const declaration = definition.declarations[0];
|
|
134904
|
+
if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
|
|
134905
|
+
return void 0;
|
|
134906
|
+
}
|
|
134907
|
+
if (isDeclarationExported(declaration)) {
|
|
134908
|
+
return void 0;
|
|
134909
|
+
}
|
|
134910
|
+
const references = getReferenceNodes(declaration, checker, file);
|
|
134911
|
+
return references && { references, declaration, replacement: declaration.initializer };
|
|
134912
|
+
}
|
|
134913
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
|
|
134914
|
+
}
|
|
134915
|
+
function isDeclarationExported(declaration) {
|
|
134916
|
+
const variableStatement = cast(declaration.parent.parent, isVariableStatement);
|
|
134917
|
+
return some(variableStatement.modifiers, isExportModifier);
|
|
134918
|
+
}
|
|
134919
|
+
function getReferenceNodes(declaration, checker, file) {
|
|
134920
|
+
const references = [];
|
|
134921
|
+
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
134922
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
134923
|
+
return true;
|
|
134924
|
+
}
|
|
134925
|
+
if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
|
|
134926
|
+
return true;
|
|
134927
|
+
}
|
|
134928
|
+
if (isTypeQueryNode(ref.parent)) {
|
|
134929
|
+
return true;
|
|
134930
|
+
}
|
|
134931
|
+
if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
|
|
134932
|
+
return true;
|
|
134933
|
+
}
|
|
134934
|
+
references.push(ref);
|
|
134935
|
+
});
|
|
134936
|
+
return references.length === 0 || cannotInline ? void 0 : references;
|
|
134937
|
+
}
|
|
134938
|
+
function getReplacementExpression(reference, replacement) {
|
|
134939
|
+
replacement = getSynthesizedDeepClone(replacement);
|
|
134940
|
+
const { parent: parent2 } = reference;
|
|
134941
|
+
if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
|
|
134942
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134943
|
+
}
|
|
134944
|
+
if (isFunctionLike(replacement) && isCallLikeExpression(parent2)) {
|
|
134945
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134946
|
+
}
|
|
134947
|
+
return replacement;
|
|
134948
|
+
}
|
|
134949
|
+
var refactorName4, refactorDescription, inlineVariableAction;
|
|
134950
|
+
var init_inlineVariable = __esm({
|
|
134951
|
+
"src/services/refactors/inlineVariable.ts"() {
|
|
134952
|
+
"use strict";
|
|
134953
|
+
init_ts4();
|
|
134954
|
+
init_ts_refactor();
|
|
134955
|
+
refactorName4 = "Inline variable";
|
|
134956
|
+
refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
|
|
134957
|
+
inlineVariableAction = {
|
|
134958
|
+
name: refactorName4,
|
|
134959
|
+
description: refactorDescription,
|
|
134960
|
+
kind: "refactor.inline.variable"
|
|
134961
|
+
};
|
|
134962
|
+
registerRefactor(refactorName4, {
|
|
134963
|
+
kinds: [inlineVariableAction.kind],
|
|
134964
|
+
getAvailableActions(context) {
|
|
134965
|
+
const {
|
|
134966
|
+
file,
|
|
134967
|
+
program,
|
|
134968
|
+
preferences,
|
|
134969
|
+
startPosition,
|
|
134970
|
+
triggerReason
|
|
134971
|
+
} = context;
|
|
134972
|
+
const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
|
|
134973
|
+
if (!info) {
|
|
134974
|
+
return emptyArray;
|
|
134975
|
+
}
|
|
134976
|
+
if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134977
|
+
return [{
|
|
134978
|
+
name: refactorName4,
|
|
134979
|
+
description: refactorDescription,
|
|
134980
|
+
actions: [inlineVariableAction]
|
|
134981
|
+
}];
|
|
134982
|
+
}
|
|
134983
|
+
if (preferences.provideRefactorNotApplicableReason) {
|
|
134984
|
+
return [{
|
|
134985
|
+
name: refactorName4,
|
|
134986
|
+
description: refactorDescription,
|
|
134987
|
+
actions: [{
|
|
134988
|
+
...inlineVariableAction,
|
|
134989
|
+
notApplicableReason: info.error
|
|
134990
|
+
}]
|
|
134991
|
+
}];
|
|
134992
|
+
}
|
|
134993
|
+
return emptyArray;
|
|
134994
|
+
},
|
|
134995
|
+
getEditsForAction(context, actionName2) {
|
|
134996
|
+
Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
|
|
134997
|
+
const { file, program, startPosition } = context;
|
|
134998
|
+
const info = getInliningInfo(
|
|
134999
|
+
file,
|
|
135000
|
+
startPosition,
|
|
135001
|
+
/*tryWithReferenceToken*/
|
|
135002
|
+
true,
|
|
135003
|
+
program
|
|
135004
|
+
);
|
|
135005
|
+
if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
135006
|
+
return void 0;
|
|
135007
|
+
}
|
|
135008
|
+
const { references, declaration, replacement } = info;
|
|
135009
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
135010
|
+
for (const node of references) {
|
|
135011
|
+
tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
|
|
135012
|
+
}
|
|
135013
|
+
tracker.delete(file, declaration);
|
|
135014
|
+
});
|
|
135015
|
+
return { edits };
|
|
135016
|
+
}
|
|
135017
|
+
});
|
|
135018
|
+
}
|
|
135019
|
+
});
|
|
135020
|
+
|
|
134846
135021
|
// src/services/refactors/moveToNewFile.ts
|
|
134847
135022
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134848
135023
|
const checker = program.getTypeChecker();
|
|
@@ -134924,29 +135099,29 @@ ${lanes.join("\n")}
|
|
|
134924
135099
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
134925
135100
|
return copiedOldImports;
|
|
134926
135101
|
}
|
|
134927
|
-
var
|
|
135102
|
+
var refactorName5, description, moveToNewFileAction;
|
|
134928
135103
|
var init_moveToNewFile = __esm({
|
|
134929
135104
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
134930
135105
|
"use strict";
|
|
134931
135106
|
init_ts4();
|
|
134932
135107
|
init_ts_refactor();
|
|
134933
|
-
|
|
135108
|
+
refactorName5 = "Move to a new file";
|
|
134934
135109
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
134935
135110
|
moveToNewFileAction = {
|
|
134936
|
-
name:
|
|
135111
|
+
name: refactorName5,
|
|
134937
135112
|
description,
|
|
134938
135113
|
kind: "refactor.move.newFile"
|
|
134939
135114
|
};
|
|
134940
|
-
registerRefactor(
|
|
135115
|
+
registerRefactor(refactorName5, {
|
|
134941
135116
|
kinds: [moveToNewFileAction.kind],
|
|
134942
135117
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
134943
135118
|
const statements = getStatementsToMove(context);
|
|
134944
135119
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
134945
|
-
return [{ name:
|
|
135120
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
134946
135121
|
}
|
|
134947
135122
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
134948
135123
|
return [{
|
|
134949
|
-
name:
|
|
135124
|
+
name: refactorName5,
|
|
134950
135125
|
description,
|
|
134951
135126
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
134952
135127
|
}];
|
|
@@ -134954,7 +135129,7 @@ ${lanes.join("\n")}
|
|
|
134954
135129
|
return emptyArray;
|
|
134955
135130
|
},
|
|
134956
135131
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
134957
|
-
Debug.assert(actionName2 ===
|
|
135132
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
134958
135133
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
134959
135134
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
134960
135135
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135872,8 +136047,8 @@ ${lanes.join("\n")}
|
|
|
135872
136047
|
if (!info)
|
|
135873
136048
|
return emptyArray;
|
|
135874
136049
|
return [{
|
|
135875
|
-
name:
|
|
135876
|
-
description:
|
|
136050
|
+
name: refactorName6,
|
|
136051
|
+
description: refactorDescription2,
|
|
135877
136052
|
actions: [functionOverloadAction]
|
|
135878
136053
|
}];
|
|
135879
136054
|
}
|
|
@@ -136064,20 +136239,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136064
136239
|
}
|
|
136065
136240
|
return signatureDecls;
|
|
136066
136241
|
}
|
|
136067
|
-
var
|
|
136242
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136068
136243
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136069
136244
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136070
136245
|
"use strict";
|
|
136071
136246
|
init_ts4();
|
|
136072
136247
|
init_ts_refactor();
|
|
136073
|
-
|
|
136074
|
-
|
|
136248
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136249
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136075
136250
|
functionOverloadAction = {
|
|
136076
|
-
name:
|
|
136077
|
-
description:
|
|
136251
|
+
name: refactorName6,
|
|
136252
|
+
description: refactorDescription2,
|
|
136078
136253
|
kind: "refactor.rewrite.function.overloadList"
|
|
136079
136254
|
};
|
|
136080
|
-
registerRefactor(
|
|
136255
|
+
registerRefactor(refactorName6, {
|
|
136081
136256
|
kinds: [functionOverloadAction.kind],
|
|
136082
136257
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136083
136258
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136093,8 +136268,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136093
136268
|
return emptyArray;
|
|
136094
136269
|
if (!isRefactorErrorInfo(info)) {
|
|
136095
136270
|
return [{
|
|
136096
|
-
name:
|
|
136097
|
-
description:
|
|
136271
|
+
name: refactorName7,
|
|
136272
|
+
description: refactorDescription3,
|
|
136098
136273
|
actions: [
|
|
136099
136274
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136100
136275
|
]
|
|
@@ -136102,8 +136277,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136102
136277
|
}
|
|
136103
136278
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136104
136279
|
return [{
|
|
136105
|
-
name:
|
|
136106
|
-
description:
|
|
136280
|
+
name: refactorName7,
|
|
136281
|
+
description: refactorDescription3,
|
|
136107
136282
|
actions: [
|
|
136108
136283
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136109
136284
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136194,14 +136369,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136194
136369
|
}
|
|
136195
136370
|
return void 0;
|
|
136196
136371
|
}
|
|
136197
|
-
var
|
|
136372
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136198
136373
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136199
136374
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136200
136375
|
"use strict";
|
|
136201
136376
|
init_ts4();
|
|
136202
136377
|
init_ts_refactor();
|
|
136203
|
-
|
|
136204
|
-
|
|
136378
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136379
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136205
136380
|
addBracesAction = {
|
|
136206
136381
|
name: "Add braces to arrow function",
|
|
136207
136382
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136212,7 +136387,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136212
136387
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136213
136388
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136214
136389
|
};
|
|
136215
|
-
registerRefactor(
|
|
136390
|
+
registerRefactor(refactorName7, {
|
|
136216
136391
|
kinds: [removeBracesAction.kind],
|
|
136217
136392
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136218
136393
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136264,8 +136439,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136264
136439
|
}
|
|
136265
136440
|
}
|
|
136266
136441
|
return [{
|
|
136267
|
-
name:
|
|
136268
|
-
description:
|
|
136442
|
+
name: refactorName8,
|
|
136443
|
+
description: refactorDescription4,
|
|
136269
136444
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136270
136445
|
}];
|
|
136271
136446
|
}
|
|
@@ -136425,14 +136600,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136425
136600
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136426
136601
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136427
136602
|
}
|
|
136428
|
-
var
|
|
136603
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136429
136604
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136430
136605
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136431
136606
|
"use strict";
|
|
136432
136607
|
init_ts4();
|
|
136433
136608
|
init_ts_refactor();
|
|
136434
|
-
|
|
136435
|
-
|
|
136609
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136610
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136436
136611
|
toAnonymousFunctionAction = {
|
|
136437
136612
|
name: "Convert to anonymous function",
|
|
136438
136613
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136448,7 +136623,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136448
136623
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136449
136624
|
kind: "refactor.rewrite.function.arrow"
|
|
136450
136625
|
};
|
|
136451
|
-
registerRefactor(
|
|
136626
|
+
registerRefactor(refactorName8, {
|
|
136452
136627
|
kinds: [
|
|
136453
136628
|
toAnonymousFunctionAction.kind,
|
|
136454
136629
|
toNamedFunctionAction.kind,
|
|
@@ -136479,13 +136654,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136479
136654
|
if (!functionDeclaration)
|
|
136480
136655
|
return emptyArray;
|
|
136481
136656
|
return [{
|
|
136482
|
-
name:
|
|
136483
|
-
description:
|
|
136657
|
+
name: refactorName9,
|
|
136658
|
+
description: refactorDescription5,
|
|
136484
136659
|
actions: [toDestructuredAction]
|
|
136485
136660
|
}];
|
|
136486
136661
|
}
|
|
136487
136662
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136488
|
-
Debug.assert(actionName2 ===
|
|
136663
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136489
136664
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136490
136665
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136491
136666
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -136995,21 +137170,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136995
137170
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
136996
137171
|
}
|
|
136997
137172
|
}
|
|
136998
|
-
var
|
|
137173
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
136999
137174
|
var init_convertParamsToDestructuredObject = __esm({
|
|
137000
137175
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
137001
137176
|
"use strict";
|
|
137002
137177
|
init_ts4();
|
|
137003
137178
|
init_ts_refactor();
|
|
137004
|
-
|
|
137179
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
137005
137180
|
minimumParameterLength = 1;
|
|
137006
|
-
|
|
137181
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
137007
137182
|
toDestructuredAction = {
|
|
137008
|
-
name:
|
|
137009
|
-
description:
|
|
137183
|
+
name: refactorName9,
|
|
137184
|
+
description: refactorDescription5,
|
|
137010
137185
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
137011
137186
|
};
|
|
137012
|
-
registerRefactor(
|
|
137187
|
+
registerRefactor(refactorName9, {
|
|
137013
137188
|
kinds: [toDestructuredAction.kind],
|
|
137014
137189
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
137015
137190
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137031,7 +137206,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137031
137206
|
const { file, startPosition } = context;
|
|
137032
137207
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137033
137208
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137034
|
-
const refactorInfo = { name:
|
|
137209
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137035
137210
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137036
137211
|
refactorInfo.actions.push(convertStringAction);
|
|
137037
137212
|
return [refactorInfo];
|
|
@@ -137057,7 +137232,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137057
137232
|
const { file, startPosition } = context;
|
|
137058
137233
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137059
137234
|
switch (actionName2) {
|
|
137060
|
-
case
|
|
137235
|
+
case refactorDescription6:
|
|
137061
137236
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137062
137237
|
default:
|
|
137063
137238
|
return Debug.fail("invalid action");
|
|
@@ -137208,20 +137383,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137208
137383
|
}
|
|
137209
137384
|
return node;
|
|
137210
137385
|
}
|
|
137211
|
-
var
|
|
137386
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137212
137387
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137213
137388
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137214
137389
|
"use strict";
|
|
137215
137390
|
init_ts4();
|
|
137216
137391
|
init_ts_refactor();
|
|
137217
|
-
|
|
137218
|
-
|
|
137392
|
+
refactorName10 = "Convert to template string";
|
|
137393
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137219
137394
|
convertStringAction = {
|
|
137220
|
-
name:
|
|
137221
|
-
description:
|
|
137395
|
+
name: refactorName10,
|
|
137396
|
+
description: refactorDescription6,
|
|
137222
137397
|
kind: "refactor.rewrite.string"
|
|
137223
137398
|
};
|
|
137224
|
-
registerRefactor(
|
|
137399
|
+
registerRefactor(refactorName10, {
|
|
137225
137400
|
kinds: [convertStringAction.kind],
|
|
137226
137401
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137227
137402
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137271,14 +137446,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137271
137446
|
return emptyArray;
|
|
137272
137447
|
if (!isRefactorErrorInfo(info)) {
|
|
137273
137448
|
return [{
|
|
137274
|
-
name:
|
|
137449
|
+
name: refactorName11,
|
|
137275
137450
|
description: convertToOptionalChainExpressionMessage,
|
|
137276
137451
|
actions: [toOptionalChainAction]
|
|
137277
137452
|
}];
|
|
137278
137453
|
}
|
|
137279
137454
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137280
137455
|
return [{
|
|
137281
|
-
name:
|
|
137456
|
+
name: refactorName11,
|
|
137282
137457
|
description: convertToOptionalChainExpressionMessage,
|
|
137283
137458
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137284
137459
|
}];
|
|
@@ -137462,20 +137637,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137462
137637
|
}
|
|
137463
137638
|
}
|
|
137464
137639
|
}
|
|
137465
|
-
var
|
|
137640
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137466
137641
|
var init_convertToOptionalChainExpression = __esm({
|
|
137467
137642
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137468
137643
|
"use strict";
|
|
137469
137644
|
init_ts4();
|
|
137470
137645
|
init_ts_refactor();
|
|
137471
|
-
|
|
137646
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137472
137647
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137473
137648
|
toOptionalChainAction = {
|
|
137474
|
-
name:
|
|
137649
|
+
name: refactorName11,
|
|
137475
137650
|
description: convertToOptionalChainExpressionMessage,
|
|
137476
137651
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137477
137652
|
};
|
|
137478
|
-
registerRefactor(
|
|
137653
|
+
registerRefactor(refactorName11, {
|
|
137479
137654
|
kinds: [toOptionalChainAction.kind],
|
|
137480
137655
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137481
137656
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137504,14 +137679,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137504
137679
|
const errors = [];
|
|
137505
137680
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137506
137681
|
errors.push({
|
|
137507
|
-
name:
|
|
137682
|
+
name: refactorName12,
|
|
137508
137683
|
description: extractFunctionAction.description,
|
|
137509
137684
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137510
137685
|
});
|
|
137511
137686
|
}
|
|
137512
137687
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137513
137688
|
errors.push({
|
|
137514
|
-
name:
|
|
137689
|
+
name: refactorName12,
|
|
137515
137690
|
description: extractConstantAction.description,
|
|
137516
137691
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137517
137692
|
});
|
|
@@ -137575,26 +137750,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137575
137750
|
const infos = [];
|
|
137576
137751
|
if (functionActions.length) {
|
|
137577
137752
|
infos.push({
|
|
137578
|
-
name:
|
|
137753
|
+
name: refactorName12,
|
|
137579
137754
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137580
137755
|
actions: functionActions
|
|
137581
137756
|
});
|
|
137582
137757
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137583
137758
|
infos.push({
|
|
137584
|
-
name:
|
|
137759
|
+
name: refactorName12,
|
|
137585
137760
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137586
137761
|
actions: [innermostErrorFunctionAction]
|
|
137587
137762
|
});
|
|
137588
137763
|
}
|
|
137589
137764
|
if (constantActions.length) {
|
|
137590
137765
|
infos.push({
|
|
137591
|
-
name:
|
|
137766
|
+
name: refactorName12,
|
|
137592
137767
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137593
137768
|
actions: constantActions
|
|
137594
137769
|
});
|
|
137595
137770
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137596
137771
|
infos.push({
|
|
137597
|
-
name:
|
|
137772
|
+
name: refactorName12,
|
|
137598
137773
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137599
137774
|
actions: [innermostErrorConstantAction]
|
|
137600
137775
|
});
|
|
@@ -139025,13 +139200,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139025
139200
|
function isStringLiteralJsxAttribute(node) {
|
|
139026
139201
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139027
139202
|
}
|
|
139028
|
-
var
|
|
139203
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139029
139204
|
var init_extractSymbol = __esm({
|
|
139030
139205
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139031
139206
|
"use strict";
|
|
139032
139207
|
init_ts4();
|
|
139033
139208
|
init_ts_refactor();
|
|
139034
|
-
|
|
139209
|
+
refactorName12 = "Extract Symbol";
|
|
139035
139210
|
extractConstantAction = {
|
|
139036
139211
|
name: "Extract Constant",
|
|
139037
139212
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139042,7 +139217,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139042
139217
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139043
139218
|
kind: "refactor.extract.function"
|
|
139044
139219
|
};
|
|
139045
|
-
registerRefactor(
|
|
139220
|
+
registerRefactor(refactorName12, {
|
|
139046
139221
|
kinds: [
|
|
139047
139222
|
extractConstantAction.kind,
|
|
139048
139223
|
extractFunctionAction.kind
|
|
@@ -139193,15 +139368,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139193
139368
|
return emptyArray;
|
|
139194
139369
|
if (!isRefactorErrorInfo(info)) {
|
|
139195
139370
|
return [{
|
|
139196
|
-
name:
|
|
139197
|
-
description:
|
|
139371
|
+
name: refactorName13,
|
|
139372
|
+
description: refactorDescription7,
|
|
139198
139373
|
actions: [inferReturnTypeAction]
|
|
139199
139374
|
}];
|
|
139200
139375
|
}
|
|
139201
139376
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139202
139377
|
return [{
|
|
139203
|
-
name:
|
|
139204
|
-
description:
|
|
139378
|
+
name: refactorName13,
|
|
139379
|
+
description: refactorDescription7,
|
|
139205
139380
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139206
139381
|
}];
|
|
139207
139382
|
}
|
|
@@ -139260,20 +139435,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139260
139435
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139261
139436
|
}
|
|
139262
139437
|
}
|
|
139263
|
-
var
|
|
139438
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139264
139439
|
var init_inferFunctionReturnType = __esm({
|
|
139265
139440
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139266
139441
|
"use strict";
|
|
139267
139442
|
init_ts4();
|
|
139268
139443
|
init_ts_refactor();
|
|
139269
|
-
|
|
139270
|
-
|
|
139444
|
+
refactorName13 = "Infer function return type";
|
|
139445
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139271
139446
|
inferReturnTypeAction = {
|
|
139272
|
-
name:
|
|
139273
|
-
description:
|
|
139447
|
+
name: refactorName13,
|
|
139448
|
+
description: refactorDescription7,
|
|
139274
139449
|
kind: "refactor.rewrite.function.returnType"
|
|
139275
139450
|
};
|
|
139276
|
-
registerRefactor(
|
|
139451
|
+
registerRefactor(refactorName13, {
|
|
139277
139452
|
kinds: [inferReturnTypeAction.kind],
|
|
139278
139453
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139279
139454
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139334,6 +139509,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139334
139509
|
init_convertImport();
|
|
139335
139510
|
init_extractType();
|
|
139336
139511
|
init_helpers();
|
|
139512
|
+
init_inlineVariable();
|
|
139337
139513
|
init_moveToNewFile();
|
|
139338
139514
|
init_moveToFile();
|
|
139339
139515
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140872,10 +141048,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140872
141048
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140873
141049
|
return { newFileName, files };
|
|
140874
141050
|
}
|
|
140875
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
141051
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140876
141052
|
synchronizeHostData();
|
|
140877
141053
|
const file = getValidSourceFile(fileName);
|
|
140878
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
141054
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140879
141055
|
}
|
|
140880
141056
|
function toLineColumnOffset(fileName, position) {
|
|
140881
141057
|
if (position === 0) {
|
|
@@ -158249,7 +158425,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158249
158425
|
case 290 /* JsxAttribute */:
|
|
158250
158426
|
if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
|
|
158251
158427
|
const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 290 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
|
|
158252
|
-
return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
|
|
158428
|
+
return argumentInfo && (getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker, 0 /* Normal */)) || fromContextualType(0 /* None */);
|
|
158253
158429
|
}
|
|
158254
158430
|
case 271 /* ImportDeclaration */:
|
|
158255
158431
|
case 277 /* ExportDeclaration */:
|
|
@@ -158318,12 +158494,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158318
158494
|
function getAlreadyUsedTypesInStringLiteralUnion(union, current) {
|
|
158319
158495
|
return mapDefined(union.types, (type) => type !== current && isLiteralTypeNode(type) && isStringLiteral(type.literal) ? type.literal.text : void 0);
|
|
158320
158496
|
}
|
|
158321
|
-
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
158497
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker, checkMode = 32 /* IsForStringLiteralArgumentCompletions */) {
|
|
158322
158498
|
let isNewIdentifier = false;
|
|
158323
158499
|
const uniques = /* @__PURE__ */ new Map();
|
|
158324
158500
|
const candidates = [];
|
|
158325
158501
|
const editingArgument = isJsxOpeningLikeElement(call) ? Debug.checkDefined(findAncestor(arg.parent, isJsxAttribute)) : arg;
|
|
158326
|
-
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
158502
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates, checkMode);
|
|
158327
158503
|
const types = flatMap(candidates, (candidate) => {
|
|
158328
158504
|
if (!signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
158329
158505
|
return;
|
|
@@ -161442,6 +161618,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161442
161618
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161443
161619
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161444
161620
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161621
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161445
161622
|
nodeEntry: () => nodeEntry,
|
|
161446
161623
|
toContextSpan: () => toContextSpan,
|
|
161447
161624
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -169648,9 +169825,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169648
169825
|
init_ts5();
|
|
169649
169826
|
init_deprecate();
|
|
169650
169827
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169651
|
-
const
|
|
169652
|
-
if (!hasProperty(
|
|
169653
|
-
Object.defineProperty(
|
|
169828
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169829
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169830
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169654
169831
|
get: deprecate(function() {
|
|
169655
169832
|
return identifierToKeywordKind(this);
|
|
169656
169833
|
}, {
|
|
@@ -169662,8 +169839,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169662
169839
|
})
|
|
169663
169840
|
});
|
|
169664
169841
|
}
|
|
169665
|
-
if (!hasProperty(
|
|
169666
|
-
Object.defineProperty(
|
|
169842
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169843
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169667
169844
|
get: deprecate(function() {
|
|
169668
169845
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169669
169846
|
}, {
|