typescript 5.5.0-dev.20240313 → 5.5.0-dev.20240314
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 +74 -4
- package/lib/tsserver.js +178 -85
- package/lib/typescript.js +178 -85
- package/lib/typingsInstaller.js +5 -1
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -1760,6 +1760,7 @@ __export(server_exports, {
|
|
|
1760
1760
|
isSuperProperty: () => isSuperProperty,
|
|
1761
1761
|
isSupportedSourceFileName: () => isSupportedSourceFileName,
|
|
1762
1762
|
isSwitchStatement: () => isSwitchStatement,
|
|
1763
|
+
isSyntacticallyString: () => isSyntacticallyString,
|
|
1763
1764
|
isSyntaxList: () => isSyntaxList,
|
|
1764
1765
|
isSyntheticExpression: () => isSyntheticExpression,
|
|
1765
1766
|
isSyntheticReference: () => isSyntheticReference,
|
|
@@ -2326,7 +2327,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2326
2327
|
|
|
2327
2328
|
// src/compiler/corePublic.ts
|
|
2328
2329
|
var versionMajorMinor = "5.5";
|
|
2329
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2330
|
+
var version = `${versionMajorMinor}.0-dev.20240314`;
|
|
2330
2331
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2331
2332
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2332
2333
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9675,6 +9676,8 @@ var Diagnostics = {
|
|
|
9675
9676
|
The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration: diag(1494, 1 /* Error */, "The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration_1494", "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration."),
|
|
9676
9677
|
_0_modifier_cannot_appear_on_an_await_using_declaration: diag(1495, 1 /* Error */, "_0_modifier_cannot_appear_on_an_await_using_declaration_1495", "'{0}' modifier cannot appear on an 'await using' declaration."),
|
|
9677
9678
|
Identifier_string_literal_or_number_literal_expected: diag(1496, 1 /* Error */, "Identifier_string_literal_or_number_literal_expected_1496", "Identifier, string literal, or number literal expected."),
|
|
9679
|
+
Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator: diag(1497, 1 /* Error */, "Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator_1497", "Expression must be enclosed in parentheses to be used as a decorator."),
|
|
9680
|
+
Invalid_syntax_in_decorator: diag(1498, 1 /* Error */, "Invalid_syntax_in_decorator_1498", "Invalid syntax in decorator."),
|
|
9678
9681
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
9679
9682
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
9680
9683
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -11326,6 +11329,8 @@ var Diagnostics = {
|
|
|
11326
11329
|
Add_optional_parameter_to_0: diag(95191, 3 /* Message */, "Add_optional_parameter_to_0_95191", "Add optional parameter to '{0}'"),
|
|
11327
11330
|
Add_optional_parameters_to_0: diag(95192, 3 /* Message */, "Add_optional_parameters_to_0_95192", "Add optional parameters to '{0}'"),
|
|
11328
11331
|
Add_all_optional_parameters: diag(95193, 3 /* Message */, "Add_all_optional_parameters_95193", "Add all optional parameters"),
|
|
11332
|
+
Wrap_in_parentheses: diag(95194, 3 /* Message */, "Wrap_in_parentheses_95194", "Wrap in parentheses"),
|
|
11333
|
+
Wrap_all_invalid_decorator_expressions_in_parentheses: diag(95195, 3 /* Message */, "Wrap_all_invalid_decorator_expressions_in_parentheses_95195", "Wrap all invalid decorator expressions in parentheses"),
|
|
11329
11334
|
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."),
|
|
11330
11335
|
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'."),
|
|
11331
11336
|
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?"),
|
|
@@ -21910,6 +21915,20 @@ function replaceFirstStar(s, replacement) {
|
|
|
21910
21915
|
function getNameFromImportAttribute(node) {
|
|
21911
21916
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
21912
21917
|
}
|
|
21918
|
+
function isSyntacticallyString(expr) {
|
|
21919
|
+
expr = skipOuterExpressions(expr);
|
|
21920
|
+
switch (expr.kind) {
|
|
21921
|
+
case 226 /* BinaryExpression */:
|
|
21922
|
+
const left = expr.left;
|
|
21923
|
+
const right = expr.right;
|
|
21924
|
+
return expr.operatorToken.kind === 40 /* PlusToken */ && (isSyntacticallyString(left) || isSyntacticallyString(right));
|
|
21925
|
+
case 228 /* TemplateExpression */:
|
|
21926
|
+
case 11 /* StringLiteral */:
|
|
21927
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
21928
|
+
return true;
|
|
21929
|
+
}
|
|
21930
|
+
return false;
|
|
21931
|
+
}
|
|
21913
21932
|
|
|
21914
21933
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21915
21934
|
function createBaseNodeFactory() {
|
|
@@ -62343,7 +62362,7 @@ function createTypeChecker(host) {
|
|
|
62343
62362
|
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
62344
62363
|
const typeVariable = typeSet[typeVarIndex];
|
|
62345
62364
|
const primitiveType = typeSet[1 - typeVarIndex];
|
|
62346
|
-
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62365
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
62347
62366
|
const constraint = getBaseConstraintOfType(typeVariable);
|
|
62348
62367
|
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
62349
62368
|
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
@@ -62948,6 +62967,9 @@ function createTypeChecker(host) {
|
|
|
62948
62967
|
function isPatternLiteralType(type) {
|
|
62949
62968
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
62950
62969
|
}
|
|
62970
|
+
function isGenericStringLikeType(type) {
|
|
62971
|
+
return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
|
|
62972
|
+
}
|
|
62951
62973
|
function isGenericType(type) {
|
|
62952
62974
|
return !!getGenericObjectFlags(type);
|
|
62953
62975
|
}
|
|
@@ -62970,7 +62992,7 @@ function createTypeChecker(host) {
|
|
|
62970
62992
|
}
|
|
62971
62993
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
62972
62994
|
}
|
|
62973
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */
|
|
62995
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
62974
62996
|
}
|
|
62975
62997
|
function getSimplifiedType(type, writing) {
|
|
62976
62998
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -82097,7 +82119,56 @@ function createTypeChecker(host) {
|
|
|
82097
82119
|
}
|
|
82098
82120
|
}
|
|
82099
82121
|
}
|
|
82122
|
+
function checkGrammarDecorator(decorator) {
|
|
82123
|
+
const sourceFile = getSourceFileOfNode(decorator);
|
|
82124
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
82125
|
+
let node = decorator.expression;
|
|
82126
|
+
if (isParenthesizedExpression(node)) {
|
|
82127
|
+
return false;
|
|
82128
|
+
}
|
|
82129
|
+
let canHaveCallExpression = true;
|
|
82130
|
+
let errorNode;
|
|
82131
|
+
while (true) {
|
|
82132
|
+
if (isExpressionWithTypeArguments(node) || isNonNullExpression(node)) {
|
|
82133
|
+
node = node.expression;
|
|
82134
|
+
continue;
|
|
82135
|
+
}
|
|
82136
|
+
if (isCallExpression(node)) {
|
|
82137
|
+
if (!canHaveCallExpression) {
|
|
82138
|
+
errorNode = node;
|
|
82139
|
+
}
|
|
82140
|
+
if (node.questionDotToken) {
|
|
82141
|
+
errorNode = node.questionDotToken;
|
|
82142
|
+
}
|
|
82143
|
+
node = node.expression;
|
|
82144
|
+
canHaveCallExpression = false;
|
|
82145
|
+
continue;
|
|
82146
|
+
}
|
|
82147
|
+
if (isPropertyAccessExpression(node)) {
|
|
82148
|
+
if (node.questionDotToken) {
|
|
82149
|
+
errorNode = node.questionDotToken;
|
|
82150
|
+
}
|
|
82151
|
+
node = node.expression;
|
|
82152
|
+
canHaveCallExpression = false;
|
|
82153
|
+
continue;
|
|
82154
|
+
}
|
|
82155
|
+
if (!isIdentifier(node)) {
|
|
82156
|
+
errorNode = node;
|
|
82157
|
+
}
|
|
82158
|
+
break;
|
|
82159
|
+
}
|
|
82160
|
+
if (errorNode) {
|
|
82161
|
+
addRelatedInfo(
|
|
82162
|
+
error2(decorator.expression, Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator),
|
|
82163
|
+
createDiagnosticForNode(errorNode, Diagnostics.Invalid_syntax_in_decorator)
|
|
82164
|
+
);
|
|
82165
|
+
return true;
|
|
82166
|
+
}
|
|
82167
|
+
}
|
|
82168
|
+
return false;
|
|
82169
|
+
}
|
|
82100
82170
|
function checkDecorator(node) {
|
|
82171
|
+
checkGrammarDecorator(node);
|
|
82101
82172
|
const signature = getResolvedSignature(node);
|
|
82102
82173
|
checkDeprecatedSignature(signature, node);
|
|
82103
82174
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -94273,7 +94344,7 @@ function transformTypeScript(context) {
|
|
|
94273
94344
|
),
|
|
94274
94345
|
valueExpression
|
|
94275
94346
|
);
|
|
94276
|
-
const outerAssignment = valueExpression
|
|
94347
|
+
const outerAssignment = isSyntacticallyString(valueExpression) ? innerAssignment : factory2.createAssignment(
|
|
94277
94348
|
factory2.createElementAccessExpression(
|
|
94278
94349
|
currentNamespaceContainerName,
|
|
94279
94350
|
innerAssignment
|
|
@@ -145634,22 +145705,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
145634
145705
|
}
|
|
145635
145706
|
return [];
|
|
145636
145707
|
}
|
|
145637
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
145708
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes66, formatOptions, preferences = emptyOptions) {
|
|
145638
145709
|
synchronizeHostData();
|
|
145639
145710
|
const sourceFile = getValidSourceFile(fileName);
|
|
145640
145711
|
const span = createTextSpanFromBounds(start2, end);
|
|
145641
145712
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145642
|
-
return flatMap(deduplicate(
|
|
145713
|
+
return flatMap(deduplicate(errorCodes66, equateValues, compareValues), (errorCode) => {
|
|
145643
145714
|
cancellationToken.throwIfCancellationRequested();
|
|
145644
145715
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
145645
145716
|
});
|
|
145646
145717
|
}
|
|
145647
|
-
function getCombinedCodeFix(scope,
|
|
145718
|
+
function getCombinedCodeFix(scope, fixId53, formatOptions, preferences = emptyOptions) {
|
|
145648
145719
|
synchronizeHostData();
|
|
145649
145720
|
Debug.assert(scope.type === "file");
|
|
145650
145721
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
145651
145722
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145652
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
145723
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId53, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
145653
145724
|
}
|
|
145654
145725
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
145655
145726
|
synchronizeHostData();
|
|
@@ -147328,14 +147399,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
|
|
|
147328
147399
|
void 0
|
|
147329
147400
|
);
|
|
147330
147401
|
}
|
|
147331
|
-
function createCodeFixAction(fixName8, changes, description3,
|
|
147332
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
147402
|
+
function createCodeFixAction(fixName8, changes, description3, fixId53, fixAllDescription, command) {
|
|
147403
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, diagnosticToString(fixAllDescription), command);
|
|
147333
147404
|
}
|
|
147334
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description3,
|
|
147335
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
147405
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId53, fixAllDescription, command) {
|
|
147406
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
147336
147407
|
}
|
|
147337
|
-
function createCodeFixActionWorker(fixName8, description3, changes,
|
|
147338
|
-
return { fixName: fixName8, description: description3, changes, fixId:
|
|
147408
|
+
function createCodeFixActionWorker(fixName8, description3, changes, fixId53, fixAllDescription, command) {
|
|
147409
|
+
return { fixName: fixName8, description: description3, changes, fixId: fixId53, fixAllDescription, commands: command ? [command] : void 0 };
|
|
147339
147410
|
}
|
|
147340
147411
|
function registerCodeFix(reg) {
|
|
147341
147412
|
for (const error2 of reg.errorCodes) {
|
|
@@ -147343,9 +147414,9 @@ function registerCodeFix(reg) {
|
|
|
147343
147414
|
errorCodeToFixes.add(String(error2), reg);
|
|
147344
147415
|
}
|
|
147345
147416
|
if (reg.fixIds) {
|
|
147346
|
-
for (const
|
|
147347
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
147348
|
-
fixIdToRegistration.set(
|
|
147417
|
+
for (const fixId53 of reg.fixIds) {
|
|
147418
|
+
Debug.assert(!fixIdToRegistration.has(fixId53));
|
|
147419
|
+
fixIdToRegistration.set(fixId53, reg);
|
|
147349
147420
|
}
|
|
147350
147421
|
}
|
|
147351
147422
|
}
|
|
@@ -147354,17 +147425,17 @@ function getSupportedErrorCodes() {
|
|
|
147354
147425
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
147355
147426
|
}
|
|
147356
147427
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
147357
|
-
const { errorCodes:
|
|
147428
|
+
const { errorCodes: errorCodes66 } = registration;
|
|
147358
147429
|
let maybeFixableDiagnostics = 0;
|
|
147359
147430
|
for (const diag2 of diagnostics) {
|
|
147360
|
-
if (contains(
|
|
147431
|
+
if (contains(errorCodes66, diag2.code))
|
|
147361
147432
|
maybeFixableDiagnostics++;
|
|
147362
147433
|
if (maybeFixableDiagnostics > 1)
|
|
147363
147434
|
break;
|
|
147364
147435
|
}
|
|
147365
147436
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
147366
|
-
return ({ fixId:
|
|
147367
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
147437
|
+
return ({ fixId: fixId53, fixAllDescription, ...action }) => {
|
|
147438
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId53, fixAllDescription };
|
|
147368
147439
|
};
|
|
147369
147440
|
}
|
|
147370
147441
|
function getFixes(context) {
|
|
@@ -147381,14 +147452,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
147381
147452
|
function createFileTextChanges(fileName, textChanges2) {
|
|
147382
147453
|
return { fileName, textChanges: textChanges2 };
|
|
147383
147454
|
}
|
|
147384
|
-
function codeFixAll(context,
|
|
147455
|
+
function codeFixAll(context, errorCodes66, use) {
|
|
147385
147456
|
const commands = [];
|
|
147386
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
147457
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes66, (diag2) => use(t, diag2, commands)));
|
|
147387
147458
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
147388
147459
|
}
|
|
147389
|
-
function eachDiagnostic(context,
|
|
147460
|
+
function eachDiagnostic(context, errorCodes66, cb) {
|
|
147390
147461
|
for (const diag2 of getDiagnostics(context)) {
|
|
147391
|
-
if (contains(
|
|
147462
|
+
if (contains(errorCodes66, diag2.code)) {
|
|
147392
147463
|
cb(diag2);
|
|
147393
147464
|
}
|
|
147394
147465
|
}
|
|
@@ -151799,10 +151870,10 @@ registerCodeFix({
|
|
|
151799
151870
|
const info = errorCodeFixIdMap[errorCode];
|
|
151800
151871
|
if (!info)
|
|
151801
151872
|
return emptyArray;
|
|
151802
|
-
const { descriptions, fixId:
|
|
151873
|
+
const { descriptions, fixId: fixId53, fixAllDescriptions } = info;
|
|
151803
151874
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
151804
151875
|
return [
|
|
151805
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
151876
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId53, fixAllDescriptions)
|
|
151806
151877
|
];
|
|
151807
151878
|
},
|
|
151808
151879
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
@@ -152607,7 +152678,7 @@ registerCodeFix({
|
|
|
152607
152678
|
},
|
|
152608
152679
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
152609
152680
|
getAllCodeActions: (context) => {
|
|
152610
|
-
const { program, fixId:
|
|
152681
|
+
const { program, fixId: fixId53 } = context;
|
|
152611
152682
|
const checker = program.getTypeChecker();
|
|
152612
152683
|
const seen = /* @__PURE__ */ new Map();
|
|
152613
152684
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
@@ -152617,11 +152688,11 @@ registerCodeFix({
|
|
|
152617
152688
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
|
|
152618
152689
|
return;
|
|
152619
152690
|
}
|
|
152620
|
-
if (
|
|
152691
|
+
if (fixId53 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
152621
152692
|
addFunctionDeclaration(changes, context, info);
|
|
152622
|
-
} else if (
|
|
152693
|
+
} else if (fixId53 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
152623
152694
|
addObjectLiteralProperties(changes, context, info);
|
|
152624
|
-
} else if (
|
|
152695
|
+
} else if (fixId53 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
152625
152696
|
addJsxAttributes(changes, context, info);
|
|
152626
152697
|
} else {
|
|
152627
152698
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -154520,21 +154591,21 @@ registerCodeFix({
|
|
|
154520
154591
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
154521
154592
|
}
|
|
154522
154593
|
return actions2;
|
|
154523
|
-
function fix(type2,
|
|
154594
|
+
function fix(type2, fixId53, fixAllDescription) {
|
|
154524
154595
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
154525
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
154596
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId53, fixAllDescription);
|
|
154526
154597
|
}
|
|
154527
154598
|
},
|
|
154528
154599
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
154529
154600
|
getAllCodeActions(context) {
|
|
154530
|
-
const { fixId:
|
|
154601
|
+
const { fixId: fixId53, program, sourceFile } = context;
|
|
154531
154602
|
const checker = program.getTypeChecker();
|
|
154532
154603
|
return codeFixAll(context, errorCodes45, (changes, err) => {
|
|
154533
154604
|
const info = getInfo15(err.file, err.start, checker);
|
|
154534
154605
|
if (!info)
|
|
154535
154606
|
return;
|
|
154536
154607
|
const { typeNode, type } = info;
|
|
154537
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ &&
|
|
154608
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId53 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
154538
154609
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
154539
154610
|
});
|
|
154540
154611
|
}
|
|
@@ -157242,11 +157313,31 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
157242
157313
|
}
|
|
157243
157314
|
}
|
|
157244
157315
|
|
|
157245
|
-
// src/services/codefixes/
|
|
157246
|
-
var fixId45 = "
|
|
157247
|
-
var errorCodes58 = [Diagnostics.
|
|
157316
|
+
// src/services/codefixes/wrapDecoratorInParentheses.ts
|
|
157317
|
+
var fixId45 = "wrapDecoratorInParentheses";
|
|
157318
|
+
var errorCodes58 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
|
|
157248
157319
|
registerCodeFix({
|
|
157249
157320
|
errorCodes: errorCodes58,
|
|
157321
|
+
getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
|
|
157322
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span.start));
|
|
157323
|
+
return [createCodeFixAction(fixId45, changes, Diagnostics.Wrap_in_parentheses, fixId45, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
|
|
157324
|
+
},
|
|
157325
|
+
fixIds: [fixId45],
|
|
157326
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
|
|
157327
|
+
});
|
|
157328
|
+
function makeChange10(changeTracker, sourceFile, pos) {
|
|
157329
|
+
const token = getTokenAtPosition(sourceFile, pos);
|
|
157330
|
+
const decorator = findAncestor(token, isDecorator);
|
|
157331
|
+
Debug.assert(!!decorator, "Expected position to be owned by a decorator.");
|
|
157332
|
+
const replacement = factory.createParenthesizedExpression(decorator.expression);
|
|
157333
|
+
changeTracker.replaceNode(sourceFile, decorator.expression, replacement);
|
|
157334
|
+
}
|
|
157335
|
+
|
|
157336
|
+
// src/services/codefixes/convertToMappedObjectType.ts
|
|
157337
|
+
var fixId46 = "fixConvertToMappedObjectType";
|
|
157338
|
+
var errorCodes59 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
157339
|
+
registerCodeFix({
|
|
157340
|
+
errorCodes: errorCodes59,
|
|
157250
157341
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
157251
157342
|
const { sourceFile, span } = context;
|
|
157252
157343
|
const info = getInfo20(sourceFile, span.start);
|
|
@@ -157254,10 +157345,10 @@ registerCodeFix({
|
|
|
157254
157345
|
return void 0;
|
|
157255
157346
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
157256
157347
|
const name = idText(info.container.name);
|
|
157257
|
-
return [createCodeFixAction(
|
|
157348
|
+
return [createCodeFixAction(fixId46, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId46, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
157258
157349
|
},
|
|
157259
|
-
fixIds: [
|
|
157260
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157350
|
+
fixIds: [fixId46],
|
|
157351
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
|
|
157261
157352
|
const info = getInfo20(diag2.file, diag2.start);
|
|
157262
157353
|
if (info)
|
|
157263
157354
|
doChange39(changes, diag2.file, info);
|
|
@@ -157305,12 +157396,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
|
157305
157396
|
}
|
|
157306
157397
|
|
|
157307
157398
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
157308
|
-
var
|
|
157309
|
-
var
|
|
157399
|
+
var fixId47 = "removeAccidentalCallParentheses";
|
|
157400
|
+
var errorCodes60 = [
|
|
157310
157401
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
157311
157402
|
];
|
|
157312
157403
|
registerCodeFix({
|
|
157313
|
-
errorCodes:
|
|
157404
|
+
errorCodes: errorCodes60,
|
|
157314
157405
|
getCodeActions(context) {
|
|
157315
157406
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
157316
157407
|
if (!callExpression) {
|
|
@@ -157319,30 +157410,30 @@ registerCodeFix({
|
|
|
157319
157410
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157320
157411
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
157321
157412
|
});
|
|
157322
|
-
return [createCodeFixActionWithoutFixAll(
|
|
157413
|
+
return [createCodeFixActionWithoutFixAll(fixId47, changes, Diagnostics.Remove_parentheses)];
|
|
157323
157414
|
},
|
|
157324
|
-
fixIds: [
|
|
157415
|
+
fixIds: [fixId47]
|
|
157325
157416
|
});
|
|
157326
157417
|
|
|
157327
157418
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
157328
|
-
var
|
|
157329
|
-
var
|
|
157419
|
+
var fixId48 = "removeUnnecessaryAwait";
|
|
157420
|
+
var errorCodes61 = [
|
|
157330
157421
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
157331
157422
|
];
|
|
157332
157423
|
registerCodeFix({
|
|
157333
|
-
errorCodes:
|
|
157424
|
+
errorCodes: errorCodes61,
|
|
157334
157425
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
157335
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157426
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span));
|
|
157336
157427
|
if (changes.length > 0) {
|
|
157337
|
-
return [createCodeFixAction(
|
|
157428
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Remove_unnecessary_await, fixId48, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
157338
157429
|
}
|
|
157339
157430
|
},
|
|
157340
|
-
fixIds: [
|
|
157431
|
+
fixIds: [fixId48],
|
|
157341
157432
|
getAllCodeActions: (context) => {
|
|
157342
|
-
return codeFixAll(context,
|
|
157433
|
+
return codeFixAll(context, errorCodes61, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
|
|
157343
157434
|
}
|
|
157344
157435
|
});
|
|
157345
|
-
function
|
|
157436
|
+
function makeChange11(changeTracker, sourceFile, span) {
|
|
157346
157437
|
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === 135 /* AwaitKeyword */);
|
|
157347
157438
|
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
157348
157439
|
if (!awaitExpression) {
|
|
@@ -157367,20 +157458,20 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
157367
157458
|
}
|
|
157368
157459
|
|
|
157369
157460
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
157370
|
-
var
|
|
157371
|
-
var
|
|
157461
|
+
var errorCodes62 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
157462
|
+
var fixId49 = "splitTypeOnlyImport";
|
|
157372
157463
|
registerCodeFix({
|
|
157373
|
-
errorCodes:
|
|
157374
|
-
fixIds: [
|
|
157464
|
+
errorCodes: errorCodes62,
|
|
157465
|
+
fixIds: [fixId49],
|
|
157375
157466
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
157376
157467
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157377
157468
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
157378
157469
|
});
|
|
157379
157470
|
if (changes.length) {
|
|
157380
|
-
return [createCodeFixAction(
|
|
157471
|
+
return [createCodeFixAction(fixId49, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId49, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
157381
157472
|
}
|
|
157382
157473
|
},
|
|
157383
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157474
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, error2) => {
|
|
157384
157475
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
157385
157476
|
})
|
|
157386
157477
|
});
|
|
@@ -157429,23 +157520,23 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
157429
157520
|
}
|
|
157430
157521
|
|
|
157431
157522
|
// src/services/codefixes/convertConstToLet.ts
|
|
157432
|
-
var
|
|
157433
|
-
var
|
|
157523
|
+
var fixId50 = "fixConvertConstToLet";
|
|
157524
|
+
var errorCodes63 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
157434
157525
|
registerCodeFix({
|
|
157435
|
-
errorCodes:
|
|
157526
|
+
errorCodes: errorCodes63,
|
|
157436
157527
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
157437
157528
|
const { sourceFile, span, program } = context;
|
|
157438
157529
|
const info = getInfo21(sourceFile, span.start, program);
|
|
157439
157530
|
if (info === void 0)
|
|
157440
157531
|
return;
|
|
157441
157532
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
157442
|
-
return [createCodeFixActionMaybeFixAll(
|
|
157533
|
+
return [createCodeFixActionMaybeFixAll(fixId50, changes, Diagnostics.Convert_const_to_let, fixId50, Diagnostics.Convert_all_const_to_let)];
|
|
157443
157534
|
},
|
|
157444
157535
|
getAllCodeActions: (context) => {
|
|
157445
157536
|
const { program } = context;
|
|
157446
157537
|
const seen = /* @__PURE__ */ new Map();
|
|
157447
157538
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157448
|
-
eachDiagnostic(context,
|
|
157539
|
+
eachDiagnostic(context, errorCodes63, (diag2) => {
|
|
157449
157540
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
157450
157541
|
if (info) {
|
|
157451
157542
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
@@ -157456,7 +157547,7 @@ registerCodeFix({
|
|
|
157456
157547
|
});
|
|
157457
157548
|
}));
|
|
157458
157549
|
},
|
|
157459
|
-
fixIds: [
|
|
157550
|
+
fixIds: [fixId50]
|
|
157460
157551
|
});
|
|
157461
157552
|
function getInfo21(sourceFile, pos, program) {
|
|
157462
157553
|
var _a;
|
|
@@ -157477,11 +157568,11 @@ function doChange40(changes, sourceFile, token) {
|
|
|
157477
157568
|
}
|
|
157478
157569
|
|
|
157479
157570
|
// src/services/codefixes/fixExpectedComma.ts
|
|
157480
|
-
var
|
|
157571
|
+
var fixId51 = "fixExpectedComma";
|
|
157481
157572
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
157482
|
-
var
|
|
157573
|
+
var errorCodes64 = [expectedErrorCode];
|
|
157483
157574
|
registerCodeFix({
|
|
157484
|
-
errorCodes:
|
|
157575
|
+
errorCodes: errorCodes64,
|
|
157485
157576
|
getCodeActions(context) {
|
|
157486
157577
|
const { sourceFile } = context;
|
|
157487
157578
|
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
@@ -157489,15 +157580,15 @@ registerCodeFix({
|
|
|
157489
157580
|
return void 0;
|
|
157490
157581
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
157491
157582
|
return [createCodeFixAction(
|
|
157492
|
-
|
|
157583
|
+
fixId51,
|
|
157493
157584
|
changes,
|
|
157494
157585
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
157495
|
-
|
|
157586
|
+
fixId51,
|
|
157496
157587
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
157497
157588
|
)];
|
|
157498
157589
|
},
|
|
157499
|
-
fixIds: [
|
|
157500
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157590
|
+
fixIds: [fixId51],
|
|
157591
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, diag2) => {
|
|
157501
157592
|
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
157502
157593
|
if (info)
|
|
157503
157594
|
doChange41(changes, context.sourceFile, info);
|
|
@@ -157514,25 +157605,25 @@ function doChange41(changes, sourceFile, { node }) {
|
|
|
157514
157605
|
|
|
157515
157606
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
157516
157607
|
var fixName7 = "addVoidToPromise";
|
|
157517
|
-
var
|
|
157518
|
-
var
|
|
157608
|
+
var fixId52 = "addVoidToPromise";
|
|
157609
|
+
var errorCodes65 = [
|
|
157519
157610
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
157520
157611
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
157521
157612
|
];
|
|
157522
157613
|
registerCodeFix({
|
|
157523
|
-
errorCodes:
|
|
157524
|
-
fixIds: [
|
|
157614
|
+
errorCodes: errorCodes65,
|
|
157615
|
+
fixIds: [fixId52],
|
|
157525
157616
|
getCodeActions(context) {
|
|
157526
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157617
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange12(t, context.sourceFile, context.span, context.program));
|
|
157527
157618
|
if (changes.length > 0) {
|
|
157528
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
157619
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId52, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
157529
157620
|
}
|
|
157530
157621
|
},
|
|
157531
157622
|
getAllCodeActions(context) {
|
|
157532
|
-
return codeFixAll(context,
|
|
157623
|
+
return codeFixAll(context, errorCodes65, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
157533
157624
|
}
|
|
157534
157625
|
});
|
|
157535
|
-
function
|
|
157626
|
+
function makeChange12(changes, sourceFile, span, program, seen) {
|
|
157536
157627
|
const node = getTokenAtPosition(sourceFile, span.start);
|
|
157537
157628
|
if (!isIdentifier(node) || !isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0)
|
|
157538
157629
|
return;
|
|
@@ -175017,6 +175108,7 @@ __export(ts_exports2, {
|
|
|
175017
175108
|
isSuperProperty: () => isSuperProperty,
|
|
175018
175109
|
isSupportedSourceFileName: () => isSupportedSourceFileName,
|
|
175019
175110
|
isSwitchStatement: () => isSwitchStatement,
|
|
175111
|
+
isSyntacticallyString: () => isSyntacticallyString,
|
|
175020
175112
|
isSyntaxList: () => isSyntaxList,
|
|
175021
175113
|
isSyntheticExpression: () => isSyntheticExpression,
|
|
175022
175114
|
isSyntheticReference: () => isSyntheticReference,
|
|
@@ -186020,10 +186112,10 @@ ${e.message}`;
|
|
|
186020
186112
|
}
|
|
186021
186113
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
186022
186114
|
}
|
|
186023
|
-
getCombinedCodeFix({ scope, fixId:
|
|
186115
|
+
getCombinedCodeFix({ scope, fixId: fixId53 }, simplifiedResult) {
|
|
186024
186116
|
Debug.assert(scope.type === "file");
|
|
186025
186117
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
186026
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
186118
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId53, this.getFormatOptions(file), this.getPreferences(file));
|
|
186027
186119
|
if (simplifiedResult) {
|
|
186028
186120
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
186029
186121
|
} else {
|
|
@@ -186062,8 +186154,8 @@ ${e.message}`;
|
|
|
186062
186154
|
mapCodeAction({ description: description3, changes, commands }) {
|
|
186063
186155
|
return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
186064
186156
|
}
|
|
186065
|
-
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId:
|
|
186066
|
-
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
186157
|
+
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId53, fixAllDescription }) {
|
|
186158
|
+
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId53, fixAllDescription };
|
|
186067
186159
|
}
|
|
186068
186160
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
186069
186161
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -189793,6 +189885,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189793
189885
|
isSuperProperty,
|
|
189794
189886
|
isSupportedSourceFileName,
|
|
189795
189887
|
isSwitchStatement,
|
|
189888
|
+
isSyntacticallyString,
|
|
189796
189889
|
isSyntaxList,
|
|
189797
189890
|
isSyntheticExpression,
|
|
189798
189891
|
isSyntheticReference,
|