@typescript-deploys/pr-build 5.2.0-pr-54546-4 → 5.2.0-pr-54281-18
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/lib.es2023.array.d.ts +36 -618
- package/lib/tsc.js +37 -127
- package/lib/tsserver.js +242 -285
- package/lib/tsserverlibrary.js +260 -291
- package/lib/typescript.js +260 -288
- package/lib/typingsInstaller.js +10 -14
- package/package.json +2 -3
package/lib/tsserver.js
CHANGED
|
@@ -919,11 +919,8 @@ __export(server_exports, {
|
|
|
919
919
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
920
920
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
921
921
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
922
|
-
getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
|
|
923
922
|
getOutputExtension: () => getOutputExtension,
|
|
924
923
|
getOutputFileNames: () => getOutputFileNames,
|
|
925
|
-
getOutputJSFileName: () => getOutputJSFileName,
|
|
926
|
-
getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
|
|
927
924
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
928
925
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
929
926
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -2307,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2307
2304
|
|
|
2308
2305
|
// src/compiler/corePublic.ts
|
|
2309
2306
|
var versionMajorMinor = "5.2";
|
|
2310
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2307
|
+
var version = `${versionMajorMinor}.0-insiders.20230607`;
|
|
2311
2308
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2312
2309
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2313
2310
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9497,6 +9494,8 @@ var Diagnostics = {
|
|
|
9497
9494
|
Class_constructor_may_not_be_a_generator: diag(1368, 1 /* Error */, "Class_constructor_may_not_be_a_generator_1368", "Class constructor may not be a generator."),
|
|
9498
9495
|
Did_you_mean_0: diag(1369, 3 /* Message */, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
|
|
9499
9496
|
This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error: diag(1371, 1 /* Error */, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371", "This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'."),
|
|
9497
|
+
Convert_to_type_only_import: diag(1373, 3 /* Message */, "Convert_to_type_only_import_1373", "Convert to type-only import"),
|
|
9498
|
+
Convert_all_imports_not_used_as_a_value_to_type_only_imports: diag(1374, 3 /* Message */, "Convert_all_imports_not_used_as_a_value_to_type_only_imports_1374", "Convert all imports not used as a value to type-only imports"),
|
|
9500
9499
|
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, 1 /* Error */, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
9501
9500
|
_0_was_imported_here: diag(1376, 3 /* Message */, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
9502
9501
|
_0_was_exported_here: diag(1377, 3 /* Message */, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
@@ -9649,7 +9648,6 @@ var Diagnostics = {
|
|
|
9649
9648
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
9650
9649
|
Add_extends_constraint: diag(2211, 3 /* Message */, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
9651
9650
|
Add_extends_constraint_to_all_type_parameters: diag(2212, 3 /* Message */, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
|
|
9652
|
-
The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2213, 1 /* Error */, "The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supp_2213", "The project root is ambiguous, but is required to determine the module format of output '.js' files. Supply the `rootDir` compiler option to disambiguate."),
|
|
9653
9651
|
Duplicate_identifier_0: diag(2300, 1 /* Error */, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
9654
9652
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, 1 /* Error */, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
9655
9653
|
Static_members_cannot_reference_class_type_parameters: diag(2302, 1 /* Error */, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -10703,8 +10701,6 @@ var Diagnostics = {
|
|
|
10703
10701
|
Resolved_under_condition_0: diag(6414, 3 /* Message */, "Resolved_under_condition_0_6414", "Resolved under condition '{0}'."),
|
|
10704
10702
|
Failed_to_resolve_under_condition_0: diag(6415, 3 /* Message */, "Failed_to_resolve_under_condition_0_6415", "Failed to resolve under condition '{0}'."),
|
|
10705
10703
|
Exiting_conditional_exports: diag(6416, 3 /* Message */, "Exiting_conditional_exports_6416", "Exiting conditional exports."),
|
|
10706
|
-
Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0: diag(6417, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0_6417", "Searching all ancestor node_modules directories for preferred extensions: {0}."),
|
|
10707
|
-
Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0: diag(6418, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0_6418", "Searching all ancestor node_modules directories for fallback extensions: {0}."),
|
|
10708
10704
|
The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, 3 /* Message */, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
|
|
10709
10705
|
The_expected_type_comes_from_this_index_signature: diag(6501, 3 /* Message */, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
|
|
10710
10706
|
The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, 3 /* Message */, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
|
|
@@ -11217,9 +11213,9 @@ var Diagnostics = {
|
|
|
11217
11213
|
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
11218
11214
|
Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
|
|
11219
11215
|
Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11216
|
+
Inline_variable: diag(95180, 3 /* Message */, "Inline_variable_95180", "Inline variable"),
|
|
11217
|
+
Could_not_find_variable_to_inline: diag(95181, 3 /* Message */, "Could_not_find_variable_to_inline_95181", "Could not find variable to inline."),
|
|
11218
|
+
Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined: diag(95182, 3 /* Message */, "Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined_95182", "Variables that share a name with a type or namespace in the same scope cannot be inlined."),
|
|
11223
11219
|
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."),
|
|
11224
11220
|
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'."),
|
|
11225
11221
|
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?"),
|
|
@@ -43087,13 +43083,11 @@ function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName,
|
|
|
43087
43083
|
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
43088
43084
|
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
43089
43085
|
if (priorityExtensions) {
|
|
43090
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0, formatExtensions(priorityExtensions));
|
|
43091
43086
|
const result = lookup(priorityExtensions);
|
|
43092
43087
|
if (result)
|
|
43093
43088
|
return result;
|
|
43094
43089
|
}
|
|
43095
43090
|
if (secondaryExtensions && !typesScopeOnly) {
|
|
43096
|
-
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0, formatExtensions(secondaryExtensions));
|
|
43097
43091
|
return lookup(secondaryExtensions);
|
|
43098
43092
|
}
|
|
43099
43093
|
function lookup(extensions2) {
|
|
@@ -47313,11 +47307,10 @@ var CheckMode = /* @__PURE__ */ ((CheckMode3) => {
|
|
|
47313
47307
|
CheckMode3[CheckMode3["Inferential"] = 2] = "Inferential";
|
|
47314
47308
|
CheckMode3[CheckMode3["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47315
47309
|
CheckMode3[CheckMode3["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47316
|
-
CheckMode3[CheckMode3["
|
|
47317
|
-
CheckMode3[CheckMode3["
|
|
47318
|
-
CheckMode3[CheckMode3["
|
|
47319
|
-
CheckMode3[CheckMode3["
|
|
47320
|
-
CheckMode3[CheckMode3["TypeOnly"] = 256] = "TypeOnly";
|
|
47310
|
+
CheckMode3[CheckMode3["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47311
|
+
CheckMode3[CheckMode3["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47312
|
+
CheckMode3[CheckMode3["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47313
|
+
CheckMode3[CheckMode3["TypeOnly"] = 128] = "TypeOnly";
|
|
47321
47314
|
return CheckMode3;
|
|
47322
47315
|
})(CheckMode || {});
|
|
47323
47316
|
var SignatureCheckMode = /* @__PURE__ */ ((SignatureCheckMode3) => {
|
|
@@ -47597,9 +47590,9 @@ function createTypeChecker(host) {
|
|
|
47597
47590
|
candidatesOutArray,
|
|
47598
47591
|
/*argumentCount*/
|
|
47599
47592
|
void 0,
|
|
47600
|
-
|
|
47593
|
+
32 /* IsForStringLiteralArgumentCompletions */
|
|
47601
47594
|
)),
|
|
47602
|
-
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount,
|
|
47595
|
+
getResolvedSignatureForSignatureHelp: (node, candidatesOutArray, argumentCount) => runWithoutResolvedSignatureCaching(node, () => getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */)),
|
|
47603
47596
|
getExpandedParameters,
|
|
47604
47597
|
hasEffectiveRestParameter,
|
|
47605
47598
|
containsArgumentsReference,
|
|
@@ -55554,7 +55547,7 @@ function createTypeChecker(host) {
|
|
|
55554
55547
|
return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : void 0;
|
|
55555
55548
|
}
|
|
55556
55549
|
function getTypeForBindingElement(declaration) {
|
|
55557
|
-
const checkMode = declaration.dotDotDotToken ?
|
|
55550
|
+
const checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55558
55551
|
const parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55559
55552
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55560
55553
|
}
|
|
@@ -62752,10 +62745,7 @@ function createTypeChecker(host) {
|
|
|
62752
62745
|
const newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62753
62746
|
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62754
62747
|
if (result.flags & 138117121 /* ObjectFlagsType */ && !(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62755
|
-
|
|
62756
|
-
if (!(result.objectFlags & 524288 /* CouldContainTypeVariablesComputed */)) {
|
|
62757
|
-
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (resultCouldContainTypeVariables ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
62758
|
-
}
|
|
62748
|
+
result.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (some(typeArguments, couldContainTypeVariables) ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
62759
62749
|
}
|
|
62760
62750
|
target.instantiations.set(id, result);
|
|
62761
62751
|
}
|
|
@@ -69378,8 +69368,6 @@ function createTypeChecker(host) {
|
|
|
69378
69368
|
}
|
|
69379
69369
|
function isConstantReference(node) {
|
|
69380
69370
|
switch (node.kind) {
|
|
69381
|
-
case 110 /* ThisKeyword */:
|
|
69382
|
-
return true;
|
|
69383
69371
|
case 80 /* Identifier */:
|
|
69384
69372
|
if (!isThisInTypeQuery(node)) {
|
|
69385
69373
|
const symbol = getResolvedSymbol(node);
|
|
@@ -70454,7 +70442,7 @@ function createTypeChecker(host) {
|
|
|
70454
70442
|
return type.flags & 2097152 /* Intersection */ ? some(type.types, isGenericTypeWithoutNullableConstraint) : !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
70455
70443
|
}
|
|
70456
70444
|
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
70457
|
-
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode &
|
|
70445
|
+
const contextualType = (isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node)) && !((isJsxOpeningElement(node.parent) || isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 /* RestBindingElement */ ? getContextualType2(node, 8 /* SkipBindingPatterns */) : getContextualType2(
|
|
70458
70446
|
node,
|
|
70459
70447
|
/*contextFlags*/
|
|
70460
70448
|
void 0
|
|
@@ -71211,7 +71199,7 @@ function createTypeChecker(host) {
|
|
|
71211
71199
|
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
71212
71200
|
const parent2 = declaration.parent.parent;
|
|
71213
71201
|
const name = declaration.propertyName || declaration.name;
|
|
71214
|
-
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ?
|
|
71202
|
+
const parentType = getContextualTypeForVariableLikeDeclaration(parent2, contextFlags) || parent2.kind !== 207 /* BindingElement */ && parent2.initializer && checkDeclarationInitializer(parent2, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71215
71203
|
if (!parentType || isBindingPattern(name) || isComputedNonLiteralName(name))
|
|
71216
71204
|
return void 0;
|
|
71217
71205
|
if (parent2.name.kind === 206 /* ArrayBindingPattern */) {
|
|
@@ -72260,9 +72248,7 @@ function createTypeChecker(host) {
|
|
|
72260
72248
|
elementTypes.push(undefinedOrMissingType);
|
|
72261
72249
|
elementFlags.push(2 /* Optional */);
|
|
72262
72250
|
} else {
|
|
72263
|
-
const
|
|
72264
|
-
const elementCheckMode = (checkMode || 0 /* Normal */) | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72265
|
-
const type = checkExpressionForMutableLocation(e, elementCheckMode, forceTuple);
|
|
72251
|
+
const type = checkExpressionForMutableLocation(e, checkMode, forceTuple);
|
|
72266
72252
|
elementTypes.push(addOptionality(
|
|
72267
72253
|
type,
|
|
72268
72254
|
/*isProperty*/
|
|
@@ -72270,7 +72256,7 @@ function createTypeChecker(host) {
|
|
|
72270
72256
|
hasOmittedExpression
|
|
72271
72257
|
));
|
|
72272
72258
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72273
|
-
if (
|
|
72259
|
+
if (inTupleContext && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
72274
72260
|
const inferenceContext = getInferenceContext(node);
|
|
72275
72261
|
Debug.assert(inferenceContext);
|
|
72276
72262
|
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
@@ -72411,13 +72397,11 @@ function createTypeChecker(host) {
|
|
|
72411
72397
|
let member = getSymbolOfDeclaration(memberDecl);
|
|
72412
72398
|
const computedNameType = memberDecl.name && memberDecl.name.kind === 166 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : void 0;
|
|
72413
72399
|
if (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 303 /* ShorthandPropertyAssignment */ || isObjectLiteralMethod(memberDecl)) {
|
|
72414
|
-
|
|
72415
|
-
const propCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72416
|
-
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, propCheckMode) : (
|
|
72400
|
+
let type = memberDecl.kind === 302 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : (
|
|
72417
72401
|
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
|
|
72418
72402
|
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
|
|
72419
72403
|
// we don't want to say "could not find 'a'".
|
|
72420
|
-
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name,
|
|
72404
|
+
memberDecl.kind === 303 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode)
|
|
72421
72405
|
);
|
|
72422
72406
|
if (isInJavascript) {
|
|
72423
72407
|
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
|
|
@@ -72461,7 +72445,7 @@ function createTypeChecker(host) {
|
|
|
72461
72445
|
prop.links.target = member;
|
|
72462
72446
|
member = prop;
|
|
72463
72447
|
allPropertiesTable == null ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
72464
|
-
if (
|
|
72448
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && (memberDecl.kind === 302 /* PropertyAssignment */ || memberDecl.kind === 173 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
72465
72449
|
const inferenceContext = getInferenceContext(node);
|
|
72466
72450
|
Debug.assert(inferenceContext);
|
|
72467
72451
|
const inferenceNode = memberDecl.kind === 302 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
@@ -72634,9 +72618,7 @@ function createTypeChecker(host) {
|
|
|
72634
72618
|
for (const attributeDecl of attributes.properties) {
|
|
72635
72619
|
const member = attributeDecl.symbol;
|
|
72636
72620
|
if (isJsxAttribute(attributeDecl)) {
|
|
72637
|
-
const
|
|
72638
|
-
const attributeCheckMode = checkMode | (shouldAddAsIntraExpressionInferenceSite ? 16 /* SkipAddingIntraExpressionSites */ : 0);
|
|
72639
|
-
const exprType = checkJsxAttribute(attributeDecl, attributeCheckMode);
|
|
72621
|
+
const exprType = checkJsxAttribute(attributeDecl, checkMode);
|
|
72640
72622
|
objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
|
|
72641
72623
|
const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
|
|
72642
72624
|
attributeSymbol.declarations = member.declarations;
|
|
@@ -72657,7 +72639,7 @@ function createTypeChecker(host) {
|
|
|
72657
72639
|
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
|
|
72658
72640
|
}
|
|
72659
72641
|
}
|
|
72660
|
-
if (
|
|
72642
|
+
if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
|
|
72661
72643
|
const inferenceContext = getInferenceContext(attributes);
|
|
72662
72644
|
Debug.assert(inferenceContext);
|
|
72663
72645
|
const inferenceNode = attributeDecl.initializer.expression;
|
|
@@ -74275,7 +74257,7 @@ function createTypeChecker(host) {
|
|
|
74275
74257
|
}
|
|
74276
74258
|
for (let i = 0; i < argCount; i++) {
|
|
74277
74259
|
const arg = args[i];
|
|
74278
|
-
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode &
|
|
74260
|
+
if (arg.kind !== 231 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74279
74261
|
const paramType = getTypeAtPosition(signature, i);
|
|
74280
74262
|
if (couldContainTypeVariables(paramType)) {
|
|
74281
74263
|
const argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
@@ -74888,12 +74870,12 @@ function createTypeChecker(host) {
|
|
|
74888
74870
|
const args = getEffectiveCallArguments(node);
|
|
74889
74871
|
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
|
|
74890
74872
|
let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
|
|
74891
|
-
argCheckMode |= checkMode &
|
|
74873
|
+
argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
74892
74874
|
let candidatesForArgumentError;
|
|
74893
74875
|
let candidateForArgumentArityError;
|
|
74894
74876
|
let candidateForTypeArgumentError;
|
|
74895
74877
|
let result;
|
|
74896
|
-
const signatureHelpTrailingComma = !!(checkMode &
|
|
74878
|
+
const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 212 /* CallExpression */ && node.arguments.hasTrailingComma;
|
|
74897
74879
|
if (candidates.length > 1) {
|
|
74898
74880
|
result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
74899
74881
|
}
|
|
@@ -75112,7 +75094,7 @@ function createTypeChecker(host) {
|
|
|
75112
75094
|
continue;
|
|
75113
75095
|
}
|
|
75114
75096
|
if (argCheckMode) {
|
|
75115
|
-
argCheckMode = checkMode &
|
|
75097
|
+
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
75116
75098
|
if (inferenceContext) {
|
|
75117
75099
|
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
75118
75100
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
@@ -78190,7 +78172,7 @@ function createTypeChecker(host) {
|
|
|
78190
78172
|
case 36 /* ExclamationEqualsToken */:
|
|
78191
78173
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
78192
78174
|
case 38 /* ExclamationEqualsEqualsToken */:
|
|
78193
|
-
if (!(checkMode && checkMode &
|
|
78175
|
+
if (!(checkMode && checkMode & 128 /* TypeOnly */)) {
|
|
78194
78176
|
if (isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) {
|
|
78195
78177
|
const eqType = operator === 35 /* EqualsEqualsToken */ || operator === 37 /* EqualsEqualsEqualsToken */;
|
|
78196
78178
|
error(errorNode, Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true");
|
|
@@ -78849,7 +78831,7 @@ function createTypeChecker(host) {
|
|
|
78849
78831
|
}
|
|
78850
78832
|
}
|
|
78851
78833
|
const startInvocationCount = flowInvocationCount;
|
|
78852
|
-
const type = checkExpression(node,
|
|
78834
|
+
const type = checkExpression(node, 128 /* TypeOnly */);
|
|
78853
78835
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78854
78836
|
const cache = flowTypeCache || (flowTypeCache = []);
|
|
78855
78837
|
cache[getNodeId(node)] = type;
|
|
@@ -81320,7 +81302,7 @@ function createTypeChecker(host) {
|
|
|
81320
81302
|
checkComputedPropertyName(node.propertyName);
|
|
81321
81303
|
}
|
|
81322
81304
|
const parent2 = node.parent.parent;
|
|
81323
|
-
const parentCheckMode = node.dotDotDotToken ?
|
|
81305
|
+
const parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81324
81306
|
const parentType = getTypeForBindingElementParent(parent2, parentCheckMode);
|
|
81325
81307
|
const name = node.propertyName || node.name;
|
|
81326
81308
|
if (parentType && !isBindingPattern(name)) {
|
|
@@ -100242,7 +100224,7 @@ function transformJsx(context) {
|
|
|
100242
100224
|
continue;
|
|
100243
100225
|
}
|
|
100244
100226
|
finishObjectLiteralIfNeeded();
|
|
100245
|
-
expressions.push(
|
|
100227
|
+
expressions.push(attr.expression);
|
|
100246
100228
|
continue;
|
|
100247
100229
|
}
|
|
100248
100230
|
properties.push(transformJsxAttributeToObjectLiteralElement(attr));
|
|
@@ -111987,15 +111969,6 @@ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, get
|
|
|
111987
111969
|
getDeclarationEmitExtensionForPath(inputFileName)
|
|
111988
111970
|
);
|
|
111989
111971
|
}
|
|
111990
|
-
function getOutputDeclarationFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
|
|
111991
|
-
const directory = options.declarationDir || options.outDir ? getNormalizedAbsolutePath(options.declarationDir || options.outDir, currentDirectory) : void 0;
|
|
111992
|
-
const outputPathWithoutChangedExtension = directory ? resolvePath(directory, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
|
|
111993
|
-
const outputFileName = changeExtension(
|
|
111994
|
-
outputPathWithoutChangedExtension,
|
|
111995
|
-
getDeclarationEmitExtensionForPath(inputFileName)
|
|
111996
|
-
);
|
|
111997
|
-
return outputFileName;
|
|
111998
|
-
}
|
|
111999
111972
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory2) {
|
|
112000
111973
|
if (configFile.options.emitDeclarationOnly)
|
|
112001
111974
|
return void 0;
|
|
@@ -112006,18 +111979,6 @@ function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSou
|
|
|
112006
111979
|
);
|
|
112007
111980
|
return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
112008
111981
|
}
|
|
112009
|
-
function getOutputJSFileNameWithoutConfigFile(inputFileName, options, ignoreCase, currentDirectory, getCommonSourceDirectory2) {
|
|
112010
|
-
if (options.emitDeclarationOnly)
|
|
112011
|
-
return void 0;
|
|
112012
|
-
const isJsonFile = fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
112013
|
-
const outDir = options.outDir ? getNormalizedAbsolutePath(options.outDir, currentDirectory) : void 0;
|
|
112014
|
-
const outputPathWithoutChangedExtension = outDir ? resolvePath(outDir, getRelativePathFromDirectory(getCommonSourceDirectory2(), inputFileName, ignoreCase)) : inputFileName;
|
|
112015
|
-
const outputFileName = changeExtension(
|
|
112016
|
-
outputPathWithoutChangedExtension,
|
|
112017
|
-
getOutputExtension(inputFileName, options)
|
|
112018
|
-
);
|
|
112019
|
-
return !isJsonFile || !options.configFilePath || comparePaths(inputFileName, outputFileName, options.configFilePath, ignoreCase) !== 0 /* EqualTo */ ? outputFileName : void 0;
|
|
112020
|
-
}
|
|
112021
111982
|
function createAddOutput() {
|
|
112022
111983
|
let outputs;
|
|
112023
111984
|
return { addOutput, getOutputs };
|
|
@@ -118558,15 +118519,6 @@ function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host,
|
|
|
118558
118519
|
return { impliedNodeFormat, packageJsonLocations, packageJsonScope };
|
|
118559
118520
|
}
|
|
118560
118521
|
}
|
|
118561
|
-
function moduleFormatNeedsPackageJsonLookup(fileName, options) {
|
|
118562
|
-
switch (getEmitModuleResolutionKind(options)) {
|
|
118563
|
-
case 3 /* Node16 */:
|
|
118564
|
-
case 99 /* NodeNext */:
|
|
118565
|
-
return fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]);
|
|
118566
|
-
default:
|
|
118567
|
-
return false;
|
|
118568
|
-
}
|
|
118569
|
-
}
|
|
118570
118522
|
var plainJSErrors = /* @__PURE__ */ new Set([
|
|
118571
118523
|
// binder errors
|
|
118572
118524
|
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
|
|
@@ -118687,7 +118639,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118687
118639
|
let files;
|
|
118688
118640
|
let symlinks;
|
|
118689
118641
|
let commonSourceDirectory;
|
|
118690
|
-
let assumedCommonSourceDirectory;
|
|
118691
118642
|
let typeChecker;
|
|
118692
118643
|
let classifiableNames;
|
|
118693
118644
|
const ambientModuleNameToUnmodifiedFileName = /* @__PURE__ */ new Map();
|
|
@@ -119179,9 +119130,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119179
119130
|
}
|
|
119180
119131
|
return commonSourceDirectory;
|
|
119181
119132
|
}
|
|
119182
|
-
function getAssumedCommonSourceDirectory() {
|
|
119183
|
-
return commonSourceDirectory ?? (assumedCommonSourceDirectory ?? (assumedCommonSourceDirectory = getCommonSourceDirectory(options, () => rootNames, host.getCurrentDirectory(), getCanonicalFileName)));
|
|
119184
|
-
}
|
|
119185
119133
|
function getClassifiableNames() {
|
|
119186
119134
|
var _a2;
|
|
119187
119135
|
if (!classifiableNames) {
|
|
@@ -119405,7 +119353,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119405
119353
|
})(SeenPackageName || (SeenPackageName = {}));
|
|
119406
119354
|
const seenPackageNames = /* @__PURE__ */ new Map();
|
|
119407
119355
|
for (const oldSourceFile of oldSourceFiles) {
|
|
119408
|
-
const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
|
|
119356
|
+
const sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
119409
119357
|
let newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(
|
|
119410
119358
|
oldSourceFile.fileName,
|
|
119411
119359
|
oldSourceFile.resolvedPath,
|
|
@@ -120367,48 +120315,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120367
120315
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
120368
120316
|
return result;
|
|
120369
120317
|
}
|
|
120370
|
-
function
|
|
120371
|
-
|
|
120372
|
-
|
|
120373
|
-
|
|
120374
|
-
if (projectReference) {
|
|
120375
|
-
Debug.assert(useSourceOfProjectReferenceRedirect);
|
|
120376
|
-
fileNameForModuleFormatDetection = getOutputDeclarationFileName(
|
|
120377
|
-
fileNameForModuleFormatDetection,
|
|
120378
|
-
projectReference.commandLine,
|
|
120379
|
-
!host.useCaseSensitiveFileNames()
|
|
120380
|
-
) || getOutputJSFileName(
|
|
120381
|
-
fileNameForModuleFormatDetection,
|
|
120382
|
-
projectReference.commandLine,
|
|
120383
|
-
!host.useCaseSensitiveFileNames()
|
|
120384
|
-
) || fileNameForModuleFormatDetection;
|
|
120385
|
-
} else {
|
|
120386
|
-
fileNameForModuleFormatDetection = getOutputDeclarationFileNameWithoutConfigFile(
|
|
120387
|
-
fileNameForModuleFormatDetection,
|
|
120388
|
-
options,
|
|
120389
|
-
!host.useCaseSensitiveFileNames(),
|
|
120390
|
-
currentDirectory,
|
|
120391
|
-
getAssumedCommonSourceDirectory
|
|
120392
|
-
) || getOutputJSFileNameWithoutConfigFile(
|
|
120393
|
-
fileNameForModuleFormatDetection,
|
|
120394
|
-
options,
|
|
120395
|
-
!host.useCaseSensitiveFileNames(),
|
|
120396
|
-
currentDirectory,
|
|
120397
|
-
getAssumedCommonSourceDirectory
|
|
120398
|
-
) || fileNameForModuleFormatDetection;
|
|
120399
|
-
}
|
|
120400
|
-
}
|
|
120401
|
-
return getImpliedNodeFormatForFileWorker(
|
|
120402
|
-
fileNameForModuleFormatDetection,
|
|
120403
|
-
moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(),
|
|
120404
|
-
host,
|
|
120405
|
-
options
|
|
120406
|
-
);
|
|
120407
|
-
}
|
|
120408
|
-
function getCreateSourceFileOptions(fileName) {
|
|
120409
|
-
const result = getImpliedNodeFormatForFile2(fileName);
|
|
120410
|
-
const languageVersion = getEmitScriptTarget(options);
|
|
120411
|
-
const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options);
|
|
120318
|
+
function getCreateSourceFileOptions(fileName, moduleResolutionCache2, host2, options2) {
|
|
120319
|
+
const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache2 == null ? void 0 : moduleResolutionCache2.getPackageJsonInfoCache(), host2, options2);
|
|
120320
|
+
const languageVersion = getEmitScriptTarget(options2);
|
|
120321
|
+
const setExternalModuleIndicator2 = getSetExternalModuleIndicator(options2);
|
|
120412
120322
|
return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2 } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2 };
|
|
120413
120323
|
}
|
|
120414
120324
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
@@ -120480,7 +120390,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120480
120390
|
redirectedPath = toPath3(redirect);
|
|
120481
120391
|
}
|
|
120482
120392
|
}
|
|
120483
|
-
const sourceFileOptions = getCreateSourceFileOptions(fileName);
|
|
120393
|
+
const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
120484
120394
|
const file = host.getSourceFile(
|
|
120485
120395
|
fileName,
|
|
120486
120396
|
sourceFileOptions,
|
|
@@ -121103,9 +121013,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
121103
121013
|
createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
|
|
121104
121014
|
}
|
|
121105
121015
|
}
|
|
121106
|
-
if (assumedCommonSourceDirectory && assumedCommonSourceDirectory !== getCommonSourceDirectory2()) {
|
|
121107
|
-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.The_project_root_is_ambiguous_but_is_required_to_determine_the_module_format_of_output_js_files_Supply_the_rootDir_compiler_option_to_disambiguate));
|
|
121108
|
-
}
|
|
121109
121016
|
if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) {
|
|
121110
121017
|
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
|
|
121111
121018
|
}
|
|
@@ -135732,8 +135639,8 @@ function getApplicableRefactors(context, includeInteractiveActions) {
|
|
|
135732
135639
|
return context.cancellationToken && context.cancellationToken.isCancellationRequested() || !((_a = refactor.kinds) == null ? void 0 : _a.some((kind) => refactorKindBeginsWith(kind, context.kind))) ? void 0 : refactor.getAvailableActions(context, includeInteractiveActions);
|
|
135733
135640
|
}));
|
|
135734
135641
|
}
|
|
135735
|
-
function getEditsForRefactor(context,
|
|
135736
|
-
const refactor = refactors.get(
|
|
135642
|
+
function getEditsForRefactor(context, refactorName14, actionName2, interactiveRefactorArguments) {
|
|
135643
|
+
const refactor = refactors.get(refactorName14);
|
|
135737
135644
|
return refactor && refactor.getEditsForAction(context, actionName2, interactiveRefactorArguments);
|
|
135738
135645
|
}
|
|
135739
135646
|
|
|
@@ -136501,24 +136408,147 @@ function refactorKindBeginsWith(known, requested) {
|
|
|
136501
136408
|
return known.substr(0, requested.length) === requested;
|
|
136502
136409
|
}
|
|
136503
136410
|
|
|
136411
|
+
// src/services/refactors/inlineVariable.ts
|
|
136412
|
+
var refactorName4 = "Inline variable";
|
|
136413
|
+
var refactorDescription = getLocaleSpecificMessage(Diagnostics.Inline_variable);
|
|
136414
|
+
var inlineVariableAction = {
|
|
136415
|
+
name: refactorName4,
|
|
136416
|
+
description: refactorDescription,
|
|
136417
|
+
kind: "refactor.inline.variable"
|
|
136418
|
+
};
|
|
136419
|
+
registerRefactor(refactorName4, {
|
|
136420
|
+
kinds: [inlineVariableAction.kind],
|
|
136421
|
+
getAvailableActions(context) {
|
|
136422
|
+
const {
|
|
136423
|
+
file,
|
|
136424
|
+
program,
|
|
136425
|
+
preferences,
|
|
136426
|
+
startPosition,
|
|
136427
|
+
triggerReason
|
|
136428
|
+
} = context;
|
|
136429
|
+
const info = getInliningInfo(file, startPosition, triggerReason === "invoked", program);
|
|
136430
|
+
if (!info) {
|
|
136431
|
+
return emptyArray;
|
|
136432
|
+
}
|
|
136433
|
+
if (ts_refactor_exports.isRefactorErrorInfo(info) && preferences.provideRefactorNotApplicableReason) {
|
|
136434
|
+
return [{
|
|
136435
|
+
name: refactorName4,
|
|
136436
|
+
description: refactorDescription,
|
|
136437
|
+
actions: [{
|
|
136438
|
+
...inlineVariableAction,
|
|
136439
|
+
notApplicableReason: info.error
|
|
136440
|
+
}]
|
|
136441
|
+
}];
|
|
136442
|
+
}
|
|
136443
|
+
if (!ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
136444
|
+
return [{
|
|
136445
|
+
name: refactorName4,
|
|
136446
|
+
description: refactorDescription,
|
|
136447
|
+
actions: [inlineVariableAction]
|
|
136448
|
+
}];
|
|
136449
|
+
}
|
|
136450
|
+
return emptyArray;
|
|
136451
|
+
},
|
|
136452
|
+
getEditsForAction(context, actionName2) {
|
|
136453
|
+
Debug.assert(actionName2 === refactorName4, "Unexpected refactor invoked");
|
|
136454
|
+
const { file, program, startPosition } = context;
|
|
136455
|
+
const info = getInliningInfo(
|
|
136456
|
+
file,
|
|
136457
|
+
startPosition,
|
|
136458
|
+
/*tryWithReferenceToken*/
|
|
136459
|
+
true,
|
|
136460
|
+
program
|
|
136461
|
+
);
|
|
136462
|
+
if (!info || ts_refactor_exports.isRefactorErrorInfo(info)) {
|
|
136463
|
+
return void 0;
|
|
136464
|
+
}
|
|
136465
|
+
const { references, declaration, replacement } = info;
|
|
136466
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (tracker) => {
|
|
136467
|
+
for (const node of references) {
|
|
136468
|
+
tracker.replaceNode(file, node, getReplacementExpression(node, replacement));
|
|
136469
|
+
}
|
|
136470
|
+
tracker.delete(file, declaration);
|
|
136471
|
+
});
|
|
136472
|
+
return { edits };
|
|
136473
|
+
}
|
|
136474
|
+
});
|
|
136475
|
+
function getInliningInfo(file, startPosition, tryWithReferenceToken, program) {
|
|
136476
|
+
var _a, _b;
|
|
136477
|
+
const checker = program.getTypeChecker();
|
|
136478
|
+
const token = getTokenAtPosition(file, startPosition);
|
|
136479
|
+
const parent2 = token.parent;
|
|
136480
|
+
if (isInitializedVariable(parent2) && isVariableDeclarationInVariableStatement(parent2) && isIdentifier(parent2.name)) {
|
|
136481
|
+
if (((_a = parent2.symbol.declarations) == null ? void 0 : _a.length) !== 1) {
|
|
136482
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
136483
|
+
}
|
|
136484
|
+
if (findAncestor(parent2, (node) => canHaveModifiers(node) && some(node.modifiers, isExportModifier))) {
|
|
136485
|
+
return void 0;
|
|
136486
|
+
}
|
|
136487
|
+
const references = getReferenceNodes(parent2, checker, file);
|
|
136488
|
+
return references && { references, declaration: parent2, replacement: parent2.initializer };
|
|
136489
|
+
}
|
|
136490
|
+
if (tryWithReferenceToken && isIdentifier(token)) {
|
|
136491
|
+
const definition = checker.resolveName(
|
|
136492
|
+
token.text,
|
|
136493
|
+
token,
|
|
136494
|
+
111551 /* Value */,
|
|
136495
|
+
/*excludeGlobals*/
|
|
136496
|
+
false
|
|
136497
|
+
);
|
|
136498
|
+
if (((_b = definition == null ? void 0 : definition.declarations) == null ? void 0 : _b.length) !== 1) {
|
|
136499
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Variables_that_share_a_name_with_a_type_or_namespace_in_the_same_scope_cannot_be_inlined) };
|
|
136500
|
+
}
|
|
136501
|
+
const declaration = definition.declarations[0];
|
|
136502
|
+
if (!isInitializedVariable(declaration) || !isVariableDeclarationInVariableStatement(declaration) || !isIdentifier(declaration.name)) {
|
|
136503
|
+
return void 0;
|
|
136504
|
+
}
|
|
136505
|
+
const references = getReferenceNodes(declaration, checker, file);
|
|
136506
|
+
return references && { references, declaration, replacement: declaration.initializer };
|
|
136507
|
+
}
|
|
136508
|
+
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_find_variable_to_inline) };
|
|
136509
|
+
}
|
|
136510
|
+
function getReferenceNodes(declaration, checker, file) {
|
|
136511
|
+
const references = [];
|
|
136512
|
+
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
136513
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
136514
|
+
return true;
|
|
136515
|
+
}
|
|
136516
|
+
if (isTypeQueryNode(ref.parent)) {
|
|
136517
|
+
return true;
|
|
136518
|
+
}
|
|
136519
|
+
if (findAncestor(ref, (node) => node === declaration.initializer)) {
|
|
136520
|
+
return true;
|
|
136521
|
+
}
|
|
136522
|
+
references.push(ref);
|
|
136523
|
+
});
|
|
136524
|
+
return references.length === 0 || cannotInline ? void 0 : references;
|
|
136525
|
+
}
|
|
136526
|
+
function getReplacementExpression(reference, replacement) {
|
|
136527
|
+
const { parent: parent2 } = reference;
|
|
136528
|
+
if (isExpression(parent2) && (getExpressionPrecedence(replacement) < getExpressionPrecedence(parent2) || needsParentheses(parent2))) {
|
|
136529
|
+
return factory.createParenthesizedExpression(replacement);
|
|
136530
|
+
}
|
|
136531
|
+
return replacement;
|
|
136532
|
+
}
|
|
136533
|
+
|
|
136504
136534
|
// src/services/refactors/moveToNewFile.ts
|
|
136505
|
-
var
|
|
136535
|
+
var refactorName5 = "Move to a new file";
|
|
136506
136536
|
var description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file);
|
|
136507
136537
|
var moveToNewFileAction = {
|
|
136508
|
-
name:
|
|
136538
|
+
name: refactorName5,
|
|
136509
136539
|
description,
|
|
136510
136540
|
kind: "refactor.move.newFile"
|
|
136511
136541
|
};
|
|
136512
|
-
registerRefactor(
|
|
136542
|
+
registerRefactor(refactorName5, {
|
|
136513
136543
|
kinds: [moveToNewFileAction.kind],
|
|
136514
136544
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
136515
136545
|
const statements = getStatementsToMove(context);
|
|
136516
136546
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
136517
|
-
return [{ name:
|
|
136547
|
+
return [{ name: refactorName5, description, actions: [moveToNewFileAction] }];
|
|
136518
136548
|
}
|
|
136519
136549
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
136520
136550
|
return [{
|
|
136521
|
-
name:
|
|
136551
|
+
name: refactorName5,
|
|
136522
136552
|
description,
|
|
136523
136553
|
actions: [{ ...moveToNewFileAction, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_statement_or_statements) }]
|
|
136524
136554
|
}];
|
|
@@ -136526,7 +136556,7 @@ registerRefactor(refactorName4, {
|
|
|
136526
136556
|
return emptyArray;
|
|
136527
136557
|
},
|
|
136528
136558
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
136529
|
-
Debug.assert(actionName2 ===
|
|
136559
|
+
Debug.assert(actionName2 === refactorName5, "Wrong refactor invoked");
|
|
136530
136560
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
136531
136561
|
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange3(context.file, context.program, statements, t, context.host, context.preferences, context));
|
|
136532
136562
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
@@ -137503,14 +137533,14 @@ function getOverloadRangeToMove(sourceFile, statement) {
|
|
|
137503
137533
|
var ts_refactor_addOrRemoveBracesToArrowFunction_exports = {};
|
|
137504
137534
|
|
|
137505
137535
|
// src/services/refactors/convertOverloadListToSingleSignature.ts
|
|
137506
|
-
var
|
|
137507
|
-
var
|
|
137536
|
+
var refactorName6 = "Convert overload list to single signature";
|
|
137537
|
+
var refactorDescription2 = getLocaleSpecificMessage(Diagnostics.Convert_overload_list_to_single_signature);
|
|
137508
137538
|
var functionOverloadAction = {
|
|
137509
|
-
name:
|
|
137510
|
-
description:
|
|
137539
|
+
name: refactorName6,
|
|
137540
|
+
description: refactorDescription2,
|
|
137511
137541
|
kind: "refactor.rewrite.function.overloadList"
|
|
137512
137542
|
};
|
|
137513
|
-
registerRefactor(
|
|
137543
|
+
registerRefactor(refactorName6, {
|
|
137514
137544
|
kinds: [functionOverloadAction.kind],
|
|
137515
137545
|
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
137516
137546
|
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
@@ -137521,8 +137551,8 @@ function getRefactorActionsToConvertOverloadsToOneSignature(context) {
|
|
|
137521
137551
|
if (!info)
|
|
137522
137552
|
return emptyArray;
|
|
137523
137553
|
return [{
|
|
137524
|
-
name:
|
|
137525
|
-
description:
|
|
137554
|
+
name: refactorName6,
|
|
137555
|
+
description: refactorDescription2,
|
|
137526
137556
|
actions: [functionOverloadAction]
|
|
137527
137557
|
}];
|
|
137528
137558
|
}
|
|
@@ -137715,8 +137745,8 @@ function getConvertableOverloadListAtPosition(file, startPosition, program) {
|
|
|
137715
137745
|
}
|
|
137716
137746
|
|
|
137717
137747
|
// src/services/refactors/addOrRemoveBracesToArrowFunction.ts
|
|
137718
|
-
var
|
|
137719
|
-
var
|
|
137748
|
+
var refactorName7 = "Add or remove braces in an arrow function";
|
|
137749
|
+
var refactorDescription3 = getLocaleSpecificMessage(Diagnostics.Add_or_remove_braces_in_an_arrow_function);
|
|
137720
137750
|
var addBracesAction = {
|
|
137721
137751
|
name: "Add braces to arrow function",
|
|
137722
137752
|
description: getLocaleSpecificMessage(Diagnostics.Add_braces_to_arrow_function),
|
|
@@ -137727,7 +137757,7 @@ var removeBracesAction = {
|
|
|
137727
137757
|
description: getLocaleSpecificMessage(Diagnostics.Remove_braces_from_arrow_function),
|
|
137728
137758
|
kind: "refactor.rewrite.arrow.braces.remove"
|
|
137729
137759
|
};
|
|
137730
|
-
registerRefactor(
|
|
137760
|
+
registerRefactor(refactorName7, {
|
|
137731
137761
|
kinds: [removeBracesAction.kind],
|
|
137732
137762
|
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
137733
137763
|
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
@@ -137739,8 +137769,8 @@ function getRefactorActionsToRemoveFunctionBraces(context) {
|
|
|
137739
137769
|
return emptyArray;
|
|
137740
137770
|
if (!isRefactorErrorInfo(info)) {
|
|
137741
137771
|
return [{
|
|
137742
|
-
name:
|
|
137743
|
-
description:
|
|
137772
|
+
name: refactorName7,
|
|
137773
|
+
description: refactorDescription3,
|
|
137744
137774
|
actions: [
|
|
137745
137775
|
info.addBraces ? addBracesAction : removeBracesAction
|
|
137746
137776
|
]
|
|
@@ -137748,8 +137778,8 @@ function getRefactorActionsToRemoveFunctionBraces(context) {
|
|
|
137748
137778
|
}
|
|
137749
137779
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
137750
137780
|
return [{
|
|
137751
|
-
name:
|
|
137752
|
-
description:
|
|
137781
|
+
name: refactorName7,
|
|
137782
|
+
description: refactorDescription3,
|
|
137753
137783
|
actions: [
|
|
137754
137784
|
{ ...addBracesAction, notApplicableReason: info.error },
|
|
137755
137785
|
{ ...removeBracesAction, notApplicableReason: info.error }
|
|
@@ -137845,8 +137875,8 @@ function getConvertibleArrowFunctionAtPosition(file, startPosition, considerFunc
|
|
|
137845
137875
|
var ts_refactor_convertArrowFunctionOrFunctionExpression_exports = {};
|
|
137846
137876
|
|
|
137847
137877
|
// src/services/refactors/convertArrowFunctionOrFunctionExpression.ts
|
|
137848
|
-
var
|
|
137849
|
-
var
|
|
137878
|
+
var refactorName8 = "Convert arrow function or function expression";
|
|
137879
|
+
var refactorDescription4 = getLocaleSpecificMessage(Diagnostics.Convert_arrow_function_or_function_expression);
|
|
137850
137880
|
var toAnonymousFunctionAction = {
|
|
137851
137881
|
name: "Convert to anonymous function",
|
|
137852
137882
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_anonymous_function),
|
|
@@ -137862,7 +137892,7 @@ var toArrowFunctionAction = {
|
|
|
137862
137892
|
description: getLocaleSpecificMessage(Diagnostics.Convert_to_arrow_function),
|
|
137863
137893
|
kind: "refactor.rewrite.function.arrow"
|
|
137864
137894
|
};
|
|
137865
|
-
registerRefactor(
|
|
137895
|
+
registerRefactor(refactorName8, {
|
|
137866
137896
|
kinds: [
|
|
137867
137897
|
toAnonymousFunctionAction.kind,
|
|
137868
137898
|
toNamedFunctionAction.kind,
|
|
@@ -137904,8 +137934,8 @@ function getRefactorActionsToConvertFunctionExpressions(context) {
|
|
|
137904
137934
|
}
|
|
137905
137935
|
}
|
|
137906
137936
|
return [{
|
|
137907
|
-
name:
|
|
137908
|
-
description:
|
|
137937
|
+
name: refactorName8,
|
|
137938
|
+
description: refactorDescription4,
|
|
137909
137939
|
actions: possibleActions.length === 0 && context.preferences.provideRefactorNotApplicableReason ? errors : possibleActions
|
|
137910
137940
|
}];
|
|
137911
137941
|
}
|
|
@@ -138070,15 +138100,15 @@ function isFunctionReferencedInFile(sourceFile, typeChecker, node) {
|
|
|
138070
138100
|
var ts_refactor_convertParamsToDestructuredObject_exports = {};
|
|
138071
138101
|
|
|
138072
138102
|
// src/services/refactors/convertParamsToDestructuredObject.ts
|
|
138073
|
-
var
|
|
138103
|
+
var refactorName9 = "Convert parameters to destructured object";
|
|
138074
138104
|
var minimumParameterLength = 1;
|
|
138075
|
-
var
|
|
138105
|
+
var refactorDescription5 = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
|
|
138076
138106
|
var toDestructuredAction = {
|
|
138077
|
-
name:
|
|
138078
|
-
description:
|
|
138107
|
+
name: refactorName9,
|
|
138108
|
+
description: refactorDescription5,
|
|
138079
138109
|
kind: "refactor.rewrite.parameters.toDestructured"
|
|
138080
138110
|
};
|
|
138081
|
-
registerRefactor(
|
|
138111
|
+
registerRefactor(refactorName9, {
|
|
138082
138112
|
kinds: [toDestructuredAction.kind],
|
|
138083
138113
|
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
138084
138114
|
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
@@ -138092,13 +138122,13 @@ function getRefactorActionsToConvertParametersToDestructuredObject(context) {
|
|
|
138092
138122
|
if (!functionDeclaration)
|
|
138093
138123
|
return emptyArray;
|
|
138094
138124
|
return [{
|
|
138095
|
-
name:
|
|
138096
|
-
description:
|
|
138125
|
+
name: refactorName9,
|
|
138126
|
+
description: refactorDescription5,
|
|
138097
138127
|
actions: [toDestructuredAction]
|
|
138098
138128
|
}];
|
|
138099
138129
|
}
|
|
138100
138130
|
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName2) {
|
|
138101
|
-
Debug.assert(actionName2 ===
|
|
138131
|
+
Debug.assert(actionName2 === refactorName9, "Unexpected action name");
|
|
138102
138132
|
const { file, startPosition, program, cancellationToken, host } = context;
|
|
138103
138133
|
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
138104
138134
|
if (!functionDeclaration || !cancellationToken)
|
|
@@ -138613,14 +138643,14 @@ function getFunctionNames(functionDeclaration) {
|
|
|
138613
138643
|
var ts_refactor_convertStringOrTemplateLiteral_exports = {};
|
|
138614
138644
|
|
|
138615
138645
|
// src/services/refactors/convertStringOrTemplateLiteral.ts
|
|
138616
|
-
var
|
|
138617
|
-
var
|
|
138646
|
+
var refactorName10 = "Convert to template string";
|
|
138647
|
+
var refactorDescription6 = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
138618
138648
|
var convertStringAction = {
|
|
138619
|
-
name:
|
|
138620
|
-
description:
|
|
138649
|
+
name: refactorName10,
|
|
138650
|
+
description: refactorDescription6,
|
|
138621
138651
|
kind: "refactor.rewrite.string"
|
|
138622
138652
|
};
|
|
138623
|
-
registerRefactor(
|
|
138653
|
+
registerRefactor(refactorName10, {
|
|
138624
138654
|
kinds: [convertStringAction.kind],
|
|
138625
138655
|
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
138626
138656
|
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
@@ -138629,7 +138659,7 @@ function getRefactorActionsToConvertToTemplateString(context) {
|
|
|
138629
138659
|
const { file, startPosition } = context;
|
|
138630
138660
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
138631
138661
|
const maybeBinary = getParentBinaryExpression(node);
|
|
138632
|
-
const refactorInfo = { name:
|
|
138662
|
+
const refactorInfo = { name: refactorName10, description: refactorDescription6, actions: [] };
|
|
138633
138663
|
if (isBinaryExpression(maybeBinary) && treeToArray(maybeBinary).isValidConcatenation) {
|
|
138634
138664
|
refactorInfo.actions.push(convertStringAction);
|
|
138635
138665
|
return [refactorInfo];
|
|
@@ -138655,7 +138685,7 @@ function getRefactorEditsToConvertToTemplateString(context, actionName2) {
|
|
|
138655
138685
|
const { file, startPosition } = context;
|
|
138656
138686
|
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
138657
138687
|
switch (actionName2) {
|
|
138658
|
-
case
|
|
138688
|
+
case refactorDescription6:
|
|
138659
138689
|
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
138660
138690
|
default:
|
|
138661
138691
|
return Debug.fail("invalid action");
|
|
@@ -138837,14 +138867,14 @@ function getExpressionFromParenthesesOrExpression(node) {
|
|
|
138837
138867
|
var ts_refactor_convertToOptionalChainExpression_exports = {};
|
|
138838
138868
|
|
|
138839
138869
|
// src/services/refactors/convertToOptionalChainExpression.ts
|
|
138840
|
-
var
|
|
138870
|
+
var refactorName11 = "Convert to optional chain expression";
|
|
138841
138871
|
var convertToOptionalChainExpressionMessage = getLocaleSpecificMessage(Diagnostics.Convert_to_optional_chain_expression);
|
|
138842
138872
|
var toOptionalChainAction = {
|
|
138843
|
-
name:
|
|
138873
|
+
name: refactorName11,
|
|
138844
138874
|
description: convertToOptionalChainExpressionMessage,
|
|
138845
138875
|
kind: "refactor.rewrite.expression.optionalChain"
|
|
138846
138876
|
};
|
|
138847
|
-
registerRefactor(
|
|
138877
|
+
registerRefactor(refactorName11, {
|
|
138848
138878
|
kinds: [toOptionalChainAction.kind],
|
|
138849
138879
|
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
138850
138880
|
getAvailableActions: getRefactorActionsToConvertToOptionalChain
|
|
@@ -138855,14 +138885,14 @@ function getRefactorActionsToConvertToOptionalChain(context) {
|
|
|
138855
138885
|
return emptyArray;
|
|
138856
138886
|
if (!isRefactorErrorInfo(info)) {
|
|
138857
138887
|
return [{
|
|
138858
|
-
name:
|
|
138888
|
+
name: refactorName11,
|
|
138859
138889
|
description: convertToOptionalChainExpressionMessage,
|
|
138860
138890
|
actions: [toOptionalChainAction]
|
|
138861
138891
|
}];
|
|
138862
138892
|
}
|
|
138863
138893
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
138864
138894
|
return [{
|
|
138865
|
-
name:
|
|
138895
|
+
name: refactorName11,
|
|
138866
138896
|
description: convertToOptionalChainExpressionMessage,
|
|
138867
138897
|
actions: [{ ...toOptionalChainAction, notApplicableReason: info.error }]
|
|
138868
138898
|
}];
|
|
@@ -139058,7 +139088,7 @@ __export(ts_refactor_extractSymbol_exports, {
|
|
|
139058
139088
|
});
|
|
139059
139089
|
|
|
139060
139090
|
// src/services/refactors/extractSymbol.ts
|
|
139061
|
-
var
|
|
139091
|
+
var refactorName12 = "Extract Symbol";
|
|
139062
139092
|
var extractConstantAction = {
|
|
139063
139093
|
name: "Extract Constant",
|
|
139064
139094
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
@@ -139069,7 +139099,7 @@ var extractFunctionAction = {
|
|
|
139069
139099
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139070
139100
|
kind: "refactor.extract.function"
|
|
139071
139101
|
};
|
|
139072
|
-
registerRefactor(
|
|
139102
|
+
registerRefactor(refactorName12, {
|
|
139073
139103
|
kinds: [
|
|
139074
139104
|
extractConstantAction.kind,
|
|
139075
139105
|
extractFunctionAction.kind
|
|
@@ -139088,14 +139118,14 @@ function getRefactorActionsToExtractSymbol(context) {
|
|
|
139088
139118
|
const errors = [];
|
|
139089
139119
|
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
139090
139120
|
errors.push({
|
|
139091
|
-
name:
|
|
139121
|
+
name: refactorName12,
|
|
139092
139122
|
description: extractFunctionAction.description,
|
|
139093
139123
|
actions: [{ ...extractFunctionAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
139094
139124
|
});
|
|
139095
139125
|
}
|
|
139096
139126
|
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
139097
139127
|
errors.push({
|
|
139098
|
-
name:
|
|
139128
|
+
name: refactorName12,
|
|
139099
139129
|
description: extractConstantAction.description,
|
|
139100
139130
|
actions: [{ ...extractConstantAction, notApplicableReason: getStringError(rangeToExtract.errors) }]
|
|
139101
139131
|
});
|
|
@@ -139159,26 +139189,26 @@ function getRefactorActionsToExtractSymbol(context) {
|
|
|
139159
139189
|
const infos = [];
|
|
139160
139190
|
if (functionActions.length) {
|
|
139161
139191
|
infos.push({
|
|
139162
|
-
name:
|
|
139192
|
+
name: refactorName12,
|
|
139163
139193
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139164
139194
|
actions: functionActions
|
|
139165
139195
|
});
|
|
139166
139196
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorFunctionAction) {
|
|
139167
139197
|
infos.push({
|
|
139168
|
-
name:
|
|
139198
|
+
name: refactorName12,
|
|
139169
139199
|
description: getLocaleSpecificMessage(Diagnostics.Extract_function),
|
|
139170
139200
|
actions: [innermostErrorFunctionAction]
|
|
139171
139201
|
});
|
|
139172
139202
|
}
|
|
139173
139203
|
if (constantActions.length) {
|
|
139174
139204
|
infos.push({
|
|
139175
|
-
name:
|
|
139205
|
+
name: refactorName12,
|
|
139176
139206
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
139177
139207
|
actions: constantActions
|
|
139178
139208
|
});
|
|
139179
139209
|
} else if (context.preferences.provideRefactorNotApplicableReason && innermostErrorConstantAction) {
|
|
139180
139210
|
infos.push({
|
|
139181
|
-
name:
|
|
139211
|
+
name: refactorName12,
|
|
139182
139212
|
description: getLocaleSpecificMessage(Diagnostics.Extract_constant),
|
|
139183
139213
|
actions: [innermostErrorConstantAction]
|
|
139184
139214
|
});
|
|
@@ -140710,14 +140740,14 @@ registerRefactor(actionName, {
|
|
|
140710
140740
|
var ts_refactor_inferFunctionReturnType_exports = {};
|
|
140711
140741
|
|
|
140712
140742
|
// src/services/refactors/inferFunctionReturnType.ts
|
|
140713
|
-
var
|
|
140714
|
-
var
|
|
140743
|
+
var refactorName13 = "Infer function return type";
|
|
140744
|
+
var refactorDescription7 = getLocaleSpecificMessage(Diagnostics.Infer_function_return_type);
|
|
140715
140745
|
var inferReturnTypeAction = {
|
|
140716
|
-
name:
|
|
140717
|
-
description:
|
|
140746
|
+
name: refactorName13,
|
|
140747
|
+
description: refactorDescription7,
|
|
140718
140748
|
kind: "refactor.rewrite.function.returnType"
|
|
140719
140749
|
};
|
|
140720
|
-
registerRefactor(
|
|
140750
|
+
registerRefactor(refactorName13, {
|
|
140721
140751
|
kinds: [inferReturnTypeAction.kind],
|
|
140722
140752
|
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
140723
140753
|
getAvailableActions: getRefactorActionsToInferReturnType
|
|
@@ -140736,15 +140766,15 @@ function getRefactorActionsToInferReturnType(context) {
|
|
|
140736
140766
|
return emptyArray;
|
|
140737
140767
|
if (!isRefactorErrorInfo(info)) {
|
|
140738
140768
|
return [{
|
|
140739
|
-
name:
|
|
140740
|
-
description:
|
|
140769
|
+
name: refactorName13,
|
|
140770
|
+
description: refactorDescription7,
|
|
140741
140771
|
actions: [inferReturnTypeAction]
|
|
140742
140772
|
}];
|
|
140743
140773
|
}
|
|
140744
140774
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
140745
140775
|
return [{
|
|
140746
|
-
name:
|
|
140747
|
-
description:
|
|
140776
|
+
name: refactorName13,
|
|
140777
|
+
description: refactorDescription7,
|
|
140748
140778
|
actions: [{ ...inferReturnTypeAction, notApplicableReason: info.error }]
|
|
140749
140779
|
}];
|
|
140750
140780
|
}
|
|
@@ -142988,10 +143018,10 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
142988
143018
|
const newFileName = createNewFileName(sourceFile, program, getRefactorContext(sourceFile, positionOrRange, preferences, emptyOptions), host);
|
|
142989
143019
|
return { newFileName, files };
|
|
142990
143020
|
}
|
|
142991
|
-
function getEditsForRefactor2(fileName, formatOptions, positionOrRange,
|
|
143021
|
+
function getEditsForRefactor2(fileName, formatOptions, positionOrRange, refactorName14, actionName2, preferences = emptyOptions, interactiveRefactorArguments) {
|
|
142992
143022
|
synchronizeHostData();
|
|
142993
143023
|
const file = getValidSourceFile(fileName);
|
|
142994
|
-
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions),
|
|
143024
|
+
return ts_refactor_exports.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName14, actionName2, interactiveRefactorArguments);
|
|
142995
143025
|
}
|
|
142996
143026
|
function toLineColumnOffset(fileName, position) {
|
|
142997
143027
|
if (position === 0) {
|
|
@@ -147695,41 +147725,19 @@ var fixId13 = "convertToTypeOnlyImport";
|
|
|
147695
147725
|
registerCodeFix({
|
|
147696
147726
|
errorCodes: errorCodes14,
|
|
147697
147727
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
147698
|
-
var _a;
|
|
147699
147728
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
147700
147729
|
if (declaration) {
|
|
147701
147730
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
147702
|
-
|
|
147703
|
-
const mainAction = createCodeFixAction(
|
|
147704
|
-
fixId13,
|
|
147705
|
-
changes,
|
|
147706
|
-
declaration.kind === 275 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
147707
|
-
fixId13,
|
|
147708
|
-
Diagnostics.Fix_all_with_type_only_imports
|
|
147709
|
-
);
|
|
147710
|
-
if (some(importDeclarationChanges)) {
|
|
147711
|
-
return [
|
|
147712
|
-
createCodeFixActionWithoutFixAll(fixId13, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
147713
|
-
mainAction
|
|
147714
|
-
];
|
|
147715
|
-
}
|
|
147716
|
-
return [mainAction];
|
|
147731
|
+
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
147717
147732
|
}
|
|
147718
147733
|
return void 0;
|
|
147719
147734
|
},
|
|
147720
147735
|
fixIds: [fixId13],
|
|
147721
147736
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
147722
|
-
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
147723
147737
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
147724
|
-
const
|
|
147725
|
-
if (
|
|
147726
|
-
doChange11(changes, diag2.file,
|
|
147727
|
-
fixedImportDeclarations.add(errorDeclaration);
|
|
147728
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */ && !fixedImportDeclarations.has(errorDeclaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(errorDeclaration, diag2.file, context.program)) {
|
|
147729
|
-
doChange11(changes, diag2.file, errorDeclaration.parent.parent.parent);
|
|
147730
|
-
fixedImportDeclarations.add(errorDeclaration.parent.parent.parent);
|
|
147731
|
-
} else if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 275 /* ImportSpecifier */) {
|
|
147732
|
-
doChange11(changes, diag2.file, errorDeclaration);
|
|
147738
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
147739
|
+
if (declaration) {
|
|
147740
|
+
doChange11(changes, diag2.file, declaration);
|
|
147733
147741
|
}
|
|
147734
147742
|
});
|
|
147735
147743
|
}
|
|
@@ -147738,27 +147746,7 @@ function getDeclaration2(sourceFile, pos) {
|
|
|
147738
147746
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
147739
147747
|
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
147740
147748
|
}
|
|
147741
|
-
function canConvertImportDeclarationForSpecifier(specifier, sourceFile, program) {
|
|
147742
|
-
if (specifier.parent.parent.name) {
|
|
147743
|
-
return false;
|
|
147744
|
-
}
|
|
147745
|
-
const nonTypeOnlySpecifiers = specifier.parent.elements.filter((e) => !e.isTypeOnly);
|
|
147746
|
-
if (nonTypeOnlySpecifiers.length === 1) {
|
|
147747
|
-
return true;
|
|
147748
|
-
}
|
|
147749
|
-
const checker = program.getTypeChecker();
|
|
147750
|
-
for (const specifier2 of nonTypeOnlySpecifiers) {
|
|
147751
|
-
const isUsedAsValue = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(specifier2.name, checker, sourceFile, (usage) => {
|
|
147752
|
-
return !isValidTypeOnlyAliasUseSite(usage);
|
|
147753
|
-
});
|
|
147754
|
-
if (isUsedAsValue) {
|
|
147755
|
-
return false;
|
|
147756
|
-
}
|
|
147757
|
-
}
|
|
147758
|
-
return true;
|
|
147759
|
-
}
|
|
147760
147749
|
function doChange11(changes, sourceFile, declaration) {
|
|
147761
|
-
var _a;
|
|
147762
147750
|
if (isImportSpecifier(declaration)) {
|
|
147763
147751
|
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
147764
147752
|
declaration,
|
|
@@ -147829,16 +147817,6 @@ function doChange11(changes, sourceFile, declaration) {
|
|
|
147829
147817
|
)
|
|
147830
147818
|
]);
|
|
147831
147819
|
} else {
|
|
147832
|
-
const newNamedBindings = ((_a = importClause.namedBindings) == null ? void 0 : _a.kind) === 274 /* NamedImports */ ? factory.updateNamedImports(
|
|
147833
|
-
importClause.namedBindings,
|
|
147834
|
-
sameMap(importClause.namedBindings.elements, (e) => factory.updateImportSpecifier(
|
|
147835
|
-
e,
|
|
147836
|
-
/*isTypeOnly*/
|
|
147837
|
-
false,
|
|
147838
|
-
e.propertyName,
|
|
147839
|
-
e.name
|
|
147840
|
-
))
|
|
147841
|
-
) : importClause.namedBindings;
|
|
147842
147820
|
const importDeclaration = factory.updateImportDeclaration(
|
|
147843
147821
|
declaration,
|
|
147844
147822
|
declaration.modifiers,
|
|
@@ -147847,7 +147825,7 @@ function doChange11(changes, sourceFile, declaration) {
|
|
|
147847
147825
|
/*isTypeOnly*/
|
|
147848
147826
|
true,
|
|
147849
147827
|
importClause.name,
|
|
147850
|
-
|
|
147828
|
+
importClause.namedBindings
|
|
147851
147829
|
),
|
|
147852
147830
|
declaration.moduleSpecifier,
|
|
147853
147831
|
declaration.assertClause
|
|
@@ -151536,7 +151514,7 @@ registerCodeFix({
|
|
|
151536
151514
|
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
151537
151515
|
}
|
|
151538
151516
|
if (typeOnlyChanges.length) {
|
|
151539
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.
|
|
151517
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
151540
151518
|
}
|
|
151541
151519
|
return actions2;
|
|
151542
151520
|
},
|
|
@@ -159469,7 +159447,7 @@ function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, c
|
|
|
159469
159447
|
}
|
|
159470
159448
|
const keys = getOwnKeys(exports);
|
|
159471
159449
|
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
|
159472
|
-
const conditions =
|
|
159450
|
+
const conditions = mode === 99 /* ESNext */ ? ["node", "import", "types"] : ["node", "require", "types"];
|
|
159473
159451
|
addCompletionEntriesFromPathsOrExports(
|
|
159474
159452
|
result,
|
|
159475
159453
|
fragmentSubpath,
|
|
@@ -159718,6 +159696,7 @@ __export(ts_FindAllReferences_exports, {
|
|
|
159718
159696
|
getTextSpanOfEntry: () => getTextSpanOfEntry,
|
|
159719
159697
|
isContextWithStartAndEndNode: () => isContextWithStartAndEndNode,
|
|
159720
159698
|
isDeclarationOfSymbol: () => isDeclarationOfSymbol,
|
|
159699
|
+
isWriteAccessForReference: () => isWriteAccessForReference,
|
|
159721
159700
|
nodeEntry: () => nodeEntry,
|
|
159722
159701
|
toContextSpan: () => toContextSpan,
|
|
159723
159702
|
toHighlightSpan: () => toHighlightSpan,
|
|
@@ -162830,29 +162809,13 @@ function provideInlayHints(context) {
|
|
|
162830
162809
|
if (!signature || !candidates.length) {
|
|
162831
162810
|
return;
|
|
162832
162811
|
}
|
|
162833
|
-
let
|
|
162834
|
-
|
|
162812
|
+
for (let i = 0; i < args.length; ++i) {
|
|
162813
|
+
const originalArg = args[i];
|
|
162835
162814
|
const arg = skipParentheses(originalArg);
|
|
162836
162815
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
162837
162816
|
continue;
|
|
162838
162817
|
}
|
|
162839
|
-
|
|
162840
|
-
if (isSpreadElement(arg)) {
|
|
162841
|
-
const spreadType = checker.getTypeAtLocation(arg.expression);
|
|
162842
|
-
if (checker.isTupleType(spreadType)) {
|
|
162843
|
-
const { elementFlags, fixedLength } = spreadType.target;
|
|
162844
|
-
if (fixedLength === 0) {
|
|
162845
|
-
continue;
|
|
162846
|
-
}
|
|
162847
|
-
const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
|
|
162848
|
-
const requiredArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162849
|
-
if (requiredArgs > 0) {
|
|
162850
|
-
spreadArgs = firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
|
|
162851
|
-
}
|
|
162852
|
-
}
|
|
162853
|
-
}
|
|
162854
|
-
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, signatureParamPos);
|
|
162855
|
-
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
162818
|
+
const identifierNameInfo = checker.getParameterIdentifierNameAtPosition(signature, i);
|
|
162856
162819
|
if (identifierNameInfo) {
|
|
162857
162820
|
const [parameterName, isFirstVariadicArgument] = identifierNameInfo;
|
|
162858
162821
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
@@ -170886,11 +170849,8 @@ __export(ts_exports2, {
|
|
|
170886
170849
|
getOriginalNodeId: () => getOriginalNodeId,
|
|
170887
170850
|
getOriginalSourceFile: () => getOriginalSourceFile,
|
|
170888
170851
|
getOutputDeclarationFileName: () => getOutputDeclarationFileName,
|
|
170889
|
-
getOutputDeclarationFileNameWithoutConfigFile: () => getOutputDeclarationFileNameWithoutConfigFile,
|
|
170890
170852
|
getOutputExtension: () => getOutputExtension,
|
|
170891
170853
|
getOutputFileNames: () => getOutputFileNames,
|
|
170892
|
-
getOutputJSFileName: () => getOutputJSFileName,
|
|
170893
|
-
getOutputJSFileNameWithoutConfigFile: () => getOutputJSFileNameWithoutConfigFile,
|
|
170894
170854
|
getOutputPathsFor: () => getOutputPathsFor,
|
|
170895
170855
|
getOutputPathsForBundle: () => getOutputPathsForBundle,
|
|
170896
170856
|
getOwnEmitOutputFilePath: () => getOwnEmitOutputFilePath,
|
|
@@ -172381,9 +172341,9 @@ function buildOverload(name) {
|
|
|
172381
172341
|
|
|
172382
172342
|
// src/deprecatedCompat/5.0/identifierProperties.ts
|
|
172383
172343
|
addObjectAllocatorPatcher((objectAllocator2) => {
|
|
172384
|
-
const
|
|
172385
|
-
if (!hasProperty(
|
|
172386
|
-
Object.defineProperty(
|
|
172344
|
+
const Identifier75 = objectAllocator2.getIdentifierConstructor();
|
|
172345
|
+
if (!hasProperty(Identifier75.prototype, "originalKeywordKind")) {
|
|
172346
|
+
Object.defineProperty(Identifier75.prototype, "originalKeywordKind", {
|
|
172387
172347
|
get: deprecate(function() {
|
|
172388
172348
|
return identifierToKeywordKind(this);
|
|
172389
172349
|
}, {
|
|
@@ -172395,8 +172355,8 @@ addObjectAllocatorPatcher((objectAllocator2) => {
|
|
|
172395
172355
|
})
|
|
172396
172356
|
});
|
|
172397
172357
|
}
|
|
172398
|
-
if (!hasProperty(
|
|
172399
|
-
Object.defineProperty(
|
|
172358
|
+
if (!hasProperty(Identifier75.prototype, "isInJSDocNamespace")) {
|
|
172359
|
+
Object.defineProperty(Identifier75.prototype, "isInJSDocNamespace", {
|
|
172400
172360
|
get: deprecate(function() {
|
|
172401
172361
|
return this.flags & 2048 /* IdentifierIsInJSDocNamespace */ ? true : void 0;
|
|
172402
172362
|
}, {
|
|
@@ -185362,11 +185322,8 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
185362
185322
|
getOriginalNodeId,
|
|
185363
185323
|
getOriginalSourceFile,
|
|
185364
185324
|
getOutputDeclarationFileName,
|
|
185365
|
-
getOutputDeclarationFileNameWithoutConfigFile,
|
|
185366
185325
|
getOutputExtension,
|
|
185367
185326
|
getOutputFileNames,
|
|
185368
|
-
getOutputJSFileName,
|
|
185369
|
-
getOutputJSFileNameWithoutConfigFile,
|
|
185370
185327
|
getOutputPathsFor,
|
|
185371
185328
|
getOutputPathsForBundle,
|
|
185372
185329
|
getOwnEmitOutputFilePath,
|