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/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-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
|
}
|
|
@@ -134051,8 +134077,8 @@ ${lanes.join("\n")}
|
|
|
134051
134077
|
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);
|
|
134052
134078
|
}));
|
|
134053
134079
|
}
|
|
134054
|
-
function getEditsForRefactor(context,
|
|
134055
|
-
const refactor = refactors.get(
|
|
134080
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
134081
|
+
const refactor = refactors.get(refactorName14);
|
|
134056
134082
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
134057
134083
|
}
|
|
134058
134084
|
var refactors;
|
|
@@ -134858,6 +134884,155 @@ ${lanes.join("\n")}
|
|
|
134858
134884
|
}
|
|
134859
134885
|
});
|
|
134860
134886
|
|
|
134887
|
+
// src/services/refactors/inlineVariable.ts
|
|
134888
|
+
function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
|
|
134889
|
+
var _a, _b;
|
|
134890
|
+
const checker = program.getTypeChecker();
|
|
134891
|
+
const token = getTouchingPropertyName(file, startPosition);
|
|
134892
|
+
const parent2 = token.parent;
|
|
134893
|
+
if (!isIdentifier(token)) {
|
|
134894
|
+
return void 0;
|
|
134895
|
+
}
|
|
134896
|
+
if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2)) {
|
|
134897
|
+
if (((_a = checker.getMergedSymbol(parent2.symbol).declarations) == null ? void 0 : _a.length) !== 1) {
|
|
134898
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
|
|
134899
|
+
}
|
|
134900
|
+
if (isDeclarationExported(parent2)) {
|
|
134901
|
+
return void 0;
|
|
134902
|
+
}
|
|
134903
|
+
const references = getReferenceNodes(parent2, checker, file);
|
|
134904
|
+
return references && { references, declaration: parent2, replacement: parent2.initializer };
|
|
134905
|
+
}
|
|
134906
|
+
if (tryWithReferenceToken) {
|
|
134907
|
+
let definition = checker.resolveName(
|
|
134908
|
+
token.text,
|
|
134909
|
+
token,
|
|
134910
|
+
111551 /* Value */,
|
|
134911
|
+
/*excludeGlobals*/
|
|
134912
|
+
false
|
|
134913
|
+
);
|
|
134914
|
+
definition = definition && checker.getMergedSymbol(definition);
|
|
134915
|
+
if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
|
|
134916
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_with_multiple_declarations_cannot_be_inlined) };
|
|
134917
|
+
}
|
|
134918
|
+
const declaration = definition.declarations[0];
|
|
134919
|
+
if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
|
|
134920
|
+
return void 0;
|
|
134921
|
+
}
|
|
134922
|
+
if (isDeclarationExported(declaration)) {
|
|
134923
|
+
return void 0;
|
|
134924
|
+
}
|
|
134925
|
+
const references = getReferenceNodes(declaration, checker, file);
|
|
134926
|
+
return references && { references, declaration, replacement: declaration.initializer };
|
|
134927
|
+
}
|
|
134928
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
|
|
134929
|
+
}
|
|
134930
|
+
function isDeclarationExported(declaration) {
|
|
134931
|
+
const variableStatement = cast(declaration.parent.parent, isVariableStatement);
|
|
134932
|
+
return some(variableStatement.modifiers, isExportModifier);
|
|
134933
|
+
}
|
|
134934
|
+
function getReferenceNodes(declaration, checker, file) {
|
|
134935
|
+
const references = [];
|
|
134936
|
+
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
134937
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
134938
|
+
return true;
|
|
134939
|
+
}
|
|
134940
|
+
if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
|
|
134941
|
+
return true;
|
|
134942
|
+
}
|
|
134943
|
+
if (isTypeQueryNode(ref.parent)) {
|
|
134944
|
+
return true;
|
|
134945
|
+
}
|
|
134946
|
+
if (textRangeContainsPositionInclusive(declaration, ref.pos)) {
|
|
134947
|
+
return true;
|
|
134948
|
+
}
|
|
134949
|
+
references.push(ref);
|
|
134950
|
+
});
|
|
134951
|
+
return references.length === 0 || cannotInline ? void 0 : references;
|
|
134952
|
+
}
|
|
134953
|
+
function getReplacementExpression(reference, replacement) {
|
|
134954
|
+
replacement = getSynthesizedDeepClone(replacement);
|
|
134955
|
+
const { parent: parent2 } = reference;
|
|
134956
|
+
if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
|
|
134957
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134958
|
+
}
|
|
134959
|
+
if (isFunctionLike(replacement) && isCallLikeExpression(parent2)) {
|
|
134960
|
+
return factory.createParenthesizedExpression(replacement);
|
|
134961
|
+
}
|
|
134962
|
+
return replacement;
|
|
134963
|
+
}
|
|
134964
|
+
var refactorName4, refactorDescription, inlineVariableAction;
|
|
134965
|
+
var init_inlineVariable = __esm({
|
|
134966
|
+
"src/services/refactors/inlineVariable.ts"() {
|
|
134967
|
+
"use strict";
|
|
134968
|
+
init_ts4();
|
|
134969
|
+
init_ts_refactor();
|
|
134970
|
+
refactorName4 = "Inline variable";
|
|
134971
|
+
refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
|
|
134972
|
+
inlineVariableAction = {
|
|
134973
|
+
name: refactorName4,
|
|
134974
|
+
description: refactorDescription,
|
|
134975
|
+
kind: "refactor.inline.variable"
|
|
134976
|
+
};
|
|
134977
|
+
registerRefactor(refactorName4, {
|
|
134978
|
+
kinds: [inlineVariableAction.kind],
|
|
134979
|
+
getAvailableActions(context) {
|
|
134980
|
+
const {
|
|
134981
|
+
file,
|
|
134982
|
+
program,
|
|
134983
|
+
preferences,
|
|
134984
|
+
startPosition,
|
|
134985
|
+
triggerReason
|
|
134986
|
+
} = context;
|
|
134987
|
+
const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
|
|
134988
|
+
if (!info) {
|
|
134989
|
+
return emptyArray;
|
|
134990
|
+
}
|
|
134991
|
+
if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
134992
|
+
return [{
|
|
134993
|
+
name: refactorName4,
|
|
134994
|
+
description: refactorDescription,
|
|
134995
|
+
actions: [inlineVariableAction]
|
|
134996
|
+
}];
|
|
134997
|
+
}
|
|
134998
|
+
if (preferences.provideRefactorNotApplicableReason) {
|
|
134999
|
+
return [{
|
|
135000
|
+
name: refactorName4,
|
|
135001
|
+
description: refactorDescription,
|
|
135002
|
+
actions: [{
|
|
135003
|
+
...inlineVariableAction,
|
|
135004
|
+
notApplicableReason: info.error
|
|
135005
|
+
}]
|
|
135006
|
+
}];
|
|
135007
|
+
}
|
|
135008
|
+
return emptyArray;
|
|
135009
|
+
},
|
|
135010
|
+
getEditsForAction(context, actionName2) {
|
|
135011
|
+
Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
|
|
135012
|
+
const { file, program, startPosition } = context;
|
|
135013
|
+
const info = getInliningInfo(
|
|
135014
|
+
file,
|
|
135015
|
+
startPosition,
|
|
135016
|
+
/*tryWithReferenceToken*/
|
|
135017
|
+
true,
|
|
135018
|
+
program
|
|
135019
|
+
);
|
|
135020
|
+
if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
135021
|
+
return void 0;
|
|
135022
|
+
}
|
|
135023
|
+
const { references, declaration, replacement } = info;
|
|
135024
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
135025
|
+
for (const node of references) {
|
|
135026
|
+
tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
|
|
135027
|
+
}
|
|
135028
|
+
tracker.delete(file, declaration);
|
|
135029
|
+
});
|
|
135030
|
+
return { edits };
|
|
135031
|
+
}
|
|
135032
|
+
});
|
|
135033
|
+
}
|
|
135034
|
+
});
|
|
135035
|
+
|
|
134861
135036
|
// src/services/refactors/moveToNewFile.ts
|
|
134862
135037
|
function doChange3(oldFile, program, toMove, changes, host, preferences, context) {
|
|
134863
135038
|
const checker = program.getTypeChecker();
|
|
@@ -134939,29 +135114,29 @@ ${lanes.join("\n")}
|
|
|
134939
135114
|
append(copiedOldImports, makeImportOrRequire(oldFile, oldFileDefault, oldFileNamedImports, getBaseFileName(oldFile.fileName), program, host, useEsModuleSyntax, quotePreference));
|
|
134940
135115
|
return copiedOldImports;
|
|
134941
135116
|
}
|
|
134942
|
-
var
|
|
135117
|
+
var refactorName5, description, moveToNewFileAction;
|
|
134943
135118
|
var init_moveToNewFile = __esm({
|
|
134944
135119
|
"src/services/refactors/moveToNewFile.ts"() {
|
|
134945
135120
|
"use strict";
|
|
134946
135121
|
init_ts4();
|
|
134947
135122
|
init_ts_refactor();
|
|
134948
|
-
|
|
135123
|
+
refactorName5 = "Move to a new file";
|
|
134949
135124
|
description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
134950
135125
|
moveToNewFileAction = {
|
|
134951
|
-
name:
|
|
135126
|
+
name: refactorName5,
|
|
134952
135127
|
description,
|
|
134953
135128
|
kind: "refactor.move.newFile"
|
|
134954
135129
|
};
|
|
134955
|
-
registerRefactor(
|
|
135130
|
+
registerRefactor(refactorName5, {
|
|
134956
135131
|
kinds: [moveToNewFileAction.kind],
|
|
134957
135132
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
134958
135133
|
const statements = getStatementsToMove(context);
|
|
134959
135134
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
134960
|
-
return [{ name:
|
|
135135
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
134961
135136
|
}
|
|
134962
135137
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
134963
135138
|
return [{
|
|
134964
|
-
name:
|
|
135139
|
+
name: refactorName5,
|
|
134965
135140
|
description,
|
|
134966
135141
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
134967
135142
|
}];
|
|
@@ -134969,7 +135144,7 @@ ${lanes.join("\n")}
|
|
|
134969
135144
|
return emptyArray;
|
|
134970
135145
|
},
|
|
134971
135146
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
134972
|
-
Debug.assert(actionName2 ===
|
|
135147
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
134973
135148
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
134974
135149
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
134975
135150
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -135887,8 +136062,8 @@ ${lanes.join("\n")}
|
|
|
135887
136062
|
if (!info)
|
|
135888
136063
|
return emptyArray;
|
|
135889
136064
|
return [{
|
|
135890
|
-
name:
|
|
135891
|
-
description:
|
|
136065
|
+
name: refactorName6,
|
|
136066
|
+
description: refactorDescription2,
|
|
135892
136067
|
actions: [functionOverloadAction]
|
|
135893
136068
|
}];
|
|
135894
136069
|
}
|
|
@@ -136079,20 +136254,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136079
136254
|
}
|
|
136080
136255
|
return signatureDecls;
|
|
136081
136256
|
}
|
|
136082
|
-
var
|
|
136257
|
+
var refactorName6, refactorDescription2, functionOverloadAction;
|
|
136083
136258
|
var init_convertOverloadListToSingleSignature = __esm({
|
|
136084
136259
|
"src/services/refactors/convertOverloadListToSingleSignature.ts"() {
|
|
136085
136260
|
"use strict";
|
|
136086
136261
|
init_ts4();
|
|
136087
136262
|
init_ts_refactor();
|
|
136088
|
-
|
|
136089
|
-
|
|
136263
|
+
refactorName6 = "Convert overload list to single signature";
|
|
136264
|
+
refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
136090
136265
|
functionOverloadAction = {
|
|
136091
|
-
name:
|
|
136092
|
-
description:
|
|
136266
|
+
name: refactorName6,
|
|
136267
|
+
description: refactorDescription2,
|
|
136093
136268
|
kind: "refactor.rewrite.function.overloadList"
|
|
136094
136269
|
};
|
|
136095
|
-
registerRefactor(
|
|
136270
|
+
registerRefactor(refactorName6, {
|
|
136096
136271
|
kinds: [functionOverloadAction.kind],
|
|
136097
136272
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
136098
136273
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -136108,8 +136283,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136108
136283
|
return emptyArray;
|
|
136109
136284
|
if (!isRefactorErrorInfo(info)) {
|
|
136110
136285
|
return [{
|
|
136111
|
-
name:
|
|
136112
|
-
description:
|
|
136286
|
+
name: refactorName7,
|
|
136287
|
+
description: refactorDescription3,
|
|
136113
136288
|
actions: [
|
|
136114
136289
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
136115
136290
|
]
|
|
@@ -136117,8 +136292,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136117
136292
|
}
|
|
136118
136293
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136119
136294
|
return [{
|
|
136120
|
-
name:
|
|
136121
|
-
description:
|
|
136295
|
+
name: refactorName7,
|
|
136296
|
+
description: refactorDescription3,
|
|
136122
136297
|
actions: [
|
|
136123
136298
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
136124
136299
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -136209,14 +136384,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136209
136384
|
}
|
|
136210
136385
|
return void 0;
|
|
136211
136386
|
}
|
|
136212
|
-
var
|
|
136387
|
+
var refactorName7, refactorDescription3, addBracesAction, removeBracesAction;
|
|
136213
136388
|
var init_addOrRemoveBracesToArrowFunction = __esm({
|
|
136214
136389
|
"src/services/refactors/addOrRemoveBracesToArrowFunction.ts"() {
|
|
136215
136390
|
"use strict";
|
|
136216
136391
|
init_ts4();
|
|
136217
136392
|
init_ts_refactor();
|
|
136218
|
-
|
|
136219
|
-
|
|
136393
|
+
refactorName7 = "Add or remove braces in an arrow function";
|
|
136394
|
+
refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
136220
136395
|
addBracesAction = {
|
|
136221
136396
|
name: "Add braces to arrow function",
|
|
136222
136397
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -136227,7 +136402,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136227
136402
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
136228
136403
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
136229
136404
|
};
|
|
136230
|
-
registerRefactor(
|
|
136405
|
+
registerRefactor(refactorName7, {
|
|
136231
136406
|
kinds: [removeBracesAction.kind],
|
|
136232
136407
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
136233
136408
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -136279,8 +136454,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136279
136454
|
}
|
|
136280
136455
|
}
|
|
136281
136456
|
return [{
|
|
136282
|
-
name:
|
|
136283
|
-
description:
|
|
136457
|
+
name: refactorName8,
|
|
136458
|
+
description: refactorDescription4,
|
|
136284
136459
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
136285
136460
|
}];
|
|
136286
136461
|
}
|
|
@@ -136440,14 +136615,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136440
136615
|
function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
136441
136616
|
return !!node.name && ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(node.name, typeChecker, sourceFile);
|
|
136442
136617
|
}
|
|
136443
|
-
var
|
|
136618
|
+
var refactorName8, refactorDescription4, toAnonymousFunctionAction, toNamedFunctionAction, toArrowFunctionAction;
|
|
136444
136619
|
var init_convertArrowFunctionOrFunctionExpression = __esm({
|
|
136445
136620
|
"src/services/refactors/convertArrowFunctionOrFunctionExpression.ts"() {
|
|
136446
136621
|
"use strict";
|
|
136447
136622
|
init_ts4();
|
|
136448
136623
|
init_ts_refactor();
|
|
136449
|
-
|
|
136450
|
-
|
|
136624
|
+
refactorName8 = "Convert arrow function or function expression";
|
|
136625
|
+
refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
136451
136626
|
toAnonymousFunctionAction = {
|
|
136452
136627
|
name: "Convert to anonymous function",
|
|
136453
136628
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -136463,7 +136638,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136463
136638
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
136464
136639
|
kind: "refactor.rewrite.function.arrow"
|
|
136465
136640
|
};
|
|
136466
|
-
registerRefactor(
|
|
136641
|
+
registerRefactor(refactorName8, {
|
|
136467
136642
|
kinds: [
|
|
136468
136643
|
toAnonymousFunctionAction.kind,
|
|
136469
136644
|
toNamedFunctionAction.kind,
|
|
@@ -136494,13 +136669,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
136494
136669
|
if (!functionDeclaration)
|
|
136495
136670
|
return emptyArray;
|
|
136496
136671
|
return [{
|
|
136497
|
-
name:
|
|
136498
|
-
description:
|
|
136672
|
+
name: refactorName9,
|
|
136673
|
+
description: refactorDescription5,
|
|
136499
136674
|
actions: [toDestructuredAction]
|
|
136500
136675
|
}];
|
|
136501
136676
|
}
|
|
136502
136677
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
136503
|
-
Debug.assert(actionName2 ===
|
|
136678
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
136504
136679
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
136505
136680
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
136506
136681
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -137010,21 +137185,21 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137010
137185
|
return Debug.assertNever(functionDeclaration, `Unexpected function declaration kind ${functionDeclaration.kind}`);
|
|
137011
137186
|
}
|
|
137012
137187
|
}
|
|
137013
|
-
var
|
|
137188
|
+
var refactorName9, minimumParameterLength, refactorDescription5, toDestructuredAction;
|
|
137014
137189
|
var init_convertParamsToDestructuredObject = __esm({
|
|
137015
137190
|
"src/services/refactors/convertParamsToDestructuredObject.ts"() {
|
|
137016
137191
|
"use strict";
|
|
137017
137192
|
init_ts4();
|
|
137018
137193
|
init_ts_refactor();
|
|
137019
|
-
|
|
137194
|
+
refactorName9 = "Convert parameters to destructured object";
|
|
137020
137195
|
minimumParameterLength = 1;
|
|
137021
|
-
|
|
137196
|
+
refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
137022
137197
|
toDestructuredAction = {
|
|
137023
|
-
name:
|
|
137024
|
-
description:
|
|
137198
|
+
name: refactorName9,
|
|
137199
|
+
description: refactorDescription5,
|
|
137025
137200
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
137026
137201
|
};
|
|
137027
|
-
registerRefactor(
|
|
137202
|
+
registerRefactor(refactorName9, {
|
|
137028
137203
|
kinds: [toDestructuredAction.kind],
|
|
137029
137204
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
137030
137205
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -137046,7 +137221,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137046
137221
|
const { file, startPosition } = context;
|
|
137047
137222
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137048
137223
|
const maybeBinary = getParentBinaryExpression(node);
|
|
137049
|
-
const refactorInfo = { name:
|
|
137224
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
137050
137225
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
137051
137226
|
refactorInfo.actions.push(convertStringAction);
|
|
137052
137227
|
return [refactorInfo];
|
|
@@ -137072,7 +137247,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137072
137247
|
const { file, startPosition } = context;
|
|
137073
137248
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
137074
137249
|
switch (actionName2) {
|
|
137075
|
-
case
|
|
137250
|
+
case refactorDescription6:
|
|
137076
137251
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
137077
137252
|
default:
|
|
137078
137253
|
return Debug.fail("invalid action");
|
|
@@ -137223,20 +137398,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137223
137398
|
}
|
|
137224
137399
|
return node;
|
|
137225
137400
|
}
|
|
137226
|
-
var
|
|
137401
|
+
var refactorName10, refactorDescription6, convertStringAction, copyTrailingOperatorComments, copyCommentFromMultiNode;
|
|
137227
137402
|
var init_convertStringOrTemplateLiteral = __esm({
|
|
137228
137403
|
"src/services/refactors/convertStringOrTemplateLiteral.ts"() {
|
|
137229
137404
|
"use strict";
|
|
137230
137405
|
init_ts4();
|
|
137231
137406
|
init_ts_refactor();
|
|
137232
|
-
|
|
137233
|
-
|
|
137407
|
+
refactorName10 = "Convert to template string";
|
|
137408
|
+
refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
137234
137409
|
convertStringAction = {
|
|
137235
|
-
name:
|
|
137236
|
-
description:
|
|
137410
|
+
name: refactorName10,
|
|
137411
|
+
description: refactorDescription6,
|
|
137237
137412
|
kind: "refactor.rewrite.string"
|
|
137238
137413
|
};
|
|
137239
|
-
registerRefactor(
|
|
137414
|
+
registerRefactor(refactorName10, {
|
|
137240
137415
|
kinds: [convertStringAction.kind],
|
|
137241
137416
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
137242
137417
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -137286,14 +137461,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137286
137461
|
return emptyArray;
|
|
137287
137462
|
if (!isRefactorErrorInfo(info)) {
|
|
137288
137463
|
return [{
|
|
137289
|
-
name:
|
|
137464
|
+
name: refactorName11,
|
|
137290
137465
|
description: convertToOptionalChainExpressionMessage,
|
|
137291
137466
|
actions: [toOptionalChainAction]
|
|
137292
137467
|
}];
|
|
137293
137468
|
}
|
|
137294
137469
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137295
137470
|
return [{
|
|
137296
|
-
name:
|
|
137471
|
+
name: refactorName11,
|
|
137297
137472
|
description: convertToOptionalChainExpressionMessage,
|
|
137298
137473
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
137299
137474
|
}];
|
|
@@ -137477,20 +137652,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137477
137652
|
}
|
|
137478
137653
|
}
|
|
137479
137654
|
}
|
|
137480
|
-
var
|
|
137655
|
+
var refactorName11, convertToOptionalChainExpressionMessage, toOptionalChainAction;
|
|
137481
137656
|
var init_convertToOptionalChainExpression = __esm({
|
|
137482
137657
|
"src/services/refactors/convertToOptionalChainExpression.ts"() {
|
|
137483
137658
|
"use strict";
|
|
137484
137659
|
init_ts4();
|
|
137485
137660
|
init_ts_refactor();
|
|
137486
|
-
|
|
137661
|
+
refactorName11 = "Convert to optional chain expression";
|
|
137487
137662
|
convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
137488
137663
|
toOptionalChainAction = {
|
|
137489
|
-
name:
|
|
137664
|
+
name: refactorName11,
|
|
137490
137665
|
description: convertToOptionalChainExpressionMessage,
|
|
137491
137666
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
137492
137667
|
};
|
|
137493
|
-
registerRefactor(
|
|
137668
|
+
registerRefactor(refactorName11, {
|
|
137494
137669
|
kinds: [toOptionalChainAction.kind],
|
|
137495
137670
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
137496
137671
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -137519,14 +137694,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137519
137694
|
const errors = [];
|
|
137520
137695
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
137521
137696
|
errors.push({
|
|
137522
|
-
name:
|
|
137697
|
+
name: refactorName12,
|
|
137523
137698
|
description: extractFunctionAction.description,
|
|
137524
137699
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137525
137700
|
});
|
|
137526
137701
|
}
|
|
137527
137702
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
137528
137703
|
errors.push({
|
|
137529
|
-
name:
|
|
137704
|
+
name: refactorName12,
|
|
137530
137705
|
description: extractConstantAction.description,
|
|
137531
137706
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
137532
137707
|
});
|
|
@@ -137590,26 +137765,26 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
137590
137765
|
const infos = [];
|
|
137591
137766
|
if (functionActions.length) {
|
|
137592
137767
|
infos.push({
|
|
137593
|
-
name:
|
|
137768
|
+
name: refactorName12,
|
|
137594
137769
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137595
137770
|
actions: functionActions
|
|
137596
137771
|
});
|
|
137597
137772
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
137598
137773
|
infos.push({
|
|
137599
|
-
name:
|
|
137774
|
+
name: refactorName12,
|
|
137600
137775
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
137601
137776
|
actions: [innermostErrorFunctionAction]
|
|
137602
137777
|
});
|
|
137603
137778
|
}
|
|
137604
137779
|
if (constantActions.length) {
|
|
137605
137780
|
infos.push({
|
|
137606
|
-
name:
|
|
137781
|
+
name: refactorName12,
|
|
137607
137782
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137608
137783
|
actions: constantActions
|
|
137609
137784
|
});
|
|
137610
137785
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
137611
137786
|
infos.push({
|
|
137612
|
-
name:
|
|
137787
|
+
name: refactorName12,
|
|
137613
137788
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
137614
137789
|
actions: [innermostErrorConstantAction]
|
|
137615
137790
|
});
|
|
@@ -139040,13 +139215,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139040
139215
|
function isStringLiteralJsxAttribute(node) {
|
|
139041
139216
|
return isStringLiteral(node) && node.parent && isJsxAttribute(node.parent);
|
|
139042
139217
|
}
|
|
139043
|
-
var
|
|
139218
|
+
var refactorName12, extractConstantAction, extractFunctionAction, Messages, RangeFacts;
|
|
139044
139219
|
var init_extractSymbol = __esm({
|
|
139045
139220
|
"src/services/refactors/extractSymbol.ts"() {
|
|
139046
139221
|
"use strict";
|
|
139047
139222
|
init_ts4();
|
|
139048
139223
|
init_ts_refactor();
|
|
139049
|
-
|
|
139224
|
+
refactorName12 = "Extract Symbol";
|
|
139050
139225
|
extractConstantAction = {
|
|
139051
139226
|
name: "Extract Constant",
|
|
139052
139227
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139057,7 +139232,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139057
139232
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139058
139233
|
kind: "refactor.extract.function"
|
|
139059
139234
|
};
|
|
139060
|
-
registerRefactor(
|
|
139235
|
+
registerRefactor(refactorName12, {
|
|
139061
139236
|
kinds: [
|
|
139062
139237
|
extractConstantAction.kind,
|
|
139063
139238
|
extractFunctionAction.kind
|
|
@@ -139208,15 +139383,15 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139208
139383
|
return emptyArray;
|
|
139209
139384
|
if (!isRefactorErrorInfo(info)) {
|
|
139210
139385
|
return [{
|
|
139211
|
-
name:
|
|
139212
|
-
description:
|
|
139386
|
+
name: refactorName13,
|
|
139387
|
+
description: refactorDescription7,
|
|
139213
139388
|
actions: [inferReturnTypeAction]
|
|
139214
139389
|
}];
|
|
139215
139390
|
}
|
|
139216
139391
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
139217
139392
|
return [{
|
|
139218
|
-
name:
|
|
139219
|
-
description:
|
|
139393
|
+
name: refactorName13,
|
|
139394
|
+
description: refactorDescription7,
|
|
139220
139395
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
139221
139396
|
}];
|
|
139222
139397
|
}
|
|
@@ -139275,20 +139450,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139275
139450
|
return typeChecker.getReturnTypeOfSignature(signature);
|
|
139276
139451
|
}
|
|
139277
139452
|
}
|
|
139278
|
-
var
|
|
139453
|
+
var refactorName13, refactorDescription7, inferReturnTypeAction;
|
|
139279
139454
|
var init_inferFunctionReturnType = __esm({
|
|
139280
139455
|
"src/services/refactors/inferFunctionReturnType.ts"() {
|
|
139281
139456
|
"use strict";
|
|
139282
139457
|
init_ts4();
|
|
139283
139458
|
init_ts_refactor();
|
|
139284
|
-
|
|
139285
|
-
|
|
139459
|
+
refactorName13 = "Infer function return type";
|
|
139460
|
+
refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
139286
139461
|
inferReturnTypeAction = {
|
|
139287
|
-
name:
|
|
139288
|
-
description:
|
|
139462
|
+
name: refactorName13,
|
|
139463
|
+
description: refactorDescription7,
|
|
139289
139464
|
kind: "refactor.rewrite.function.returnType"
|
|
139290
139465
|
};
|
|
139291
|
-
registerRefactor(
|
|
139466
|
+
registerRefactor(refactorName13, {
|
|
139292
139467
|
kinds: [inferReturnTypeAction.kind],
|
|
139293
139468
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
139294
139469
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -139349,6 +139524,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
139349
139524
|
init_convertImport();
|
|
139350
139525
|
init_extractType();
|
|
139351
139526
|
init_helpers();
|
|
139527
|
+
init_inlineVariable();
|
|
139352
139528
|
init_moveToNewFile();
|
|
139353
139529
|
init_moveToFile();
|
|
139354
139530
|
init_ts_refactor_addOrRemoveBracesToArrowFunction();
|
|
@@ -140887,10 +141063,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
140887
141063
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
140888
141064
|
return { newFileName, files };
|
|
140889
141065
|
}
|
|
140890
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
141066
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
140891
141067
|
synchronizeHostData();
|
|
140892
141068
|
const file = getValidSourceFile(fileName);
|
|
140893
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
141069
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
140894
141070
|
}
|
|
140895
141071
|
function toLineColumnOffset(fileName, position) {
|
|
140896
141072
|
if (position === 0) {
|
|
@@ -158264,7 +158440,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158264
158440
|
case 290 /* JsxAttribute */:
|
|
158265
158441
|
if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
|
|
158266
158442
|
const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 290 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
|
|
158267
|
-
return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType();
|
|
158443
|
+
return argumentInfo && (getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker, 0 /* Normal */)) || fromContextualType(0 /* None */);
|
|
158268
158444
|
}
|
|
158269
158445
|
case 271 /* ImportDeclaration */:
|
|
158270
158446
|
case 277 /* ExportDeclaration */:
|
|
@@ -158333,12 +158509,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158333
158509
|
function getAlreadyUsedTypesInStringLiteralUnion(union, current) {
|
|
158334
158510
|
return mapDefined(union.types, (type) => type !== current && isLiteralTypeNode(type) && isStringLiteral(type.literal) ? type.literal.text : void 0);
|
|
158335
158511
|
}
|
|
158336
|
-
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
158512
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker, checkMode = 32 /* IsForStringLiteralArgumentCompletions */) {
|
|
158337
158513
|
let isNewIdentifier = false;
|
|
158338
158514
|
const uniques = /* @__PURE__ */ new Map();
|
|
158339
158515
|
const candidates = [];
|
|
158340
158516
|
const editingArgument = isJsxOpeningLikeElement(call) ? Debug.checkDefined(findAncestor(arg.parent, isJsxAttribute)) : arg;
|
|
158341
|
-
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
158517
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates, checkMode);
|
|
158342
158518
|
const types = flatMap(candidates, (candidate) => {
|
|
158343
158519
|
if (!signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
158344
158520
|
return;
|
|
@@ -161457,6 +161633,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161457
161633
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
161458
161634
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
161459
161635
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
161636
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
161460
161637
|
nodeEntry: () => nodeEntry,
|
|
161461
161638
|
toContextSpan: () => toContextSpan,
|
|
161462
161639
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -169663,9 +169840,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169663
169840
|
init_ts5();
|
|
169664
169841
|
init_deprecate();
|
|
169665
169842
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
169666
|
-
const
|
|
169667
|
-
if (!hasProperty(
|
|
169668
|
-
Object.defineProperty(
|
|
169843
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
169844
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
169845
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
169669
169846
|
get: deprecate(function() {
|
|
169670
169847
|
return identifierToKeywordKind(this);
|
|
169671
169848
|
}, {
|
|
@@ -169677,8 +169854,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169677
169854
|
})
|
|
169678
169855
|
});
|
|
169679
169856
|
}
|
|
169680
|
-
if (!hasProperty(
|
|
169681
|
-
Object.defineProperty(
|
|
169857
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
169858
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
169682
169859
|
get: deprecate(function() {
|
|
169683
169860
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
169684
169861
|
}, {
|