@typescript-deploys/pr-build 4.6.0-pr-47400-2 → 4.6.0-pr-47552-4
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.dom.d.ts +144 -58
- package/lib/lib.dom.iterable.d.ts +7 -0
- package/lib/lib.es2015.iterable.d.ts +2 -1
- package/lib/lib.es2020.intl.d.ts +4 -0
- package/lib/lib.es5.d.ts +0 -2
- package/lib/lib.webworker.d.ts +80 -17
- package/lib/lib.webworker.iterable.d.ts +7 -0
- package/lib/protocol.d.ts +1 -0
- package/lib/tsc.js +318 -126
- package/lib/tsserver.js +682 -264
- package/lib/tsserverlibrary.d.ts +12 -6
- package/lib/tsserverlibrary.js +682 -264
- package/lib/typescript.d.ts +11 -6
- package/lib/typescript.js +668 -262
- package/lib/typescriptServices.d.ts +11 -6
- package/lib/typescriptServices.js +668 -262
- package/lib/typingsInstaller.js +379 -145
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220122";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -6810,11 +6810,15 @@ var ts;
|
|
|
6810
6810
|
ts.getFileWatcherEventKind = getFileWatcherEventKind;
|
|
6811
6811
|
/*@internal*/
|
|
6812
6812
|
ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
|
|
6813
|
+
var curSysLog = ts.noop; // eslint-disable-line prefer-const
|
|
6813
6814
|
/*@internal*/
|
|
6814
|
-
|
|
6815
|
+
function sysLog(s) {
|
|
6816
|
+
return curSysLog(s);
|
|
6817
|
+
}
|
|
6818
|
+
ts.sysLog = sysLog;
|
|
6815
6819
|
/*@internal*/
|
|
6816
6820
|
function setSysLog(logger) {
|
|
6817
|
-
|
|
6821
|
+
curSysLog = logger;
|
|
6818
6822
|
}
|
|
6819
6823
|
ts.setSysLog = setSysLog;
|
|
6820
6824
|
/**
|
|
@@ -6949,7 +6953,7 @@ var ts;
|
|
|
6949
6953
|
}
|
|
6950
6954
|
function onTimerToUpdateChildWatches() {
|
|
6951
6955
|
timerToUpdateChildWatches = undefined;
|
|
6952
|
-
|
|
6956
|
+
sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
|
|
6953
6957
|
var start = ts.timestamp();
|
|
6954
6958
|
var invokeMap = new ts.Map();
|
|
6955
6959
|
while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
|
|
@@ -6962,7 +6966,7 @@ var ts;
|
|
|
6962
6966
|
var hasChanges = updateChildWatches(dirName, dirPath, options);
|
|
6963
6967
|
invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
|
|
6964
6968
|
}
|
|
6965
|
-
|
|
6969
|
+
sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
|
|
6966
6970
|
callbackCache.forEach(function (callbacks, rootDirName) {
|
|
6967
6971
|
var existing = invokeMap.get(rootDirName);
|
|
6968
6972
|
if (existing) {
|
|
@@ -6978,7 +6982,7 @@ var ts;
|
|
|
6978
6982
|
}
|
|
6979
6983
|
});
|
|
6980
6984
|
var elapsed = ts.timestamp() - start;
|
|
6981
|
-
|
|
6985
|
+
sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
|
|
6982
6986
|
}
|
|
6983
6987
|
function removeChildWatches(parentWatcher) {
|
|
6984
6988
|
if (!parentWatcher)
|
|
@@ -7565,7 +7569,7 @@ var ts;
|
|
|
7565
7569
|
* @param createWatcher
|
|
7566
7570
|
*/
|
|
7567
7571
|
function invokeCallbackAndUpdateWatcher(createWatcher) {
|
|
7568
|
-
|
|
7572
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
|
|
7569
7573
|
// Call the callback for current directory
|
|
7570
7574
|
callback("rename", "");
|
|
7571
7575
|
// If watcher is not closed, update it
|
|
@@ -7590,7 +7594,7 @@ var ts;
|
|
|
7590
7594
|
}
|
|
7591
7595
|
}
|
|
7592
7596
|
if (hitSystemWatcherLimit) {
|
|
7593
|
-
|
|
7597
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to fsWatchFile");
|
|
7594
7598
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7595
7599
|
}
|
|
7596
7600
|
try {
|
|
@@ -7606,7 +7610,7 @@ var ts;
|
|
|
7606
7610
|
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
|
7607
7611
|
// so instead of throwing error, use fs.watchFile
|
|
7608
7612
|
hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC");
|
|
7609
|
-
|
|
7613
|
+
sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
|
|
7610
7614
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
7611
7615
|
}
|
|
7612
7616
|
}
|
|
@@ -8205,6 +8209,7 @@ var ts;
|
|
|
8205
8209
|
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8206
8210
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8207
8211
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8212
|
+
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8208
8213
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8209
8214
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8210
8215
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -8288,7 +8293,7 @@ var ts;
|
|
|
8288
8293
|
Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
|
|
8289
8294
|
Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
|
|
8290
8295
|
Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
8291
|
-
|
|
8296
|
+
A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."),
|
|
8292
8297
|
Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
|
|
8293
8298
|
A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
|
|
8294
8299
|
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
@@ -8311,6 +8316,7 @@ var ts;
|
|
|
8311
8316
|
constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
|
|
8312
8317
|
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
|
|
8313
8318
|
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
|
|
8319
|
+
A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, ts.DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."),
|
|
8314
8320
|
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
|
|
8315
8321
|
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
|
|
8316
8322
|
The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
|
|
@@ -8691,6 +8697,7 @@ var ts;
|
|
|
8691
8697
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
|
|
8692
8698
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
|
|
8693
8699
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8700
|
+
Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
|
|
8694
8701
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8695
8702
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8696
8703
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -9084,7 +9091,7 @@ var ts;
|
|
|
9084
9091
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9085
9092
|
_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
|
|
9086
9093
|
Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
|
|
9087
|
-
|
|
9094
|
+
Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
|
|
9088
9095
|
Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
|
|
9089
9096
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
9090
9097
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
@@ -9460,6 +9467,8 @@ var ts;
|
|
|
9460
9467
|
Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
|
|
9461
9468
|
Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
|
|
9462
9469
|
Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
|
|
9470
|
+
Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
|
|
9471
|
+
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9463
9472
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9464
9473
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9465
9474
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -15471,6 +15480,34 @@ var ts;
|
|
|
15471
15480
|
}
|
|
15472
15481
|
}
|
|
15473
15482
|
ts.getThisContainer = getThisContainer;
|
|
15483
|
+
/**
|
|
15484
|
+
* @returns Whether the node creates a new 'this' scope for its children.
|
|
15485
|
+
*/
|
|
15486
|
+
function isThisContainerOrFunctionBlock(node) {
|
|
15487
|
+
switch (node.kind) {
|
|
15488
|
+
// Arrow functions use the same scope, but may do so in a "delayed" manner
|
|
15489
|
+
// For example, `const getThis = () => this` may be before a super() call in a derived constructor
|
|
15490
|
+
case 213 /* ArrowFunction */:
|
|
15491
|
+
case 255 /* FunctionDeclaration */:
|
|
15492
|
+
case 212 /* FunctionExpression */:
|
|
15493
|
+
case 166 /* PropertyDeclaration */:
|
|
15494
|
+
return true;
|
|
15495
|
+
case 234 /* Block */:
|
|
15496
|
+
switch (node.parent.kind) {
|
|
15497
|
+
case 170 /* Constructor */:
|
|
15498
|
+
case 168 /* MethodDeclaration */:
|
|
15499
|
+
case 171 /* GetAccessor */:
|
|
15500
|
+
case 172 /* SetAccessor */:
|
|
15501
|
+
// Object properties can have computed names; only method-like bodies start a new scope
|
|
15502
|
+
return true;
|
|
15503
|
+
default:
|
|
15504
|
+
return false;
|
|
15505
|
+
}
|
|
15506
|
+
default:
|
|
15507
|
+
return false;
|
|
15508
|
+
}
|
|
15509
|
+
}
|
|
15510
|
+
ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
|
|
15474
15511
|
function isInTopLevelContext(node) {
|
|
15475
15512
|
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
|
15476
15513
|
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
|
@@ -15829,7 +15866,7 @@ var ts;
|
|
|
15829
15866
|
}
|
|
15830
15867
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
|
|
15831
15868
|
function getExternalModuleRequireArgument(node) {
|
|
15832
|
-
return
|
|
15869
|
+
return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
|
|
15833
15870
|
}
|
|
15834
15871
|
ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
|
|
15835
15872
|
function isInternalModuleImportEqualsDeclaration(node) {
|
|
@@ -15887,17 +15924,29 @@ var ts;
|
|
|
15887
15924
|
* Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
|
|
15888
15925
|
* This function does not test if the node is in a JavaScript file or not.
|
|
15889
15926
|
*/
|
|
15890
|
-
function
|
|
15927
|
+
function isVariableDeclarationInitializedToRequire(node) {
|
|
15928
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
|
|
15929
|
+
}
|
|
15930
|
+
ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
|
|
15931
|
+
/**
|
|
15932
|
+
* Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
|
|
15933
|
+
*/
|
|
15934
|
+
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
|
|
15935
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
|
|
15936
|
+
}
|
|
15937
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
15938
|
+
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
15891
15939
|
if (node.kind === 202 /* BindingElement */) {
|
|
15892
15940
|
node = node.parent.parent;
|
|
15893
15941
|
}
|
|
15894
|
-
return ts.isVariableDeclaration(node) &&
|
|
15942
|
+
return ts.isVariableDeclaration(node) &&
|
|
15943
|
+
!!node.initializer &&
|
|
15944
|
+
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
15895
15945
|
}
|
|
15896
|
-
ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
|
|
15897
15946
|
function isRequireVariableStatement(node) {
|
|
15898
15947
|
return ts.isVariableStatement(node)
|
|
15899
15948
|
&& node.declarationList.declarations.length > 0
|
|
15900
|
-
&& ts.every(node.declarationList.declarations, function (decl) { return
|
|
15949
|
+
&& ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
|
|
15901
15950
|
}
|
|
15902
15951
|
ts.isRequireVariableStatement = isRequireVariableStatement;
|
|
15903
15952
|
function isSingleOrDoubleQuote(charCode) {
|
|
@@ -19384,7 +19433,7 @@ var ts;
|
|
|
19384
19433
|
getSourceMapSourceConstructor: function () { return SourceMapSource; },
|
|
19385
19434
|
};
|
|
19386
19435
|
function setObjectAllocator(alloc) {
|
|
19387
|
-
ts.objectAllocator
|
|
19436
|
+
Object.assign(ts.objectAllocator, alloc);
|
|
19388
19437
|
}
|
|
19389
19438
|
ts.setObjectAllocator = setObjectAllocator;
|
|
19390
19439
|
function formatStringFromArgs(text, args, baseIndex) {
|
|
@@ -19392,13 +19441,22 @@ var ts;
|
|
|
19392
19441
|
return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
|
|
19393
19442
|
}
|
|
19394
19443
|
ts.formatStringFromArgs = formatStringFromArgs;
|
|
19444
|
+
var localizedDiagnosticMessages;
|
|
19395
19445
|
/* @internal */
|
|
19396
19446
|
function setLocalizedDiagnosticMessages(messages) {
|
|
19397
|
-
|
|
19447
|
+
localizedDiagnosticMessages = messages;
|
|
19398
19448
|
}
|
|
19399
19449
|
ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
|
|
19450
|
+
/* @internal */
|
|
19451
|
+
// If the localized messages json is unset, and if given function use it to set the json
|
|
19452
|
+
function maybeSetLocalizedDiagnosticMessages(getMessages) {
|
|
19453
|
+
if (!localizedDiagnosticMessages && getMessages) {
|
|
19454
|
+
localizedDiagnosticMessages = getMessages();
|
|
19455
|
+
}
|
|
19456
|
+
}
|
|
19457
|
+
ts.maybeSetLocalizedDiagnosticMessages = maybeSetLocalizedDiagnosticMessages;
|
|
19400
19458
|
function getLocaleSpecificMessage(message) {
|
|
19401
|
-
return
|
|
19459
|
+
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
|
|
19402
19460
|
}
|
|
19403
19461
|
ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
|
|
19404
19462
|
function createDetachedDiagnostic(fileName, start, length, message) {
|
|
@@ -26057,7 +26115,7 @@ var ts;
|
|
|
26057
26115
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
26058
26116
|
*/
|
|
26059
26117
|
function copyPrologue(source, target, ensureUseStrict, visitor) {
|
|
26060
|
-
var offset = copyStandardPrologue(source, target, ensureUseStrict);
|
|
26118
|
+
var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
|
|
26061
26119
|
return copyCustomPrologue(source, target, offset, visitor);
|
|
26062
26120
|
}
|
|
26063
26121
|
function isUseStrictPrologue(node) {
|
|
@@ -26070,12 +26128,14 @@ var ts;
|
|
|
26070
26128
|
* Copies only the standard (string-expression) prologue-directives into the target statement-array.
|
|
26071
26129
|
* @param source origin statements array
|
|
26072
26130
|
* @param target result statements array
|
|
26131
|
+
* @param statementOffset The offset at which to begin the copy.
|
|
26073
26132
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
26133
|
+
* @returns Count of how many directive statements were copied.
|
|
26074
26134
|
*/
|
|
26075
|
-
function copyStandardPrologue(source, target, ensureUseStrict) {
|
|
26135
|
+
function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
|
|
26136
|
+
if (statementOffset === void 0) { statementOffset = 0; }
|
|
26076
26137
|
ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
|
|
26077
26138
|
var foundUseStrict = false;
|
|
26078
|
-
var statementOffset = 0;
|
|
26079
26139
|
var numStatements = source.length;
|
|
26080
26140
|
while (statementOffset < numStatements) {
|
|
26081
26141
|
var statement = source[statementOffset];
|
|
@@ -27498,7 +27558,7 @@ var ts;
|
|
|
27498
27558
|
importName: "__createBinding",
|
|
27499
27559
|
scoped: false,
|
|
27500
27560
|
priority: 1,
|
|
27501
|
-
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.
|
|
27561
|
+
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
|
|
27502
27562
|
};
|
|
27503
27563
|
ts.setModuleDefaultHelper = {
|
|
27504
27564
|
name: "typescript:commonjscreatevalue",
|
|
@@ -35005,7 +35065,7 @@ var ts;
|
|
|
35005
35065
|
// one out no matter what.
|
|
35006
35066
|
var finallyBlock;
|
|
35007
35067
|
if (!catchClause || token() === 96 /* FinallyKeyword */) {
|
|
35008
|
-
parseExpected(96 /* FinallyKeyword
|
|
35068
|
+
parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected);
|
|
35009
35069
|
finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
|
35010
35070
|
}
|
|
35011
35071
|
return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc);
|
|
@@ -36049,7 +36109,7 @@ var ts;
|
|
|
36049
36109
|
var pos = getNodePos();
|
|
36050
36110
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
36051
36111
|
parseExpected(58 /* ColonToken */);
|
|
36052
|
-
var value =
|
|
36112
|
+
var value = parseAssignmentExpressionOrHigher();
|
|
36053
36113
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
36054
36114
|
}
|
|
36055
36115
|
function parseAssertClause() {
|
|
@@ -41133,7 +41193,7 @@ var ts;
|
|
|
41133
41193
|
? 1 /* Recursive */ : 0 /* None */
|
|
41134
41194
|
};
|
|
41135
41195
|
}
|
|
41136
|
-
if (ts.isImplicitGlob(spec)) {
|
|
41196
|
+
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
41137
41197
|
return {
|
|
41138
41198
|
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
41139
41199
|
flags: 1 /* Recursive */
|
|
@@ -44466,7 +44526,7 @@ var ts;
|
|
|
44466
44526
|
maybeBindExpressionFlowIfCall(node.expression);
|
|
44467
44527
|
}
|
|
44468
44528
|
function maybeBindExpressionFlowIfCall(node) {
|
|
44469
|
-
// A top level or
|
|
44529
|
+
// A top level or comma expression call expression with a dotted function name and at least one argument
|
|
44470
44530
|
// is potentially an assertion and is therefore included in the control flow.
|
|
44471
44531
|
if (node.kind === 207 /* CallExpression */) {
|
|
44472
44532
|
var call = node;
|
|
@@ -44634,22 +44694,27 @@ var ts;
|
|
|
44634
44694
|
}
|
|
44635
44695
|
return state;
|
|
44636
44696
|
}
|
|
44637
|
-
function onLeft(left, state,
|
|
44697
|
+
function onLeft(left, state, node) {
|
|
44638
44698
|
if (!state.skip) {
|
|
44639
|
-
|
|
44699
|
+
var maybeBound = maybeBind(left);
|
|
44700
|
+
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
44701
|
+
maybeBindExpressionFlowIfCall(left);
|
|
44702
|
+
}
|
|
44703
|
+
return maybeBound;
|
|
44640
44704
|
}
|
|
44641
44705
|
}
|
|
44642
|
-
function onOperator(operatorToken, state,
|
|
44706
|
+
function onOperator(operatorToken, state, _node) {
|
|
44643
44707
|
if (!state.skip) {
|
|
44644
|
-
if (operatorToken.kind === 27 /* CommaToken */) {
|
|
44645
|
-
maybeBindExpressionFlowIfCall(node.left);
|
|
44646
|
-
}
|
|
44647
44708
|
bind(operatorToken);
|
|
44648
44709
|
}
|
|
44649
44710
|
}
|
|
44650
|
-
function onRight(right, state,
|
|
44711
|
+
function onRight(right, state, node) {
|
|
44651
44712
|
if (!state.skip) {
|
|
44652
|
-
|
|
44713
|
+
var maybeBound = maybeBind(right);
|
|
44714
|
+
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
44715
|
+
maybeBindExpressionFlowIfCall(right);
|
|
44716
|
+
}
|
|
44717
|
+
return maybeBound;
|
|
44653
44718
|
}
|
|
44654
44719
|
}
|
|
44655
44720
|
function onExit(node, state) {
|
|
@@ -45392,6 +45457,8 @@ var ts;
|
|
|
45392
45457
|
return;
|
|
45393
45458
|
}
|
|
45394
45459
|
ts.setParent(node, parent);
|
|
45460
|
+
if (ts.tracing)
|
|
45461
|
+
node.tracingPath = file.path;
|
|
45395
45462
|
var saveInStrictMode = inStrictMode;
|
|
45396
45463
|
// Even though in the AST the jsdoc @typedef node belongs to the current node,
|
|
45397
45464
|
// its symbol might be in the same scope with the current node's symbol. Consider:
|
|
@@ -46212,7 +46279,7 @@ var ts;
|
|
|
46212
46279
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
46213
46280
|
}
|
|
46214
46281
|
if (!ts.isBindingPattern(node.name)) {
|
|
46215
|
-
if (ts.isInJSFile(node) && ts.
|
|
46282
|
+
if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
|
|
46216
46283
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
46217
46284
|
}
|
|
46218
46285
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -46723,6 +46790,9 @@ var ts;
|
|
|
46723
46790
|
TypeFacts[TypeFacts["EmptyObjectStrictFacts"] = 16318463] = "EmptyObjectStrictFacts";
|
|
46724
46791
|
TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
|
|
46725
46792
|
TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
|
|
46793
|
+
// Masks
|
|
46794
|
+
TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
|
|
46795
|
+
TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
|
|
46726
46796
|
})(TypeFacts || (TypeFacts = {}));
|
|
46727
46797
|
var typeofEQFacts = new ts.Map(ts.getEntries({
|
|
46728
46798
|
string: 1 /* TypeofEQString */,
|
|
@@ -48995,7 +49065,7 @@ var ts;
|
|
|
48995
49065
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
48996
49066
|
|| node.kind === 295 /* ShorthandPropertyAssignment */
|
|
48997
49067
|
|| node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
48998
|
-
|| ts.
|
|
49068
|
+
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
48999
49069
|
}
|
|
49000
49070
|
function isAliasableOrJsExpression(e) {
|
|
49001
49071
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -49783,8 +49853,14 @@ var ts;
|
|
|
49783
49853
|
var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
49784
49854
|
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
|
|
49785
49855
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
49786
|
-
var sourceFile = resolvedModule
|
|
49856
|
+
var sourceFile = resolvedModule
|
|
49857
|
+
&& (!resolutionDiagnostic || resolutionDiagnostic === ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set)
|
|
49858
|
+
&& host.getSourceFile(resolvedModule.resolvedFileName);
|
|
49787
49859
|
if (sourceFile) {
|
|
49860
|
+
// If there's a resolutionDiagnostic we need to report it even if a sourceFile is found.
|
|
49861
|
+
if (resolutionDiagnostic) {
|
|
49862
|
+
error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
49863
|
+
}
|
|
49788
49864
|
if (sourceFile.symbol) {
|
|
49789
49865
|
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
49790
49866
|
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
|
@@ -50926,6 +51002,7 @@ var ts;
|
|
|
50926
51002
|
getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
|
|
50927
51003
|
getCurrentDirectory: function () { return host.getCurrentDirectory(); },
|
|
50928
51004
|
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
|
|
51005
|
+
getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
|
|
50929
51006
|
useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
|
|
50930
51007
|
redirectTargetsMap: host.redirectTargetsMap,
|
|
50931
51008
|
getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
|
|
@@ -67857,10 +67934,23 @@ var ts;
|
|
|
67857
67934
|
// When an intersection contains a primitive type we ignore object type constituents as they are
|
|
67858
67935
|
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
|
|
67859
67936
|
ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */));
|
|
67860
|
-
return
|
|
67937
|
+
return getIntersectionTypeFacts(type, ignoreObjects);
|
|
67861
67938
|
}
|
|
67862
67939
|
return 16777215 /* All */;
|
|
67863
67940
|
}
|
|
67941
|
+
function getIntersectionTypeFacts(type, ignoreObjects) {
|
|
67942
|
+
// When computing the type facts of an intersection type, certain type facts are computed as `and`
|
|
67943
|
+
// and others are computed as `or`.
|
|
67944
|
+
var oredFacts = 0 /* None */;
|
|
67945
|
+
var andedFacts = 16777215 /* All */;
|
|
67946
|
+
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
|
67947
|
+
var t = _a[_i];
|
|
67948
|
+
var f = getTypeFacts(t, ignoreObjects);
|
|
67949
|
+
oredFacts |= f;
|
|
67950
|
+
andedFacts &= f;
|
|
67951
|
+
}
|
|
67952
|
+
return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
|
|
67953
|
+
}
|
|
67864
67954
|
function getTypeWithFacts(type, include) {
|
|
67865
67955
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
67866
67956
|
}
|
|
@@ -72864,9 +72954,6 @@ var ts;
|
|
|
72864
72954
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
72865
72955
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
72866
72956
|
}
|
|
72867
|
-
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
72868
|
-
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
72869
|
-
}
|
|
72870
72957
|
}
|
|
72871
72958
|
else {
|
|
72872
72959
|
if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
|
|
@@ -77875,7 +77962,7 @@ var ts;
|
|
|
77875
77962
|
}
|
|
77876
77963
|
}
|
|
77877
77964
|
function checkExpression(node, checkMode, forceTuple) {
|
|
77878
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
|
|
77965
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
|
|
77879
77966
|
var saveCurrentNode = currentNode;
|
|
77880
77967
|
currentNode = node;
|
|
77881
77968
|
instantiationCount = 0;
|
|
@@ -78521,32 +78608,38 @@ var ts;
|
|
|
78521
78608
|
if (classExtendsNull) {
|
|
78522
78609
|
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
78523
78610
|
}
|
|
78524
|
-
//
|
|
78525
|
-
// if both of the following are true:
|
|
78611
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
78526
78612
|
// - The containing class is a derived class.
|
|
78527
78613
|
// - The constructor declares parameter properties
|
|
78528
78614
|
// or the containing class declares instance member variables with initializers.
|
|
78529
|
-
var
|
|
78615
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
78530
78616
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
78531
78617
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
78532
|
-
|
|
78533
|
-
|
|
78534
|
-
|
|
78535
|
-
|
|
78536
|
-
|
|
78537
|
-
|
|
78538
|
-
|
|
78539
|
-
|
|
78540
|
-
|
|
78541
|
-
|
|
78618
|
+
if (superCallShouldBeRootLevel) {
|
|
78619
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78620
|
+
// See GH #8277
|
|
78621
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
78622
|
+
error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78623
|
+
}
|
|
78624
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
78625
|
+
else {
|
|
78626
|
+
var superCallStatement = void 0;
|
|
78627
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
78628
|
+
var statement = _a[_i];
|
|
78629
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
78630
|
+
superCallStatement = statement;
|
|
78631
|
+
break;
|
|
78632
|
+
}
|
|
78633
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
78634
|
+
break;
|
|
78635
|
+
}
|
|
78542
78636
|
}
|
|
78543
|
-
|
|
78544
|
-
|
|
78637
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78638
|
+
// See GH #8277
|
|
78639
|
+
if (superCallStatement === undefined) {
|
|
78640
|
+
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78545
78641
|
}
|
|
78546
78642
|
}
|
|
78547
|
-
if (!superCallStatement) {
|
|
78548
|
-
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78549
|
-
}
|
|
78550
78643
|
}
|
|
78551
78644
|
}
|
|
78552
78645
|
else if (!classExtendsNull) {
|
|
@@ -78554,6 +78647,19 @@ var ts;
|
|
|
78554
78647
|
}
|
|
78555
78648
|
}
|
|
78556
78649
|
}
|
|
78650
|
+
function superCallIsRootLevelInConstructor(superCall, body) {
|
|
78651
|
+
var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
|
|
78652
|
+
return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
|
|
78653
|
+
}
|
|
78654
|
+
function nodeImmediatelyReferencesSuperOrThis(node) {
|
|
78655
|
+
if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
|
|
78656
|
+
return true;
|
|
78657
|
+
}
|
|
78658
|
+
if (ts.isThisContainerOrFunctionBlock(node)) {
|
|
78659
|
+
return false;
|
|
78660
|
+
}
|
|
78661
|
+
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
78662
|
+
}
|
|
78557
78663
|
function checkAccessorDeclaration(node) {
|
|
78558
78664
|
if (produceDiagnostics) {
|
|
78559
78665
|
// Grammar checking accessors
|
|
@@ -80537,7 +80643,7 @@ var ts;
|
|
|
80537
80643
|
}
|
|
80538
80644
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
80539
80645
|
var symbol = getSymbolOfNode(node);
|
|
80540
|
-
if (symbol.flags & 2097152 /* Alias */ && ts.
|
|
80646
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
80541
80647
|
checkAliasSymbol(node);
|
|
80542
80648
|
return;
|
|
80543
80649
|
}
|
|
@@ -80615,7 +80721,7 @@ var ts;
|
|
|
80615
80721
|
return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
|
|
80616
80722
|
}
|
|
80617
80723
|
function checkVariableDeclaration(node) {
|
|
80618
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
|
|
80724
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
|
|
80619
80725
|
checkGrammarVariableDeclaration(node);
|
|
80620
80726
|
checkVariableLikeDeclaration(node);
|
|
80621
80727
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -83005,6 +83111,17 @@ var ts;
|
|
|
83005
83111
|
return false;
|
|
83006
83112
|
}
|
|
83007
83113
|
}
|
|
83114
|
+
if (!ts.isImportEqualsDeclaration(node) && node.assertClause) {
|
|
83115
|
+
var hasError = false;
|
|
83116
|
+
for (var _i = 0, _a = node.assertClause.elements; _i < _a.length; _i++) {
|
|
83117
|
+
var clause = _a[_i];
|
|
83118
|
+
if (!ts.isStringLiteral(clause.value)) {
|
|
83119
|
+
hasError = true;
|
|
83120
|
+
error(clause.value, ts.Diagnostics.Import_assertion_values_must_be_string_literal_expressions);
|
|
83121
|
+
}
|
|
83122
|
+
}
|
|
83123
|
+
return !hasError;
|
|
83124
|
+
}
|
|
83008
83125
|
return true;
|
|
83009
83126
|
}
|
|
83010
83127
|
function checkAliasSymbol(node) {
|
|
@@ -83698,7 +83815,7 @@ var ts;
|
|
|
83698
83815
|
}
|
|
83699
83816
|
}
|
|
83700
83817
|
function checkDeferredNode(node) {
|
|
83701
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
|
|
83818
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath });
|
|
83702
83819
|
var saveCurrentNode = currentNode;
|
|
83703
83820
|
currentNode = node;
|
|
83704
83821
|
instantiationCount = 0;
|
|
@@ -87632,7 +87749,7 @@ var ts;
|
|
|
87632
87749
|
return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine);
|
|
87633
87750
|
case 293 /* AssertEntry */:
|
|
87634
87751
|
ts.Debug.type(node);
|
|
87635
|
-
return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.
|
|
87752
|
+
return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode));
|
|
87636
87753
|
case 266 /* ImportClause */:
|
|
87637
87754
|
ts.Debug.type(node);
|
|
87638
87755
|
return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
|
|
@@ -88676,34 +88793,31 @@ var ts;
|
|
|
88676
88793
|
}
|
|
88677
88794
|
ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
|
|
88678
88795
|
/**
|
|
88679
|
-
*
|
|
88680
|
-
|
|
88681
|
-
|
|
88682
|
-
|
|
88683
|
-
|
|
88684
|
-
|
|
88796
|
+
* @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
|
|
88797
|
+
*/
|
|
88798
|
+
function getSuperCallFromStatement(statement) {
|
|
88799
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
88800
|
+
return undefined;
|
|
88801
|
+
}
|
|
88802
|
+
var expression = ts.skipParentheses(statement.expression);
|
|
88803
|
+
return ts.isSuperCall(expression)
|
|
88804
|
+
? expression
|
|
88805
|
+
: undefined;
|
|
88806
|
+
}
|
|
88807
|
+
ts.getSuperCallFromStatement = getSuperCallFromStatement;
|
|
88808
|
+
/**
|
|
88809
|
+
* @returns The index (after prologue statements) of a super call, or -1 if not found.
|
|
88685
88810
|
*/
|
|
88686
|
-
function
|
|
88687
|
-
|
|
88688
|
-
var
|
|
88689
|
-
|
|
88690
|
-
|
|
88691
|
-
if (index === statements.length) {
|
|
88692
|
-
// list contains nothing but prologue directives (or empty) - exit
|
|
88693
|
-
return index;
|
|
88694
|
-
}
|
|
88695
|
-
var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
|
|
88696
|
-
if (superIndex > -1) {
|
|
88697
|
-
for (var i = index; i <= superIndex; i++) {
|
|
88698
|
-
result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
|
|
88699
|
-
}
|
|
88700
|
-
return superIndex + 1;
|
|
88811
|
+
function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
|
|
88812
|
+
for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
|
|
88813
|
+
var statement = statements[i];
|
|
88814
|
+
if (getSuperCallFromStatement(statement)) {
|
|
88815
|
+
return i;
|
|
88701
88816
|
}
|
|
88702
|
-
return index;
|
|
88703
88817
|
}
|
|
88704
|
-
return
|
|
88818
|
+
return -1;
|
|
88705
88819
|
}
|
|
88706
|
-
ts.
|
|
88820
|
+
ts.findSuperStatementIndex = findSuperStatementIndex;
|
|
88707
88821
|
function getProperties(node, requireInitializer, isStatic) {
|
|
88708
88822
|
return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
|
|
88709
88823
|
}
|
|
@@ -90602,6 +90716,7 @@ var ts;
|
|
|
90602
90716
|
case 176 /* TypePredicate */:
|
|
90603
90717
|
case 133 /* BooleanKeyword */:
|
|
90604
90718
|
return factory.createIdentifier("Boolean");
|
|
90719
|
+
case 197 /* TemplateLiteralType */:
|
|
90605
90720
|
case 149 /* StringKeyword */:
|
|
90606
90721
|
return factory.createIdentifier("String");
|
|
90607
90722
|
case 147 /* ObjectKeyword */:
|
|
@@ -90940,10 +91055,14 @@ var ts;
|
|
|
90940
91055
|
return ts.visitFunctionBody(body, visitor, context);
|
|
90941
91056
|
}
|
|
90942
91057
|
var statements = [];
|
|
90943
|
-
var indexOfFirstStatement = 0;
|
|
90944
91058
|
resumeLexicalEnvironment();
|
|
90945
|
-
|
|
90946
|
-
|
|
91059
|
+
var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
91060
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
|
|
91061
|
+
// If there was a super call, visit existing statements up to and including it
|
|
91062
|
+
if (superStatementIndex >= 0) {
|
|
91063
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
|
|
91064
|
+
}
|
|
91065
|
+
// Transform parameters into property assignments. Transforms this:
|
|
90947
91066
|
//
|
|
90948
91067
|
// constructor (public x, public y) {
|
|
90949
91068
|
// }
|
|
@@ -90955,9 +91074,17 @@ var ts;
|
|
|
90955
91074
|
// this.y = y;
|
|
90956
91075
|
// }
|
|
90957
91076
|
//
|
|
90958
|
-
|
|
90959
|
-
//
|
|
90960
|
-
|
|
91077
|
+
var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
|
|
91078
|
+
// If there is a super() call, the parameter properties go immediately after it
|
|
91079
|
+
if (superStatementIndex >= 0) {
|
|
91080
|
+
ts.addRange(statements, parameterPropertyAssignments);
|
|
91081
|
+
}
|
|
91082
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
91083
|
+
else {
|
|
91084
|
+
statements = ts.addRange(parameterPropertyAssignments, statements);
|
|
91085
|
+
}
|
|
91086
|
+
// Add remaining statements from the body, skipping the super() call if it was found
|
|
91087
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
90961
91088
|
// End the lexical environment.
|
|
90962
91089
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
90963
91090
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -92855,6 +92982,7 @@ var ts;
|
|
|
92855
92982
|
/*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
|
|
92856
92983
|
}
|
|
92857
92984
|
function transformConstructorBody(node, constructor, isDerivedClass) {
|
|
92985
|
+
var _a;
|
|
92858
92986
|
var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
|
|
92859
92987
|
if (!useDefineForClassFields) {
|
|
92860
92988
|
properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
|
|
@@ -92866,9 +92994,21 @@ var ts;
|
|
|
92866
92994
|
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
|
|
92867
92995
|
}
|
|
92868
92996
|
resumeLexicalEnvironment();
|
|
92869
|
-
var
|
|
92997
|
+
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
92998
|
+
var indexOfFirstStatementAfterSuper = 0;
|
|
92999
|
+
var prologueStatementCount = 0;
|
|
93000
|
+
var superStatementIndex = -1;
|
|
92870
93001
|
var statements = [];
|
|
92871
|
-
if (
|
|
93002
|
+
if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
|
|
93003
|
+
prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
93004
|
+
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
93005
|
+
// If there was a super call, visit existing statements up to and including it
|
|
93006
|
+
if (superStatementIndex >= 0) {
|
|
93007
|
+
indexOfFirstStatementAfterSuper = superStatementIndex + 1;
|
|
93008
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
|
|
93009
|
+
}
|
|
93010
|
+
}
|
|
93011
|
+
if (needsSyntheticConstructor) {
|
|
92872
93012
|
// Add a synthetic `super` call:
|
|
92873
93013
|
//
|
|
92874
93014
|
// super(...arguments);
|
|
@@ -92876,9 +93016,6 @@ var ts;
|
|
|
92876
93016
|
statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
|
|
92877
93017
|
/*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
|
|
92878
93018
|
}
|
|
92879
|
-
if (constructor) {
|
|
92880
|
-
indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
|
|
92881
|
-
}
|
|
92882
93019
|
// Add the property initializers. Transforms this:
|
|
92883
93020
|
//
|
|
92884
93021
|
// public x = 1;
|
|
@@ -92889,31 +93026,59 @@ var ts;
|
|
|
92889
93026
|
// this.x = 1;
|
|
92890
93027
|
// }
|
|
92891
93028
|
//
|
|
93029
|
+
// If we do useDefineForClassFields, they'll be converted elsewhere.
|
|
93030
|
+
// We instead *remove* them from the transformed output at this stage.
|
|
93031
|
+
var parameterPropertyDeclarationCount = 0;
|
|
92892
93032
|
if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
|
|
92893
|
-
|
|
92894
|
-
|
|
92895
|
-
afterParameterProperties = constructor.body.statements.length;
|
|
93033
|
+
if (useDefineForClassFields) {
|
|
93034
|
+
statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
|
|
92896
93035
|
}
|
|
92897
|
-
|
|
92898
|
-
|
|
92899
|
-
|
|
93036
|
+
else {
|
|
93037
|
+
for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
|
|
93038
|
+
var statement = _b[_i];
|
|
93039
|
+
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93040
|
+
parameterPropertyDeclarationCount++;
|
|
93041
|
+
}
|
|
93042
|
+
}
|
|
93043
|
+
if (parameterPropertyDeclarationCount > 0) {
|
|
93044
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
|
|
93045
|
+
// If there was a super() call found, add parameter properties immediately after it
|
|
93046
|
+
if (superStatementIndex >= 0) {
|
|
93047
|
+
ts.addRange(statements, parameterProperties);
|
|
93048
|
+
}
|
|
93049
|
+
// If a synthetic super() call was added, add them just after it
|
|
93050
|
+
else if (needsSyntheticConstructor) {
|
|
93051
|
+
statements = __spreadArray(__spreadArray([
|
|
93052
|
+
statements[0]
|
|
93053
|
+
], parameterProperties, true), statements.slice(1), true);
|
|
93054
|
+
}
|
|
93055
|
+
// Since there wasn't a super() call, add them to the top of the constructor
|
|
93056
|
+
else {
|
|
93057
|
+
statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
|
|
93058
|
+
}
|
|
93059
|
+
indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
|
|
92900
93060
|
}
|
|
92901
|
-
indexOfFirstStatement = afterParameterProperties;
|
|
92902
93061
|
}
|
|
92903
93062
|
}
|
|
92904
93063
|
var receiver = factory.createThis();
|
|
92905
93064
|
// private methods can be called in property initializers, they should execute first.
|
|
92906
93065
|
addMethodStatements(statements, privateMethodsAndAccessors, receiver);
|
|
92907
93066
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
92908
|
-
// Add existing statements
|
|
93067
|
+
// Add existing statements after the initial prologues and super call
|
|
92909
93068
|
if (constructor) {
|
|
92910
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements,
|
|
93069
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
|
|
92911
93070
|
}
|
|
92912
93071
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92913
93072
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
92914
93073
|
/*location*/ constructor ? constructor.body.statements : node.members),
|
|
92915
93074
|
/*multiLine*/ true),
|
|
92916
93075
|
/*location*/ constructor ? constructor.body : undefined);
|
|
93076
|
+
function visitBodyStatement(statement) {
|
|
93077
|
+
if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93078
|
+
return undefined;
|
|
93079
|
+
}
|
|
93080
|
+
return visitor(statement);
|
|
93081
|
+
}
|
|
92917
93082
|
}
|
|
92918
93083
|
/**
|
|
92919
93084
|
* Generates assignment statements for property initializers.
|
|
@@ -95434,10 +95599,19 @@ var ts;
|
|
|
95434
95599
|
var _a;
|
|
95435
95600
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95436
95601
|
var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
|
|
95437
|
-
var args = [tagName, objectProperties
|
|
95602
|
+
var args = [tagName, objectProperties];
|
|
95603
|
+
// function jsx(type, config, maybeKey) {}
|
|
95604
|
+
// "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
|
|
95605
|
+
if (keyAttr) {
|
|
95606
|
+
args.push(transformJsxAttributeInitializer(keyAttr.initializer));
|
|
95607
|
+
}
|
|
95438
95608
|
if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
|
|
95439
95609
|
var originalFile = ts.getOriginalNode(currentSourceFile);
|
|
95440
95610
|
if (originalFile && ts.isSourceFile(originalFile)) {
|
|
95611
|
+
// "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
|
|
95612
|
+
if (keyAttr === undefined) {
|
|
95613
|
+
args.push(factory.createVoidZero());
|
|
95614
|
+
}
|
|
95441
95615
|
// isStaticChildren development flag
|
|
95442
95616
|
args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
|
|
95443
95617
|
// __source development flag
|
|
@@ -96705,37 +96879,39 @@ var ts;
|
|
|
96705
96879
|
var prologue = [];
|
|
96706
96880
|
var statements = [];
|
|
96707
96881
|
resumeLexicalEnvironment();
|
|
96882
|
+
// In derived classes, there may be code before the necessary super() call
|
|
96883
|
+
// We'll remove pre-super statements to be tacked on after the rest of the body
|
|
96884
|
+
var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
|
|
96885
|
+
var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
|
|
96886
|
+
var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
|
|
96708
96887
|
// If a super call has already been synthesized,
|
|
96709
96888
|
// we're going to assume that we should just transform everything after that.
|
|
96710
96889
|
// The assumption is that no prior step in the pipeline has added any prologue directives.
|
|
96711
|
-
var statementOffset =
|
|
96890
|
+
var statementOffset = postSuperStatementsStart;
|
|
96712
96891
|
if (!hasSynthesizedSuper)
|
|
96713
|
-
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
|
|
96714
|
-
addDefaultValueAssignmentsIfNeeded(statements, constructor);
|
|
96715
|
-
addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
|
|
96892
|
+
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
|
|
96716
96893
|
if (!hasSynthesizedSuper)
|
|
96717
|
-
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
|
|
96718
|
-
// If
|
|
96894
|
+
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
|
|
96895
|
+
// If there already exists a call to `super()`, visit the statement directly
|
|
96719
96896
|
var superCallExpression;
|
|
96720
96897
|
if (hasSynthesizedSuper) {
|
|
96721
96898
|
superCallExpression = createDefaultSuperCallOrThis();
|
|
96722
96899
|
}
|
|
96723
|
-
else if (
|
|
96724
|
-
|
|
96725
|
-
if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
|
|
96726
|
-
superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
|
|
96727
|
-
}
|
|
96900
|
+
else if (superCall) {
|
|
96901
|
+
superCallExpression = visitSuperCallInBody(superCall);
|
|
96728
96902
|
}
|
|
96729
96903
|
if (superCallExpression) {
|
|
96730
96904
|
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
96731
|
-
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
|
|
96732
96905
|
}
|
|
96906
|
+
// Add parameter defaults at the beginning of the output, with prologue statements
|
|
96907
|
+
addDefaultValueAssignmentsIfNeeded(prologue, constructor);
|
|
96908
|
+
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
96733
96909
|
// visit the remaining statements
|
|
96734
96910
|
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
|
|
96735
96911
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
96736
96912
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
96737
|
-
if (isDerivedClass) {
|
|
96738
|
-
if (superCallExpression &&
|
|
96913
|
+
if (isDerivedClass || superCallExpression) {
|
|
96914
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
|
|
96739
96915
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
96740
96916
|
// following representation:
|
|
96741
96917
|
//
|
|
@@ -96755,10 +96931,10 @@ var ts;
|
|
|
96755
96931
|
// return C;
|
|
96756
96932
|
// })(Base);
|
|
96757
96933
|
// ```
|
|
96758
|
-
var
|
|
96934
|
+
var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
|
|
96759
96935
|
var returnStatement = factory.createReturnStatement(superCallExpression);
|
|
96760
|
-
ts.setCommentRange(returnStatement, ts.getCommentRange(
|
|
96761
|
-
ts.setEmitFlags(
|
|
96936
|
+
ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
|
|
96937
|
+
ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
|
|
96762
96938
|
statements.push(returnStatement);
|
|
96763
96939
|
}
|
|
96764
96940
|
else {
|
|
@@ -96783,9 +96959,19 @@ var ts;
|
|
|
96783
96959
|
// return C;
|
|
96784
96960
|
// })(Base);
|
|
96785
96961
|
// ```
|
|
96786
|
-
//
|
|
96787
|
-
|
|
96788
|
-
|
|
96962
|
+
// If the super() call is the first statement, we can directly create and assign its result to `_this`
|
|
96963
|
+
if (superStatementIndex <= existingPrologue.length) {
|
|
96964
|
+
insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
|
|
96965
|
+
}
|
|
96966
|
+
// Since the `super()` call isn't the first statement, it's split across 1-2 statements:
|
|
96967
|
+
// * A prologue `var _this = this;`, in case the constructor accesses this before super()
|
|
96968
|
+
// * If it exists, a reassignment to that `_this` of the super() call
|
|
96969
|
+
else {
|
|
96970
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
96971
|
+
if (superCallExpression) {
|
|
96972
|
+
insertSuperThisCaptureThisForNode(statements, superCallExpression);
|
|
96973
|
+
}
|
|
96974
|
+
}
|
|
96789
96975
|
if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
96790
96976
|
statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
|
|
96791
96977
|
}
|
|
@@ -96808,11 +96994,27 @@ var ts;
|
|
|
96808
96994
|
// ```
|
|
96809
96995
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
96810
96996
|
}
|
|
96811
|
-
var
|
|
96997
|
+
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
|
|
96812
96998
|
/*location*/ constructor.body.statements),
|
|
96813
96999
|
/*multiLine*/ true);
|
|
96814
|
-
ts.setTextRange(
|
|
96815
|
-
return
|
|
97000
|
+
ts.setTextRange(body, constructor.body);
|
|
97001
|
+
return body;
|
|
97002
|
+
}
|
|
97003
|
+
function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
|
|
97004
|
+
for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
|
|
97005
|
+
var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
|
|
97006
|
+
if (superCall) {
|
|
97007
|
+
// With a super() call, split the statements into pre-super() and 'body' (post-super())
|
|
97008
|
+
return {
|
|
97009
|
+
superCall: superCall,
|
|
97010
|
+
superStatementIndex: i,
|
|
97011
|
+
};
|
|
97012
|
+
}
|
|
97013
|
+
}
|
|
97014
|
+
// Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
|
|
97015
|
+
return {
|
|
97016
|
+
superStatementIndex: -1,
|
|
97017
|
+
};
|
|
96816
97018
|
}
|
|
96817
97019
|
/**
|
|
96818
97020
|
* We want to try to avoid emitting a return statement in certain cases if a user already returned something.
|
|
@@ -97041,6 +97243,18 @@ var ts;
|
|
|
97041
97243
|
}
|
|
97042
97244
|
return false;
|
|
97043
97245
|
}
|
|
97246
|
+
/**
|
|
97247
|
+
* Assigns the `this` in a constructor to the result of its `super()` call.
|
|
97248
|
+
*
|
|
97249
|
+
* @param statements Statements in the constructor body.
|
|
97250
|
+
* @param superExpression Existing `super()` call for the constructor.
|
|
97251
|
+
*/
|
|
97252
|
+
function insertSuperThisCaptureThisForNode(statements, superExpression) {
|
|
97253
|
+
enableSubstitutionsForCapturedThis();
|
|
97254
|
+
var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
|
|
97255
|
+
ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
|
|
97256
|
+
ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
|
|
97257
|
+
}
|
|
97044
97258
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
97045
97259
|
enableSubstitutionsForCapturedThis();
|
|
97046
97260
|
var captureThisStatement = factory.createVariableStatement(
|
|
@@ -97350,7 +97564,7 @@ var ts;
|
|
|
97350
97564
|
if (ts.isBlock(body)) {
|
|
97351
97565
|
// ensureUseStrict is false because no new prologue-directive should be added.
|
|
97352
97566
|
// addStandardPrologue will put already-existing directives at the beginning of the target statement-array
|
|
97353
|
-
statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
|
|
97567
|
+
statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
|
|
97354
97568
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
|
|
97355
97569
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
|
|
97356
97570
|
}
|
|
@@ -98721,7 +98935,7 @@ var ts;
|
|
|
98721
98935
|
/*type*/ undefined, factory.updateBlock(func.body, statements))),
|
|
98722
98936
|
/*typeArguments*/ undefined, call.arguments))));
|
|
98723
98937
|
}
|
|
98724
|
-
function
|
|
98938
|
+
function visitSuperCallInBody(node) {
|
|
98725
98939
|
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
|
|
98726
98940
|
}
|
|
98727
98941
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
@@ -119262,11 +119476,12 @@ var ts;
|
|
|
119262
119476
|
};
|
|
119263
119477
|
}
|
|
119264
119478
|
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
119479
|
+
var _a;
|
|
119265
119480
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
|
|
119266
119481
|
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
119267
119482
|
return false;
|
|
119268
119483
|
}
|
|
119269
|
-
return ts.getImpliedNodeFormatForFile(importingSourceFileName,
|
|
119484
|
+
return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
|
|
119270
119485
|
}
|
|
119271
119486
|
function getModuleResolutionHost(host) {
|
|
119272
119487
|
var _a;
|
|
@@ -119826,11 +120041,13 @@ var ts;
|
|
|
119826
120041
|
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
|
|
119827
120042
|
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
|
|
119828
120043
|
function tryDirectoryWithPackageJson(packageRootIndex) {
|
|
120044
|
+
var _a, _b;
|
|
119829
120045
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
119830
120046
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
119831
120047
|
var moduleFileToTry = path;
|
|
119832
|
-
|
|
119833
|
-
|
|
120048
|
+
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
120049
|
+
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
120050
|
+
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
119834
120051
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
119835
120052
|
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
|
|
119836
120053
|
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
@@ -120130,22 +120347,31 @@ var ts;
|
|
|
120130
120347
|
ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
120131
120348
|
}
|
|
120132
120349
|
ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
|
|
120350
|
+
function prettyPathForFileError(error, cwd) {
|
|
120351
|
+
var line = ts.formatColorAndReset(":" + error.line, ts.ForegroundColorEscapeSequences.Grey);
|
|
120352
|
+
if (ts.pathIsAbsolute(error.fileName) && ts.pathIsAbsolute(cwd)) {
|
|
120353
|
+
return ts.getRelativePathFromDirectory(cwd, error.fileName, /* ignoreCase */ false) + line;
|
|
120354
|
+
}
|
|
120355
|
+
return error.fileName + line;
|
|
120356
|
+
}
|
|
120133
120357
|
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
120134
120358
|
if (errorCount === 0)
|
|
120135
120359
|
return "";
|
|
120136
120360
|
var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
|
|
120137
120361
|
var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; })
|
|
120138
120362
|
.filter(function (value, index, self) { return self.indexOf(value) === index; });
|
|
120363
|
+
var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory());
|
|
120139
120364
|
var d = errorCount === 1 ?
|
|
120140
120365
|
ts.createCompilerDiagnostic(filesInError[0] !== undefined ?
|
|
120141
120366
|
ts.Diagnostics.Found_1_error_in_1 :
|
|
120142
|
-
ts.Diagnostics.Found_1_error, errorCount,
|
|
120367
|
+
ts.Diagnostics.Found_1_error, errorCount, firstFileReference) :
|
|
120143
120368
|
ts.createCompilerDiagnostic(distinctFileNamesWithLines.length === 0 ?
|
|
120144
120369
|
ts.Diagnostics.Found_0_errors :
|
|
120145
120370
|
distinctFileNamesWithLines.length === 1 ?
|
|
120146
|
-
ts.Diagnostics.
|
|
120147
|
-
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
|
|
120148
|
-
|
|
120371
|
+
ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 :
|
|
120372
|
+
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length);
|
|
120373
|
+
var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "";
|
|
120374
|
+
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix;
|
|
120149
120375
|
}
|
|
120150
120376
|
ts.getErrorSummaryText = getErrorSummaryText;
|
|
120151
120377
|
function createTabularErrorsDisplay(filesInError, host) {
|
|
@@ -120167,8 +120393,8 @@ var ts;
|
|
|
120167
120393
|
var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
|
|
120168
120394
|
" ".repeat(leftPaddingGoal - errorCountDigitsLength)
|
|
120169
120395
|
: "";
|
|
120170
|
-
var
|
|
120171
|
-
tabularData += "" + leftPadding + errorCount + " " +
|
|
120396
|
+
var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
|
|
120397
|
+
tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n";
|
|
120172
120398
|
});
|
|
120173
120399
|
return tabularData;
|
|
120174
120400
|
}
|
|
@@ -120669,6 +120895,7 @@ var ts;
|
|
|
120669
120895
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
120670
120896
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
120671
120897
|
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
120898
|
+
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
120672
120899
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
120673
120900
|
var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
|
|
120674
120901
|
var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
|
|
@@ -120831,14 +121058,21 @@ var ts;
|
|
|
120831
121058
|
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
|
|
120832
121059
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
120833
121060
|
if (hasChangedConfigFileParsingErrors) {
|
|
121061
|
+
if (reportFileChangeDetectedOnCreateProgram) {
|
|
121062
|
+
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
121063
|
+
}
|
|
120834
121064
|
builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
120835
121065
|
hasChangedConfigFileParsingErrors = false;
|
|
120836
121066
|
}
|
|
120837
121067
|
}
|
|
120838
121068
|
else {
|
|
121069
|
+
if (reportFileChangeDetectedOnCreateProgram) {
|
|
121070
|
+
reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
|
|
121071
|
+
}
|
|
120839
121072
|
createNewProgram(hasInvalidatedResolution);
|
|
120840
121073
|
}
|
|
120841
121074
|
changesAffectResolution = false; // reset for next sync
|
|
121075
|
+
reportFileChangeDetectedOnCreateProgram = false;
|
|
120842
121076
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
120843
121077
|
host.afterProgramCreate(builderProgram);
|
|
120844
121078
|
}
|
|
@@ -121040,7 +121274,7 @@ var ts;
|
|
|
121040
121274
|
}
|
|
121041
121275
|
function updateProgramWithWatchStatus() {
|
|
121042
121276
|
timerToUpdateProgram = undefined;
|
|
121043
|
-
|
|
121277
|
+
reportFileChangeDetectedOnCreateProgram = true;
|
|
121044
121278
|
updateProgram();
|
|
121045
121279
|
}
|
|
121046
121280
|
function updateProgram() {
|
|
@@ -123147,6 +123381,7 @@ var ts;
|
|
|
123147
123381
|
ScriptElementKind["externalModuleName"] = "external module name";
|
|
123148
123382
|
/**
|
|
123149
123383
|
* <JsxTagName attribute1 attribute2={0} />
|
|
123384
|
+
* @deprecated
|
|
123150
123385
|
*/
|
|
123151
123386
|
ScriptElementKind["jsxAttribute"] = "JSX attribute";
|
|
123152
123387
|
/** String literal */
|
|
@@ -124472,7 +124707,7 @@ var ts;
|
|
|
124472
124707
|
isWhiteSpaceOnlyJsxText(child);
|
|
124473
124708
|
if (lookInPreviousChild) {
|
|
124474
124709
|
// actual start of the node is past the position - previous token should be at the end of previous child
|
|
124475
|
-
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
|
|
124710
|
+
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
|
|
124476
124711
|
return candidate_1 && findRightmostToken(candidate_1, sourceFile);
|
|
124477
124712
|
}
|
|
124478
124713
|
else {
|
|
@@ -124486,7 +124721,7 @@ var ts;
|
|
|
124486
124721
|
// the only known case is when position is at the end of the file.
|
|
124487
124722
|
// Try to find the rightmost token in the file without filtering.
|
|
124488
124723
|
// Namely we are skipping the check: 'position < node.end'
|
|
124489
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
124724
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
124490
124725
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
124491
124726
|
}
|
|
124492
124727
|
}
|
|
@@ -124502,17 +124737,19 @@ var ts;
|
|
|
124502
124737
|
if (children.length === 0) {
|
|
124503
124738
|
return n;
|
|
124504
124739
|
}
|
|
124505
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
124740
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
124506
124741
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
124507
124742
|
}
|
|
124508
124743
|
/**
|
|
124509
124744
|
* Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
|
|
124510
124745
|
*/
|
|
124511
|
-
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
|
|
124746
|
+
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
|
|
124512
124747
|
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
|
|
124513
124748
|
var child = children[i];
|
|
124514
124749
|
if (isWhiteSpaceOnlyJsxText(child)) {
|
|
124515
|
-
|
|
124750
|
+
if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
|
|
124751
|
+
ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
|
|
124752
|
+
}
|
|
124516
124753
|
}
|
|
124517
124754
|
else if (nodeHasTokens(children[i], sourceFile)) {
|
|
124518
124755
|
return children[i];
|
|
@@ -125038,6 +125275,7 @@ var ts;
|
|
|
125038
125275
|
useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
|
|
125039
125276
|
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache,
|
|
125040
125277
|
getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache),
|
|
125278
|
+
getPackageJsonInfoCache: function () { var _a; return (_a = program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); },
|
|
125041
125279
|
getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
|
|
125042
125280
|
redirectTargetsMap: program.redirectTargetsMap,
|
|
125043
125281
|
getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
|
|
@@ -128724,6 +128962,8 @@ var ts;
|
|
|
128724
128962
|
CompletionSource["ThisProperty"] = "ThisProperty/";
|
|
128725
128963
|
/** Auto-import that comes attached to a class member snippet */
|
|
128726
128964
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
128965
|
+
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
128966
|
+
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
128727
128967
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
128728
128968
|
var SymbolOriginInfoKind;
|
|
128729
128969
|
(function (SymbolOriginInfoKind) {
|
|
@@ -128733,6 +128973,7 @@ var ts;
|
|
|
128733
128973
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
|
|
128734
128974
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
128735
128975
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
128976
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
128736
128977
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
128737
128978
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
128738
128979
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -128760,6 +129001,9 @@ var ts;
|
|
|
128760
129001
|
function originIsNullableMember(origin) {
|
|
128761
129002
|
return !!(origin.kind & 16 /* Nullable */);
|
|
128762
129003
|
}
|
|
129004
|
+
function originIsTypeOnlyAlias(origin) {
|
|
129005
|
+
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
129006
|
+
}
|
|
128763
129007
|
var KeywordCompletionFilters;
|
|
128764
129008
|
(function (KeywordCompletionFilters) {
|
|
128765
129009
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -128782,6 +129026,7 @@ var ts;
|
|
|
128782
129026
|
function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
|
|
128783
129027
|
var _a, _b, _c;
|
|
128784
129028
|
var start = ts.timestamp();
|
|
129029
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
128785
129030
|
var resolutionLimitExceeded = false;
|
|
128786
129031
|
var ambientCount = 0;
|
|
128787
129032
|
var resolvedCount = 0;
|
|
@@ -128804,7 +129049,7 @@ var ts;
|
|
|
128804
129049
|
var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
|
|
128805
129050
|
var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
|
|
128806
129051
|
var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
|
|
128807
|
-
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache)
|
|
129052
|
+
? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
|
|
128808
129053
|
: undefined;
|
|
128809
129054
|
if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
|
|
128810
129055
|
resolutionLimitExceeded = true;
|
|
@@ -128978,7 +129223,7 @@ var ts;
|
|
|
128978
129223
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128979
129224
|
}
|
|
128980
129225
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
128981
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129226
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
128982
129227
|
// Verify if the file is JSX language variant
|
|
128983
129228
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
128984
129229
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -128989,7 +129234,7 @@ var ts;
|
|
|
128989
129234
|
var entries = ts.createSortedArray();
|
|
128990
129235
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128991
129236
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128992
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129237
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128993
129238
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128994
129239
|
}
|
|
128995
129240
|
else {
|
|
@@ -128997,7 +129242,7 @@ var ts;
|
|
|
128997
129242
|
return undefined;
|
|
128998
129243
|
}
|
|
128999
129244
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
129000
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129245
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129001
129246
|
}
|
|
129002
129247
|
if (keywordFilters !== 0 /* None */) {
|
|
129003
129248
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -129103,7 +129348,7 @@ var ts;
|
|
|
129103
129348
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
129104
129349
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
129105
129350
|
}
|
|
129106
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
|
|
129351
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129107
129352
|
var _a, _b;
|
|
129108
129353
|
var insertText;
|
|
129109
129354
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -129163,6 +129408,9 @@ var ts;
|
|
|
129163
129408
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
129164
129409
|
}
|
|
129165
129410
|
}
|
|
129411
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
129412
|
+
hasAction = true;
|
|
129413
|
+
}
|
|
129166
129414
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
129167
129415
|
preferences.includeCompletionsWithInsertText &&
|
|
129168
129416
|
completionKind === 3 /* MemberLike */ &&
|
|
@@ -129174,8 +129422,7 @@ var ts;
|
|
|
129174
129422
|
source = CompletionSource.ClassMemberSnippet;
|
|
129175
129423
|
}
|
|
129176
129424
|
}
|
|
129177
|
-
|
|
129178
|
-
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129425
|
+
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129179
129426
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
129180
129427
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
129181
129428
|
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
|
|
@@ -129213,7 +129460,7 @@ var ts;
|
|
|
129213
129460
|
// entries (like JavaScript identifier entries).
|
|
129214
129461
|
return {
|
|
129215
129462
|
name: name,
|
|
129216
|
-
kind:
|
|
129463
|
+
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
|
|
129217
129464
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
129218
129465
|
sortText: sortText,
|
|
129219
129466
|
source: source,
|
|
@@ -129508,8 +129755,11 @@ var ts;
|
|
|
129508
129755
|
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
|
|
129509
129756
|
return CompletionSource.ThisProperty;
|
|
129510
129757
|
}
|
|
129758
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
129759
|
+
return CompletionSource.TypeOnlyAlias;
|
|
129760
|
+
}
|
|
129511
129761
|
}
|
|
129512
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129762
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129513
129763
|
var _a;
|
|
129514
129764
|
var start = ts.timestamp();
|
|
129515
129765
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -129530,12 +129780,12 @@ var ts;
|
|
|
129530
129780
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129531
129781
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129532
129782
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129533
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
|
|
129783
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129534
129784
|
if (!entry) {
|
|
129535
129785
|
continue;
|
|
129536
129786
|
}
|
|
129537
129787
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129538
|
-
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129788
|
+
var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129539
129789
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129540
129790
|
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129541
129791
|
}
|
|
@@ -129548,6 +129798,7 @@ var ts;
|
|
|
129548
129798
|
add: function (name) { return uniques.set(name, true); },
|
|
129549
129799
|
};
|
|
129550
129800
|
function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
|
|
129801
|
+
var allFlags = symbol.flags;
|
|
129551
129802
|
if (!ts.isSourceFile(location)) {
|
|
129552
129803
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
129553
129804
|
if (ts.isExportAssignment(location.parent)) {
|
|
@@ -129573,11 +129824,10 @@ var ts;
|
|
|
129573
129824
|
|| symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
|
|
129574
129825
|
return false;
|
|
129575
129826
|
}
|
|
129576
|
-
|
|
129577
|
-
symbol = symbolOrigin;
|
|
129827
|
+
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
129578
129828
|
// import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
|
|
129579
129829
|
if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
|
|
129580
|
-
return !!(
|
|
129830
|
+
return !!(allFlags & 1920 /* Namespace */);
|
|
129581
129831
|
}
|
|
129582
129832
|
if (isTypeOnlyLocation) {
|
|
129583
129833
|
// It's a type, but you can reach it by namespace.type as well
|
|
@@ -129585,7 +129835,7 @@ var ts;
|
|
|
129585
129835
|
}
|
|
129586
129836
|
}
|
|
129587
129837
|
// expressions are value space (which includes the value namespaces)
|
|
129588
|
-
return !!(
|
|
129838
|
+
return !!(allFlags & 111551 /* Value */);
|
|
129589
129839
|
}
|
|
129590
129840
|
}
|
|
129591
129841
|
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
|
|
@@ -129738,6 +129988,11 @@ var ts;
|
|
|
129738
129988
|
};
|
|
129739
129989
|
}
|
|
129740
129990
|
}
|
|
129991
|
+
if (originIsTypeOnlyAlias(origin)) {
|
|
129992
|
+
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
129993
|
+
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
129994
|
+
return { codeActions: [codeAction_1], sourceDisplay: undefined };
|
|
129995
|
+
}
|
|
129741
129996
|
if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
|
|
129742
129997
|
return { codeActions: undefined, sourceDisplay: undefined };
|
|
129743
129998
|
}
|
|
@@ -130124,6 +130379,7 @@ var ts;
|
|
|
130124
130379
|
symbolToSortTextIdMap: symbolToSortTextIdMap,
|
|
130125
130380
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
130126
130381
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
130382
|
+
isRightOfOpenTag: isRightOfOpenTag,
|
|
130127
130383
|
importCompletionNode: importCompletionNode,
|
|
130128
130384
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
130129
130385
|
};
|
|
@@ -130202,9 +130458,7 @@ var ts;
|
|
|
130202
130458
|
// GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
|
|
130203
130459
|
// if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
|
|
130204
130460
|
// we will check (and cache) the type of `this` *before* checking the type of the node.
|
|
130205
|
-
|
|
130206
|
-
if (!ts.isSourceFile(container) && container.parent)
|
|
130207
|
-
typeChecker.getTypeAtLocation(container);
|
|
130461
|
+
typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
|
|
130208
130462
|
var type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
|
|
130209
130463
|
var insertQuestionDot = false;
|
|
130210
130464
|
if (type.isNullableType()) {
|
|
@@ -130415,21 +130669,29 @@ var ts;
|
|
|
130415
130669
|
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
|
130416
130670
|
isInSnippetScope = isSnippetScope(scopeNode);
|
|
130417
130671
|
var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
|
|
130672
|
+
var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
|
|
130418
130673
|
symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
|
|
130419
130674
|
ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
|
|
130420
|
-
for (var
|
|
130421
|
-
var symbol =
|
|
130675
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
130676
|
+
var symbol = symbols[i];
|
|
130422
130677
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
130423
130678
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
130424
130679
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
|
|
130425
130680
|
}
|
|
130681
|
+
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
130682
|
+
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
130683
|
+
if (typeOnlyAliasDeclaration) {
|
|
130684
|
+
var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
|
|
130685
|
+
symbolToOriginInfoMap[i] = origin;
|
|
130686
|
+
}
|
|
130687
|
+
}
|
|
130426
130688
|
}
|
|
130427
130689
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
130428
130690
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
|
|
130429
130691
|
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
130430
130692
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
130431
|
-
for (var
|
|
130432
|
-
var symbol =
|
|
130693
|
+
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
130694
|
+
var symbol = _a[_i];
|
|
130433
130695
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
130434
130696
|
symbols.push(symbol);
|
|
130435
130697
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
|
|
@@ -131828,10 +132090,14 @@ var ts;
|
|
|
131828
132090
|
/** True if symbol is a type or a module containing at least one type. */
|
|
131829
132091
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
131830
132092
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
131831
|
-
|
|
131832
|
-
|
|
131833
|
-
|
|
131834
|
-
|
|
132093
|
+
// Since an alias can be merged with a local declaration, we need to test both the alias and its target.
|
|
132094
|
+
// This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
|
|
132095
|
+
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
132096
|
+
function nonAliasCanBeReferencedAtTypeLocation(symbol) {
|
|
132097
|
+
return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
|
|
132098
|
+
!!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
|
|
132099
|
+
checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
|
|
132100
|
+
}
|
|
131835
132101
|
}
|
|
131836
132102
|
function isDeprecated(symbol, checker) {
|
|
131837
132103
|
var declarations = ts.skipAlias(symbol, checker).declarations;
|
|
@@ -133059,7 +133325,7 @@ var ts;
|
|
|
133059
133325
|
ts.Debug.assert(parent.name === node);
|
|
133060
133326
|
return true;
|
|
133061
133327
|
case 202 /* BindingElement */:
|
|
133062
|
-
return ts.isInJSFile(node) && ts.
|
|
133328
|
+
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
|
|
133063
133329
|
default:
|
|
133064
133330
|
return false;
|
|
133065
133331
|
}
|
|
@@ -133540,7 +133806,7 @@ var ts;
|
|
|
133540
133806
|
function getTextSpan(node, sourceFile, endNode) {
|
|
133541
133807
|
var start = node.getStart(sourceFile);
|
|
133542
133808
|
var end = (endNode || node).getEnd();
|
|
133543
|
-
if (ts.isStringLiteralLike(node)) {
|
|
133809
|
+
if (ts.isStringLiteralLike(node) && (end - start) > 2) {
|
|
133544
133810
|
ts.Debug.assert(endNode === undefined);
|
|
133545
133811
|
start += 1;
|
|
133546
133812
|
end -= 1;
|
|
@@ -134085,8 +134351,8 @@ var ts;
|
|
|
134085
134351
|
var sourceId = ts.getNodeId(sourceFile);
|
|
134086
134352
|
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
|
|
134087
134353
|
var anyNewSymbols = false;
|
|
134088
|
-
for (var _i = 0,
|
|
134089
|
-
var sym =
|
|
134354
|
+
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
134355
|
+
var sym = symbols_1[_i];
|
|
134090
134356
|
anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
|
|
134091
134357
|
}
|
|
134092
134358
|
return anyNewSymbols;
|
|
@@ -134459,7 +134725,7 @@ var ts;
|
|
|
134459
134725
|
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
|
134460
134726
|
if (ts.isInJSFile(referenceLocation)
|
|
134461
134727
|
&& referenceLocation.parent.kind === 202 /* BindingElement */
|
|
134462
|
-
&& ts.
|
|
134728
|
+
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
|
|
134463
134729
|
referenceSymbol = referenceLocation.parent.symbol;
|
|
134464
134730
|
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
|
|
134465
134731
|
// this case, just skip it, since the bound identifiers are not an alias of the import.
|
|
@@ -136060,7 +136326,7 @@ var ts;
|
|
|
136060
136326
|
return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
136061
136327
|
}
|
|
136062
136328
|
if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
|
|
136063
|
-
var node = ts.
|
|
136329
|
+
var node = ts.getTouchingToken(sourceFile, position);
|
|
136064
136330
|
if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
|
|
136065
136331
|
var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
136066
136332
|
var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
|
|
@@ -136170,7 +136436,7 @@ var ts;
|
|
|
136170
136436
|
return declaration.parent.kind === 268 /* NamedImports */;
|
|
136171
136437
|
case 202 /* BindingElement */:
|
|
136172
136438
|
case 253 /* VariableDeclaration */:
|
|
136173
|
-
return ts.isInJSFile(declaration) && ts.
|
|
136439
|
+
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
136174
136440
|
default:
|
|
136175
136441
|
return false;
|
|
136176
136442
|
}
|
|
@@ -136860,7 +137126,7 @@ var ts;
|
|
|
136860
137126
|
textSpan: ts.createTextSpanFromNode(declaration),
|
|
136861
137127
|
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
|
136862
137128
|
containerName: containerName ? containerName.text : "",
|
|
136863
|
-
containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
|
|
137129
|
+
containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */,
|
|
136864
137130
|
};
|
|
136865
137131
|
}
|
|
136866
137132
|
})(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
|
|
@@ -141074,18 +141340,7 @@ var ts;
|
|
|
141074
141340
|
}
|
|
141075
141341
|
return unionPropertyKind;
|
|
141076
141342
|
}
|
|
141077
|
-
|
|
141078
|
-
switch (location.parent && location.parent.kind) {
|
|
141079
|
-
// If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
|
|
141080
|
-
case 279 /* JsxOpeningElement */:
|
|
141081
|
-
case 277 /* JsxElement */:
|
|
141082
|
-
case 278 /* JsxSelfClosingElement */:
|
|
141083
|
-
return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */;
|
|
141084
|
-
case 284 /* JsxAttribute */:
|
|
141085
|
-
return "JSX attribute" /* jsxAttribute */;
|
|
141086
|
-
default:
|
|
141087
|
-
return "property" /* memberVariableElement */;
|
|
141088
|
-
}
|
|
141343
|
+
return "property" /* memberVariableElement */;
|
|
141089
141344
|
}
|
|
141090
141345
|
return "" /* unknown */;
|
|
141091
141346
|
}
|
|
@@ -144949,6 +145204,7 @@ var ts;
|
|
|
144949
145204
|
ChangeTracker.prototype.delete = function (sourceFile, node) {
|
|
144950
145205
|
this.deletedNodes.push({ sourceFile: sourceFile, node: node });
|
|
144951
145206
|
};
|
|
145207
|
+
/** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
|
|
144952
145208
|
ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
|
|
144953
145209
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
144954
145210
|
this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
|
|
@@ -145103,7 +145359,11 @@ var ts;
|
|
|
145103
145359
|
oldTags[i] = merged;
|
|
145104
145360
|
return !!merged;
|
|
145105
145361
|
}); });
|
|
145106
|
-
var
|
|
145362
|
+
var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
|
|
145363
|
+
var jsDoc = ts.singleOrUndefined(parent.jsDoc);
|
|
145364
|
+
var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
|
|
145365
|
+
ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
|
|
145366
|
+
var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
|
|
145107
145367
|
var host = updateJSDocHost(parent);
|
|
145108
145368
|
this.insertJsdocCommentBefore(sourceFile, host, tag);
|
|
145109
145369
|
};
|
|
@@ -145348,6 +145608,15 @@ var ts;
|
|
|
145348
145608
|
ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
|
|
145349
145609
|
this.insertText(sourceFile, node.getStart(sourceFile), "export ");
|
|
145350
145610
|
};
|
|
145611
|
+
ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
|
|
145612
|
+
var prevSpecifier = namedImports.elements[index - 1];
|
|
145613
|
+
if (prevSpecifier) {
|
|
145614
|
+
this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
|
|
145615
|
+
}
|
|
145616
|
+
else {
|
|
145617
|
+
this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
|
|
145618
|
+
}
|
|
145619
|
+
};
|
|
145351
145620
|
/**
|
|
145352
145621
|
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
|
|
145353
145622
|
* i.e. arguments in arguments lists, parameters in parameter lists etc.
|
|
@@ -145533,6 +145802,8 @@ var ts;
|
|
|
145533
145802
|
}
|
|
145534
145803
|
case 339 /* JSDocReturnTag */:
|
|
145535
145804
|
return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
|
|
145805
|
+
case 341 /* JSDocTypeTag */:
|
|
145806
|
+
return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
|
|
145536
145807
|
}
|
|
145537
145808
|
}
|
|
145538
145809
|
// find first non-whitespace position in the leading trivia of the node
|
|
@@ -146233,20 +146504,31 @@ var ts;
|
|
|
146233
146504
|
codefix.registerCodeFix({
|
|
146234
146505
|
errorCodes: errorCodes,
|
|
146235
146506
|
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
|
|
146236
|
-
var
|
|
146507
|
+
var assertion = getAssertion(context.sourceFile, context.span.start);
|
|
146508
|
+
if (assertion === undefined)
|
|
146509
|
+
return undefined;
|
|
146510
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
|
|
146237
146511
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
|
|
146238
146512
|
},
|
|
146239
146513
|
fixIds: [fixId],
|
|
146240
|
-
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146514
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146515
|
+
var assertion = getAssertion(diag.file, diag.start);
|
|
146516
|
+
if (assertion) {
|
|
146517
|
+
makeChange(changes, diag.file, assertion);
|
|
146518
|
+
}
|
|
146519
|
+
}); },
|
|
146241
146520
|
});
|
|
146242
|
-
function makeChange(changeTracker, sourceFile,
|
|
146243
|
-
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
146244
|
-
var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
|
|
146521
|
+
function makeChange(changeTracker, sourceFile, assertion) {
|
|
146245
146522
|
var replacement = ts.isAsExpression(assertion)
|
|
146246
146523
|
? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
|
|
146247
146524
|
: ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
|
|
146248
146525
|
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
|
|
146249
146526
|
}
|
|
146527
|
+
function getAssertion(sourceFile, pos) {
|
|
146528
|
+
if (ts.isInJSFile(sourceFile))
|
|
146529
|
+
return undefined;
|
|
146530
|
+
return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
|
|
146531
|
+
}
|
|
146250
146532
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
146251
146533
|
})(ts || (ts = {}));
|
|
146252
146534
|
/* @internal */
|
|
@@ -148837,7 +149119,8 @@ var ts;
|
|
|
148837
149119
|
ts.Diagnostics.Cannot_find_namespace_0.code,
|
|
148838
149120
|
ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
|
|
148839
149121
|
ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
|
|
148840
|
-
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
|
|
149122
|
+
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
|
|
149123
|
+
ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
|
|
148841
149124
|
];
|
|
148842
149125
|
codefix.registerCodeFix({
|
|
148843
149126
|
errorCodes: errorCodes,
|
|
@@ -148942,6 +149225,9 @@ var ts;
|
|
|
148942
149225
|
}
|
|
148943
149226
|
break;
|
|
148944
149227
|
}
|
|
149228
|
+
case 4 /* PromoteTypeOnly */:
|
|
149229
|
+
// Excluding from fix-all
|
|
149230
|
+
break;
|
|
148945
149231
|
default:
|
|
148946
149232
|
ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
|
|
148947
149233
|
}
|
|
@@ -149033,6 +149319,7 @@ var ts;
|
|
|
149033
149319
|
ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
|
|
149034
149320
|
ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
|
|
149035
149321
|
ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
|
|
149322
|
+
ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
|
|
149036
149323
|
})(ImportFixKind || (ImportFixKind = {}));
|
|
149037
149324
|
// These should not be combined as bitflags, but are given powers of 2 values to
|
|
149038
149325
|
// easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
|
|
@@ -149058,9 +149345,17 @@ var ts;
|
|
|
149058
149345
|
};
|
|
149059
149346
|
}
|
|
149060
149347
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
149348
|
+
function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
|
|
149349
|
+
var compilerOptions = program.getCompilerOptions();
|
|
149350
|
+
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
149351
|
+
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
149352
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
|
|
149353
|
+
}
|
|
149354
|
+
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
149061
149355
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149062
149356
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149063
|
-
|
|
149357
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
149358
|
+
return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
|
|
149064
149359
|
}
|
|
149065
149360
|
function codeFixActionToCodeAction(_a) {
|
|
149066
149361
|
var description = _a.description, changes = _a.changes, commands = _a.commands;
|
|
@@ -149115,12 +149410,12 @@ var ts;
|
|
|
149115
149410
|
return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
|
|
149116
149411
|
}
|
|
149117
149412
|
}
|
|
149118
|
-
function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) {
|
|
149413
|
+
function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
|
|
149119
149414
|
var _a = getNewImportFixes(program, importingFile,
|
|
149120
149415
|
/*position*/ undefined,
|
|
149121
149416
|
/*isValidTypeOnlyUseSite*/ false,
|
|
149122
149417
|
/*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
|
|
149123
|
-
var result = getBestFix(fixes, importingFile, program,
|
|
149418
|
+
var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
|
|
149124
149419
|
return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
|
|
149125
149420
|
}
|
|
149126
149421
|
codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
|
|
@@ -149254,7 +149549,7 @@ var ts;
|
|
|
149254
149549
|
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
149255
149550
|
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
|
149256
149551
|
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
|
149257
|
-
if (ts.
|
|
149552
|
+
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
|
149258
149553
|
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
|
149259
149554
|
}
|
|
149260
149555
|
if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
|
|
@@ -149337,26 +149632,34 @@ var ts;
|
|
|
149337
149632
|
}
|
|
149338
149633
|
function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
|
|
149339
149634
|
var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
|
|
149340
|
-
|
|
149341
|
-
|
|
149342
|
-
|
|
149343
|
-
|
|
149635
|
+
if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
|
149636
|
+
return getFixesInfoForUMDImport(context, symbolToken);
|
|
149637
|
+
}
|
|
149638
|
+
if (!ts.isIdentifier(symbolToken)) {
|
|
149639
|
+
return undefined;
|
|
149640
|
+
}
|
|
149641
|
+
if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
149642
|
+
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
149643
|
+
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
149644
|
+
return fix && { fixes: [fix], symbolName: symbolName_1 };
|
|
149645
|
+
}
|
|
149646
|
+
var info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
149647
|
+
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
149648
|
+
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
149344
149649
|
}
|
|
149345
|
-
function sortFixes(fixes, sourceFile, program,
|
|
149346
|
-
|
|
149347
|
-
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); });
|
|
149650
|
+
function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
149651
|
+
return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
|
|
149348
149652
|
}
|
|
149349
|
-
function getBestFix(fixes, sourceFile, program,
|
|
149653
|
+
function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
|
|
149350
149654
|
if (!ts.some(fixes))
|
|
149351
149655
|
return;
|
|
149352
149656
|
// These will always be placed first if available, and are better than other kinds
|
|
149353
149657
|
if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
|
|
149354
149658
|
return fixes[0];
|
|
149355
149659
|
}
|
|
149356
|
-
var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
|
|
149357
149660
|
return fixes.reduce(function (best, fix) {
|
|
149358
149661
|
// Takes true branch of conditional if `fix` is better than `best`
|
|
149359
|
-
return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
149662
|
+
return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
|
|
149360
149663
|
});
|
|
149361
149664
|
}
|
|
149362
149665
|
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
|
|
@@ -149364,10 +149667,15 @@ var ts;
|
|
|
149364
149667
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
149365
149668
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
149366
149669
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
149670
|
+
|| ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
|
|
149367
149671
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
149368
149672
|
}
|
|
149369
149673
|
return 0 /* EqualTo */;
|
|
149370
149674
|
}
|
|
149675
|
+
var notDotOrSlashPattern = /[^.\/]/;
|
|
149676
|
+
function isOnlyDotsAndSlashes(path) {
|
|
149677
|
+
return !notDotOrSlashPattern.test(path);
|
|
149678
|
+
}
|
|
149371
149679
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
149372
149680
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
149373
149681
|
return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
|
|
@@ -149459,6 +149767,16 @@ var ts;
|
|
|
149459
149767
|
}));
|
|
149460
149768
|
return { fixes: fixes, symbolName: symbolName };
|
|
149461
149769
|
}
|
|
149770
|
+
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
149771
|
+
var checker = program.getTypeChecker();
|
|
149772
|
+
var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
149773
|
+
if (!symbol)
|
|
149774
|
+
return undefined;
|
|
149775
|
+
var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
|
|
149776
|
+
if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
|
|
149777
|
+
return undefined;
|
|
149778
|
+
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
149779
|
+
}
|
|
149462
149780
|
function jsxModeNeedsExplicitImport(jsx) {
|
|
149463
149781
|
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
149464
149782
|
}
|
|
@@ -149466,12 +149784,18 @@ var ts;
|
|
|
149466
149784
|
var parent = symbolToken.parent;
|
|
149467
149785
|
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
149468
149786
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
149469
|
-
if (
|
|
149787
|
+
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
149470
149788
|
return jsxNamespace;
|
|
149471
149789
|
}
|
|
149472
149790
|
}
|
|
149473
149791
|
return symbolToken.text;
|
|
149474
149792
|
}
|
|
149793
|
+
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
|
|
149794
|
+
if (ts.isIntrinsicJsxName(symbolToken.text))
|
|
149795
|
+
return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
|
|
149796
|
+
var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
149797
|
+
return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
|
|
149798
|
+
}
|
|
149475
149799
|
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
|
|
149476
149800
|
function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
149477
149801
|
var _a;
|
|
@@ -149570,10 +149894,80 @@ var ts;
|
|
|
149570
149894
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
149571
149895
|
return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
|
|
149572
149896
|
}
|
|
149897
|
+
case 4 /* PromoteTypeOnly */: {
|
|
149898
|
+
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
149899
|
+
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
|
|
149900
|
+
return promotedDeclaration.kind === 269 /* ImportSpecifier */
|
|
149901
|
+
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
|
|
149902
|
+
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
|
|
149903
|
+
}
|
|
149573
149904
|
default:
|
|
149574
149905
|
return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
|
|
149575
149906
|
}
|
|
149576
149907
|
}
|
|
149908
|
+
function getModuleSpecifierText(promotedDeclaration) {
|
|
149909
|
+
var _a, _b;
|
|
149910
|
+
return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
|
|
149911
|
+
? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
|
|
149912
|
+
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
|
|
149913
|
+
}
|
|
149914
|
+
function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
|
|
149915
|
+
// See comment in `doAddExistingFix` on constant with the same name.
|
|
149916
|
+
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
|
|
149917
|
+
switch (aliasDeclaration.kind) {
|
|
149918
|
+
case 269 /* ImportSpecifier */:
|
|
149919
|
+
if (aliasDeclaration.isTypeOnly) {
|
|
149920
|
+
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
|
|
149921
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
149922
|
+
var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
|
|
149923
|
+
var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
|
|
149924
|
+
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
149925
|
+
}
|
|
149926
|
+
else {
|
|
149927
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
149928
|
+
}
|
|
149929
|
+
return aliasDeclaration;
|
|
149930
|
+
}
|
|
149931
|
+
else {
|
|
149932
|
+
ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
149933
|
+
promoteImportClause(aliasDeclaration.parent.parent);
|
|
149934
|
+
return aliasDeclaration.parent.parent;
|
|
149935
|
+
}
|
|
149936
|
+
case 266 /* ImportClause */:
|
|
149937
|
+
promoteImportClause(aliasDeclaration);
|
|
149938
|
+
return aliasDeclaration;
|
|
149939
|
+
case 267 /* NamespaceImport */:
|
|
149940
|
+
promoteImportClause(aliasDeclaration.parent);
|
|
149941
|
+
return aliasDeclaration.parent;
|
|
149942
|
+
case 264 /* ImportEqualsDeclaration */:
|
|
149943
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
|
|
149944
|
+
return aliasDeclaration;
|
|
149945
|
+
default:
|
|
149946
|
+
ts.Debug.failBadSyntaxKind(aliasDeclaration);
|
|
149947
|
+
}
|
|
149948
|
+
function promoteImportClause(importClause) {
|
|
149949
|
+
changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
149950
|
+
if (convertExistingToTypeOnly) {
|
|
149951
|
+
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
|
|
149952
|
+
if (namedImports && namedImports.elements.length > 1) {
|
|
149953
|
+
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
|
|
149954
|
+
aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
|
|
149955
|
+
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
149956
|
+
// The import specifier being promoted will be the only non-type-only,
|
|
149957
|
+
// import in the NamedImports, so it should be moved to the front.
|
|
149958
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
149959
|
+
changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
|
|
149960
|
+
}
|
|
149961
|
+
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
|
|
149962
|
+
var element = _a[_i];
|
|
149963
|
+
if (element !== aliasDeclaration && !element.isTypeOnly) {
|
|
149964
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
|
|
149965
|
+
}
|
|
149966
|
+
}
|
|
149967
|
+
}
|
|
149968
|
+
}
|
|
149969
|
+
}
|
|
149970
|
+
}
|
|
149577
149971
|
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
|
|
149578
149972
|
var _a;
|
|
149579
149973
|
if (clause.kind === 200 /* ObjectBindingPattern */) {
|
|
@@ -149611,13 +150005,7 @@ var ts;
|
|
|
149611
150005
|
var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
|
|
149612
150006
|
? 0
|
|
149613
150007
|
: ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
|
|
149614
|
-
|
|
149615
|
-
if (prevSpecifier) {
|
|
149616
|
-
changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
|
|
149617
|
-
}
|
|
149618
|
-
else {
|
|
149619
|
-
changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
|
|
149620
|
-
}
|
|
150008
|
+
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
149621
150009
|
}
|
|
149622
150010
|
}
|
|
149623
150011
|
else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
|
|
@@ -149975,7 +150363,7 @@ var ts;
|
|
|
149975
150363
|
var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
149976
150364
|
codefix.registerCodeFix({
|
|
149977
150365
|
errorCodes: errorCodes,
|
|
149978
|
-
getCodeActions: function (context) {
|
|
150366
|
+
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
149979
150367
|
var sourceFile = context.sourceFile, program = context.program, span = context.span;
|
|
149980
150368
|
var diagnostic;
|
|
149981
150369
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) {
|
|
@@ -149990,7 +150378,8 @@ var ts;
|
|
|
149990
150378
|
});
|
|
149991
150379
|
function doChange(changes, sourceFile, pos, checker) {
|
|
149992
150380
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
149993
|
-
ts.
|
|
150381
|
+
if (!ts.isThis(token))
|
|
150382
|
+
return undefined;
|
|
149994
150383
|
var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false);
|
|
149995
150384
|
if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn))
|
|
149996
150385
|
return undefined;
|
|
@@ -151800,6 +152189,9 @@ var ts;
|
|
|
151800
152189
|
codefix.registerCodeFix({
|
|
151801
152190
|
errorCodes: errorCodes,
|
|
151802
152191
|
getCodeActions: function (context) {
|
|
152192
|
+
var syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
152193
|
+
if (syntacticDiagnostics.length)
|
|
152194
|
+
return;
|
|
151803
152195
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, context.span.start, context.span.length, context.errorCode); });
|
|
151804
152196
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_unreachable_code, fixId, ts.Diagnostics.Remove_all_unreachable_code)];
|
|
151805
152197
|
},
|
|
@@ -152203,7 +152595,7 @@ var ts;
|
|
|
152203
152595
|
});
|
|
152204
152596
|
var name = declaration && ts.getNameOfDeclaration(declaration);
|
|
152205
152597
|
return !name || changes.length === 0 ? undefined
|
|
152206
|
-
: [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token),
|
|
152598
|
+
: [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getTextOfNode(name)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
|
|
152207
152599
|
},
|
|
152208
152600
|
fixIds: [fixId],
|
|
152209
152601
|
getAllCodeActions: function (context) {
|
|
@@ -152281,7 +152673,7 @@ var ts;
|
|
|
152281
152673
|
case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
|
|
152282
152674
|
var symbol = program.getTypeChecker().getSymbolAtLocation(token);
|
|
152283
152675
|
if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
|
|
152284
|
-
annotateVariableDeclaration(changes, importAdder,
|
|
152676
|
+
annotateVariableDeclaration(changes, importAdder, ts.getSourceFileOfNode(symbol.valueDeclaration), symbol.valueDeclaration, program, host, cancellationToken);
|
|
152285
152677
|
importAdder.writeFixes(changes);
|
|
152286
152678
|
return symbol.valueDeclaration;
|
|
152287
152679
|
}
|
|
@@ -153980,35 +154372,34 @@ var ts;
|
|
|
153980
154372
|
codefix.registerCodeFix({
|
|
153981
154373
|
errorCodes: errorCodes,
|
|
153982
154374
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
153983
|
-
var
|
|
153984
|
-
if (!
|
|
154375
|
+
var info = getInfo(context.sourceFile, context.span.start);
|
|
154376
|
+
if (!info)
|
|
153985
154377
|
return;
|
|
153986
|
-
var result = [
|
|
153987
|
-
|
|
153988
|
-
|
|
153989
|
-
|
|
153990
|
-
ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
|
|
154378
|
+
var result = [];
|
|
154379
|
+
ts.append(result, getActionForAddMissingUndefinedType(context, info));
|
|
154380
|
+
ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
|
|
154381
|
+
ts.append(result, getActionForAddMissingInitializer(context, info));
|
|
153991
154382
|
return result;
|
|
153992
154383
|
},
|
|
153993
154384
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
153994
154385
|
getAllCodeActions: function (context) {
|
|
153995
154386
|
return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
153996
|
-
var
|
|
153997
|
-
if (!
|
|
154387
|
+
var info = getInfo(diag.file, diag.start);
|
|
154388
|
+
if (!info)
|
|
153998
154389
|
return;
|
|
153999
154390
|
switch (context.fixId) {
|
|
154000
154391
|
case fixIdAddDefiniteAssignmentAssertions:
|
|
154001
|
-
addDefiniteAssignmentAssertion(changes, diag.file,
|
|
154392
|
+
addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
|
|
154002
154393
|
break;
|
|
154003
154394
|
case fixIdAddUndefinedType:
|
|
154004
|
-
addUndefinedType(changes, diag.file,
|
|
154395
|
+
addUndefinedType(changes, diag.file, info);
|
|
154005
154396
|
break;
|
|
154006
154397
|
case fixIdAddInitializer:
|
|
154007
154398
|
var checker = context.program.getTypeChecker();
|
|
154008
|
-
var initializer = getInitializer(checker,
|
|
154399
|
+
var initializer = getInitializer(checker, info.prop);
|
|
154009
154400
|
if (!initializer)
|
|
154010
154401
|
return;
|
|
154011
|
-
addInitializer(changes, diag.file,
|
|
154402
|
+
addInitializer(changes, diag.file, info.prop, initializer);
|
|
154012
154403
|
break;
|
|
154013
154404
|
default:
|
|
154014
154405
|
ts.Debug.fail(JSON.stringify(context.fixId));
|
|
@@ -154016,35 +154407,50 @@ var ts;
|
|
|
154016
154407
|
});
|
|
154017
154408
|
},
|
|
154018
154409
|
});
|
|
154019
|
-
function
|
|
154410
|
+
function getInfo(sourceFile, pos) {
|
|
154020
154411
|
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
154021
|
-
|
|
154412
|
+
if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
|
|
154413
|
+
var type = ts.getEffectiveTypeAnnotationNode(token.parent);
|
|
154414
|
+
if (type) {
|
|
154415
|
+
return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
|
|
154416
|
+
}
|
|
154417
|
+
}
|
|
154418
|
+
return undefined;
|
|
154022
154419
|
}
|
|
154023
|
-
function getActionForAddMissingDefiniteAssignmentAssertion(context,
|
|
154024
|
-
|
|
154025
|
-
|
|
154420
|
+
function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
|
|
154421
|
+
if (info.isJs)
|
|
154422
|
+
return undefined;
|
|
154423
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
|
|
154424
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
|
|
154026
154425
|
}
|
|
154027
154426
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
154028
154427
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
154029
154428
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
154030
154429
|
}
|
|
154031
|
-
function getActionForAddMissingUndefinedType(context,
|
|
154032
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile,
|
|
154033
|
-
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0,
|
|
154430
|
+
function getActionForAddMissingUndefinedType(context, info) {
|
|
154431
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
|
|
154432
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
|
|
154034
154433
|
}
|
|
154035
|
-
function addUndefinedType(changeTracker,
|
|
154434
|
+
function addUndefinedType(changeTracker, sourceFile, info) {
|
|
154036
154435
|
var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
|
|
154037
|
-
var
|
|
154038
|
-
var
|
|
154039
|
-
|
|
154436
|
+
var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
|
|
154437
|
+
var unionTypeNode = ts.factory.createUnionTypeNode(types);
|
|
154438
|
+
if (info.isJs) {
|
|
154439
|
+
changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
|
|
154440
|
+
}
|
|
154441
|
+
else {
|
|
154442
|
+
changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
|
|
154443
|
+
}
|
|
154040
154444
|
}
|
|
154041
|
-
function getActionForAddMissingInitializer(context,
|
|
154445
|
+
function getActionForAddMissingInitializer(context, info) {
|
|
154446
|
+
if (info.isJs)
|
|
154447
|
+
return undefined;
|
|
154042
154448
|
var checker = context.program.getTypeChecker();
|
|
154043
|
-
var initializer = getInitializer(checker,
|
|
154449
|
+
var initializer = getInitializer(checker, info.prop);
|
|
154044
154450
|
if (!initializer)
|
|
154045
154451
|
return undefined;
|
|
154046
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile,
|
|
154047
|
-
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0,
|
|
154452
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
|
|
154453
|
+
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
|
|
154048
154454
|
}
|
|
154049
154455
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
154050
154456
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
@@ -160421,6 +160827,7 @@ var ts;
|
|
|
160421
160827
|
], false);
|
|
160422
160828
|
function createLanguageService(host, documentRegistry, syntaxOnlyOrLanguageServiceMode) {
|
|
160423
160829
|
var _a;
|
|
160830
|
+
var _b;
|
|
160424
160831
|
if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); }
|
|
160425
160832
|
var languageServiceMode;
|
|
160426
160833
|
if (syntaxOnlyOrLanguageServiceMode === undefined) {
|
|
@@ -160441,10 +160848,8 @@ var ts;
|
|
|
160441
160848
|
? new CancellationTokenObject(host.getCancellationToken())
|
|
160442
160849
|
: NoopCancellationToken;
|
|
160443
160850
|
var currentDirectory = host.getCurrentDirectory();
|
|
160444
|
-
//
|
|
160445
|
-
|
|
160446
|
-
ts.setLocalizedDiagnosticMessages(host.getLocalizedDiagnosticMessages());
|
|
160447
|
-
}
|
|
160851
|
+
// Checks if the localized messages json is set, and if not, query the host for it
|
|
160852
|
+
ts.maybeSetLocalizedDiagnosticMessages((_b = host.getLocalizedDiagnosticMessages) === null || _b === void 0 ? void 0 : _b.bind(host));
|
|
160448
160853
|
function log(message) {
|
|
160449
160854
|
if (host.log) {
|
|
160450
160855
|
host.log(message);
|
|
@@ -160546,6 +160951,7 @@ var ts;
|
|
|
160546
160951
|
hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
|
|
160547
160952
|
trace: parseConfigHost.trace,
|
|
160548
160953
|
resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
|
|
160954
|
+
getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
|
|
160549
160955
|
resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
|
|
160550
160956
|
useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
|
|
160551
160957
|
getParsedCommandLine: getParsedCommandLine,
|
|
@@ -165176,6 +165582,9 @@ var ts;
|
|
|
165176
165582
|
Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
165177
165583
|
return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
|
|
165178
165584
|
};
|
|
165585
|
+
Project.prototype.getModuleResolutionCache = function () {
|
|
165586
|
+
return this.resolutionCache.getModuleResolutionCache();
|
|
165587
|
+
};
|
|
165179
165588
|
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
|
|
165180
165589
|
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
|
|
165181
165590
|
};
|
|
@@ -166438,6 +166847,7 @@ var ts;
|
|
|
166438
166847
|
if (!program) {
|
|
166439
166848
|
return ts.emptyArray;
|
|
166440
166849
|
}
|
|
166850
|
+
var start = ts.timestamp();
|
|
166441
166851
|
var dependencyNames;
|
|
166442
166852
|
var rootNames;
|
|
166443
166853
|
var rootFileName = ts.combinePaths(hostProject.currentDirectory, ts.inferredTypesContainingFile);
|
|
@@ -166447,14 +166857,14 @@ var ts;
|
|
|
166447
166857
|
(_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a.forEach(function (_, dependenyName) { return addDependency(dependenyName); });
|
|
166448
166858
|
(_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
|
|
166449
166859
|
}
|
|
166860
|
+
var dependenciesAdded = 0;
|
|
166450
166861
|
if (dependencyNames) {
|
|
166451
|
-
var dependenciesAdded = 0;
|
|
166452
166862
|
var symlinkCache = hostProject.getSymlinkCache();
|
|
166453
166863
|
for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
|
|
166454
166864
|
var name = _d[_c];
|
|
166455
166865
|
// Avoid creating a large project that would significantly slow down time to editor interactivity
|
|
166456
166866
|
if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
|
|
166457
|
-
hostProject.log("
|
|
166867
|
+
hostProject.log("AutoImportProviderProject: attempted to add more than " + this.maxDependencies + " dependencies. Aborting.");
|
|
166458
166868
|
return ts.emptyArray;
|
|
166459
166869
|
}
|
|
166460
166870
|
// 1. Try to load from the implementation package. For many dependencies, the
|
|
@@ -166488,6 +166898,9 @@ var ts;
|
|
|
166488
166898
|
}
|
|
166489
166899
|
}
|
|
166490
166900
|
}
|
|
166901
|
+
if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) {
|
|
166902
|
+
hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms");
|
|
166903
|
+
}
|
|
166491
166904
|
return rootNames || ts.emptyArray;
|
|
166492
166905
|
function addDependency(dependency) {
|
|
166493
166906
|
if (!ts.startsWith(dependency, "@types/")) {
|
|
@@ -166588,6 +167001,11 @@ var ts;
|
|
|
166588
167001
|
return this.hostProject.getSymlinkCache();
|
|
166589
167002
|
};
|
|
166590
167003
|
/*@internal*/
|
|
167004
|
+
AutoImportProviderProject.prototype.getModuleResolutionCache = function () {
|
|
167005
|
+
var _a;
|
|
167006
|
+
return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getModuleResolutionCache();
|
|
167007
|
+
};
|
|
167008
|
+
/*@internal*/
|
|
166591
167009
|
AutoImportProviderProject.maxDependencies = 10;
|
|
166592
167010
|
/*@internal*/
|
|
166593
167011
|
AutoImportProviderProject.compilerOptionsOverrides = {
|