typescript 5.5.0-dev.20240522 → 5.5.0-dev.20240523
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 +44 -63
- package/lib/typescript.d.ts +29 -0
- package/lib/typescript.js +292 -65
- package/package.json +4 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240523`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -7508,6 +7508,8 @@ var Diagnostics = {
|
|
|
7508
7508
|
Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit: diag(9035, 1 /* Error */, "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035", "Add satisfies and a type assertion to this expression (satisfies T as T) to make the type explicit."),
|
|
7509
7509
|
Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
|
|
7510
7510
|
Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
|
|
7511
|
+
Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations: diag(9038, 1 /* Error */, "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038", "Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."),
|
|
7512
|
+
Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations: diag(9039, 1 /* Error */, "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039", "Type containing private name '{0}' can't be used with --isolatedDeclarations."),
|
|
7511
7513
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
7512
7514
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
7513
7515
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
@@ -45053,7 +45055,6 @@ function createTypeChecker(host) {
|
|
|
45053
45055
|
var syntacticNodeBuilder = createSyntacticTypeNodeBuilder(compilerOptions, {
|
|
45054
45056
|
isEntityNameVisible,
|
|
45055
45057
|
isExpandoFunctionDeclaration,
|
|
45056
|
-
isNonNarrowedBindableName,
|
|
45057
45058
|
getAllAccessorDeclarations: getAllAccessorDeclarationsForDeclaration,
|
|
45058
45059
|
requiresAddingImplicitUndefined,
|
|
45059
45060
|
isUndefinedIdentifierExpression(node) {
|
|
@@ -49228,6 +49229,7 @@ function createTypeChecker(host) {
|
|
|
49228
49229
|
return result;
|
|
49229
49230
|
}
|
|
49230
49231
|
}
|
|
49232
|
+
context.tracker.reportInferenceFallback(existing);
|
|
49231
49233
|
return void 0;
|
|
49232
49234
|
}
|
|
49233
49235
|
function symbolToNode(symbol, context, meaning) {
|
|
@@ -51263,6 +51265,9 @@ function createTypeChecker(host) {
|
|
|
51263
51265
|
symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
|
|
51264
51266
|
symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
|
|
51265
51267
|
) {
|
|
51268
|
+
if (symAtLocation !== unknownSymbol) {
|
|
51269
|
+
context.tracker.reportInferenceFallback(node);
|
|
51270
|
+
}
|
|
51266
51271
|
introducesError = true;
|
|
51267
51272
|
return { introducesError, node, sym };
|
|
51268
51273
|
}
|
|
@@ -51281,6 +51286,7 @@ function createTypeChecker(host) {
|
|
|
51281
51286
|
/*shouldComputeAliasesToMakeVisible*/
|
|
51282
51287
|
false
|
|
51283
51288
|
).accessibility !== 0 /* Accessible */) {
|
|
51289
|
+
context.tracker.reportInferenceFallback(node);
|
|
51284
51290
|
introducesError = true;
|
|
51285
51291
|
} else {
|
|
51286
51292
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
@@ -84975,22 +84981,6 @@ function createTypeChecker(host) {
|
|
|
84975
84981
|
}
|
|
84976
84982
|
return false;
|
|
84977
84983
|
}
|
|
84978
|
-
function isNonNarrowedBindableName(node) {
|
|
84979
|
-
if (!hasBindableName(node.parent)) {
|
|
84980
|
-
return false;
|
|
84981
|
-
}
|
|
84982
|
-
const expression = node.expression;
|
|
84983
|
-
if (!isEntityNameExpression(expression)) {
|
|
84984
|
-
return true;
|
|
84985
|
-
}
|
|
84986
|
-
const type = getTypeOfExpression(expression);
|
|
84987
|
-
const symbol = getSymbolAtLocation(expression);
|
|
84988
|
-
if (!symbol) {
|
|
84989
|
-
return false;
|
|
84990
|
-
}
|
|
84991
|
-
const declaredType = getTypeOfSymbol(symbol);
|
|
84992
|
-
return declaredType === type;
|
|
84993
|
-
}
|
|
84994
84984
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
84995
84985
|
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
84996
84986
|
type.symbol,
|
|
@@ -85109,7 +85099,6 @@ function createTypeChecker(host) {
|
|
|
85109
85099
|
return node && getExternalModuleFileFromDeclaration(node);
|
|
85110
85100
|
},
|
|
85111
85101
|
isLiteralConstDeclaration,
|
|
85112
|
-
isNonNarrowedBindableName,
|
|
85113
85102
|
isLateBound: (nodeIn) => {
|
|
85114
85103
|
const node = getParseTreeNode(nodeIn, isDeclaration);
|
|
85115
85104
|
const symbol = node && getSymbolOfDeclaration(node);
|
|
@@ -110029,7 +110018,7 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110029
110018
|
[260 /* VariableDeclaration */]: Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110030
110019
|
[172 /* PropertyDeclaration */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110031
110020
|
[171 /* PropertySignature */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110032
|
-
[167 /* ComputedPropertyName */]: Diagnostics.
|
|
110021
|
+
[167 /* ComputedPropertyName */]: Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations,
|
|
110033
110022
|
[305 /* SpreadAssignment */]: Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations,
|
|
110034
110023
|
[304 /* ShorthandPropertyAssignment */]: Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations,
|
|
110035
110024
|
[209 /* ArrayLiteralExpression */]: Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations,
|
|
@@ -110042,6 +110031,9 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110042
110031
|
if (heritageClause) {
|
|
110043
110032
|
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
|
110044
110033
|
}
|
|
110034
|
+
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
|
110035
|
+
return createEntityInTypeNodeError(node);
|
|
110036
|
+
}
|
|
110045
110037
|
Debug.type(node);
|
|
110046
110038
|
switch (node.kind) {
|
|
110047
110039
|
case 177 /* GetAccessor */:
|
|
@@ -110077,8 +110069,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110077
110069
|
}
|
|
110078
110070
|
}
|
|
110079
110071
|
function findNearestDeclaration(node) {
|
|
110080
|
-
const result = findAncestor(node, (n) => isExportAssignment(n) ||
|
|
110081
|
-
return
|
|
110072
|
+
const result = findAncestor(node, (n) => isExportAssignment(n) || isStatement(n) || isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n));
|
|
110073
|
+
if (!result) return void 0;
|
|
110074
|
+
if (isExportAssignment(result)) return result;
|
|
110075
|
+
if (isReturnStatement(result)) {
|
|
110076
|
+
return findAncestor(result, (n) => isFunctionLikeDeclaration(n) && !isConstructorDeclaration(n));
|
|
110077
|
+
}
|
|
110078
|
+
return isStatement(result) ? void 0 : result;
|
|
110082
110079
|
}
|
|
110083
110080
|
function createAccessorTypeError(node) {
|
|
110084
110081
|
const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
|
|
@@ -110092,11 +110089,10 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110092
110089
|
}
|
|
110093
110090
|
return diag2;
|
|
110094
110091
|
}
|
|
110095
|
-
function
|
|
110096
|
-
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110092
|
+
function addParentDeclarationRelatedInfo(node, diag2) {
|
|
110097
110093
|
const parentDeclaration = findNearestDeclaration(node);
|
|
110098
110094
|
if (parentDeclaration) {
|
|
110099
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110095
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
110100
110096
|
parentDeclaration.name,
|
|
110101
110097
|
/*includeTrivia*/
|
|
110102
110098
|
false
|
|
@@ -110105,30 +110101,19 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110105
110101
|
}
|
|
110106
110102
|
return diag2;
|
|
110107
110103
|
}
|
|
110104
|
+
function createObjectLiteralError(node) {
|
|
110105
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110106
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110107
|
+
return diag2;
|
|
110108
|
+
}
|
|
110108
110109
|
function createArrayLiteralError(node) {
|
|
110109
110110
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110110
|
-
|
|
110111
|
-
if (parentDeclaration) {
|
|
110112
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110113
|
-
parentDeclaration.name,
|
|
110114
|
-
/*includeTrivia*/
|
|
110115
|
-
false
|
|
110116
|
-
);
|
|
110117
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110118
|
-
}
|
|
110111
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110119
110112
|
return diag2;
|
|
110120
110113
|
}
|
|
110121
110114
|
function createReturnTypeError(node) {
|
|
110122
110115
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110123
|
-
|
|
110124
|
-
if (parentDeclaration) {
|
|
110125
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110126
|
-
parentDeclaration.name,
|
|
110127
|
-
/*includeTrivia*/
|
|
110128
|
-
false
|
|
110129
|
-
);
|
|
110130
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110131
|
-
}
|
|
110116
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110132
110117
|
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
|
|
110133
110118
|
return diag2;
|
|
110134
110119
|
}
|
|
@@ -110166,11 +110151,20 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110166
110151
|
function createClassExpressionError(node) {
|
|
110167
110152
|
return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
|
|
110168
110153
|
}
|
|
110154
|
+
function createEntityInTypeNodeError(node) {
|
|
110155
|
+
const diag2 = createDiagnosticForNode(node, Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations, getTextOfNode(
|
|
110156
|
+
node,
|
|
110157
|
+
/*includeTrivia*/
|
|
110158
|
+
false
|
|
110159
|
+
));
|
|
110160
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110161
|
+
return diag2;
|
|
110162
|
+
}
|
|
110169
110163
|
function createExpressionError(node, diagnosticMessage) {
|
|
110170
110164
|
const parentDeclaration = findNearestDeclaration(node);
|
|
110171
110165
|
let diag2;
|
|
110172
110166
|
if (parentDeclaration) {
|
|
110173
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110167
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
110174
110168
|
parentDeclaration.name,
|
|
110175
110169
|
/*includeTrivia*/
|
|
110176
110170
|
false
|
|
@@ -110895,8 +110889,11 @@ function transformDeclarations(context) {
|
|
|
110895
110889
|
if (shouldStripInternal(input)) return;
|
|
110896
110890
|
if (isDeclaration(input)) {
|
|
110897
110891
|
if (isDeclarationAndNotVisible(input)) return;
|
|
110898
|
-
if (hasDynamicName(input)
|
|
110899
|
-
if (isolatedDeclarations && isClassDeclaration(input.parent)
|
|
110892
|
+
if (hasDynamicName(input)) {
|
|
110893
|
+
if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
|
|
110894
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
|
|
110895
|
+
}
|
|
110896
|
+
if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
|
|
110900
110897
|
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
|
|
110901
110898
|
}
|
|
110902
110899
|
if (!isEntityNameExpression(input.name.expression)) {
|
|
@@ -112829,7 +112826,6 @@ var notImplementedResolver = {
|
|
|
112829
112826
|
isArgumentsLocalBinding: notImplemented,
|
|
112830
112827
|
getExternalModuleFileFromDeclaration: notImplemented,
|
|
112831
112828
|
isLiteralConstDeclaration: notImplemented,
|
|
112832
|
-
isNonNarrowedBindableName: notImplemented,
|
|
112833
112829
|
getJsxFactoryEntity: notImplemented,
|
|
112834
112830
|
getJsxFragmentFactoryEntity: notImplemented,
|
|
112835
112831
|
isBindingCapturedByNode: notImplemented,
|
|
@@ -129110,7 +129106,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
129110
129106
|
expression,
|
|
129111
129107
|
/*includeBigInt*/
|
|
129112
129108
|
false
|
|
129113
|
-
)
|
|
129109
|
+
)) {
|
|
129114
129110
|
context.tracker.reportInferenceFallback(prop.name);
|
|
129115
129111
|
result = false;
|
|
129116
129112
|
}
|
|
@@ -129124,21 +129120,6 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
129124
129120
|
for (const prop of objectLiteral.properties) {
|
|
129125
129121
|
Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
|
|
129126
129122
|
const name = prop.name;
|
|
129127
|
-
if (prop.name.kind === 167 /* ComputedPropertyName */) {
|
|
129128
|
-
if (!resolver.isNonNarrowedBindableName(prop.name)) {
|
|
129129
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
129130
|
-
} else if (isEntityNameExpression(prop.name.expression)) {
|
|
129131
|
-
const visibilityResult = resolver.isEntityNameVisible(
|
|
129132
|
-
prop.name.expression,
|
|
129133
|
-
context.enclosingDeclaration,
|
|
129134
|
-
/*shouldComputeAliasToMakeVisible*/
|
|
129135
|
-
false
|
|
129136
|
-
);
|
|
129137
|
-
if (visibilityResult.accessibility !== 0 /* Accessible */) {
|
|
129138
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
129139
|
-
}
|
|
129140
|
-
}
|
|
129141
|
-
}
|
|
129142
129123
|
switch (prop.kind) {
|
|
129143
129124
|
case 174 /* MethodDeclaration */:
|
|
129144
129125
|
canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
|
package/lib/typescript.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ declare namespace ts {
|
|
|
121
121
|
ProvideCallHierarchyOutgoingCalls = "provideCallHierarchyOutgoingCalls",
|
|
122
122
|
ProvideInlayHints = "provideInlayHints",
|
|
123
123
|
WatchChange = "watchChange",
|
|
124
|
+
MapCode = "mapCode",
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* A TypeScript Server message
|
|
@@ -1769,6 +1770,33 @@ declare namespace ts {
|
|
|
1769
1770
|
export interface InlayHintsResponse extends Response {
|
|
1770
1771
|
body?: InlayHintItem[];
|
|
1771
1772
|
}
|
|
1773
|
+
export interface MapCodeRequestArgs extends FileRequestArgs {
|
|
1774
|
+
/**
|
|
1775
|
+
* The files and changes to try and apply/map.
|
|
1776
|
+
*/
|
|
1777
|
+
mapping: MapCodeRequestDocumentMapping;
|
|
1778
|
+
}
|
|
1779
|
+
export interface MapCodeRequestDocumentMapping {
|
|
1780
|
+
/**
|
|
1781
|
+
* The specific code to map/insert/replace in the file.
|
|
1782
|
+
*/
|
|
1783
|
+
contents: string[];
|
|
1784
|
+
/**
|
|
1785
|
+
* Areas of "focus" to inform the code mapper with. For example, cursor
|
|
1786
|
+
* location, current selection, viewport, etc. Nested arrays denote
|
|
1787
|
+
* priority: toplevel arrays are more important than inner arrays, and
|
|
1788
|
+
* inner array priorities are based on items within that array. Items
|
|
1789
|
+
* earlier in the arrays have higher priority.
|
|
1790
|
+
*/
|
|
1791
|
+
focusLocations?: TextSpan[][];
|
|
1792
|
+
}
|
|
1793
|
+
export interface MapCodeRequest extends FileRequest {
|
|
1794
|
+
command: CommandTypes.MapCode;
|
|
1795
|
+
arguments: MapCodeRequestArgs;
|
|
1796
|
+
}
|
|
1797
|
+
export interface MapCodeResponse extends Response {
|
|
1798
|
+
body: readonly FileCodeEdits[];
|
|
1799
|
+
}
|
|
1772
1800
|
/**
|
|
1773
1801
|
* Synchronous request for semantic diagnostics of one file.
|
|
1774
1802
|
*/
|
|
@@ -3468,6 +3496,7 @@ declare namespace ts {
|
|
|
3468
3496
|
private getLinkedEditingRange;
|
|
3469
3497
|
private getDocumentHighlights;
|
|
3470
3498
|
private provideInlayHints;
|
|
3499
|
+
private mapCode;
|
|
3471
3500
|
private setCompilerOptionsForInferredProjects;
|
|
3472
3501
|
private getProjectInfo;
|
|
3473
3502
|
private getProjectInfoWorker;
|
package/lib/typescript.js
CHANGED
|
@@ -112,6 +112,7 @@ __export(typescript_exports, {
|
|
|
112
112
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
113
113
|
ListFormat: () => ListFormat,
|
|
114
114
|
LogLevel: () => LogLevel,
|
|
115
|
+
MapCode: () => ts_MapCode_exports,
|
|
115
116
|
MemberOverrideStatus: () => MemberOverrideStatus,
|
|
116
117
|
ModifierFlags: () => ModifierFlags,
|
|
117
118
|
ModuleDetectionKind: () => ModuleDetectionKind,
|
|
@@ -2369,7 +2370,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2369
2370
|
|
|
2370
2371
|
// src/compiler/corePublic.ts
|
|
2371
2372
|
var versionMajorMinor = "5.5";
|
|
2372
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2373
|
+
var version = `${versionMajorMinor}.0-dev.20240523`;
|
|
2373
2374
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2374
2375
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2375
2376
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -11116,6 +11117,8 @@ var Diagnostics = {
|
|
|
11116
11117
|
Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit: diag(9035, 1 /* Error */, "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035", "Add satisfies and a type assertion to this expression (satisfies T as T) to make the type explicit."),
|
|
11117
11118
|
Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
|
|
11118
11119
|
Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
|
|
11120
|
+
Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations: diag(9038, 1 /* Error */, "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038", "Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."),
|
|
11121
|
+
Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations: diag(9039, 1 /* Error */, "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039", "Type containing private name '{0}' can't be used with --isolatedDeclarations."),
|
|
11119
11122
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
11120
11123
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
11121
11124
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
@@ -49847,7 +49850,6 @@ function createTypeChecker(host) {
|
|
|
49847
49850
|
var syntacticNodeBuilder = createSyntacticTypeNodeBuilder(compilerOptions, {
|
|
49848
49851
|
isEntityNameVisible,
|
|
49849
49852
|
isExpandoFunctionDeclaration,
|
|
49850
|
-
isNonNarrowedBindableName,
|
|
49851
49853
|
getAllAccessorDeclarations: getAllAccessorDeclarationsForDeclaration,
|
|
49852
49854
|
requiresAddingImplicitUndefined,
|
|
49853
49855
|
isUndefinedIdentifierExpression(node) {
|
|
@@ -54022,6 +54024,7 @@ function createTypeChecker(host) {
|
|
|
54022
54024
|
return result;
|
|
54023
54025
|
}
|
|
54024
54026
|
}
|
|
54027
|
+
context.tracker.reportInferenceFallback(existing);
|
|
54025
54028
|
return void 0;
|
|
54026
54029
|
}
|
|
54027
54030
|
function symbolToNode(symbol, context, meaning) {
|
|
@@ -56057,6 +56060,9 @@ function createTypeChecker(host) {
|
|
|
56057
56060
|
symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
|
|
56058
56061
|
symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
|
|
56059
56062
|
) {
|
|
56063
|
+
if (symAtLocation !== unknownSymbol) {
|
|
56064
|
+
context.tracker.reportInferenceFallback(node);
|
|
56065
|
+
}
|
|
56060
56066
|
introducesError = true;
|
|
56061
56067
|
return { introducesError, node, sym };
|
|
56062
56068
|
}
|
|
@@ -56075,6 +56081,7 @@ function createTypeChecker(host) {
|
|
|
56075
56081
|
/*shouldComputeAliasesToMakeVisible*/
|
|
56076
56082
|
false
|
|
56077
56083
|
).accessibility !== 0 /* Accessible */) {
|
|
56084
|
+
context.tracker.reportInferenceFallback(node);
|
|
56078
56085
|
introducesError = true;
|
|
56079
56086
|
} else {
|
|
56080
56087
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
@@ -89769,22 +89776,6 @@ function createTypeChecker(host) {
|
|
|
89769
89776
|
}
|
|
89770
89777
|
return false;
|
|
89771
89778
|
}
|
|
89772
|
-
function isNonNarrowedBindableName(node) {
|
|
89773
|
-
if (!hasBindableName(node.parent)) {
|
|
89774
|
-
return false;
|
|
89775
|
-
}
|
|
89776
|
-
const expression = node.expression;
|
|
89777
|
-
if (!isEntityNameExpression(expression)) {
|
|
89778
|
-
return true;
|
|
89779
|
-
}
|
|
89780
|
-
const type = getTypeOfExpression(expression);
|
|
89781
|
-
const symbol = getSymbolAtLocation(expression);
|
|
89782
|
-
if (!symbol) {
|
|
89783
|
-
return false;
|
|
89784
|
-
}
|
|
89785
|
-
const declaredType = getTypeOfSymbol(symbol);
|
|
89786
|
-
return declaredType === type;
|
|
89787
|
-
}
|
|
89788
89779
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
89789
89780
|
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
89790
89781
|
type.symbol,
|
|
@@ -89903,7 +89894,6 @@ function createTypeChecker(host) {
|
|
|
89903
89894
|
return node && getExternalModuleFileFromDeclaration(node);
|
|
89904
89895
|
},
|
|
89905
89896
|
isLiteralConstDeclaration,
|
|
89906
|
-
isNonNarrowedBindableName,
|
|
89907
89897
|
isLateBound: (nodeIn) => {
|
|
89908
89898
|
const node = getParseTreeNode(nodeIn, isDeclaration);
|
|
89909
89899
|
const symbol = node && getSymbolOfDeclaration(node);
|
|
@@ -115005,7 +114995,7 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115005
114995
|
[260 /* VariableDeclaration */]: Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
115006
114996
|
[172 /* PropertyDeclaration */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
115007
114997
|
[171 /* PropertySignature */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
115008
|
-
[167 /* ComputedPropertyName */]: Diagnostics.
|
|
114998
|
+
[167 /* ComputedPropertyName */]: Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations,
|
|
115009
114999
|
[305 /* SpreadAssignment */]: Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations,
|
|
115010
115000
|
[304 /* ShorthandPropertyAssignment */]: Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations,
|
|
115011
115001
|
[209 /* ArrayLiteralExpression */]: Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations,
|
|
@@ -115018,6 +115008,9 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115018
115008
|
if (heritageClause) {
|
|
115019
115009
|
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
|
115020
115010
|
}
|
|
115011
|
+
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
|
115012
|
+
return createEntityInTypeNodeError(node);
|
|
115013
|
+
}
|
|
115021
115014
|
Debug.type(node);
|
|
115022
115015
|
switch (node.kind) {
|
|
115023
115016
|
case 177 /* GetAccessor */:
|
|
@@ -115053,8 +115046,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115053
115046
|
}
|
|
115054
115047
|
}
|
|
115055
115048
|
function findNearestDeclaration(node) {
|
|
115056
|
-
const result = findAncestor(node, (n) => isExportAssignment(n) ||
|
|
115057
|
-
return
|
|
115049
|
+
const result = findAncestor(node, (n) => isExportAssignment(n) || isStatement(n) || isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n));
|
|
115050
|
+
if (!result) return void 0;
|
|
115051
|
+
if (isExportAssignment(result)) return result;
|
|
115052
|
+
if (isReturnStatement(result)) {
|
|
115053
|
+
return findAncestor(result, (n) => isFunctionLikeDeclaration(n) && !isConstructorDeclaration(n));
|
|
115054
|
+
}
|
|
115055
|
+
return isStatement(result) ? void 0 : result;
|
|
115058
115056
|
}
|
|
115059
115057
|
function createAccessorTypeError(node) {
|
|
115060
115058
|
const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
|
|
@@ -115068,11 +115066,10 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115068
115066
|
}
|
|
115069
115067
|
return diag2;
|
|
115070
115068
|
}
|
|
115071
|
-
function
|
|
115072
|
-
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115069
|
+
function addParentDeclarationRelatedInfo(node, diag2) {
|
|
115073
115070
|
const parentDeclaration = findNearestDeclaration(node);
|
|
115074
115071
|
if (parentDeclaration) {
|
|
115075
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115072
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
115076
115073
|
parentDeclaration.name,
|
|
115077
115074
|
/*includeTrivia*/
|
|
115078
115075
|
false
|
|
@@ -115081,30 +115078,19 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115081
115078
|
}
|
|
115082
115079
|
return diag2;
|
|
115083
115080
|
}
|
|
115081
|
+
function createObjectLiteralError(node) {
|
|
115082
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115083
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115084
|
+
return diag2;
|
|
115085
|
+
}
|
|
115084
115086
|
function createArrayLiteralError(node) {
|
|
115085
115087
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115086
|
-
|
|
115087
|
-
if (parentDeclaration) {
|
|
115088
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115089
|
-
parentDeclaration.name,
|
|
115090
|
-
/*includeTrivia*/
|
|
115091
|
-
false
|
|
115092
|
-
);
|
|
115093
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
115094
|
-
}
|
|
115088
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115095
115089
|
return diag2;
|
|
115096
115090
|
}
|
|
115097
115091
|
function createReturnTypeError(node) {
|
|
115098
115092
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115099
|
-
|
|
115100
|
-
if (parentDeclaration) {
|
|
115101
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115102
|
-
parentDeclaration.name,
|
|
115103
|
-
/*includeTrivia*/
|
|
115104
|
-
false
|
|
115105
|
-
);
|
|
115106
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
115107
|
-
}
|
|
115093
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115108
115094
|
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
|
|
115109
115095
|
return diag2;
|
|
115110
115096
|
}
|
|
@@ -115142,11 +115128,20 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115142
115128
|
function createClassExpressionError(node) {
|
|
115143
115129
|
return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
|
|
115144
115130
|
}
|
|
115131
|
+
function createEntityInTypeNodeError(node) {
|
|
115132
|
+
const diag2 = createDiagnosticForNode(node, Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations, getTextOfNode(
|
|
115133
|
+
node,
|
|
115134
|
+
/*includeTrivia*/
|
|
115135
|
+
false
|
|
115136
|
+
));
|
|
115137
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115138
|
+
return diag2;
|
|
115139
|
+
}
|
|
115145
115140
|
function createExpressionError(node, diagnosticMessage) {
|
|
115146
115141
|
const parentDeclaration = findNearestDeclaration(node);
|
|
115147
115142
|
let diag2;
|
|
115148
115143
|
if (parentDeclaration) {
|
|
115149
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115144
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
115150
115145
|
parentDeclaration.name,
|
|
115151
115146
|
/*includeTrivia*/
|
|
115152
115147
|
false
|
|
@@ -115871,8 +115866,11 @@ function transformDeclarations(context) {
|
|
|
115871
115866
|
if (shouldStripInternal(input)) return;
|
|
115872
115867
|
if (isDeclaration(input)) {
|
|
115873
115868
|
if (isDeclarationAndNotVisible(input)) return;
|
|
115874
|
-
if (hasDynamicName(input)
|
|
115875
|
-
if (isolatedDeclarations && isClassDeclaration(input.parent)
|
|
115869
|
+
if (hasDynamicName(input)) {
|
|
115870
|
+
if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
|
|
115871
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
|
|
115872
|
+
}
|
|
115873
|
+
if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
|
|
115876
115874
|
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
|
|
115877
115875
|
}
|
|
115878
115876
|
if (!isEntityNameExpression(input.name.expression)) {
|
|
@@ -117816,7 +117814,6 @@ var notImplementedResolver = {
|
|
|
117816
117814
|
isArgumentsLocalBinding: notImplemented,
|
|
117817
117815
|
getExternalModuleFileFromDeclaration: notImplemented,
|
|
117818
117816
|
isLiteralConstDeclaration: notImplemented,
|
|
117819
|
-
isNonNarrowedBindableName: notImplemented,
|
|
117820
117817
|
getJsxFactoryEntity: notImplemented,
|
|
117821
117818
|
getJsxFragmentFactoryEntity: notImplemented,
|
|
117822
117819
|
isBindingCapturedByNode: notImplemented,
|
|
@@ -134240,7 +134237,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
134240
134237
|
expression,
|
|
134241
134238
|
/*includeBigInt*/
|
|
134242
134239
|
false
|
|
134243
|
-
)
|
|
134240
|
+
)) {
|
|
134244
134241
|
context.tracker.reportInferenceFallback(prop.name);
|
|
134245
134242
|
result = false;
|
|
134246
134243
|
}
|
|
@@ -134254,21 +134251,6 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
134254
134251
|
for (const prop of objectLiteral.properties) {
|
|
134255
134252
|
Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
|
|
134256
134253
|
const name = prop.name;
|
|
134257
|
-
if (prop.name.kind === 167 /* ComputedPropertyName */) {
|
|
134258
|
-
if (!resolver.isNonNarrowedBindableName(prop.name)) {
|
|
134259
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
134260
|
-
} else if (isEntityNameExpression(prop.name.expression)) {
|
|
134261
|
-
const visibilityResult = resolver.isEntityNameVisible(
|
|
134262
|
-
prop.name.expression,
|
|
134263
|
-
context.enclosingDeclaration,
|
|
134264
|
-
/*shouldComputeAliasToMakeVisible*/
|
|
134265
|
-
false
|
|
134266
|
-
);
|
|
134267
|
-
if (visibilityResult.accessibility !== 0 /* Accessible */) {
|
|
134268
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
134269
|
-
}
|
|
134270
|
-
}
|
|
134271
|
-
}
|
|
134272
134254
|
switch (prop.kind) {
|
|
134273
134255
|
case 174 /* MethodDeclaration */:
|
|
134274
134256
|
canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
|
|
@@ -149423,6 +149405,16 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
149423
149405
|
const sourceFile = getValidSourceFile(fileName);
|
|
149424
149406
|
return ts_InlayHints_exports.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences));
|
|
149425
149407
|
}
|
|
149408
|
+
function mapCode2(sourceFile, contents, focusLocations, formatOptions, preferences) {
|
|
149409
|
+
return ts_MapCode_exports.mapCode(
|
|
149410
|
+
syntaxTreeCache.getCurrentSourceFile(sourceFile),
|
|
149411
|
+
contents,
|
|
149412
|
+
focusLocations,
|
|
149413
|
+
host,
|
|
149414
|
+
ts_formatting_exports.getFormatContext(formatOptions, host),
|
|
149415
|
+
preferences
|
|
149416
|
+
);
|
|
149417
|
+
}
|
|
149426
149418
|
const ls = {
|
|
149427
149419
|
dispose,
|
|
149428
149420
|
cleanupSemanticCache,
|
|
@@ -149493,7 +149485,8 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
149493
149485
|
uncommentSelection,
|
|
149494
149486
|
provideInlayHints: provideInlayHints2,
|
|
149495
149487
|
getSupportedCodeFixes,
|
|
149496
|
-
getPasteEdits
|
|
149488
|
+
getPasteEdits,
|
|
149489
|
+
mapCode: mapCode2
|
|
149497
149490
|
};
|
|
149498
149491
|
switch (languageServiceMode) {
|
|
149499
149492
|
case 0 /* Semantic */:
|
|
@@ -158080,6 +158073,7 @@ var errorCodes47 = [
|
|
|
158080
158073
|
Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations.code,
|
|
158081
158074
|
Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations.code,
|
|
158082
158075
|
Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations.code,
|
|
158076
|
+
Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations.code,
|
|
158083
158077
|
Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations.code,
|
|
158084
158078
|
Diagnostics.Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations.code,
|
|
158085
158079
|
Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations.code,
|
|
@@ -158090,6 +158084,7 @@ var errorCodes47 = [
|
|
|
158090
158084
|
Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
|
|
158091
158085
|
Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
|
|
158092
158086
|
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
|
|
158087
|
+
Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations.code,
|
|
158093
158088
|
Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code
|
|
158094
158089
|
];
|
|
158095
158090
|
var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
|
|
@@ -158250,7 +158245,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
158250
158245
|
if (findAncestor(targetNode, isEnumMember)) {
|
|
158251
158246
|
return void 0;
|
|
158252
158247
|
}
|
|
158253
|
-
if (isExpressionTarget && findAncestor(targetNode, isHeritageClause)) {
|
|
158248
|
+
if (isExpressionTarget && (findAncestor(targetNode, isHeritageClause) || findAncestor(targetNode, isTypeNode))) {
|
|
158254
158249
|
return void 0;
|
|
158255
158250
|
}
|
|
158256
158251
|
if (isSpreadElement(targetNode)) {
|
|
@@ -170779,6 +170774,213 @@ function getRightHandSideOfAssignment(rightHandSide) {
|
|
|
170779
170774
|
}
|
|
170780
170775
|
}
|
|
170781
170776
|
|
|
170777
|
+
// src/services/_namespaces/ts.MapCode.ts
|
|
170778
|
+
var ts_MapCode_exports = {};
|
|
170779
|
+
__export(ts_MapCode_exports, {
|
|
170780
|
+
mapCode: () => mapCode
|
|
170781
|
+
});
|
|
170782
|
+
|
|
170783
|
+
// src/services/mapCode.ts
|
|
170784
|
+
function mapCode(sourceFile, contents, focusLocations, host, formatContext, preferences) {
|
|
170785
|
+
return ts_textChanges_exports.ChangeTracker.with(
|
|
170786
|
+
{ host, formatContext, preferences },
|
|
170787
|
+
(changeTracker) => {
|
|
170788
|
+
const parsed = contents.map((c) => parse(sourceFile, c));
|
|
170789
|
+
const flattenedLocations = focusLocations && flatten(focusLocations);
|
|
170790
|
+
for (const nodes of parsed) {
|
|
170791
|
+
placeNodeGroup(
|
|
170792
|
+
sourceFile,
|
|
170793
|
+
changeTracker,
|
|
170794
|
+
nodes,
|
|
170795
|
+
flattenedLocations
|
|
170796
|
+
);
|
|
170797
|
+
}
|
|
170798
|
+
}
|
|
170799
|
+
);
|
|
170800
|
+
}
|
|
170801
|
+
function parse(sourceFile, content) {
|
|
170802
|
+
const nodeKinds = [
|
|
170803
|
+
{
|
|
170804
|
+
parse: () => createSourceFile(
|
|
170805
|
+
"__mapcode_content_nodes.ts",
|
|
170806
|
+
content,
|
|
170807
|
+
sourceFile.languageVersion,
|
|
170808
|
+
/*setParentNodes*/
|
|
170809
|
+
true,
|
|
170810
|
+
sourceFile.scriptKind
|
|
170811
|
+
),
|
|
170812
|
+
body: (sf) => sf.statements
|
|
170813
|
+
},
|
|
170814
|
+
{
|
|
170815
|
+
parse: () => createSourceFile(
|
|
170816
|
+
"__mapcode_class_content_nodes.ts",
|
|
170817
|
+
`class __class {
|
|
170818
|
+
${content}
|
|
170819
|
+
}`,
|
|
170820
|
+
sourceFile.languageVersion,
|
|
170821
|
+
/*setParentNodes*/
|
|
170822
|
+
true,
|
|
170823
|
+
sourceFile.scriptKind
|
|
170824
|
+
),
|
|
170825
|
+
body: (cw) => cw.statements[0].members
|
|
170826
|
+
}
|
|
170827
|
+
];
|
|
170828
|
+
const parsedNodes = [];
|
|
170829
|
+
for (const { parse: parse2, body: body2 } of nodeKinds) {
|
|
170830
|
+
const sourceFile2 = parse2();
|
|
170831
|
+
const bod = body2(sourceFile2);
|
|
170832
|
+
if (bod.length && sourceFile2.parseDiagnostics.length === 0) {
|
|
170833
|
+
return bod;
|
|
170834
|
+
} else if (bod.length) {
|
|
170835
|
+
parsedNodes.push({ sourceFile: sourceFile2, body: bod });
|
|
170836
|
+
}
|
|
170837
|
+
}
|
|
170838
|
+
const { body } = parsedNodes.sort(
|
|
170839
|
+
(a, b) => a.sourceFile.parseDiagnostics.length - b.sourceFile.parseDiagnostics.length
|
|
170840
|
+
)[0];
|
|
170841
|
+
return body;
|
|
170842
|
+
}
|
|
170843
|
+
function placeNodeGroup(originalFile, changeTracker, changes, focusLocations) {
|
|
170844
|
+
if (isClassElement(changes[0]) || isTypeElement(changes[0])) {
|
|
170845
|
+
placeClassNodeGroup(
|
|
170846
|
+
originalFile,
|
|
170847
|
+
changeTracker,
|
|
170848
|
+
changes,
|
|
170849
|
+
focusLocations
|
|
170850
|
+
);
|
|
170851
|
+
} else {
|
|
170852
|
+
placeStatements(
|
|
170853
|
+
originalFile,
|
|
170854
|
+
changeTracker,
|
|
170855
|
+
changes,
|
|
170856
|
+
focusLocations
|
|
170857
|
+
);
|
|
170858
|
+
}
|
|
170859
|
+
}
|
|
170860
|
+
function placeClassNodeGroup(originalFile, changeTracker, changes, focusLocations) {
|
|
170861
|
+
let classOrInterface;
|
|
170862
|
+
if (!focusLocations || !focusLocations.length) {
|
|
170863
|
+
classOrInterface = find(originalFile.statements, or(isClassLike, isInterfaceDeclaration));
|
|
170864
|
+
} else {
|
|
170865
|
+
classOrInterface = forEach(focusLocations, (location) => findAncestor(
|
|
170866
|
+
getTokenAtPosition(originalFile, location.start),
|
|
170867
|
+
or(isClassLike, isInterfaceDeclaration)
|
|
170868
|
+
));
|
|
170869
|
+
}
|
|
170870
|
+
if (!classOrInterface) {
|
|
170871
|
+
return;
|
|
170872
|
+
}
|
|
170873
|
+
const firstMatch = classOrInterface.members.find((member) => changes.some((change) => matchNode(change, member)));
|
|
170874
|
+
if (firstMatch) {
|
|
170875
|
+
const lastMatch = findLast(
|
|
170876
|
+
classOrInterface.members,
|
|
170877
|
+
(member) => changes.some((change) => matchNode(change, member))
|
|
170878
|
+
);
|
|
170879
|
+
forEach(changes, wipeNode);
|
|
170880
|
+
changeTracker.replaceNodeRangeWithNodes(
|
|
170881
|
+
originalFile,
|
|
170882
|
+
firstMatch,
|
|
170883
|
+
lastMatch,
|
|
170884
|
+
changes
|
|
170885
|
+
);
|
|
170886
|
+
return;
|
|
170887
|
+
}
|
|
170888
|
+
forEach(changes, wipeNode);
|
|
170889
|
+
changeTracker.insertNodesAfter(
|
|
170890
|
+
originalFile,
|
|
170891
|
+
classOrInterface.members[classOrInterface.members.length - 1],
|
|
170892
|
+
changes
|
|
170893
|
+
);
|
|
170894
|
+
}
|
|
170895
|
+
function placeStatements(originalFile, changeTracker, changes, focusLocations) {
|
|
170896
|
+
if (!(focusLocations == null ? void 0 : focusLocations.length)) {
|
|
170897
|
+
changeTracker.insertNodesAtEndOfFile(
|
|
170898
|
+
originalFile,
|
|
170899
|
+
changes,
|
|
170900
|
+
/*blankLineBetween*/
|
|
170901
|
+
false
|
|
170902
|
+
);
|
|
170903
|
+
return;
|
|
170904
|
+
}
|
|
170905
|
+
for (const location of focusLocations) {
|
|
170906
|
+
const scope = findAncestor(
|
|
170907
|
+
getTokenAtPosition(originalFile, location.start),
|
|
170908
|
+
(block) => or(isBlock, isSourceFile)(block) && some(block.statements, (origStmt) => changes.some((newStmt) => matchNode(newStmt, origStmt)))
|
|
170909
|
+
);
|
|
170910
|
+
if (scope) {
|
|
170911
|
+
const start = scope.statements.find((stmt) => changes.some((node) => matchNode(node, stmt)));
|
|
170912
|
+
if (start) {
|
|
170913
|
+
const end = findLast(scope.statements, (stmt) => changes.some((node) => matchNode(node, stmt)));
|
|
170914
|
+
forEach(changes, wipeNode);
|
|
170915
|
+
changeTracker.replaceNodeRangeWithNodes(
|
|
170916
|
+
originalFile,
|
|
170917
|
+
start,
|
|
170918
|
+
end,
|
|
170919
|
+
changes
|
|
170920
|
+
);
|
|
170921
|
+
return;
|
|
170922
|
+
}
|
|
170923
|
+
}
|
|
170924
|
+
}
|
|
170925
|
+
let scopeStatements = originalFile.statements;
|
|
170926
|
+
for (const location of focusLocations) {
|
|
170927
|
+
const block = findAncestor(
|
|
170928
|
+
getTokenAtPosition(originalFile, location.start),
|
|
170929
|
+
isBlock
|
|
170930
|
+
);
|
|
170931
|
+
if (block) {
|
|
170932
|
+
scopeStatements = block.statements;
|
|
170933
|
+
break;
|
|
170934
|
+
}
|
|
170935
|
+
}
|
|
170936
|
+
forEach(changes, wipeNode);
|
|
170937
|
+
changeTracker.insertNodesAfter(
|
|
170938
|
+
originalFile,
|
|
170939
|
+
scopeStatements[scopeStatements.length - 1],
|
|
170940
|
+
changes
|
|
170941
|
+
);
|
|
170942
|
+
}
|
|
170943
|
+
function matchNode(a, b) {
|
|
170944
|
+
var _a, _b, _c, _d, _e, _f;
|
|
170945
|
+
if (a.kind !== b.kind) {
|
|
170946
|
+
return false;
|
|
170947
|
+
}
|
|
170948
|
+
if (a.kind === 176 /* Constructor */) {
|
|
170949
|
+
return a.kind === b.kind;
|
|
170950
|
+
}
|
|
170951
|
+
if (isNamedDeclaration(a) && isNamedDeclaration(b)) {
|
|
170952
|
+
return a.name.getText() === b.name.getText();
|
|
170953
|
+
}
|
|
170954
|
+
if (isIfStatement(a) && isIfStatement(b)) {
|
|
170955
|
+
return a.expression.getText() === b.expression.getText();
|
|
170956
|
+
}
|
|
170957
|
+
if (isWhileStatement(a) && isWhileStatement(b)) {
|
|
170958
|
+
return a.expression.getText() === b.expression.getText();
|
|
170959
|
+
}
|
|
170960
|
+
if (isForStatement(a) && isForStatement(b)) {
|
|
170961
|
+
return ((_a = a.initializer) == null ? void 0 : _a.getText()) === ((_b = b.initializer) == null ? void 0 : _b.getText()) && ((_c = a.incrementor) == null ? void 0 : _c.getText()) === ((_d = b.incrementor) == null ? void 0 : _d.getText()) && ((_e = a.condition) == null ? void 0 : _e.getText()) === ((_f = b.condition) == null ? void 0 : _f.getText());
|
|
170962
|
+
}
|
|
170963
|
+
if (isForInOrOfStatement(a) && isForInOrOfStatement(b)) {
|
|
170964
|
+
return a.expression.getText() === b.expression.getText() && a.initializer.getText() === b.initializer.getText();
|
|
170965
|
+
}
|
|
170966
|
+
if (isLabeledStatement(a) && isLabeledStatement(b)) {
|
|
170967
|
+
return a.label.getText() === b.label.getText();
|
|
170968
|
+
}
|
|
170969
|
+
if (a.getText() === b.getText()) {
|
|
170970
|
+
return true;
|
|
170971
|
+
}
|
|
170972
|
+
return false;
|
|
170973
|
+
}
|
|
170974
|
+
function wipeNode(node) {
|
|
170975
|
+
resetNodePositions(node);
|
|
170976
|
+
node.parent = void 0;
|
|
170977
|
+
}
|
|
170978
|
+
function resetNodePositions(node) {
|
|
170979
|
+
node.pos = -1;
|
|
170980
|
+
node.end = -1;
|
|
170981
|
+
node.forEachChild(resetNodePositions);
|
|
170982
|
+
}
|
|
170983
|
+
|
|
170782
170984
|
// src/services/_namespaces/ts.OrganizeImports.ts
|
|
170783
170985
|
var ts_OrganizeImports_exports = {};
|
|
170784
170986
|
__export(ts_OrganizeImports_exports, {
|
|
@@ -177566,6 +177768,7 @@ __export(ts_exports2, {
|
|
|
177566
177768
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
177567
177769
|
ListFormat: () => ListFormat,
|
|
177568
177770
|
LogLevel: () => LogLevel,
|
|
177771
|
+
MapCode: () => ts_MapCode_exports,
|
|
177569
177772
|
MemberOverrideStatus: () => MemberOverrideStatus,
|
|
177570
177773
|
ModifierFlags: () => ModifierFlags,
|
|
177571
177774
|
ModuleDetectionKind: () => ModuleDetectionKind,
|
|
@@ -180747,6 +180950,7 @@ var CommandTypes = /* @__PURE__ */ ((CommandTypes2) => {
|
|
|
180747
180950
|
CommandTypes2["ProvideCallHierarchyOutgoingCalls"] = "provideCallHierarchyOutgoingCalls";
|
|
180748
180951
|
CommandTypes2["ProvideInlayHints"] = "provideInlayHints";
|
|
180749
180952
|
CommandTypes2["WatchChange"] = "watchChange";
|
|
180953
|
+
CommandTypes2["MapCode"] = "mapCode";
|
|
180750
180954
|
return CommandTypes2;
|
|
180751
180955
|
})(CommandTypes || {});
|
|
180752
180956
|
var WatchFileKind2 = /* @__PURE__ */ ((WatchFileKind3) => {
|
|
@@ -188687,6 +188891,9 @@ var Session3 = class _Session {
|
|
|
188687
188891
|
},
|
|
188688
188892
|
["provideInlayHints" /* ProvideInlayHints */]: (request) => {
|
|
188689
188893
|
return this.requiredResponse(this.provideInlayHints(request.arguments));
|
|
188894
|
+
},
|
|
188895
|
+
["mapCode" /* MapCode */]: (request) => {
|
|
188896
|
+
return this.requiredResponse(this.mapCode(request.arguments));
|
|
188690
188897
|
}
|
|
188691
188898
|
}));
|
|
188692
188899
|
this.host = opts.host;
|
|
@@ -189549,6 +189756,25 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
189549
189756
|
};
|
|
189550
189757
|
});
|
|
189551
189758
|
}
|
|
189759
|
+
mapCode(args) {
|
|
189760
|
+
var _a;
|
|
189761
|
+
const formatOptions = this.getHostFormatOptions();
|
|
189762
|
+
const preferences = this.getHostPreferences();
|
|
189763
|
+
const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args);
|
|
189764
|
+
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
189765
|
+
const focusLocations = (_a = args.mapping.focusLocations) == null ? void 0 : _a.map((spans) => {
|
|
189766
|
+
return spans.map((loc) => {
|
|
189767
|
+
const start = scriptInfo.lineOffsetToPosition(loc.start.line, loc.start.offset);
|
|
189768
|
+
const end = scriptInfo.lineOffsetToPosition(loc.end.line, loc.end.offset);
|
|
189769
|
+
return {
|
|
189770
|
+
start,
|
|
189771
|
+
length: end - start
|
|
189772
|
+
};
|
|
189773
|
+
});
|
|
189774
|
+
});
|
|
189775
|
+
const changes = languageService.mapCode(file, args.mapping.contents, focusLocations, formatOptions, preferences);
|
|
189776
|
+
return this.mapTextChangesToCodeEdits(changes);
|
|
189777
|
+
}
|
|
189552
189778
|
setCompilerOptionsForInferredProjects(args) {
|
|
189553
189779
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
189554
189780
|
}
|
|
@@ -191973,6 +192199,7 @@ if (typeof console !== "undefined") {
|
|
|
191973
192199
|
LexicalEnvironmentFlags,
|
|
191974
192200
|
ListFormat,
|
|
191975
192201
|
LogLevel,
|
|
192202
|
+
MapCode,
|
|
191976
192203
|
MemberOverrideStatus,
|
|
191977
192204
|
ModifierFlags,
|
|
191978
192205
|
ModuleDetectionKind,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.5.0-dev.
|
|
5
|
+
"version": "5.5.0-dev.20240523",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"!**/.gitattributes"
|
|
40
40
|
],
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@dprint/formatter": "^0.3.0",
|
|
43
|
+
"@dprint/typescript": "0.90.5",
|
|
42
44
|
"@esfx/canceltoken": "^1.0.0",
|
|
43
45
|
"@octokit/rest": "^20.1.1",
|
|
44
46
|
"@types/chai": "^4.3.16",
|
|
@@ -110,5 +112,5 @@
|
|
|
110
112
|
"node": "20.1.0",
|
|
111
113
|
"npm": "8.19.4"
|
|
112
114
|
},
|
|
113
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "ddf43cd0e0091057254b1fcfcaf880140dfb7ea1"
|
|
114
116
|
}
|