typescript 5.2.0-dev.20230524 → 5.2.0-dev.20230527
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 +50 -38
- package/lib/tsserver.js +132 -76
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +132 -76
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +132 -76
- package/lib/typingsInstaller.js +2 -1
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -2304,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2304
2304
|
|
|
2305
2305
|
// src/compiler/corePublic.ts
|
|
2306
2306
|
var versionMajorMinor = "5.2";
|
|
2307
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2307
|
+
var version = `${versionMajorMinor}.0-dev.20230527`;
|
|
2308
2308
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2309
2309
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2310
2310
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -47307,6 +47307,7 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
47307
47307
|
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47308
47308
|
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47309
47309
|
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47310
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
47310
47311
|
return CheckMode3;
|
|
47311
47312
|
})(CheckMode || {});
|
|
47312
47313
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -52553,32 +52554,34 @@ function createTypeChecker(host) {
|
|
|
52553
52554
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 172 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
52554
52555
|
typeElements.push(preserveCommentsOn(methodDeclaration));
|
|
52555
52556
|
}
|
|
52557
|
+
if (signatures.length || !optionalToken) {
|
|
52558
|
+
return;
|
|
52559
|
+
}
|
|
52560
|
+
}
|
|
52561
|
+
let propertyTypeNode;
|
|
52562
|
+
if (shouldUsePlaceholderForProperty(propertySymbol, context)) {
|
|
52563
|
+
propertyTypeNode = createElidedInformationPlaceholder(context);
|
|
52556
52564
|
} else {
|
|
52557
|
-
|
|
52558
|
-
|
|
52559
|
-
|
|
52560
|
-
} else {
|
|
52561
|
-
if (propertyIsReverseMapped) {
|
|
52562
|
-
context.reverseMappedStack || (context.reverseMappedStack = []);
|
|
52563
|
-
context.reverseMappedStack.push(propertySymbol);
|
|
52564
|
-
}
|
|
52565
|
-
propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
52566
|
-
if (propertyIsReverseMapped) {
|
|
52567
|
-
context.reverseMappedStack.pop();
|
|
52568
|
-
}
|
|
52565
|
+
if (propertyIsReverseMapped) {
|
|
52566
|
+
context.reverseMappedStack || (context.reverseMappedStack = []);
|
|
52567
|
+
context.reverseMappedStack.push(propertySymbol);
|
|
52569
52568
|
}
|
|
52570
|
-
|
|
52571
|
-
if (
|
|
52572
|
-
context.
|
|
52569
|
+
propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
52570
|
+
if (propertyIsReverseMapped) {
|
|
52571
|
+
context.reverseMappedStack.pop();
|
|
52573
52572
|
}
|
|
52574
|
-
const propertySignature = factory.createPropertySignature(
|
|
52575
|
-
modifiers,
|
|
52576
|
-
propertyName,
|
|
52577
|
-
optionalToken,
|
|
52578
|
-
propertyTypeNode
|
|
52579
|
-
);
|
|
52580
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
52581
52573
|
}
|
|
52574
|
+
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(148 /* ReadonlyKeyword */)] : void 0;
|
|
52575
|
+
if (modifiers) {
|
|
52576
|
+
context.approximateLength += 9;
|
|
52577
|
+
}
|
|
52578
|
+
const propertySignature = factory.createPropertySignature(
|
|
52579
|
+
modifiers,
|
|
52580
|
+
propertyName,
|
|
52581
|
+
optionalToken,
|
|
52582
|
+
propertyTypeNode
|
|
52583
|
+
);
|
|
52584
|
+
typeElements.push(preserveCommentsOn(propertySignature));
|
|
52582
52585
|
function preserveCommentsOn(node) {
|
|
52583
52586
|
var _a2;
|
|
52584
52587
|
if (some(propertySymbol.declarations, (d) => d.kind === 354 /* JSDocPropertyTag */)) {
|
|
@@ -61931,9 +61934,9 @@ function createTypeChecker(host) {
|
|
|
61931
61934
|
);
|
|
61932
61935
|
if (freshMapper) {
|
|
61933
61936
|
const freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
|
|
61934
|
-
for (
|
|
61935
|
-
if (root.inferTypeParameters
|
|
61936
|
-
|
|
61937
|
+
for (let i = 0; i < freshParams.length; i++) {
|
|
61938
|
+
if (freshParams[i] !== root.inferTypeParameters[i]) {
|
|
61939
|
+
freshParams[i].mapper = freshCombinedMapper;
|
|
61937
61940
|
}
|
|
61938
61941
|
}
|
|
61939
61942
|
}
|
|
@@ -62836,6 +62839,9 @@ function createTypeChecker(host) {
|
|
|
62836
62839
|
const elementFlags = tupleType.target.elementFlags;
|
|
62837
62840
|
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
62838
62841
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
62842
|
+
if (singleton === typeVariable) {
|
|
62843
|
+
return mappedType;
|
|
62844
|
+
}
|
|
62839
62845
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
62840
62846
|
});
|
|
62841
62847
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
|
|
@@ -63173,6 +63179,10 @@ function createTypeChecker(host) {
|
|
|
63173
63179
|
return true;
|
|
63174
63180
|
}
|
|
63175
63181
|
switch (node.kind) {
|
|
63182
|
+
case 233 /* AsExpression */:
|
|
63183
|
+
if (!isConstAssertion(node)) {
|
|
63184
|
+
break;
|
|
63185
|
+
}
|
|
63176
63186
|
case 293 /* JsxExpression */:
|
|
63177
63187
|
case 216 /* ParenthesizedExpression */:
|
|
63178
63188
|
return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
|
|
@@ -69451,7 +69461,7 @@ function createTypeChecker(host) {
|
|
|
69451
69461
|
target.antecedents = saveAntecedents;
|
|
69452
69462
|
} else if (flags & 2 /* Start */) {
|
|
69453
69463
|
const container = flow.node;
|
|
69454
|
-
if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && reference.kind
|
|
69464
|
+
if (container && container !== flowContainer && reference.kind !== 210 /* PropertyAccessExpression */ && reference.kind !== 211 /* ElementAccessExpression */ && !(reference.kind === 110 /* ThisKeyword */ && container.kind !== 218 /* ArrowFunction */)) {
|
|
69455
69465
|
flow = container.flowNode;
|
|
69456
69466
|
continue;
|
|
69457
69467
|
}
|
|
@@ -77938,7 +77948,7 @@ function createTypeChecker(host) {
|
|
|
77938
77948
|
Debug.assertIsDefined(leftType);
|
|
77939
77949
|
const rightType = getLastResult(state);
|
|
77940
77950
|
Debug.assertIsDefined(rightType);
|
|
77941
|
-
result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node);
|
|
77951
|
+
result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, state.checkMode, node);
|
|
77942
77952
|
}
|
|
77943
77953
|
state.skip = false;
|
|
77944
77954
|
setLeftType(
|
|
@@ -78000,9 +78010,9 @@ function createTypeChecker(host) {
|
|
|
78000
78010
|
leftType = checkExpression(left, checkMode);
|
|
78001
78011
|
}
|
|
78002
78012
|
const rightType = checkExpression(right, checkMode);
|
|
78003
|
-
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
|
|
78013
|
+
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode);
|
|
78004
78014
|
}
|
|
78005
|
-
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
|
|
78015
|
+
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode) {
|
|
78006
78016
|
const operator = operatorToken.kind;
|
|
78007
78017
|
switch (operator) {
|
|
78008
78018
|
case 42 /* AsteriskToken */:
|
|
@@ -78159,12 +78169,14 @@ function createTypeChecker(host) {
|
|
|
78159
78169
|
case 36 /* ExclamationEqualsToken */:
|
|
78160
78170
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
78161
78171
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
78162
|
-
if (
|
|
78163
|
-
|
|
78164
|
-
|
|
78172
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
78173
|
+
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
78174
|
+
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
78175
|
+
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
78176
|
+
}
|
|
78177
|
+
checkNaNEquality(errorNode, operator, left, right);
|
|
78178
|
+
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
78165
78179
|
}
|
|
78166
|
-
checkNaNEquality(errorNode, operator, left, right);
|
|
78167
|
-
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
78168
78180
|
return booleanType;
|
|
78169
78181
|
case 104 /* InstanceOfKeyword */:
|
|
78170
78182
|
return checkInstanceOfExpression(left, right, leftType, rightType);
|
|
@@ -78475,7 +78487,7 @@ function createTypeChecker(host) {
|
|
|
78475
78487
|
}
|
|
78476
78488
|
}
|
|
78477
78489
|
function checkConditionalExpression(node, checkMode) {
|
|
78478
|
-
const type = checkTruthinessExpression(node.condition);
|
|
78490
|
+
const type = checkTruthinessExpression(node.condition, checkMode);
|
|
78479
78491
|
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
|
|
78480
78492
|
const type1 = checkExpression(node.whenTrue, checkMode);
|
|
78481
78493
|
const type2 = checkExpression(node.whenFalse, checkMode);
|
|
@@ -78816,7 +78828,7 @@ function createTypeChecker(host) {
|
|
|
78816
78828
|
}
|
|
78817
78829
|
}
|
|
78818
78830
|
const startInvocationCount = flowInvocationCount;
|
|
78819
|
-
const type = checkExpression(node);
|
|
78831
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
78820
78832
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78821
78833
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
78822
78834
|
cache[getNodeId(node)] = type;
|
|
@@ -78892,7 +78904,7 @@ function createTypeChecker(host) {
|
|
|
78892
78904
|
if (getIsolatedModules(compilerOptions)) {
|
|
78893
78905
|
Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
78894
78906
|
const constEnumDeclaration = type.symbol.valueDeclaration;
|
|
78895
|
-
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
78907
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node)) {
|
|
78896
78908
|
error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
78897
78909
|
}
|
|
78898
78910
|
}
|
|
@@ -135594,12 +135606,12 @@ function getEditsForRefactor(context, refactorName13, actionName2, interactiveRe
|
|
|
135594
135606
|
var refactorName = "Convert export";
|
|
135595
135607
|
var defaultToNamedAction = {
|
|
135596
135608
|
name: "Convert default export to named export",
|
|
135597
|
-
description: Diagnostics.Convert_default_export_to_named_export
|
|
135609
|
+
description: getLocaleSpecificMessage(Diagnostics.Convert_default_export_to_named_export),
|
|
135598
135610
|
kind: "refactor.rewrite.export.named"
|
|
135599
135611
|
};
|
|
135600
135612
|
var namedToDefaultAction = {
|
|
135601
135613
|
name: "Convert named export to default export",
|
|
135602
|
-
description: Diagnostics.Convert_named_export_to_default_export
|
|
135614
|
+
description: getLocaleSpecificMessage(Diagnostics.Convert_named_export_to_default_export),
|
|
135603
135615
|
kind: "refactor.rewrite.export.default"
|
|
135604
135616
|
};
|
|
135605
135617
|
registerRefactor(refactorName, {
|
|
@@ -135617,7 +135629,7 @@ registerRefactor(refactorName, {
|
|
|
135617
135629
|
}
|
|
135618
135630
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
135619
135631
|
return [
|
|
135620
|
-
{ name: refactorName, description: Diagnostics.Convert_default_export_to_named_export
|
|
135632
|
+
{ name: refactorName, description: getLocaleSpecificMessage(Diagnostics.Convert_default_export_to_named_export), actions: [
|
|
135621
135633
|
{ ...defaultToNamedAction, notApplicableReason: info.error },
|
|
135622
135634
|
{ ...namedToDefaultAction, notApplicableReason: info.error }
|
|
135623
135635
|
] }
|
|
@@ -135840,17 +135852,17 @@ var refactorName2 = "Convert import";
|
|
|
135840
135852
|
var actions = {
|
|
135841
135853
|
[0 /* Named */]: {
|
|
135842
135854
|
name: "Convert namespace import to named imports",
|
|
135843
|
-
description: Diagnostics.Convert_namespace_import_to_named_imports
|
|
135855
|
+
description: getLocaleSpecificMessage(Diagnostics.Convert_namespace_import_to_named_imports),
|
|
135844
135856
|
kind: "refactor.rewrite.import.named"
|
|
135845
135857
|
},
|
|
135846
135858
|
[2 /* Namespace */]: {
|
|
135847
135859
|
name: "Convert named imports to namespace import",
|
|
135848
|
-
description: Diagnostics.Convert_named_imports_to_namespace_import
|
|
135860
|
+
description: getLocaleSpecificMessage(Diagnostics.Convert_named_imports_to_namespace_import),
|
|
135849
135861
|
kind: "refactor.rewrite.import.namespace"
|
|
135850
135862
|
},
|
|
135851
135863
|
[1 /* Default */]: {
|
|
135852
135864
|
name: "Convert named imports to default import",
|
|
135853
|
-
description: Diagnostics.Convert_named_imports_to_default_import
|
|
135865
|
+
description: getLocaleSpecificMessage(Diagnostics.Convert_named_imports_to_default_import),
|
|
135854
135866
|
kind: "refactor.rewrite.import.default"
|
|
135855
135867
|
}
|
|
135856
135868
|
};
|
|
@@ -136506,10 +136518,9 @@ registerRefactor(refactorNameForMoveToFile, {
|
|
|
136506
136518
|
}
|
|
136507
136519
|
});
|
|
136508
136520
|
function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
|
|
136509
|
-
var _a;
|
|
136510
136521
|
const checker = program.getTypeChecker();
|
|
136511
136522
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
136512
|
-
if (!host.fileExists(targetFile)
|
|
136523
|
+
if (!host.fileExists(targetFile)) {
|
|
136513
136524
|
changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
|
|
136514
136525
|
addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
|
|
136515
136526
|
} else {
|
|
@@ -136547,6 +136558,13 @@ function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, chang
|
|
|
136547
136558
|
if (typeof targetFile !== "string") {
|
|
136548
136559
|
if (targetFile.statements.length > 0) {
|
|
136549
136560
|
changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
|
|
136561
|
+
} else {
|
|
136562
|
+
changes.insertNodesAtEndOfFile(
|
|
136563
|
+
targetFile,
|
|
136564
|
+
body,
|
|
136565
|
+
/*blankLineBetween*/
|
|
136566
|
+
false
|
|
136567
|
+
);
|
|
136550
136568
|
}
|
|
136551
136569
|
if (imports.length > 0) {
|
|
136552
136570
|
insertImports(
|
|
@@ -137133,6 +137151,10 @@ function getRangeToMove(context) {
|
|
|
137133
137151
|
if (isNamedDeclaration(startStatement) && startStatement.name && rangeContainsRange(startStatement.name, range)) {
|
|
137134
137152
|
return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] };
|
|
137135
137153
|
}
|
|
137154
|
+
const overloadRangeToMove = getOverloadRangeToMove(file, startStatement);
|
|
137155
|
+
if (overloadRangeToMove) {
|
|
137156
|
+
return overloadRangeToMove;
|
|
137157
|
+
}
|
|
137136
137158
|
if (range.pos > startStatement.getStart(file))
|
|
137137
137159
|
return void 0;
|
|
137138
137160
|
const afterEndNodeIndex = findIndex(statements, (s) => s.end > range.end, startNodeIndex);
|
|
@@ -137328,13 +137350,26 @@ function isNonVariableTopLevelDeclaration(node) {
|
|
|
137328
137350
|
return false;
|
|
137329
137351
|
}
|
|
137330
137352
|
}
|
|
137353
|
+
function getOverloadRangeToMove(sourceFile, statement) {
|
|
137354
|
+
if (isFunctionLikeDeclaration(statement)) {
|
|
137355
|
+
const declarations = statement.symbol.declarations;
|
|
137356
|
+
if (declarations === void 0 || length(declarations) <= 1 || !contains(declarations, statement)) {
|
|
137357
|
+
return void 0;
|
|
137358
|
+
}
|
|
137359
|
+
const lastDecl = declarations[length(declarations) - 1];
|
|
137360
|
+
const statementsToMove = mapDefined(declarations, (d) => getSourceFileOfNode(d) === sourceFile && isStatement(d) ? d : void 0);
|
|
137361
|
+
const end = findLastIndex(sourceFile.statements, (s) => s.end > lastDecl.end);
|
|
137362
|
+
return { toMove: statementsToMove, afterLast: end >= 0 ? sourceFile.statements[end] : void 0 };
|
|
137363
|
+
}
|
|
137364
|
+
return void 0;
|
|
137365
|
+
}
|
|
137331
137366
|
|
|
137332
137367
|
// src/services/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.ts
|
|
137333
137368
|
var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
|
|
137334
137369
|
|
|
137335
137370
|
// src/services/refactors/convertOverloadListToSingleSignature.ts
|
|
137336
137371
|
var refactorName5 = "Convert overload list to single signature";
|
|
137337
|
-
var refactorDescription = Diagnostics.Convert_overload_list_to_single_signature
|
|
137372
|
+
var refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
137338
137373
|
var functionOverloadAction = {
|
|
137339
137374
|
name: refactorName5,
|
|
137340
137375
|
description: refactorDescription,
|
|
@@ -137546,15 +137581,15 @@ function getConvertableOverloadListAtPosition(file, startPosition, program) {
|
|
|
137546
137581
|
|
|
137547
137582
|
// src/services/refactors/addOrRemoveBracesToArrowFunction.ts
|
|
137548
137583
|
var refactorName6 = "Add or remove braces in an arrow function";
|
|
137549
|
-
var refactorDescription2 = Diagnostics.Add_or_remove_braces_in_an_arrow_function
|
|
137584
|
+
var refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
137550
137585
|
var addBracesAction = {
|
|
137551
137586
|
name: "Add braces to arrow function",
|
|
137552
|
-
description: Diagnostics.Add_braces_to_arrow_function
|
|
137587
|
+
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
137553
137588
|
kind: "refactor.rewrite.arrow.braces.add"
|
|
137554
137589
|
};
|
|
137555
137590
|
var removeBracesAction = {
|
|
137556
137591
|
name: "Remove braces from arrow function",
|
|
137557
|
-
description: Diagnostics.Remove_braces_from_arrow_function
|
|
137592
|
+
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
137558
137593
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
137559
137594
|
};
|
|
137560
137595
|
registerRefactor(refactorName6, {
|
|
@@ -138508,7 +138543,7 @@ function getEditsForToTemplateLiteral(context, node) {
|
|
|
138508
138543
|
}
|
|
138509
138544
|
}
|
|
138510
138545
|
function isNotEqualsOperator(node) {
|
|
138511
|
-
return node.operatorToken.kind
|
|
138546
|
+
return !(node.operatorToken.kind === 64 /* EqualsToken */ || node.operatorToken.kind === 65 /* PlusEqualsToken */);
|
|
138512
138547
|
}
|
|
138513
138548
|
function getParentBinaryExpression(expr) {
|
|
138514
138549
|
const container = findAncestor(expr.parent, (n) => {
|
|
@@ -140484,7 +140519,7 @@ var ts_refactor_generateGetAccessorAndSetAccessor_exports = {};
|
|
|
140484
140519
|
|
|
140485
140520
|
// src/services/refactors/generateGetAccessorAndSetAccessor.ts
|
|
140486
140521
|
var actionName = "Generate 'get' and 'set' accessors";
|
|
140487
|
-
var actionDescription = Diagnostics.Generate_get_and_set_accessors
|
|
140522
|
+
var actionDescription = getLocaleSpecificMessage(Diagnostics.Generate_get_and_set_accessors);
|
|
140488
140523
|
var generateGetSetAction = {
|
|
140489
140524
|
name: actionName,
|
|
140490
140525
|
description: actionDescription,
|
|
@@ -140541,7 +140576,7 @@ var ts_refactor_inferFunctionReturnType_exports = {};
|
|
|
140541
140576
|
|
|
140542
140577
|
// src/services/refactors/inferFunctionReturnType.ts
|
|
140543
140578
|
var refactorName12 = "Infer function return type";
|
|
140544
|
-
var refactorDescription6 = Diagnostics.Infer_function_return_type
|
|
140579
|
+
var refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
140545
140580
|
var inferReturnTypeAction = {
|
|
140546
140581
|
name: refactorName12,
|
|
140547
140582
|
description: refactorDescription6,
|
|
@@ -141884,7 +141919,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
141884
141919
|
onUnRecoverableConfigFileDiagnostic: noop
|
|
141885
141920
|
};
|
|
141886
141921
|
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
|
141922
|
+
let releasedScriptKinds = /* @__PURE__ */ new Set();
|
|
141887
141923
|
if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
141924
|
+
compilerHost = void 0;
|
|
141925
|
+
parsedCommandLines = void 0;
|
|
141926
|
+
releasedScriptKinds = void 0;
|
|
141888
141927
|
return;
|
|
141889
141928
|
}
|
|
141890
141929
|
const options = {
|
|
@@ -141897,6 +141936,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
141897
141936
|
program = createProgram(options);
|
|
141898
141937
|
compilerHost = void 0;
|
|
141899
141938
|
parsedCommandLines = void 0;
|
|
141939
|
+
releasedScriptKinds = void 0;
|
|
141900
141940
|
sourceMapper.clearCache();
|
|
141901
141941
|
program.getTypeChecker();
|
|
141902
141942
|
return;
|
|
@@ -141951,10 +141991,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
141951
141991
|
if (!shouldCreateNewSourceFile) {
|
|
141952
141992
|
const oldSourceFile = program && program.getSourceFileByPath(path);
|
|
141953
141993
|
if (oldSourceFile) {
|
|
141954
|
-
if (scriptKind === oldSourceFile.scriptKind) {
|
|
141994
|
+
if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
|
|
141955
141995
|
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
141956
141996
|
} else {
|
|
141957
141997
|
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
141998
|
+
releasedScriptKinds.add(oldSourceFile.resolvedPath);
|
|
141958
141999
|
}
|
|
141959
142000
|
}
|
|
141960
142001
|
}
|
|
@@ -150434,9 +150475,6 @@ function getActionsForMissingMethodDeclaration(context, info) {
|
|
|
150434
150475
|
if (call === void 0) {
|
|
150435
150476
|
return void 0;
|
|
150436
150477
|
}
|
|
150437
|
-
if (isPrivateIdentifier(token)) {
|
|
150438
|
-
return void 0;
|
|
150439
|
-
}
|
|
150440
150478
|
const methodName = token.text;
|
|
150441
150479
|
const addMethodDeclarationChanges = (modifierFlags2) => ts_textChanges_exports.ChangeTracker.with(context, (t) => addMethodDeclaration(context, t, call, token, modifierFlags2, parentDeclaration, declSourceFile));
|
|
150442
150480
|
const actions2 = [createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, methodName], fixMissingMember, Diagnostics.Add_all_missing_members)];
|
|
@@ -153486,6 +153524,7 @@ function createSignatureDeclarationFromCallExpression(kind, context, importAdder
|
|
|
153486
153524
|
type === void 0 ? factory.createKeywordTypeNode(159 /* UnknownKeyword */) : type
|
|
153487
153525
|
);
|
|
153488
153526
|
case 261 /* FunctionDeclaration */:
|
|
153527
|
+
Debug.assert(typeof name === "string" || isIdentifier(name), "Unexpected name");
|
|
153489
153528
|
return factory.createFunctionDeclaration(
|
|
153490
153529
|
modifiers,
|
|
153491
153530
|
asteriskToken,
|
|
@@ -161507,9 +161546,9 @@ var Core;
|
|
|
161507
161546
|
if (refNode.parent.kind === 303 /* ShorthandPropertyAssignment */) {
|
|
161508
161547
|
getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference2);
|
|
161509
161548
|
}
|
|
161510
|
-
const
|
|
161511
|
-
if (
|
|
161512
|
-
addReference2(
|
|
161549
|
+
const containingNode = getContainingNodeIfInHeritageClause(refNode);
|
|
161550
|
+
if (containingNode) {
|
|
161551
|
+
addReference2(containingNode);
|
|
161513
161552
|
return;
|
|
161514
161553
|
}
|
|
161515
161554
|
const typeNode = findAncestor(refNode, (a) => !isQualifiedName(a.parent) && !isTypeNode(a.parent) && !isTypeElement(a.parent));
|
|
@@ -161536,8 +161575,8 @@ var Core;
|
|
|
161536
161575
|
addReference2(e);
|
|
161537
161576
|
}
|
|
161538
161577
|
}
|
|
161539
|
-
function
|
|
161540
|
-
return isIdentifier(node) || isPropertyAccessExpression(node) ?
|
|
161578
|
+
function getContainingNodeIfInHeritageClause(node) {
|
|
161579
|
+
return isIdentifier(node) || isPropertyAccessExpression(node) ? getContainingNodeIfInHeritageClause(node.parent) : isExpressionWithTypeArguments(node) ? tryCast(node.parent.parent, or(isClassLike, isInterfaceDeclaration)) : void 0;
|
|
161541
161580
|
}
|
|
161542
161581
|
function isImplementationExpression(node) {
|
|
161543
161582
|
switch (node.kind) {
|
|
@@ -163088,7 +163127,7 @@ function getDocCommentTemplateAtPosition(newLine, sourceFile, position, options)
|
|
|
163088
163127
|
const tags = (parameters ? parameterDocComments(parameters || [], isJavaScriptFile, indentationStr, newLine) : "") + (hasReturn2 ? returnsDocComment(indentationStr, newLine) : "");
|
|
163089
163128
|
const openComment = "/**";
|
|
163090
163129
|
const closeComment = " */";
|
|
163091
|
-
const hasTag = (
|
|
163130
|
+
const hasTag = length(getJSDocTags(commentOwner)) > 0;
|
|
163092
163131
|
if (tags && !hasTag) {
|
|
163093
163132
|
const preamble = openComment + newLine + indentationStr + " * ";
|
|
163094
163133
|
const endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
@@ -166011,6 +166050,17 @@ var ChangeTracker = class {
|
|
|
166011
166050
|
this.insertNodeAt(sourceFile, pos, insert, options);
|
|
166012
166051
|
}
|
|
166013
166052
|
}
|
|
166053
|
+
insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
|
|
166054
|
+
this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
|
|
166055
|
+
}
|
|
166056
|
+
insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
|
|
166057
|
+
const pos = sourceFile.end + 1;
|
|
166058
|
+
const options = {
|
|
166059
|
+
prefix: this.newLineCharacter,
|
|
166060
|
+
suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
|
|
166061
|
+
};
|
|
166062
|
+
this.insertNodesAt(sourceFile, pos, insert, options);
|
|
166063
|
+
}
|
|
166014
166064
|
insertStatementsInNewFile(fileName, statements, oldFile) {
|
|
166015
166065
|
if (!this.newFileChanges) {
|
|
166016
166066
|
this.newFileChanges = createMultiMap();
|
|
@@ -168428,7 +168478,8 @@ function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delt
|
|
|
168428
168478
|
}
|
|
168429
168479
|
processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta);
|
|
168430
168480
|
}
|
|
168431
|
-
|
|
168481
|
+
const remainingTrivia = formattingScanner.getCurrentLeadingTrivia();
|
|
168482
|
+
if (remainingTrivia) {
|
|
168432
168483
|
const indentation = SmartIndenter.nodeWillIndentChild(
|
|
168433
168484
|
options,
|
|
168434
168485
|
enclosingNode,
|
|
@@ -168438,25 +168489,30 @@ function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delt
|
|
|
168438
168489
|
/*indentByDefault*/
|
|
168439
168490
|
false
|
|
168440
168491
|
) ? initialIndentation + options.indentSize : initialIndentation;
|
|
168441
|
-
|
|
168442
|
-
|
|
168443
|
-
|
|
168444
|
-
|
|
168445
|
-
|
|
168446
|
-
|
|
168447
|
-
|
|
168448
|
-
(item) => processRange(
|
|
168492
|
+
indentTriviaItems(
|
|
168493
|
+
remainingTrivia,
|
|
168494
|
+
indentation,
|
|
168495
|
+
/*indentNextTokenOrTrivia*/
|
|
168496
|
+
true,
|
|
168497
|
+
(item) => {
|
|
168498
|
+
processRange(
|
|
168449
168499
|
item,
|
|
168450
168500
|
sourceFile.getLineAndCharacterOfPosition(item.pos),
|
|
168451
168501
|
enclosingNode,
|
|
168452
168502
|
enclosingNode,
|
|
168453
168503
|
/*dynamicIndentation*/
|
|
168454
168504
|
void 0
|
|
168455
|
-
)
|
|
168456
|
-
|
|
168457
|
-
|
|
168458
|
-
|
|
168505
|
+
);
|
|
168506
|
+
insertIndentation(
|
|
168507
|
+
item.pos,
|
|
168508
|
+
indentation,
|
|
168509
|
+
/*lineAdded*/
|
|
168510
|
+
false
|
|
168511
|
+
);
|
|
168459
168512
|
}
|
|
168513
|
+
);
|
|
168514
|
+
if (options.trimTrailingWhitespace !== false) {
|
|
168515
|
+
trimTrailingWhitespacesForRemainingRange(remainingTrivia);
|
|
168460
168516
|
}
|
|
168461
168517
|
}
|
|
168462
168518
|
if (previousRange && formattingScanner.getTokenFullStart() >= originalRange.end) {
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -10196,7 +10196,7 @@ declare namespace ts {
|
|
|
10196
10196
|
* arguments for any interactive action before offering it.
|
|
10197
10197
|
*/
|
|
10198
10198
|
getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string, includeInteractiveActions?: boolean): ApplicableRefactorInfo[];
|
|
10199
|
-
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined,
|
|
10199
|
+
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
|
|
10200
10200
|
getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
|
|
10201
10201
|
newFileName: string;
|
|
10202
10202
|
files: string[];
|