mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Update LKG.
This commit is contained in:
@@ -63,6 +63,17 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
||||
return cooked;
|
||||
};
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
@@ -1414,6 +1425,11 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
ts.clone = clone;
|
||||
/**
|
||||
* Creates a new object by adding the own properties of `second`, then the own properties of `first`.
|
||||
*
|
||||
* NOTE: This means that if a property exists in both `first` and `second`, the property in `first` will be chosen.
|
||||
*/
|
||||
function extend(first, second) {
|
||||
var result = {};
|
||||
for (var id in second) {
|
||||
@@ -5734,10 +5750,13 @@ var ts;
|
||||
}
|
||||
}
|
||||
function readFileWorker(fileName, _encoding) {
|
||||
if (!fileExists(fileName)) {
|
||||
var buffer;
|
||||
try {
|
||||
buffer = _fs.readFileSync(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
var buffer = _fs.readFileSync(fileName);
|
||||
var len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
@@ -5787,23 +5806,30 @@ var ts;
|
||||
function getAccessibleFileSystemEntries(path) {
|
||||
ts.perfLogger.logEvent("ReadDir: " + (path || "."));
|
||||
try {
|
||||
var entries = _fs.readdirSync(path || ".").sort();
|
||||
var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
|
||||
var files = [];
|
||||
var directories = [];
|
||||
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
||||
var entry = entries_2[_i];
|
||||
var dirent = entries_2[_i];
|
||||
// withFileTypes is not supported before Node 10.10.
|
||||
var entry = typeof dirent === "string" ? dirent : dirent.name;
|
||||
// This is necessary because on some file system node fails to exclude
|
||||
// "." and "..". See https://github.com/nodejs/node/issues/4002
|
||||
if (entry === "." || entry === "..") {
|
||||
continue;
|
||||
}
|
||||
var name = ts.combinePaths(path, entry);
|
||||
var stat = void 0;
|
||||
try {
|
||||
stat = _fs.statSync(name);
|
||||
if (typeof dirent === "string" || dirent.isSymbolicLink()) {
|
||||
var name = ts.combinePaths(path, entry);
|
||||
try {
|
||||
stat = _fs.statSync(name);
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
continue;
|
||||
else {
|
||||
stat = dirent;
|
||||
}
|
||||
if (stat.isFile()) {
|
||||
files.push(entry);
|
||||
@@ -5812,6 +5838,8 @@ var ts;
|
||||
directories.push(entry);
|
||||
}
|
||||
}
|
||||
files.sort();
|
||||
directories.sort();
|
||||
return { files: files, directories: directories };
|
||||
}
|
||||
catch (e) {
|
||||
@@ -5841,8 +5869,7 @@ var ts;
|
||||
return fileSystemEntryExists(path, 1 /* Directory */);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
ts.perfLogger.logEvent("ReadDir: " + path);
|
||||
return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); });
|
||||
return getAccessibleFileSystemEntries(path).directories.slice();
|
||||
}
|
||||
function realpath(path) {
|
||||
try {
|
||||
@@ -6836,7 +6863,7 @@ var ts;
|
||||
Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
|
||||
Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."),
|
||||
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
||||
await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."),
|
||||
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
||||
can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."),
|
||||
The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."),
|
||||
Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."),
|
||||
@@ -6884,14 +6911,13 @@ var ts;
|
||||
An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."),
|
||||
Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."),
|
||||
Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."),
|
||||
Did_you_mean_to_parenthesize_this_function_type: diag(1360, ts.DiagnosticCategory.Error, "Did_you_mean_to_parenthesize_this_function_type_1360", "Did you mean to parenthesize this function type?"),
|
||||
Type_only_0_must_reference_a_type_but_1_is_a_value: diag(1361, ts.DiagnosticCategory.Error, "Type_only_0_must_reference_a_type_but_1_is_a_value_1361", "Type-only {0} must reference a type, but '{1}' is a value."),
|
||||
Enum_0_cannot_be_used_as_a_value_because_only_its_type_has_been_imported: diag(1362, ts.DiagnosticCategory.Error, "Enum_0_cannot_be_used_as_a_value_because_only_its_type_has_been_imported_1362", "Enum '{0}' cannot be used as a value because only its type has been imported."),
|
||||
A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: diag(1363, ts.DiagnosticCategory.Error, "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363", "A type-only import can specify a default import or named bindings, but not both."),
|
||||
Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
|
||||
Convert_all_re_exported_types_to_type_only_exports: diag(1365, ts.DiagnosticCategory.Message, "Convert_all_re_exported_types_to_type_only_exports_1365", "Convert all re-exported types to type-only exports"),
|
||||
Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
|
||||
Split_all_invalid_type_only_imports: diag(1377, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1377", "Split all invalid type-only imports"),
|
||||
Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
|
||||
Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(1368, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_1368", "Specify emit/checking behavior for imports that are only used for types"),
|
||||
Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
|
||||
Only_ECMAScript_imports_may_use_import_type: diag(1370, ts.DiagnosticCategory.Error, "Only_ECMAScript_imports_may_use_import_type_1370", "Only ECMAScript imports may use 'import type'."),
|
||||
@@ -6899,7 +6925,8 @@ var ts;
|
||||
This_import_may_be_converted_to_a_type_only_import: diag(1372, ts.DiagnosticCategory.Suggestion, "This_import_may_be_converted_to_a_type_only_import_1372", "This import may be converted to a type-only import."),
|
||||
Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
|
||||
Convert_all_imports_not_used_as_a_value_to_type_only_imports: diag(1374, ts.DiagnosticCategory.Message, "Convert_all_imports_not_used_as_a_value_to_type_only_imports_1374", "Convert all imports not used as a value to type-only imports"),
|
||||
await_outside_of_an_async_function_is_only_allowed_at_the_top_level_of_a_module_when_module_is_esnext_or_system_and_target_is_es2017_or_higher: diag(1375, ts.DiagnosticCategory.Error, "await_outside_of_an_async_function_is_only_allowed_at_the_top_level_of_a_module_when_module_is_esnex_1375", "'await' outside of an async function is only allowed at the top level of a module when '--module' is 'esnext' or 'system' and '--target' is 'es2017' or higher."),
|
||||
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
||||
Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1376, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1376", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."),
|
||||
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."),
|
||||
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."),
|
||||
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),
|
||||
@@ -7845,7 +7872,7 @@ var ts;
|
||||
Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
||||
Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
|
||||
Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
||||
Remove_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_declaration_for_Colon_0_90004", "Remove declaration for: '{0}'"),
|
||||
Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
|
||||
Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
|
||||
Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
|
||||
Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
|
||||
@@ -7968,10 +7995,12 @@ var ts;
|
||||
Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
|
||||
Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"),
|
||||
Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
|
||||
Add_export_to_make_this_file_into_a_module: diag(95097, ts.DiagnosticCategory.Message, "Add_export_to_make_this_file_into_a_module_95097", "Add 'export {}' to make this file into a module"),
|
||||
Set_the_target_option_in_your_configuration_file_to_0: diag(95098, ts.DiagnosticCategory.Message, "Set_the_target_option_in_your_configuration_file_to_0_95098", "Set the 'target' option in your configuration file to '{0}'"),
|
||||
Set_the_module_option_in_your_configuration_file_to_0: diag(95099, ts.DiagnosticCategory.Message, "Set_the_module_option_in_your_configuration_file_to_0_95099", "Set the 'module' option in your configuration file to '{0}'"),
|
||||
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
||||
Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
||||
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
||||
can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."),
|
||||
Private_identifiers_cannot_be_used_as_parameters: diag(18009, ts.DiagnosticCategory.Error, "Private_identifiers_cannot_be_used_as_parameters_18009", "Private identifiers cannot be used as parameters"),
|
||||
An_accessibility_modifier_cannot_be_used_with_a_private_identifier: diag(18010, ts.DiagnosticCategory.Error, "An_accessibility_modifier_cannot_be_used_with_a_private_identifier_18010", "An accessibility modifier cannot be used with a private identifier."),
|
||||
The_operand_of_a_delete_operator_cannot_be_a_private_identifier: diag(18011, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011", "The operand of a 'delete' operator cannot be a private identifier."),
|
||||
@@ -7986,6 +8015,7 @@ var ts;
|
||||
A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."),
|
||||
An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."),
|
||||
An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."),
|
||||
can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."),
|
||||
Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."),
|
||||
Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher: diag(18028, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher_18028", "Private identifiers are only available when targeting ECMAScript 2015 and higher."),
|
||||
Private_identifiers_are_not_allowed_in_variable_declarations: diag(18029, ts.DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_in_variable_declarations_18029", "Private identifiers are not allowed in variable declarations."),
|
||||
@@ -26177,6 +26207,7 @@ var ts;
|
||||
error: 2 /* Error */
|
||||
}),
|
||||
affectsEmit: true,
|
||||
affectsSemanticDiagnostics: true,
|
||||
category: ts.Diagnostics.Advanced_Options,
|
||||
description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
|
||||
},
|
||||
@@ -26434,12 +26465,15 @@ var ts;
|
||||
{
|
||||
name: "experimentalDecorators",
|
||||
type: "boolean",
|
||||
affectsSemanticDiagnostics: true,
|
||||
category: ts.Diagnostics.Experimental_Options,
|
||||
description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
|
||||
},
|
||||
{
|
||||
name: "emitDecoratorMetadata",
|
||||
type: "boolean",
|
||||
affectsSemanticDiagnostics: true,
|
||||
affectsEmit: true,
|
||||
category: ts.Diagnostics.Experimental_Options,
|
||||
description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
|
||||
},
|
||||
@@ -26453,6 +26487,7 @@ var ts;
|
||||
{
|
||||
name: "resolveJsonModule",
|
||||
type: "boolean",
|
||||
affectsModuleResolution: true,
|
||||
category: ts.Diagnostics.Advanced_Options,
|
||||
description: ts.Diagnostics.Include_modules_imported_with_json_extension
|
||||
},
|
||||
@@ -26657,6 +26692,7 @@ var ts;
|
||||
name: "useDefineForClassFields",
|
||||
type: "boolean",
|
||||
affectsSemanticDiagnostics: true,
|
||||
affectsEmit: true,
|
||||
category: ts.Diagnostics.Advanced_Options,
|
||||
description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
|
||||
},
|
||||
@@ -30533,7 +30569,7 @@ var ts;
|
||||
case 104 /* ThisKeyword */:
|
||||
case 194 /* PropertyAccessExpression */:
|
||||
case 195 /* ElementAccessExpression */:
|
||||
return isNarrowableReference(expr);
|
||||
return containsNarrowableReference(expr);
|
||||
case 196 /* CallExpression */:
|
||||
return hasNarrowableArgument(expr);
|
||||
case 200 /* ParenthesizedExpression */:
|
||||
@@ -30550,20 +30586,22 @@ var ts;
|
||||
function isNarrowableReference(expr) {
|
||||
return expr.kind === 75 /* Identifier */ || expr.kind === 104 /* ThisKeyword */ || expr.kind === 102 /* SuperKeyword */ ||
|
||||
(ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
|
||||
ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) ||
|
||||
ts.isOptionalChain(expr);
|
||||
ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
|
||||
}
|
||||
function containsNarrowableReference(expr) {
|
||||
return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
|
||||
}
|
||||
function hasNarrowableArgument(expr) {
|
||||
if (expr.arguments) {
|
||||
for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
|
||||
var argument = _a[_i];
|
||||
if (isNarrowableReference(argument)) {
|
||||
if (containsNarrowableReference(argument)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expr.expression.kind === 194 /* PropertyAccessExpression */ &&
|
||||
isNarrowableReference(expr.expression.expression)) {
|
||||
containsNarrowableReference(expr.expression.expression)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -30577,7 +30615,7 @@ var ts;
|
||||
function isNarrowingBinaryExpression(expr) {
|
||||
switch (expr.operatorToken.kind) {
|
||||
case 62 /* EqualsToken */:
|
||||
return isNarrowableReference(expr.left);
|
||||
return containsNarrowableReference(expr.left);
|
||||
case 34 /* EqualsEqualsToken */:
|
||||
case 35 /* ExclamationEqualsToken */:
|
||||
case 36 /* EqualsEqualsEqualsToken */:
|
||||
@@ -30605,7 +30643,7 @@ var ts;
|
||||
return isNarrowableOperand(expr.right);
|
||||
}
|
||||
}
|
||||
return isNarrowableReference(expr);
|
||||
return containsNarrowableReference(expr);
|
||||
}
|
||||
function createBranchLabel() {
|
||||
return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined });
|
||||
@@ -34017,6 +34055,7 @@ var ts;
|
||||
var currentNode;
|
||||
var emptySymbols = ts.createSymbolTable();
|
||||
var identityMapper = ts.identity;
|
||||
var arrayVariances = [1 /* Covariant */];
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
||||
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
||||
@@ -34265,9 +34304,12 @@ var ts;
|
||||
isArrayLikeType: isArrayLikeType,
|
||||
isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
|
||||
getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
|
||||
getSuggestionForNonexistentProperty: function (node, type) { return getSuggestionForNonexistentProperty(node, type); },
|
||||
getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
|
||||
getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
|
||||
getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
|
||||
getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
|
||||
getSuggestionForNonexistentExport: function (node, target) { return getSuggestionForNonexistentExport(node, target); },
|
||||
getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
|
||||
getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
|
||||
getBaseConstraintOfType: getBaseConstraintOfType,
|
||||
getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; },
|
||||
resolveName: function (name, location, meaning, excludeGlobals) {
|
||||
@@ -35859,9 +35901,11 @@ var ts;
|
||||
// if symbolFromVariable is export - get its final target
|
||||
symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
|
||||
var symbolFromModule = getExportOfModule(targetSymbol, name.escapedText, dontResolveAlias);
|
||||
// If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default
|
||||
if (!symbolFromModule && allowSyntheticDefaultImports && name.escapedText === "default" /* Default */) {
|
||||
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
||||
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
||||
var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
|
||||
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
||||
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
||||
}
|
||||
}
|
||||
var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
|
||||
combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
|
||||
@@ -45502,8 +45546,9 @@ var ts;
|
||||
}
|
||||
/** We approximate own properties as non-methods plus methods that are inside the object literal */
|
||||
function isSpreadableProperty(prop) {
|
||||
return !(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) ||
|
||||
!prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); });
|
||||
return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
|
||||
(!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) ||
|
||||
!prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
|
||||
}
|
||||
function getSpreadSymbol(prop, readonly) {
|
||||
var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */);
|
||||
@@ -47829,6 +47874,9 @@ var ts;
|
||||
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
||||
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
||||
var variances = getAliasVariances(source.aliasSymbol);
|
||||
if (variances === ts.emptyArray) {
|
||||
return 1 /* Maybe */;
|
||||
}
|
||||
var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
|
||||
if (varianceResult !== undefined) {
|
||||
return varianceResult;
|
||||
@@ -48023,6 +48071,12 @@ var ts;
|
||||
// type references (which are intended by be compared structurally). Obtain the variance
|
||||
// information for the type parameters and relate the type arguments accordingly.
|
||||
var variances = getVariances(source.target);
|
||||
// We return Ternary.Maybe for a recursive invocation of getVariances (signalled by emptyArray). This
|
||||
// effectively means we measure variance only from type parameter occurrences that aren't nested in
|
||||
// recursive instantiations of the generic type.
|
||||
if (variances === ts.emptyArray) {
|
||||
return 1 /* Maybe */;
|
||||
}
|
||||
var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
|
||||
if (varianceResult !== undefined) {
|
||||
return varianceResult;
|
||||
@@ -48808,8 +48862,7 @@ var ts;
|
||||
// a digest of the type comparisons that occur for each type argument when instantiations of the
|
||||
// generic type are structurally compared. We infer the variance information by comparing
|
||||
// instantiations of the generic type for type arguments with known relations. The function
|
||||
// returns the emptyArray singleton if we're not in strictFunctionTypes mode or if the function
|
||||
// has been invoked recursively for the given generic type.
|
||||
// returns the emptyArray singleton when invoked recursively for the given generic type.
|
||||
function getVariancesWorker(typeParameters, cache, createMarkerType) {
|
||||
if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
|
||||
var variances = cache.variances;
|
||||
@@ -48856,9 +48909,9 @@ var ts;
|
||||
return variances;
|
||||
}
|
||||
function getVariances(type) {
|
||||
// Arrays and tuples are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters)
|
||||
// Arrays and tuples are known to be covariant, no need to spend time computing this.
|
||||
if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */) {
|
||||
return ts.emptyArray;
|
||||
return arrayVariances;
|
||||
}
|
||||
return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
|
||||
}
|
||||
@@ -52564,24 +52617,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else if (!assumeInitialized && !(getFalsyFlags(type) & 32768 /* Undefined */) && getFalsyFlags(flowType) & 32768 /* Undefined */) {
|
||||
var diag = error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
// See GH:32846 - if the user is using a variable whose type is () => T1 | ... | undefined
|
||||
// they may have meant to specify the type as (() => T1 | ...) | undefined
|
||||
// This is assumed if: the type is a FunctionType, the return type is a Union, the last constituent of
|
||||
// the union is `undefined`
|
||||
if (type.symbol && type.symbol.declarations.length === 1 && ts.isFunctionTypeNode(type.symbol.declarations[0])) {
|
||||
var funcTypeNode = type.symbol.declarations[0];
|
||||
var returnType = getReturnTypeFromAnnotation(funcTypeNode);
|
||||
if (returnType && returnType.flags & 1048576 /* Union */) {
|
||||
var unionTypes_3 = funcTypeNode.type.types;
|
||||
if (unionTypes_3 && unionTypes_3[unionTypes_3.length - 1].kind === 146 /* UndefinedKeyword */) {
|
||||
var parenedFuncType = ts.getMutableClone(funcTypeNode);
|
||||
// Highlight to the end of the second to last constituent of the union
|
||||
parenedFuncType.end = unionTypes_3[unionTypes_3.length - 2].end;
|
||||
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(parenedFuncType, ts.Diagnostics.Did_you_mean_to_parenthesize_this_function_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
// Return the declared type to reduce follow-on errors
|
||||
return type;
|
||||
}
|
||||
@@ -58196,12 +58232,17 @@ var ts;
|
||||
if (!(node.flags & 32768 /* AwaitContext */)) {
|
||||
if (isTopLevelAwait(node)) {
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) ||
|
||||
languageVersion < 4 /* ES2017 */ ||
|
||||
!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_outside_of_an_async_function_is_only_allowed_at_the_top_level_of_a_module_when_module_is_esnext_or_system_and_target_is_es2017_or_higher);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = void 0;
|
||||
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
if (!span)
|
||||
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
|
||||
diagnostics.add(diagnostic);
|
||||
}
|
||||
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
||||
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher);
|
||||
diagnostics.add(diagnostic);
|
||||
}
|
||||
}
|
||||
@@ -58211,7 +58252,7 @@ var ts;
|
||||
var sourceFile = ts.getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function);
|
||||
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
|
||||
var func = ts.getContainingFunction(node);
|
||||
if (func && func.kind !== 162 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) {
|
||||
var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
|
||||
@@ -96975,12 +97016,12 @@ var ts;
|
||||
if (!program || hasChangedAutomaticTypeDirectiveNames) {
|
||||
return false;
|
||||
}
|
||||
// If number of files in the program do not match, it is not up-to-date
|
||||
if (program.getRootFileNames().length !== rootFileNames.length) {
|
||||
// If root file names don't match
|
||||
if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
|
||||
return false;
|
||||
}
|
||||
var seenResolvedRefs;
|
||||
// If project references dont match
|
||||
// If project references don't match
|
||||
if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
|
||||
return false;
|
||||
}
|
||||
@@ -109477,7 +109518,7 @@ var ts;
|
||||
var contextToken = previousToken;
|
||||
// Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
|
||||
// Skip this partial identifier and adjust the contextToken to the token that precedes it.
|
||||
if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) {
|
||||
if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) {
|
||||
var start_1 = ts.timestamp();
|
||||
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217
|
||||
log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1));
|
||||
@@ -109720,7 +109761,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ts.isMetaProperty(node) && (node.keywordToken === 99 /* NewKeyword */ || node.keywordToken === 96 /* ImportKeyword */)) {
|
||||
if (ts.isMetaProperty(node) && (node.keywordToken === 99 /* NewKeyword */ || node.keywordToken === 96 /* ImportKeyword */) && contextToken === node.getChildAt(1)) {
|
||||
var completion = (node.keywordToken === 99 /* NewKeyword */) ? "target" : "meta";
|
||||
symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion)));
|
||||
return;
|
||||
@@ -111044,6 +111085,8 @@ var ts;
|
||||
if (!contextToken)
|
||||
return undefined;
|
||||
switch (contextToken.kind) {
|
||||
case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ }
|
||||
return undefined;
|
||||
case 26 /* SemicolonToken */: // class c {getValue(): number; | }
|
||||
case 19 /* CloseBraceToken */: // class c { method() { } | }
|
||||
// class c { method() { } b| }
|
||||
@@ -111170,8 +111213,12 @@ var ts;
|
||||
case 103 /* SwitchKeyword */:
|
||||
return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
case 78 /* CaseKeyword */:
|
||||
case 84 /* DefaultKeyword */:
|
||||
return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
case 84 /* DefaultKeyword */: {
|
||||
if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) {
|
||||
return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
case 77 /* BreakKeyword */:
|
||||
case 82 /* ContinueKeyword */:
|
||||
return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences);
|
||||
@@ -112519,9 +112566,7 @@ var ts;
|
||||
return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false });
|
||||
}
|
||||
var kind = entry.kind, node = entry.node;
|
||||
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 84 /* DefaultKeyword */
|
||||
|| !!ts.getDeclarationFromName(node)
|
||||
|| ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
||||
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDefinitionForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
||||
}
|
||||
FindAllReferences.toReferenceEntry = toReferenceEntry;
|
||||
function entryToDocumentSpan(entry) {
|
||||
@@ -112629,6 +112674,12 @@ var ts;
|
||||
var decl = ts.getDeclarationFromName(node);
|
||||
return !!decl && declarationIsWriteAccess(decl) || node.kind === 84 /* DefaultKeyword */ || ts.isWriteAccess(node);
|
||||
}
|
||||
function isDefinitionForReference(node) {
|
||||
return node.kind === 84 /* DefaultKeyword */
|
||||
|| !!ts.getDeclarationFromName(node)
|
||||
|| ts.isLiteralComputedPropertyDeclarationName(node)
|
||||
|| (node.kind === 129 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
|
||||
}
|
||||
/**
|
||||
* True if 'decl' provides a value, as in `function f() {}`;
|
||||
* false if 'decl' is just a location for a future write, as in 'let x;'
|
||||
@@ -122924,27 +122975,62 @@ var ts;
|
||||
this.insertNodeAtStartWorker(sourceFile, obj, newElement);
|
||||
};
|
||||
ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile, cls, newElement) {
|
||||
var clsStart = cls.getStart(sourceFile);
|
||||
var indentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(clsStart, sourceFile), clsStart, sourceFile, this.formatContext.options)
|
||||
+ this.formatContext.options.indentSize;
|
||||
this.insertNodeAt(sourceFile, getMembersOrProperties(cls).pos, newElement, __assign({ indentation: indentation }, this.getInsertNodeAtStartPrefixSuffix(sourceFile, cls)));
|
||||
var _a;
|
||||
var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile, cls)) !== null && _a !== void 0 ? _a : this.computeIndentationForNewMember(sourceFile, cls);
|
||||
this.insertNodeAt(sourceFile, getMembersOrProperties(cls).pos, newElement, this.getInsertNodeAtStartInsertOptions(sourceFile, cls, indentation));
|
||||
};
|
||||
ChangeTracker.prototype.getInsertNodeAtStartPrefixSuffix = function (sourceFile, cls) {
|
||||
var comma = ts.isObjectLiteralExpression(cls) ? "," : "";
|
||||
if (getMembersOrProperties(cls).length === 0) {
|
||||
if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) {
|
||||
// For `class C {\n}`, don't add the trailing "\n"
|
||||
var _a = getClassOrObjectBraceEnds(cls, sourceFile), open = _a[0], close = _a[1];
|
||||
var shouldSuffix = open && close && ts.positionsAreOnSameLine(open, close, sourceFile);
|
||||
return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") };
|
||||
/**
|
||||
* Tries to guess the indentation from the existing members of a class/interface/object. All members must be on
|
||||
* new lines and must share the same indentation.
|
||||
*/
|
||||
ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile, cls) {
|
||||
var indentation;
|
||||
var lastRange = cls;
|
||||
for (var _i = 0, _a = getMembersOrProperties(cls); _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (ts.rangeStartPositionsAreOnSameLine(lastRange, member, sourceFile)) {
|
||||
// each indented member must be on a new line
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
return { prefix: "", suffix: comma + this.newLineCharacter };
|
||||
var memberStart = member.getStart(sourceFile);
|
||||
var memberIndentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(memberStart, sourceFile), memberStart, sourceFile, this.formatContext.options);
|
||||
if (indentation === undefined) {
|
||||
indentation = memberIndentation;
|
||||
}
|
||||
else if (memberIndentation !== indentation) {
|
||||
// indentation of multiple members is not consistent
|
||||
return undefined;
|
||||
}
|
||||
lastRange = member;
|
||||
}
|
||||
else {
|
||||
return { prefix: this.newLineCharacter, suffix: comma };
|
||||
}
|
||||
return indentation;
|
||||
};
|
||||
ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile, cls) {
|
||||
var _a;
|
||||
var clsStart = cls.getStart(sourceFile);
|
||||
return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(clsStart, sourceFile), clsStart, sourceFile, this.formatContext.options)
|
||||
+ ((_a = this.formatContext.options.indentSize) !== null && _a !== void 0 ? _a : 4);
|
||||
};
|
||||
ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile, cls, indentation) {
|
||||
// Rules:
|
||||
// - Always insert leading newline.
|
||||
// - For object literals:
|
||||
// - Add a trailing comma if there are existing members in the node, or the source file is not a JSON file
|
||||
// (because trailing commas are generally illegal in a JSON file).
|
||||
// - Add a leading comma if the source file is not a JSON file, there are existing insertions,
|
||||
// and the node is empty (because we didn't add a trailing comma per the previous rule).
|
||||
// - Only insert a trailing newline if body is single-line and there are no other insertions for the node.
|
||||
// NOTE: This is handled in `finishClassesWithNodesInsertedAtStart`.
|
||||
var members = getMembersOrProperties(cls);
|
||||
var isEmpty = members.length === 0;
|
||||
var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile });
|
||||
var insertTrailingComma = ts.isObjectLiteralExpression(cls) && (!ts.isJsonSourceFile(sourceFile) || !isEmpty);
|
||||
var insertLeadingComma = ts.isObjectLiteralExpression(cls) && ts.isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
|
||||
return {
|
||||
indentation: indentation,
|
||||
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
|
||||
suffix: insertTrailingComma ? "," : ""
|
||||
};
|
||||
};
|
||||
ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
|
||||
var endPosition = this.insertNodeAfterWorker(sourceFile, this.nextCommaToken(sourceFile, after) || after, newNode);
|
||||
@@ -123146,9 +123232,16 @@ var ts;
|
||||
this.classesWithNodesInsertedAtStart.forEach(function (_a) {
|
||||
var node = _a.node, sourceFile = _a.sourceFile;
|
||||
var _b = getClassOrObjectBraceEnds(node, sourceFile), openBraceEnd = _b[0], closeBraceEnd = _b[1];
|
||||
// For `class C { }` remove the whitespace inside the braces.
|
||||
if (openBraceEnd && closeBraceEnd && ts.positionsAreOnSameLine(openBraceEnd, closeBraceEnd, sourceFile) && openBraceEnd !== closeBraceEnd - 1) {
|
||||
_this.deleteRange(sourceFile, ts.createRange(openBraceEnd, closeBraceEnd - 1));
|
||||
if (openBraceEnd !== undefined && closeBraceEnd !== undefined) {
|
||||
var isEmpty = getMembersOrProperties(node).length === 0;
|
||||
var isSingleLine = ts.positionsAreOnSameLine(openBraceEnd, closeBraceEnd, sourceFile);
|
||||
if (isEmpty && isSingleLine && openBraceEnd !== closeBraceEnd - 1) {
|
||||
// For `class C { }` remove the whitespace inside the braces.
|
||||
_this.deleteRange(sourceFile, ts.createRange(openBraceEnd, closeBraceEnd - 1));
|
||||
}
|
||||
if (isSingleLine) {
|
||||
_this.insertText(sourceFile, closeBraceEnd - 1, _this.newLineCharacter);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -123724,10 +123817,10 @@ var ts;
|
||||
? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
|
||||
: ts.getLocaleSpecificMessage(diag);
|
||||
}
|
||||
function createCodeFixActionNoFixId(fixName, changes, description) {
|
||||
function createCodeFixActionWithoutFixAll(fixName, changes, description) {
|
||||
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
|
||||
}
|
||||
codefix.createCodeFixActionNoFixId = createCodeFixActionNoFixId;
|
||||
codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll;
|
||||
function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) {
|
||||
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
|
||||
}
|
||||
@@ -123753,8 +123846,26 @@ var ts;
|
||||
return ts.arrayFrom(errorCodeToFixes.keys());
|
||||
}
|
||||
codefix.getSupportedErrorCodes = getSupportedErrorCodes;
|
||||
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
||||
var errorCodes = registration.errorCodes;
|
||||
var maybeFixableDiagnostics = 0;
|
||||
for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
|
||||
var diag = diagnostics_1[_i];
|
||||
if (ts.contains(errorCodes, diag.code))
|
||||
maybeFixableDiagnostics++;
|
||||
if (maybeFixableDiagnostics > 1)
|
||||
break;
|
||||
}
|
||||
var fixAllUnavailable = maybeFixableDiagnostics < 2;
|
||||
return function (_a) {
|
||||
var fixId = _a.fixId, fixAllDescription = _a.fixAllDescription, action = __rest(_a, ["fixId", "fixAllDescription"]);
|
||||
return fixAllUnavailable ? action : __assign(__assign({}, action), { fixId: fixId, fixAllDescription: fixAllDescription });
|
||||
};
|
||||
}
|
||||
function getFixes(context) {
|
||||
return ts.flatMap(errorCodeToFixes.get(String(context.errorCode)) || ts.emptyArray, function (f) { return f.getCodeActions(context); });
|
||||
var diagnostics = getDiagnostics(context);
|
||||
var registrations = errorCodeToFixes.get(String(context.errorCode));
|
||||
return ts.flatMap(registrations, function (f) { return ts.map(f.getCodeActions(context), removeFixIdIfFixAllUnavailable(f, diagnostics)); });
|
||||
}
|
||||
codefix.getFixes = getFixes;
|
||||
function getAllFixes(context) {
|
||||
@@ -123776,16 +123887,19 @@ var ts;
|
||||
return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands);
|
||||
}
|
||||
codefix.codeFixAll = codeFixAll;
|
||||
function eachDiagnostic(_a, errorCodes, cb) {
|
||||
var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken;
|
||||
for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); _i < _b.length; _i++) {
|
||||
var diag = _b[_i];
|
||||
function eachDiagnostic(context, errorCodes, cb) {
|
||||
for (var _i = 0, _a = getDiagnostics(context); _i < _a.length; _i++) {
|
||||
var diag = _a[_i];
|
||||
if (ts.contains(errorCodes, diag.code)) {
|
||||
cb(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
codefix.eachDiagnostic = eachDiagnostic;
|
||||
function getDiagnostics(_a) {
|
||||
var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken;
|
||||
return program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken));
|
||||
}
|
||||
})(codefix = ts.codefix || (ts.codefix = {}));
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
@@ -123842,6 +123956,28 @@ var ts;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
(function (ts) {
|
||||
var codefix;
|
||||
(function (codefix) {
|
||||
codefix.registerCodeFix({
|
||||
errorCodes: [ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code],
|
||||
getCodeActions: function (context) {
|
||||
var sourceFile = context.sourceFile;
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
|
||||
var exportDeclaration = ts.createExportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined, ts.createNamedExports([]),
|
||||
/*moduleSpecifier*/ undefined,
|
||||
/*isTypeOnly*/ false);
|
||||
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, exportDeclaration);
|
||||
});
|
||||
return [codefix.createCodeFixActionWithoutFixAll("addEmptyExportDeclaration", changes, ts.Diagnostics.Add_export_to_make_this_file_into_a_module)];
|
||||
},
|
||||
});
|
||||
})(codefix = ts.codefix || (ts.codefix = {}));
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
(function (ts) {
|
||||
var codefix;
|
||||
(function (codefix) {
|
||||
@@ -123912,7 +124048,9 @@ var ts;
|
||||
makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations);
|
||||
}
|
||||
});
|
||||
return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1
|
||||
// No fix-all because it will already be included once with the use site fix,
|
||||
// and for simplicity the fix-all doesn‘t let the user choose between use-site and declaration-site fixes.
|
||||
return codefix.createCodeFixActionWithoutFixAll("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1
|
||||
? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name]
|
||||
: ts.Diagnostics.Add_await_to_initializers);
|
||||
}
|
||||
@@ -124131,7 +124269,7 @@ var ts;
|
||||
if (forInitializer)
|
||||
return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes);
|
||||
var parent = token.parent;
|
||||
if (ts.isBinaryExpression(parent) && ts.isExpressionStatement(parent.parent)) {
|
||||
if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) {
|
||||
return applyChange(changeTracker, token, sourceFile, fixedNodes);
|
||||
}
|
||||
if (ts.isArrayLiteralExpression(parent)) {
|
||||
@@ -124193,7 +124331,9 @@ var ts;
|
||||
if (expression.operatorToken.kind === 27 /* CommaToken */) {
|
||||
return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); });
|
||||
}
|
||||
return ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left);
|
||||
return expression.operatorToken.kind === 62 /* EqualsToken */
|
||||
&& ts.isIdentifier(expression.left)
|
||||
&& !checker.getSymbolAtLocation(expression.left);
|
||||
}
|
||||
})(codefix = ts.codefix || (ts.codefix = {}));
|
||||
})(ts || (ts = {}));
|
||||
@@ -126184,7 +126324,7 @@ var ts;
|
||||
}
|
||||
});
|
||||
// No support for fix-all since this applies to the whole file at once anyway.
|
||||
return [codefix.createCodeFixActionNoFixId("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)];
|
||||
return [codefix.createCodeFixActionWithoutFixAll("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)];
|
||||
},
|
||||
});
|
||||
function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
|
||||
@@ -126783,7 +126923,8 @@ var ts;
|
||||
(function (ts) {
|
||||
var codefix;
|
||||
(function (codefix) {
|
||||
codefix.importFixId = "fixMissingImport";
|
||||
codefix.importFixName = "import";
|
||||
var importFixId = "fixMissingImport";
|
||||
var errorCodes = [
|
||||
ts.Diagnostics.Cannot_find_name_0.code,
|
||||
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
||||
@@ -126804,7 +126945,7 @@ var ts;
|
||||
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
||||
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); });
|
||||
},
|
||||
fixIds: [codefix.importFixId],
|
||||
fixIds: [importFixId],
|
||||
getAllCodeActions: function (context) {
|
||||
var sourceFile = context.sourceFile, preferences = context.preferences;
|
||||
// Namespace fixes don't conflict, so just build a list.
|
||||
@@ -127236,7 +127377,7 @@ var ts;
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
||||
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference);
|
||||
});
|
||||
return codefix.createCodeFixAction("import", changes, diag, codefix.importFixId, ts.Diagnostics.Add_all_missing_imports);
|
||||
return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
|
||||
}
|
||||
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) {
|
||||
switch (fix.kind) {
|
||||
@@ -127534,17 +127675,17 @@ var ts;
|
||||
var info = getInfo(sourceFile, context.span.start, context);
|
||||
if (!info)
|
||||
return undefined;
|
||||
var node = info.node, suggestion = info.suggestion;
|
||||
var node = info.node, suggestedSymbol = info.suggestedSymbol;
|
||||
var target = context.host.getCompilationSettings().target;
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, node, suggestion, target); });
|
||||
return [codefix.createCodeFixAction("spelling", changes, [ts.Diagnostics.Change_spelling_to_0, suggestion], fixId, ts.Diagnostics.Fix_all_detected_spelling_errors)];
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, node, suggestedSymbol, target); });
|
||||
return [codefix.createCodeFixAction("spelling", changes, [ts.Diagnostics.Change_spelling_to_0, ts.symbolName(suggestedSymbol)], fixId, ts.Diagnostics.Fix_all_detected_spelling_errors)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
||||
var info = getInfo(diag.file, diag.start, context);
|
||||
var target = context.host.getCompilationSettings().target;
|
||||
if (info)
|
||||
doChange(changes, context.sourceFile, info.node, info.suggestion, target);
|
||||
doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
||||
}); },
|
||||
});
|
||||
function getInfo(sourceFile, pos, context) {
|
||||
@@ -127553,34 +127694,42 @@ var ts;
|
||||
// ^^^^^^^
|
||||
var node = ts.getTokenAtPosition(sourceFile, pos);
|
||||
var checker = context.program.getTypeChecker();
|
||||
var suggestion;
|
||||
var suggestedSymbol;
|
||||
if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) {
|
||||
ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)");
|
||||
ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)");
|
||||
var containingType = checker.getTypeAtLocation(node.parent.expression);
|
||||
if (node.parent.flags & 32 /* OptionalChain */) {
|
||||
containingType = checker.getNonNullableType(containingType);
|
||||
}
|
||||
suggestion = checker.getSuggestionForNonexistentProperty(node, containingType);
|
||||
var name = node;
|
||||
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(name, containingType);
|
||||
}
|
||||
else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) {
|
||||
ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)");
|
||||
var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration);
|
||||
var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration);
|
||||
if (resolvedSourceFile && resolvedSourceFile.symbol) {
|
||||
suggestion = checker.getSuggestionForNonexistentExport(node, resolvedSourceFile.symbol);
|
||||
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var meaning = ts.getMeaningFromLocation(node);
|
||||
var name = ts.getTextOfNode(node);
|
||||
ts.Debug.assert(name !== undefined, "name should be defined");
|
||||
suggestion = checker.getSuggestionForNonexistentSymbol(node, name, convertSemanticMeaningToSymbolFlags(meaning));
|
||||
suggestedSymbol = checker.getSuggestedSymbolForNonexistentSymbol(node, name, convertSemanticMeaningToSymbolFlags(meaning));
|
||||
}
|
||||
return suggestion === undefined ? undefined : { node: node, suggestion: suggestion };
|
||||
return suggestedSymbol === undefined ? undefined : { node: node, suggestedSymbol: suggestedSymbol };
|
||||
}
|
||||
function doChange(changes, sourceFile, node, suggestion, target) {
|
||||
function doChange(changes, sourceFile, node, suggestedSymbol, target) {
|
||||
var suggestion = ts.symbolName(suggestedSymbol);
|
||||
if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) {
|
||||
changes.replaceNode(sourceFile, node.parent, ts.createElementAccess(node.parent.expression, ts.createLiteral(suggestion)));
|
||||
var valDecl = suggestedSymbol.valueDeclaration;
|
||||
if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) {
|
||||
changes.replaceNode(sourceFile, node, ts.createIdentifier(suggestion));
|
||||
}
|
||||
else {
|
||||
changes.replaceNode(sourceFile, node.parent, ts.createElementAccess(node.parent.expression, ts.createLiteral(suggestion)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
changes.replaceNode(sourceFile, node, ts.createIdentifier(suggestion));
|
||||
@@ -127844,7 +127993,7 @@ var ts;
|
||||
/*modifiers*/ undefined, [indexingParameter], typeNode);
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.insertNodeAtClassStart(declSourceFile, classDeclaration, indexSignature); });
|
||||
// No fixId here because code-fix-all currently only works on adding individual named properties.
|
||||
return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
|
||||
return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
|
||||
}
|
||||
function getActionForMethodDeclaration(context, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) {
|
||||
// Private methods are not implemented yet.
|
||||
@@ -128129,7 +128278,7 @@ var ts;
|
||||
return undefined;
|
||||
}
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { return doChange(changeTracker, configFile); });
|
||||
return [codefix.createCodeFixActionNoFixId(fixId, changes, ts.Diagnostics.Enable_the_experimentalDecorators_option_in_your_configuration_file)];
|
||||
return [codefix.createCodeFixActionWithoutFixAll(fixId, changes, ts.Diagnostics.Enable_the_experimentalDecorators_option_in_your_configuration_file)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes) {
|
||||
@@ -128163,7 +128312,7 @@ var ts;
|
||||
return doChange(changeTracker, configFile);
|
||||
});
|
||||
return [
|
||||
codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
||||
codefix.createCodeFixActionWithoutFixAll(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
||||
];
|
||||
},
|
||||
fixIds: [fixID],
|
||||
@@ -128184,6 +128333,49 @@ var ts;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
(function (ts) {
|
||||
var codefix;
|
||||
(function (codefix) {
|
||||
codefix.registerCodeFix({
|
||||
errorCodes: [ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code],
|
||||
getCodeActions: function (context) {
|
||||
var compilerOptions = context.program.getCompilerOptions();
|
||||
var configFile = compilerOptions.configFile;
|
||||
if (configFile === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
var codeFixes = [];
|
||||
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
||||
var moduleOutOfRange = moduleKind >= ts.ModuleKind.ES2015 && moduleKind < ts.ModuleKind.ESNext;
|
||||
if (moduleOutOfRange) {
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
|
||||
codefix.setJsonCompilerOptionValue(changes, configFile, "module", ts.createStringLiteral("esnext"));
|
||||
});
|
||||
codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"]));
|
||||
}
|
||||
var target = ts.getEmitScriptTarget(compilerOptions);
|
||||
var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */;
|
||||
if (targetOutOfRange) {
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
||||
var configObject = ts.getTsConfigObjectLiteralExpression(configFile);
|
||||
if (!configObject)
|
||||
return;
|
||||
var options = [["target", ts.createStringLiteral("es2017")]];
|
||||
if (moduleKind === ts.ModuleKind.CommonJS) {
|
||||
// Ensure we preserve the default module kind (commonjs), as targets >= ES2015 have a default module kind of es2015.
|
||||
options.push(["module", ts.createStringLiteral("commonjs")]);
|
||||
}
|
||||
codefix.setJsonCompilerOptionValues(tracker, configFile, options);
|
||||
});
|
||||
codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixTargetOption", changes, [ts.Diagnostics.Set_the_target_option_in_your_configuration_file_to_0, "es2017"]));
|
||||
}
|
||||
return codeFixes.length ? codeFixes : undefined;
|
||||
}
|
||||
});
|
||||
})(codefix = ts.codefix || (ts.codefix = {}));
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
(function (ts) {
|
||||
var codefix;
|
||||
(function (codefix) {
|
||||
@@ -128336,7 +128528,7 @@ var ts;
|
||||
});
|
||||
if (deletion.length) {
|
||||
var name = ts.isComputedPropertyName(token.parent) ? token.parent : token;
|
||||
result.push(createDeleteFix(deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, name.getText(sourceFile)]));
|
||||
result.push(createDeleteFix(deletion, [ts.Diagnostics.Remove_unused_declaration_for_Colon_0, name.getText(sourceFile)]));
|
||||
}
|
||||
}
|
||||
var prefix = ts.textChanges.ChangeTracker.with(context, function (t) { return tryPrefixDeclaration(t, errorCode, sourceFile, token); });
|
||||
@@ -128697,7 +128889,7 @@ var ts;
|
||||
(function (codefix) {
|
||||
var fixId = "fixAwaitInSyncFunction";
|
||||
var errorCodes = [
|
||||
ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function.code,
|
||||
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
||||
ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator.code,
|
||||
];
|
||||
codefix.registerCodeFix({
|
||||
@@ -128789,7 +128981,7 @@ var ts;
|
||||
}
|
||||
var fixes = [
|
||||
// fixId unnecessary because adding `// @ts-nocheck` even once will ignore every error in the file.
|
||||
codefix.createCodeFixActionNoFixId(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [
|
||||
codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [
|
||||
ts.createTextChange(sourceFile.checkJsDirective
|
||||
? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end)
|
||||
: ts.createTextSpan(0, 0), "// @ts-nocheck" + ts.getNewLineOrDefaultFromHost(host, formatContext.options)),
|
||||
@@ -129056,29 +129248,37 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function setJsonCompilerOptionValue(changeTracker, configFile, optionName, optionValue) {
|
||||
function setJsonCompilerOptionValues(changeTracker, configFile, options) {
|
||||
var tsconfigObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile);
|
||||
if (!tsconfigObjectLiteral)
|
||||
return undefined;
|
||||
var compilerOptionsProperty = findJsonProperty(tsconfigObjectLiteral, "compilerOptions");
|
||||
if (compilerOptionsProperty === undefined) {
|
||||
changeTracker.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createJsonPropertyAssignment("compilerOptions", ts.createObjectLiteral([
|
||||
createJsonPropertyAssignment(optionName, optionValue),
|
||||
])));
|
||||
changeTracker.insertNodeAtObjectStart(configFile, tsconfigObjectLiteral, createJsonPropertyAssignment("compilerOptions", ts.createObjectLiteral(options.map(function (_a) {
|
||||
var optionName = _a[0], optionValue = _a[1];
|
||||
return createJsonPropertyAssignment(optionName, optionValue);
|
||||
}), /*multiLine*/ true)));
|
||||
return;
|
||||
}
|
||||
var compilerOptions = compilerOptionsProperty.initializer;
|
||||
if (!ts.isObjectLiteralExpression(compilerOptions)) {
|
||||
return;
|
||||
}
|
||||
var optionProperty = findJsonProperty(compilerOptions, optionName);
|
||||
if (optionProperty === undefined) {
|
||||
changeTracker.insertNodeAtObjectStart(configFile, compilerOptions, createJsonPropertyAssignment(optionName, optionValue));
|
||||
}
|
||||
else {
|
||||
changeTracker.replaceNode(configFile, optionProperty.initializer, optionValue);
|
||||
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
||||
var _a = options_1[_i], optionName = _a[0], optionValue = _a[1];
|
||||
var optionProperty = findJsonProperty(compilerOptions, optionName);
|
||||
if (optionProperty === undefined) {
|
||||
changeTracker.insertNodeAtObjectStart(configFile, compilerOptions, createJsonPropertyAssignment(optionName, optionValue));
|
||||
}
|
||||
else {
|
||||
changeTracker.replaceNode(configFile, optionProperty.initializer, optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
codefix.setJsonCompilerOptionValues = setJsonCompilerOptionValues;
|
||||
function setJsonCompilerOptionValue(changeTracker, configFile, optionName, optionValue) {
|
||||
setJsonCompilerOptionValues(changeTracker, configFile, [[optionName, optionValue]]);
|
||||
}
|
||||
codefix.setJsonCompilerOptionValue = setJsonCompilerOptionValue;
|
||||
function createJsonPropertyAssignment(name, initializer) {
|
||||
return ts.createPropertyAssignment(ts.createStringLiteral(name), initializer);
|
||||
@@ -129113,7 +129313,7 @@ var ts;
|
||||
}
|
||||
function createAction(context, sourceFile, node, replacement) {
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile, node, replacement); });
|
||||
return codefix.createCodeFixActionNoFixId(fixName, changes, [ts.Diagnostics.Replace_import_with_0, changes[0].textChanges[0].newText]);
|
||||
return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Replace_import_with_0, changes[0].textChanges[0].newText]);
|
||||
}
|
||||
codefix.registerCodeFix({
|
||||
errorCodes: [
|
||||
@@ -129171,7 +129371,7 @@ var ts;
|
||||
if (ts.isExpression(expr) && !(ts.isNamedDeclaration(expr.parent) && expr.parent.name === expr)) {
|
||||
var sourceFile_1 = context.sourceFile;
|
||||
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile_1, expr, ts.createPropertyAccess(expr, "default"), {}); });
|
||||
fixes.push(codefix.createCodeFixActionNoFixId(fixName, changes, ts.Diagnostics.Use_synthetic_default_member));
|
||||
fixes.push(codefix.createCodeFixActionWithoutFixAll(fixName, changes, ts.Diagnostics.Use_synthetic_default_member));
|
||||
}
|
||||
return fixes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user