typescript 4.5.0-dev.20211027 → 4.5.0-dev.20211031
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/cs/diagnosticMessages.generated.json +1 -0
- package/lib/de/diagnosticMessages.generated.json +1 -0
- package/lib/es/diagnosticMessages.generated.json +1 -0
- package/lib/fr/diagnosticMessages.generated.json +1 -0
- package/lib/it/diagnosticMessages.generated.json +1 -0
- package/lib/ja/diagnosticMessages.generated.json +1 -0
- package/lib/ko/diagnosticMessages.generated.json +1 -0
- package/lib/lib.dom.d.ts +186 -92
- package/lib/lib.dom.iterable.d.ts +1 -7
- package/lib/lib.webworker.d.ts +60 -19
- package/lib/lib.webworker.iterable.d.ts +0 -7
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/protocol.d.ts +7 -0
- package/lib/pt-br/diagnosticMessages.generated.json +1 -0
- package/lib/ru/diagnosticMessages.generated.json +1 -0
- package/lib/tr/diagnosticMessages.generated.json +1 -0
- package/lib/tsc.js +280 -92
- package/lib/tsserver.js +612 -158
- package/lib/tsserverlibrary.d.ts +8 -0
- package/lib/tsserverlibrary.js +612 -158
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +608 -158
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +608 -158
- package/lib/typingsInstaller.js +340 -95
- package/lib/zh-cn/diagnosticMessages.generated.json +1 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +1 -0
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211031";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -2745,6 +2745,10 @@ var ts;
|
|
|
2745
2745
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
2746
2746
|
}
|
|
2747
2747
|
Debug.formatSyntaxKind = formatSyntaxKind;
|
|
2748
|
+
function formatSnippetKind(kind) {
|
|
2749
|
+
return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false);
|
|
2750
|
+
}
|
|
2751
|
+
Debug.formatSnippetKind = formatSnippetKind;
|
|
2748
2752
|
function formatNodeFlags(flags) {
|
|
2749
2753
|
return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
|
|
2750
2754
|
}
|
|
@@ -4661,6 +4665,13 @@ var ts;
|
|
|
4661
4665
|
ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
|
|
4662
4666
|
})(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
|
|
4663
4667
|
/* @internal */
|
|
4668
|
+
var MemberOverrideStatus;
|
|
4669
|
+
(function (MemberOverrideStatus) {
|
|
4670
|
+
MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok";
|
|
4671
|
+
MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride";
|
|
4672
|
+
MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride";
|
|
4673
|
+
})(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {}));
|
|
4674
|
+
/* @internal */
|
|
4664
4675
|
var UnionReduction;
|
|
4665
4676
|
(function (UnionReduction) {
|
|
4666
4677
|
UnionReduction[UnionReduction["None"] = 0] = "None";
|
|
@@ -5309,7 +5320,7 @@ var ts;
|
|
|
5309
5320
|
(function (ModuleResolutionKind) {
|
|
5310
5321
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
5311
5322
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
|
|
5312
|
-
// Starting with node12, node's module resolver has significant departures from
|
|
5323
|
+
// Starting with node12, node's module resolver has significant departures from traditional cjs resolution
|
|
5313
5324
|
// to better support ecmascript modules and their use within node - more features are still being added, so
|
|
5314
5325
|
// we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
|
|
5315
5326
|
// version-anchored resolution target
|
|
@@ -5642,6 +5653,15 @@ var ts;
|
|
|
5642
5653
|
// Masks
|
|
5643
5654
|
// - Additional bitmasks
|
|
5644
5655
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
5656
|
+
// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
|
|
5657
|
+
/* @internal */
|
|
5658
|
+
var SnippetKind;
|
|
5659
|
+
(function (SnippetKind) {
|
|
5660
|
+
SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop";
|
|
5661
|
+
SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder";
|
|
5662
|
+
SnippetKind[SnippetKind["Choice"] = 2] = "Choice";
|
|
5663
|
+
SnippetKind[SnippetKind["Variable"] = 3] = "Variable";
|
|
5664
|
+
})(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {}));
|
|
5645
5665
|
var EmitFlags;
|
|
5646
5666
|
(function (EmitFlags) {
|
|
5647
5667
|
EmitFlags[EmitFlags["None"] = 0] = "None";
|
|
@@ -8878,6 +8898,8 @@ var ts;
|
|
|
8878
8898
|
Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext'."),
|
|
8879
8899
|
Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
|
|
8880
8900
|
Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
|
|
8901
|
+
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."),
|
|
8902
|
+
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}'?"),
|
|
8881
8903
|
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}'."),
|
|
8882
8904
|
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}'."),
|
|
8883
8905
|
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}'."),
|
|
@@ -8984,6 +9006,7 @@ var ts;
|
|
|
8984
9006
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class: diag(4121, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_4121", "This member cannot have a JSDoc comment with an '@override' tag because its containing class '{0}' does not extend another class."),
|
|
8985
9007
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
8986
9008
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
9009
|
+
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8987
9010
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
8988
9011
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
8989
9012
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -9537,6 +9560,7 @@ var ts;
|
|
|
9537
9560
|
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
|
|
9538
9561
|
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
|
|
9539
9562
|
A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."),
|
|
9563
|
+
JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."),
|
|
9540
9564
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9541
9565
|
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
|
|
9542
9566
|
import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
|
|
@@ -9640,6 +9664,7 @@ var ts;
|
|
|
9640
9664
|
Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
|
|
9641
9665
|
Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
|
|
9642
9666
|
Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
|
|
9667
|
+
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}'"),
|
|
9643
9668
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9644
9669
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9645
9670
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -19833,6 +19858,8 @@ var ts;
|
|
|
19833
19858
|
case ts.ModuleKind.ES2020:
|
|
19834
19859
|
case ts.ModuleKind.ES2022:
|
|
19835
19860
|
case ts.ModuleKind.ESNext:
|
|
19861
|
+
case ts.ModuleKind.Node12:
|
|
19862
|
+
case ts.ModuleKind.NodeNext:
|
|
19836
19863
|
return true;
|
|
19837
19864
|
default:
|
|
19838
19865
|
return false;
|
|
@@ -20944,6 +20971,10 @@ var ts;
|
|
|
20944
20971
|
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20945
20972
|
}
|
|
20946
20973
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20974
|
+
function escapeSnippetText(text) {
|
|
20975
|
+
return text.replace(/\$/gm, "\\$");
|
|
20976
|
+
}
|
|
20977
|
+
ts.escapeSnippetText = escapeSnippetText;
|
|
20947
20978
|
})(ts || (ts = {}));
|
|
20948
20979
|
/* @internal */
|
|
20949
20980
|
var ts;
|
|
@@ -27147,6 +27178,25 @@ var ts;
|
|
|
27147
27178
|
}
|
|
27148
27179
|
}
|
|
27149
27180
|
ts.moveEmitHelpers = moveEmitHelpers;
|
|
27181
|
+
/**
|
|
27182
|
+
* Gets the SnippetElement of a node.
|
|
27183
|
+
*/
|
|
27184
|
+
/* @internal */
|
|
27185
|
+
function getSnippetElement(node) {
|
|
27186
|
+
var _a;
|
|
27187
|
+
return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
|
|
27188
|
+
}
|
|
27189
|
+
ts.getSnippetElement = getSnippetElement;
|
|
27190
|
+
/**
|
|
27191
|
+
* Sets the SnippetElement of a node.
|
|
27192
|
+
*/
|
|
27193
|
+
/* @internal */
|
|
27194
|
+
function setSnippetElement(node, snippet) {
|
|
27195
|
+
var emitNode = getOrCreateEmitNode(node);
|
|
27196
|
+
emitNode.snippetElement = snippet;
|
|
27197
|
+
return node;
|
|
27198
|
+
}
|
|
27199
|
+
ts.setSnippetElement = setSnippetElement;
|
|
27150
27200
|
/* @internal */
|
|
27151
27201
|
function ignoreSourceNewlines(node) {
|
|
27152
27202
|
getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
|
|
@@ -47272,6 +47322,7 @@ var ts;
|
|
|
47272
47322
|
isDeclarationVisible: isDeclarationVisible,
|
|
47273
47323
|
isPropertyAccessible: isPropertyAccessible,
|
|
47274
47324
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47325
|
+
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47275
47326
|
};
|
|
47276
47327
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
47277
47328
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -47515,6 +47566,21 @@ var ts;
|
|
|
47515
47566
|
var enumRelation = new ts.Map();
|
|
47516
47567
|
var builtinGlobals = ts.createSymbolTable();
|
|
47517
47568
|
builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
|
|
47569
|
+
// Extensions suggested for path imports when module resolution is node12 or higher.
|
|
47570
|
+
// The first element of each tuple is the extension a file has.
|
|
47571
|
+
// The second element of each tuple is the extension that should be used in a path import.
|
|
47572
|
+
// e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs".
|
|
47573
|
+
var suggestedExtensions = [
|
|
47574
|
+
[".mts", ".mjs"],
|
|
47575
|
+
[".ts", ".js"],
|
|
47576
|
+
[".cts", ".cjs"],
|
|
47577
|
+
[".mjs", ".mjs"],
|
|
47578
|
+
[".js", ".js"],
|
|
47579
|
+
[".cjs", ".cjs"],
|
|
47580
|
+
[".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"],
|
|
47581
|
+
[".jsx", ".jsx"],
|
|
47582
|
+
[".json", ".json"],
|
|
47583
|
+
];
|
|
47518
47584
|
initializeTypeChecker();
|
|
47519
47585
|
return checker;
|
|
47520
47586
|
function getJsxNamespace(location) {
|
|
@@ -49018,6 +49084,10 @@ var ts;
|
|
|
49018
49084
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
49019
49085
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
49020
49086
|
}
|
|
49087
|
+
function isOnlyImportedAsDefault(usage) {
|
|
49088
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
49089
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
49090
|
+
}
|
|
49021
49091
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
49022
49092
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
49023
49093
|
if (file && usageMode !== undefined) {
|
|
@@ -49068,8 +49138,9 @@ var ts;
|
|
|
49068
49138
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
49069
49139
|
}
|
|
49070
49140
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49141
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
49071
49142
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
49072
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
49143
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
49073
49144
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
49074
49145
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
49075
49146
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -49083,7 +49154,7 @@ var ts;
|
|
|
49083
49154
|
reportNonDefaultExport(moduleSymbol, node);
|
|
49084
49155
|
}
|
|
49085
49156
|
}
|
|
49086
|
-
else if (hasSyntheticDefault) {
|
|
49157
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
49087
49158
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
49088
49159
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49089
49160
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49208,7 +49279,7 @@ var ts;
|
|
|
49208
49279
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49209
49280
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49210
49281
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49211
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49282
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49212
49283
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49213
49284
|
}
|
|
49214
49285
|
}
|
|
@@ -49725,7 +49796,7 @@ var ts;
|
|
|
49725
49796
|
: undefined;
|
|
49726
49797
|
}
|
|
49727
49798
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
49728
|
-
var _a, _b, _c, _d, _e, _f;
|
|
49799
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
49729
49800
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
49730
49801
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
49731
49802
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -49746,7 +49817,7 @@ var ts;
|
|
|
49746
49817
|
((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
|
|
49747
49818
|
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49748
49819
|
var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
49749
|
-
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
|
|
49820
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
|
|
49750
49821
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
49751
49822
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
49752
49823
|
if (sourceFile) {
|
|
@@ -49759,6 +49830,9 @@ var ts;
|
|
|
49759
49830
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49760
49831
|
error(errorNode, ts.Diagnostics.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, moduleReference);
|
|
49761
49832
|
}
|
|
49833
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49834
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49835
|
+
}
|
|
49762
49836
|
}
|
|
49763
49837
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49764
49838
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49809,6 +49883,10 @@ var ts;
|
|
|
49809
49883
|
}
|
|
49810
49884
|
else {
|
|
49811
49885
|
var tsExtension = ts.tryExtractTSExtension(moduleReference);
|
|
49886
|
+
var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference);
|
|
49887
|
+
var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions);
|
|
49888
|
+
var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 ||
|
|
49889
|
+
moduleResolutionKind === ts.ModuleResolutionKind.NodeNext;
|
|
49812
49890
|
if (tsExtension) {
|
|
49813
49891
|
var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
|
|
49814
49892
|
var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension);
|
|
@@ -49828,6 +49906,19 @@ var ts;
|
|
|
49828
49906
|
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
49829
49907
|
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
49830
49908
|
}
|
|
49909
|
+
else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) {
|
|
49910
|
+
var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
|
|
49911
|
+
var suggestedExt = (_g = suggestedExtensions.find(function (_a) {
|
|
49912
|
+
var actualExt = _a[0], _importExt = _a[1];
|
|
49913
|
+
return host.fileExists(absoluteRef_1 + actualExt);
|
|
49914
|
+
})) === null || _g === void 0 ? void 0 : _g[1];
|
|
49915
|
+
if (suggestedExt) {
|
|
49916
|
+
error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
|
|
49917
|
+
}
|
|
49918
|
+
else {
|
|
49919
|
+
error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path);
|
|
49920
|
+
}
|
|
49921
|
+
}
|
|
49831
49922
|
else {
|
|
49832
49923
|
error(errorNode, moduleNotFoundError, moduleReference);
|
|
49833
49924
|
}
|
|
@@ -49897,40 +49988,50 @@ var ts;
|
|
|
49897
49988
|
error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
|
49898
49989
|
return symbol;
|
|
49899
49990
|
}
|
|
49900
|
-
|
|
49901
|
-
|
|
49902
|
-
|
|
49903
|
-
|
|
49904
|
-
|
|
49991
|
+
var referenceParent = referencingLocation.parent;
|
|
49992
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49993
|
+
ts.isImportCall(referenceParent)) {
|
|
49994
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49995
|
+
var type = getTypeOfSymbol(symbol);
|
|
49996
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49997
|
+
if (defaultOnlyType) {
|
|
49998
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49999
|
+
}
|
|
50000
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49905
50001
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49906
50002
|
if (!sigs || !sigs.length) {
|
|
49907
50003
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49908
50004
|
}
|
|
49909
|
-
if (sigs && sigs.length) {
|
|
49910
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49911
|
-
|
|
49912
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49913
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49914
|
-
result.parent = symbol.parent;
|
|
49915
|
-
result.target = symbol;
|
|
49916
|
-
result.originatingImport = referenceParent;
|
|
49917
|
-
if (symbol.valueDeclaration)
|
|
49918
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49919
|
-
if (symbol.constEnumOnlyModule)
|
|
49920
|
-
result.constEnumOnlyModule = true;
|
|
49921
|
-
if (symbol.members)
|
|
49922
|
-
result.members = new ts.Map(symbol.members);
|
|
49923
|
-
if (symbol.exports)
|
|
49924
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49925
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49926
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49927
|
-
return result;
|
|
50005
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
50006
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
50007
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49928
50008
|
}
|
|
49929
50009
|
}
|
|
49930
50010
|
}
|
|
49931
50011
|
}
|
|
49932
50012
|
return symbol;
|
|
49933
50013
|
}
|
|
50014
|
+
/**
|
|
50015
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
50016
|
+
*/
|
|
50017
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
50018
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
50019
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
50020
|
+
result.parent = symbol.parent;
|
|
50021
|
+
result.target = symbol;
|
|
50022
|
+
result.originatingImport = referenceParent;
|
|
50023
|
+
if (symbol.valueDeclaration)
|
|
50024
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
50025
|
+
if (symbol.constEnumOnlyModule)
|
|
50026
|
+
result.constEnumOnlyModule = true;
|
|
50027
|
+
if (symbol.members)
|
|
50028
|
+
result.members = new ts.Map(symbol.members);
|
|
50029
|
+
if (symbol.exports)
|
|
50030
|
+
result.exports = new ts.Map(symbol.exports);
|
|
50031
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
50032
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
50033
|
+
return result;
|
|
50034
|
+
}
|
|
49934
50035
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49935
50036
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49936
50037
|
}
|
|
@@ -61729,7 +61830,9 @@ var ts;
|
|
|
61729
61830
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61730
61831
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61731
61832
|
if (!type.declaration.nameType) {
|
|
61732
|
-
|
|
61833
|
+
var constraint = void 0;
|
|
61834
|
+
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
|
|
61835
|
+
(constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61733
61836
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61734
61837
|
}
|
|
61735
61838
|
if (isGenericTupleType(t)) {
|
|
@@ -67376,8 +67479,11 @@ var ts;
|
|
|
67376
67479
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67377
67480
|
switch (node.kind) {
|
|
67378
67481
|
case 79 /* Identifier */:
|
|
67379
|
-
|
|
67380
|
-
|
|
67482
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67483
|
+
var symbol = getResolvedSymbol(node);
|
|
67484
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67485
|
+
}
|
|
67486
|
+
// falls through
|
|
67381
67487
|
case 108 /* ThisKeyword */:
|
|
67382
67488
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67383
67489
|
case 229 /* NonNullExpression */:
|
|
@@ -75106,11 +75212,33 @@ var ts;
|
|
|
75106
75212
|
if (moduleSymbol) {
|
|
75107
75213
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
75108
75214
|
if (esModuleSymbol) {
|
|
75109
|
-
return createPromiseReturnType(node,
|
|
75215
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
75216
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
75110
75217
|
}
|
|
75111
75218
|
}
|
|
75112
75219
|
return createPromiseReturnType(node, anyType);
|
|
75113
75220
|
}
|
|
75221
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
75222
|
+
var memberTable = ts.createSymbolTable();
|
|
75223
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75224
|
+
newSymbol.parent = originalSymbol;
|
|
75225
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
75226
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
75227
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
75228
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
75229
|
+
}
|
|
75230
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75231
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
75232
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75233
|
+
var synthType = type;
|
|
75234
|
+
if (!synthType.defaultOnlyType) {
|
|
75235
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75236
|
+
synthType.defaultOnlyType = type_4;
|
|
75237
|
+
}
|
|
75238
|
+
return synthType.defaultOnlyType;
|
|
75239
|
+
}
|
|
75240
|
+
return undefined;
|
|
75241
|
+
}
|
|
75114
75242
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75115
75243
|
var _a;
|
|
75116
75244
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -75119,14 +75247,8 @@ var ts;
|
|
|
75119
75247
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
75120
75248
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
75121
75249
|
if (hasSyntheticDefault) {
|
|
75122
|
-
var memberTable = ts.createSymbolTable();
|
|
75123
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75124
|
-
newSymbol.parent = originalSymbol;
|
|
75125
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
75126
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
75127
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
75128
75250
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
75129
|
-
var defaultContainingObject =
|
|
75251
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
75130
75252
|
anonymousSymbol.type = defaultContainingObject;
|
|
75131
75253
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
75132
75254
|
}
|
|
@@ -75834,12 +75956,12 @@ var ts;
|
|
|
75834
75956
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75835
75957
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75836
75958
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75837
|
-
var
|
|
75959
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75838
75960
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75839
|
-
if (
|
|
75961
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75840
75962
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75841
75963
|
}
|
|
75842
|
-
return !!(filterType(
|
|
75964
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75843
75965
|
}
|
|
75844
75966
|
var type = getTypeOfExpression(node.expression);
|
|
75845
75967
|
if (!isLiteralType(type)) {
|
|
@@ -81809,7 +81931,7 @@ var ts;
|
|
|
81809
81931
|
checkKindsOfPropertyMemberOverrides(type, baseType_1);
|
|
81810
81932
|
}
|
|
81811
81933
|
}
|
|
81812
|
-
|
|
81934
|
+
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
81813
81935
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
81814
81936
|
if (implementedTypeNodes) {
|
|
81815
81937
|
for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
|
|
@@ -81844,8 +81966,7 @@ var ts;
|
|
|
81844
81966
|
checkPropertyInitialization(node);
|
|
81845
81967
|
}
|
|
81846
81968
|
}
|
|
81847
|
-
function
|
|
81848
|
-
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81969
|
+
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
81849
81970
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81850
81971
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81851
81972
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
@@ -81857,46 +81978,71 @@ var ts;
|
|
|
81857
81978
|
if (ts.isConstructorDeclaration(member)) {
|
|
81858
81979
|
ts.forEach(member.parameters, function (param) {
|
|
81859
81980
|
if (ts.isParameterPropertyDeclaration(param, member)) {
|
|
81860
|
-
|
|
81981
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
|
|
81982
|
+
/* memberIsParameterProperty */ true);
|
|
81861
81983
|
}
|
|
81862
81984
|
});
|
|
81863
81985
|
}
|
|
81864
|
-
|
|
81986
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
|
|
81987
|
+
/* memberIsParameterProperty */ false);
|
|
81865
81988
|
};
|
|
81866
81989
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
81867
81990
|
var member = _a[_i];
|
|
81868
81991
|
_loop_29(member);
|
|
81869
81992
|
}
|
|
81870
|
-
|
|
81871
|
-
|
|
81872
|
-
|
|
81873
|
-
|
|
81874
|
-
|
|
81875
|
-
|
|
81876
|
-
|
|
81877
|
-
|
|
81878
|
-
|
|
81879
|
-
|
|
81880
|
-
|
|
81881
|
-
|
|
81882
|
-
|
|
81883
|
-
|
|
81884
|
-
|
|
81885
|
-
|
|
81993
|
+
}
|
|
81994
|
+
/**
|
|
81995
|
+
* @param member Existing member node to be checked.
|
|
81996
|
+
* Note: `member` cannot be a synthetic node.
|
|
81997
|
+
*/
|
|
81998
|
+
function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
|
|
81999
|
+
if (reportErrors === void 0) { reportErrors = true; }
|
|
82000
|
+
var declaredProp = member.name
|
|
82001
|
+
&& getSymbolAtLocation(member.name)
|
|
82002
|
+
|| getSymbolAtLocation(member);
|
|
82003
|
+
if (!declaredProp) {
|
|
82004
|
+
return 0 /* Ok */;
|
|
82005
|
+
}
|
|
82006
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
|
|
82007
|
+
}
|
|
82008
|
+
/**
|
|
82009
|
+
* Checks a class member declaration for either a missing or an invalid `override` modifier.
|
|
82010
|
+
* Note: this function can be used for speculative checking,
|
|
82011
|
+
* i.e. checking a member that does not yet exist in the program.
|
|
82012
|
+
* An example of that would be to call this function in a completions scenario,
|
|
82013
|
+
* when offering a method declaration as completion.
|
|
82014
|
+
* @param errorNode The node where we should report an error, or undefined if we should not report errors.
|
|
82015
|
+
*/
|
|
82016
|
+
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
82017
|
+
var isJs = ts.isInJSFile(node);
|
|
82018
|
+
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
82019
|
+
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
82020
|
+
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
82021
|
+
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
82022
|
+
var baseType = memberIsStatic ? baseStaticType : baseWithThis;
|
|
82023
|
+
var prop = getPropertyOfType(thisType, memberEscapedName);
|
|
82024
|
+
var baseProp = getPropertyOfType(baseType, memberEscapedName);
|
|
82025
|
+
var baseClassName = typeToString(baseWithThis);
|
|
82026
|
+
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
82027
|
+
if (errorNode) {
|
|
82028
|
+
var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
|
|
81886
82029
|
suggestion ?
|
|
81887
|
-
error(
|
|
82030
|
+
error(errorNode, isJs ?
|
|
81888
82031
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 :
|
|
81889
82032
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) :
|
|
81890
|
-
error(
|
|
82033
|
+
error(errorNode, isJs ?
|
|
81891
82034
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
|
|
81892
82035
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
|
|
81893
82036
|
}
|
|
81894
|
-
|
|
81895
|
-
|
|
81896
|
-
|
|
81897
|
-
|
|
81898
|
-
|
|
81899
|
-
|
|
82037
|
+
return 2 /* HasInvalidOverride */;
|
|
82038
|
+
}
|
|
82039
|
+
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
|
|
82040
|
+
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
|
|
82041
|
+
if (memberHasOverrideModifier) {
|
|
82042
|
+
return 0 /* Ok */;
|
|
82043
|
+
}
|
|
82044
|
+
if (!baseHasAbstract) {
|
|
82045
|
+
if (errorNode) {
|
|
81900
82046
|
var diag = memberIsParameterProperty ?
|
|
81901
82047
|
isJs ?
|
|
81902
82048
|
ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
@@ -81904,20 +82050,28 @@ var ts;
|
|
|
81904
82050
|
isJs ?
|
|
81905
82051
|
ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
81906
82052
|
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
81907
|
-
error(
|
|
82053
|
+
error(errorNode, diag, baseClassName);
|
|
81908
82054
|
}
|
|
81909
|
-
|
|
81910
|
-
|
|
82055
|
+
return 1 /* NeedsOverride */;
|
|
82056
|
+
}
|
|
82057
|
+
else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
82058
|
+
if (errorNode) {
|
|
82059
|
+
error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
|
|
81911
82060
|
}
|
|
82061
|
+
return 1 /* NeedsOverride */;
|
|
81912
82062
|
}
|
|
81913
82063
|
}
|
|
81914
|
-
|
|
82064
|
+
}
|
|
82065
|
+
else if (memberHasOverrideModifier) {
|
|
82066
|
+
if (errorNode) {
|
|
81915
82067
|
var className = typeToString(type);
|
|
81916
|
-
error(
|
|
82068
|
+
error(errorNode, isJs ?
|
|
81917
82069
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
|
|
81918
82070
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
|
|
81919
82071
|
}
|
|
82072
|
+
return 2 /* HasInvalidOverride */;
|
|
81920
82073
|
}
|
|
82074
|
+
return 0 /* Ok */;
|
|
81921
82075
|
}
|
|
81922
82076
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
81923
82077
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
@@ -81960,6 +82114,31 @@ var ts;
|
|
|
81960
82114
|
}
|
|
81961
82115
|
}
|
|
81962
82116
|
}
|
|
82117
|
+
/**
|
|
82118
|
+
* Checks a member declaration node to see if has a missing or invalid `override` modifier.
|
|
82119
|
+
* @param node Class-like node where the member is declared.
|
|
82120
|
+
* @param member Member declaration node.
|
|
82121
|
+
* Note: `member` can be a synthetic node without a parent.
|
|
82122
|
+
*/
|
|
82123
|
+
function getMemberOverrideModifierStatus(node, member) {
|
|
82124
|
+
if (!member.name) {
|
|
82125
|
+
return 0 /* Ok */;
|
|
82126
|
+
}
|
|
82127
|
+
var symbol = getSymbolOfNode(node);
|
|
82128
|
+
var type = getDeclaredTypeOfSymbol(symbol);
|
|
82129
|
+
var typeWithThis = getTypeWithThisArgument(type);
|
|
82130
|
+
var staticType = getTypeOfSymbol(symbol);
|
|
82131
|
+
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
82132
|
+
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
82133
|
+
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
82134
|
+
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
82135
|
+
var memberHasOverrideModifier = member.parent
|
|
82136
|
+
? ts.hasOverrideModifier(member)
|
|
82137
|
+
: ts.hasSyntacticModifier(member, 16384 /* Override */);
|
|
82138
|
+
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
|
|
82139
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
|
|
82140
|
+
/* memberIsParameterProperty */ false, memberName);
|
|
82141
|
+
}
|
|
81963
82142
|
function getTargetSymbol(s) {
|
|
81964
82143
|
// if symbol is instantiated its flags are not copied from the 'target'
|
|
81965
82144
|
// so we'll need to get back original 'target' symbol to work with correct set of flags
|
|
@@ -94956,11 +95135,11 @@ var ts;
|
|
|
94956
95135
|
currentFileState.filenameDeclaration = declaration;
|
|
94957
95136
|
return currentFileState.filenameDeclaration.name;
|
|
94958
95137
|
}
|
|
94959
|
-
function getJsxFactoryCalleePrimitive(
|
|
94960
|
-
return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" :
|
|
95138
|
+
function getJsxFactoryCalleePrimitive(isStaticChildren) {
|
|
95139
|
+
return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
|
|
94961
95140
|
}
|
|
94962
|
-
function getJsxFactoryCallee(
|
|
94963
|
-
var type = getJsxFactoryCalleePrimitive(
|
|
95141
|
+
function getJsxFactoryCallee(isStaticChildren) {
|
|
95142
|
+
var type = getJsxFactoryCalleePrimitive(isStaticChildren);
|
|
94964
95143
|
return getImplicitImportForName(type);
|
|
94965
95144
|
}
|
|
94966
95145
|
function getImplicitJsxFragmentReference() {
|
|
@@ -95112,7 +95291,7 @@ var ts;
|
|
|
95112
95291
|
}
|
|
95113
95292
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
95114
95293
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95115
|
-
if (ts.length(nonWhitespaceChildren) === 1) {
|
|
95294
|
+
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
|
|
95116
95295
|
var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
95117
95296
|
return result_12 && factory.createPropertyAssignment("children", result_12);
|
|
95118
95297
|
}
|
|
@@ -95126,15 +95305,18 @@ var ts;
|
|
|
95126
95305
|
var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
|
|
95127
95306
|
var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
|
|
95128
95307
|
factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
|
|
95129
|
-
return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr,
|
|
95308
|
+
return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children || ts.emptyArray, isChild, location);
|
|
95130
95309
|
}
|
|
95131
|
-
function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr,
|
|
95310
|
+
function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children, isChild, location) {
|
|
95311
|
+
var _a;
|
|
95312
|
+
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95313
|
+
var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
|
|
95132
95314
|
var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
|
|
95133
95315
|
if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
|
|
95134
95316
|
var originalFile = ts.getOriginalNode(currentSourceFile);
|
|
95135
95317
|
if (originalFile && ts.isSourceFile(originalFile)) {
|
|
95136
95318
|
// isStaticChildren development flag
|
|
95137
|
-
args.push(
|
|
95319
|
+
args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
|
|
95138
95320
|
// __source development flag
|
|
95139
95321
|
var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
|
|
95140
95322
|
args.push(factory.createObjectLiteralExpression([
|
|
@@ -95146,7 +95328,7 @@ var ts;
|
|
|
95146
95328
|
args.push(factory.createThis());
|
|
95147
95329
|
}
|
|
95148
95330
|
}
|
|
95149
|
-
var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(
|
|
95331
|
+
var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(isStaticChildren), /*typeArguments*/ undefined, args), location);
|
|
95150
95332
|
if (isChild) {
|
|
95151
95333
|
ts.startOnNewLine(element);
|
|
95152
95334
|
}
|
|
@@ -95176,7 +95358,7 @@ var ts;
|
|
|
95176
95358
|
}
|
|
95177
95359
|
}
|
|
95178
95360
|
return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]),
|
|
95179
|
-
/*keyAttr*/ undefined,
|
|
95361
|
+
/*keyAttr*/ undefined, children, isChild, location);
|
|
95180
95362
|
}
|
|
95181
95363
|
function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
|
|
95182
95364
|
var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
|
|
@@ -108264,7 +108446,14 @@ var ts;
|
|
|
108264
108446
|
// clear the parenthesizer rule as we ascend
|
|
108265
108447
|
currentParenthesizerRule = undefined;
|
|
108266
108448
|
}
|
|
108267
|
-
function pipelineEmitWithHintWorker(hint, node) {
|
|
108449
|
+
function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
|
|
108450
|
+
if (allowSnippets === void 0) { allowSnippets = true; }
|
|
108451
|
+
if (allowSnippets) {
|
|
108452
|
+
var snippet = ts.getSnippetElement(node);
|
|
108453
|
+
if (snippet) {
|
|
108454
|
+
return emitSnippetNode(hint, node, snippet);
|
|
108455
|
+
}
|
|
108456
|
+
}
|
|
108268
108457
|
if (hint === 0 /* SourceFile */)
|
|
108269
108458
|
return emitSourceFile(ts.cast(node, ts.isSourceFile));
|
|
108270
108459
|
if (hint === 2 /* IdentifierName */)
|
|
@@ -108873,6 +109062,28 @@ var ts;
|
|
|
108873
109062
|
}
|
|
108874
109063
|
}
|
|
108875
109064
|
//
|
|
109065
|
+
// Snippet Elements
|
|
109066
|
+
//
|
|
109067
|
+
function emitSnippetNode(hint, node, snippet) {
|
|
109068
|
+
switch (snippet.kind) {
|
|
109069
|
+
case 1 /* Placeholder */:
|
|
109070
|
+
emitPlaceholder(hint, node, snippet);
|
|
109071
|
+
break;
|
|
109072
|
+
case 0 /* TabStop */:
|
|
109073
|
+
emitTabStop(snippet);
|
|
109074
|
+
break;
|
|
109075
|
+
}
|
|
109076
|
+
}
|
|
109077
|
+
function emitPlaceholder(hint, node, snippet) {
|
|
109078
|
+
nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
|
|
109079
|
+
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
|
|
109080
|
+
nonEscapingWrite("}"); // `}`
|
|
109081
|
+
// `${2:...}`
|
|
109082
|
+
}
|
|
109083
|
+
function emitTabStop(snippet) {
|
|
109084
|
+
nonEscapingWrite("$" + snippet.order);
|
|
109085
|
+
}
|
|
109086
|
+
//
|
|
108876
109087
|
// Identifiers
|
|
108877
109088
|
//
|
|
108878
109089
|
function emitIdentifier(node) {
|
|
@@ -111111,6 +111322,15 @@ var ts;
|
|
|
111111
111322
|
function writeProperty(s) {
|
|
111112
111323
|
writer.writeProperty(s);
|
|
111113
111324
|
}
|
|
111325
|
+
function nonEscapingWrite(s) {
|
|
111326
|
+
// This should be defined in a snippet-escaping text writer.
|
|
111327
|
+
if (writer.nonEscapingWrite) {
|
|
111328
|
+
writer.nonEscapingWrite(s);
|
|
111329
|
+
}
|
|
111330
|
+
else {
|
|
111331
|
+
writer.write(s);
|
|
111332
|
+
}
|
|
111333
|
+
}
|
|
111114
111334
|
function writeLine(count) {
|
|
111115
111335
|
if (count === void 0) { count = 1; }
|
|
111116
111336
|
for (var i = 0; i < count; i++) {
|
|
@@ -114214,8 +114434,8 @@ var ts;
|
|
|
114214
114434
|
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
114215
114435
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
114216
114436
|
// ensure that types resolutions are still correct
|
|
114217
|
-
var
|
|
114218
|
-
if (
|
|
114437
|
+
var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
114438
|
+
if (typeReferenceResolutionsChanged) {
|
|
114219
114439
|
structureIsReused = 1 /* SafeModules */;
|
|
114220
114440
|
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
114221
114441
|
}
|
|
@@ -115503,6 +115723,21 @@ var ts;
|
|
|
115503
115723
|
return resolvedRef;
|
|
115504
115724
|
}
|
|
115505
115725
|
function verifyCompilerOptions() {
|
|
115726
|
+
var isNightly = ts.stringContains(ts.version, "-dev");
|
|
115727
|
+
if (!isNightly) {
|
|
115728
|
+
if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
|
|
115729
|
+
createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
|
|
115730
|
+
}
|
|
115731
|
+
else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
|
|
115732
|
+
createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
|
|
115733
|
+
}
|
|
115734
|
+
else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
|
|
115735
|
+
createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
|
|
115736
|
+
}
|
|
115737
|
+
else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
115738
|
+
createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
|
|
115739
|
+
}
|
|
115740
|
+
}
|
|
115506
115741
|
if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
|
|
115507
115742
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
|
|
115508
115743
|
}
|
|
@@ -115651,7 +115886,9 @@ var ts;
|
|
|
115651
115886
|
}
|
|
115652
115887
|
}
|
|
115653
115888
|
if (options.resolveJsonModule) {
|
|
115654
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115889
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115890
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115891
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115655
115892
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115656
115893
|
}
|
|
115657
115894
|
// Any emit other than common js, amd, es2015 or esnext is error
|
|
@@ -115979,8 +116216,8 @@ var ts;
|
|
|
115979
116216
|
function createDiagnosticForOptionName(message, option1, option2, option3) {
|
|
115980
116217
|
createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3);
|
|
115981
116218
|
}
|
|
115982
|
-
function createOptionValueDiagnostic(option1, message, arg0) {
|
|
115983
|
-
createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0);
|
|
116219
|
+
function createOptionValueDiagnostic(option1, message, arg0, arg1) {
|
|
116220
|
+
createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
|
|
115984
116221
|
}
|
|
115985
116222
|
function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
|
|
115986
116223
|
var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
|
|
@@ -118224,6 +118461,9 @@ var ts;
|
|
|
118224
118461
|
else {
|
|
118225
118462
|
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
118226
118463
|
perDirectoryResolution.set(name, mode, resolution);
|
|
118464
|
+
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
118465
|
+
resolutionHost.onDiscoveredSymlink();
|
|
118466
|
+
}
|
|
118227
118467
|
}
|
|
118228
118468
|
resolutionsInFile.set(name, mode, resolution);
|
|
118229
118469
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
@@ -118692,6 +118932,11 @@ var ts;
|
|
|
118692
118932
|
}
|
|
118693
118933
|
}
|
|
118694
118934
|
ts.createResolutionCache = createResolutionCache;
|
|
118935
|
+
function resolutionIsSymlink(resolution) {
|
|
118936
|
+
var _a, _b;
|
|
118937
|
+
return !!(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.originalPath) ||
|
|
118938
|
+
((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.originalPath));
|
|
118939
|
+
}
|
|
118695
118940
|
})(ts || (ts = {}));
|
|
118696
118941
|
// Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
|
|
118697
118942
|
/* @internal */
|
|
@@ -126134,6 +126379,16 @@ var ts;
|
|
|
126134
126379
|
return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
|
|
126135
126380
|
}
|
|
126136
126381
|
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
|
|
126382
|
+
function getNewLineKind(newLineCharacter) {
|
|
126383
|
+
return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
|
|
126384
|
+
}
|
|
126385
|
+
ts.getNewLineKind = getNewLineKind;
|
|
126386
|
+
function diagnosticToString(diag) {
|
|
126387
|
+
return ts.isArray(diag)
|
|
126388
|
+
? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
|
|
126389
|
+
: ts.getLocaleSpecificMessage(diag);
|
|
126390
|
+
}
|
|
126391
|
+
ts.diagnosticToString = diagnosticToString;
|
|
126137
126392
|
// #endregion
|
|
126138
126393
|
})(ts || (ts = {}));
|
|
126139
126394
|
/*@internal*/
|
|
@@ -127731,7 +127986,7 @@ var ts;
|
|
|
127731
127986
|
(function (Completions) {
|
|
127732
127987
|
var StringCompletions;
|
|
127733
127988
|
(function (StringCompletions) {
|
|
127734
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken,
|
|
127989
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
127735
127990
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
127736
127991
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
127737
127992
|
return entries && convertPathCompletions(entries);
|
|
@@ -127739,12 +127994,12 @@ var ts;
|
|
|
127739
127994
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
127740
127995
|
if (!contextToken || !ts.isStringLiteralLike(contextToken))
|
|
127741
127996
|
return undefined;
|
|
127742
|
-
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
127743
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile,
|
|
127997
|
+
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
|
127998
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
|
|
127744
127999
|
}
|
|
127745
128000
|
}
|
|
127746
128001
|
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
|
|
127747
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile,
|
|
128002
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
|
|
127748
128003
|
if (completion === undefined) {
|
|
127749
128004
|
return undefined;
|
|
127750
128005
|
}
|
|
@@ -127754,7 +128009,7 @@ var ts;
|
|
|
127754
128009
|
return convertPathCompletions(completion.paths);
|
|
127755
128010
|
case 1 /* Properties */: {
|
|
127756
128011
|
var entries = [];
|
|
127757
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile,
|
|
128012
|
+
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
|
|
127758
128013
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127759
128014
|
}
|
|
127760
128015
|
case 2 /* Types */: {
|
|
@@ -128480,6 +128735,8 @@ var ts;
|
|
|
128480
128735
|
(function (CompletionSource) {
|
|
128481
128736
|
/** Completions that require `this.` insertion text */
|
|
128482
128737
|
CompletionSource["ThisProperty"] = "ThisProperty/";
|
|
128738
|
+
/** Auto-import that comes attached to a class member snippet */
|
|
128739
|
+
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
128483
128740
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
128484
128741
|
var SymbolOriginInfoKind;
|
|
128485
128742
|
(function (SymbolOriginInfoKind) {
|
|
@@ -128588,7 +128845,6 @@ var ts;
|
|
|
128588
128845
|
}
|
|
128589
128846
|
// If the request is a continuation of an earlier `isIncomplete` response,
|
|
128590
128847
|
// we can continue it from the cached previous response.
|
|
128591
|
-
var typeChecker = program.getTypeChecker();
|
|
128592
128848
|
var compilerOptions = program.getCompilerOptions();
|
|
128593
128849
|
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
|
|
128594
128850
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
|
|
@@ -128600,7 +128856,7 @@ var ts;
|
|
|
128600
128856
|
else {
|
|
128601
128857
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
|
|
128602
128858
|
}
|
|
128603
|
-
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken,
|
|
128859
|
+
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
|
|
128604
128860
|
if (stringCompletions) {
|
|
128605
128861
|
return stringCompletions;
|
|
128606
128862
|
}
|
|
@@ -128614,7 +128870,7 @@ var ts;
|
|
|
128614
128870
|
}
|
|
128615
128871
|
switch (completionData.kind) {
|
|
128616
128872
|
case 0 /* Data */:
|
|
128617
|
-
var response = completionInfoFromData(sourceFile,
|
|
128873
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128618
128874
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128619
128875
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128620
128876
|
}
|
|
@@ -128711,7 +128967,7 @@ var ts;
|
|
|
128711
128967
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128712
128968
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128713
128969
|
}
|
|
128714
|
-
function completionInfoFromData(sourceFile,
|
|
128970
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128715
128971
|
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;
|
|
128716
128972
|
// Verify if the file is JSX language variant
|
|
128717
128973
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128723,7 +128979,7 @@ var ts;
|
|
|
128723
128979
|
var entries = [];
|
|
128724
128980
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128725
128981
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128726
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128982
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128727
128983
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128728
128984
|
}
|
|
128729
128985
|
else {
|
|
@@ -128731,7 +128987,7 @@ var ts;
|
|
|
128731
128987
|
return undefined;
|
|
128732
128988
|
}
|
|
128733
128989
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128734
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128990
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128735
128991
|
}
|
|
128736
128992
|
if (keywordFilters !== 0 /* None */) {
|
|
128737
128993
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128837,14 +129093,16 @@ var ts;
|
|
|
128837
129093
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128838
129094
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128839
129095
|
}
|
|
128840
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128841
|
-
var _a;
|
|
129096
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
129097
|
+
var _a, _b;
|
|
128842
129098
|
var insertText;
|
|
128843
129099
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
128844
129100
|
var data;
|
|
128845
129101
|
var isSnippet;
|
|
129102
|
+
var source = getSourceFromOrigin(origin);
|
|
128846
129103
|
var sourceDisplay;
|
|
128847
129104
|
var hasAction;
|
|
129105
|
+
var typeChecker = program.getTypeChecker();
|
|
128848
129106
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
128849
129107
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
128850
129108
|
if (origin && originIsThisType(origin)) {
|
|
@@ -128895,12 +129153,16 @@ var ts;
|
|
|
128895
129153
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
128896
129154
|
}
|
|
128897
129155
|
}
|
|
128898
|
-
if (
|
|
128899
|
-
|
|
128900
|
-
|
|
128901
|
-
|
|
128902
|
-
|
|
128903
|
-
|
|
129156
|
+
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
129157
|
+
preferences.includeCompletionsWithInsertText &&
|
|
129158
|
+
completionKind === 3 /* MemberLike */ &&
|
|
129159
|
+
isClassLikeMemberCompletion(symbol, location)) {
|
|
129160
|
+
var importAdder = void 0;
|
|
129161
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
|
|
129162
|
+
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
129163
|
+
hasAction = true;
|
|
129164
|
+
source = CompletionSource.ClassMemberSnippet;
|
|
129165
|
+
}
|
|
128904
129166
|
}
|
|
128905
129167
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128906
129168
|
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
@@ -128912,7 +129174,7 @@ var ts;
|
|
|
128912
129174
|
&& !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
|
|
128913
129175
|
if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
|
|
128914
129176
|
// If is string like or undefined use quotes
|
|
128915
|
-
insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
129177
|
+
insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128916
129178
|
isSnippet = true;
|
|
128917
129179
|
}
|
|
128918
129180
|
else {
|
|
@@ -128921,13 +129183,20 @@ var ts;
|
|
|
128921
129183
|
}
|
|
128922
129184
|
}
|
|
128923
129185
|
if (useBraces_1) {
|
|
128924
|
-
insertText = escapeSnippetText(name) + "={$1}";
|
|
129186
|
+
insertText = ts.escapeSnippetText(name) + "={$1}";
|
|
128925
129187
|
isSnippet = true;
|
|
128926
129188
|
}
|
|
128927
129189
|
if (isSnippet) {
|
|
128928
129190
|
replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
|
|
128929
129191
|
}
|
|
128930
129192
|
}
|
|
129193
|
+
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
|
129194
|
+
return undefined;
|
|
129195
|
+
}
|
|
129196
|
+
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
129197
|
+
data = originToCompletionEntryData(origin);
|
|
129198
|
+
hasAction = !importCompletionNode;
|
|
129199
|
+
}
|
|
128931
129200
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
128932
129201
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
128933
129202
|
// really we should consider passing the meaning for the node so that we don't report
|
|
@@ -128940,7 +129209,7 @@ var ts;
|
|
|
128940
129209
|
kind: kind,
|
|
128941
129210
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
128942
129211
|
sortText: sortText,
|
|
128943
|
-
source:
|
|
129212
|
+
source: source,
|
|
128944
129213
|
hasAction: hasAction ? true : undefined,
|
|
128945
129214
|
isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined,
|
|
128946
129215
|
insertText: insertText,
|
|
@@ -128952,8 +129221,172 @@ var ts;
|
|
|
128952
129221
|
data: data,
|
|
128953
129222
|
};
|
|
128954
129223
|
}
|
|
128955
|
-
function
|
|
128956
|
-
|
|
129224
|
+
function isClassLikeMemberCompletion(symbol, location) {
|
|
129225
|
+
// TODO: support JS files.
|
|
129226
|
+
if (ts.isInJSFile(location)) {
|
|
129227
|
+
return false;
|
|
129228
|
+
}
|
|
129229
|
+
// Completion symbol must be for a class member.
|
|
129230
|
+
var memberFlags = 106500 /* ClassMember */
|
|
129231
|
+
& 900095 /* EnumMemberExcludes */;
|
|
129232
|
+
/* In
|
|
129233
|
+
`class C {
|
|
129234
|
+
|
|
|
129235
|
+
}`
|
|
129236
|
+
`location` is a class-like declaration.
|
|
129237
|
+
In
|
|
129238
|
+
`class C {
|
|
129239
|
+
m|
|
|
129240
|
+
}`
|
|
129241
|
+
`location` is an identifier,
|
|
129242
|
+
`location.parent` is a class element declaration,
|
|
129243
|
+
and `location.parent.parent` is a class-like declaration.
|
|
129244
|
+
In
|
|
129245
|
+
`abstract class C {
|
|
129246
|
+
abstract
|
|
129247
|
+
abstract m|
|
|
129248
|
+
}`
|
|
129249
|
+
`location` is a syntax list (with modifiers as children),
|
|
129250
|
+
and `location.parent` is a class-like declaration.
|
|
129251
|
+
*/
|
|
129252
|
+
return !!(symbol.flags & memberFlags) &&
|
|
129253
|
+
(ts.isClassLike(location) ||
|
|
129254
|
+
(location.parent &&
|
|
129255
|
+
location.parent.parent &&
|
|
129256
|
+
ts.isClassElement(location.parent) &&
|
|
129257
|
+
location === location.parent.name &&
|
|
129258
|
+
ts.isClassLike(location.parent.parent)) ||
|
|
129259
|
+
(location.parent &&
|
|
129260
|
+
ts.isSyntaxList(location) &&
|
|
129261
|
+
ts.isClassLike(location.parent)));
|
|
129262
|
+
}
|
|
129263
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
129264
|
+
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
129265
|
+
if (!classLikeDeclaration) {
|
|
129266
|
+
return { insertText: name };
|
|
129267
|
+
}
|
|
129268
|
+
var isSnippet;
|
|
129269
|
+
var insertText = name;
|
|
129270
|
+
var checker = program.getTypeChecker();
|
|
129271
|
+
var sourceFile = location.getSourceFile();
|
|
129272
|
+
var printer = createSnippetPrinter({
|
|
129273
|
+
removeComments: true,
|
|
129274
|
+
module: options.module,
|
|
129275
|
+
target: options.target,
|
|
129276
|
+
omitTrailingSemicolon: true,
|
|
129277
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
129278
|
+
});
|
|
129279
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
129280
|
+
var body;
|
|
129281
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129282
|
+
isSnippet = true;
|
|
129283
|
+
// We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
|
|
129284
|
+
// if it has one, so that the cursor ends up in the body once the completion is inserted.
|
|
129285
|
+
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
129286
|
+
var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
|
|
129287
|
+
ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
|
|
129288
|
+
body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
|
|
129289
|
+
}
|
|
129290
|
+
else {
|
|
129291
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
129292
|
+
}
|
|
129293
|
+
var modifiers = 0 /* None */;
|
|
129294
|
+
// Whether the suggested member should be abstract.
|
|
129295
|
+
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
|
|
129296
|
+
// Note: We are relying on checking if the context token is `abstract`,
|
|
129297
|
+
// since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
|
|
129298
|
+
// However, that is not true for the e.g. `override` modifier, so this check has its limitations.
|
|
129299
|
+
var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
|
|
129300
|
+
var completionNodes = [];
|
|
129301
|
+
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
|
|
129302
|
+
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
|
|
129303
|
+
// it adds for the given member symbol.
|
|
129304
|
+
// We store these member nodes in the `completionNodes` array.
|
|
129305
|
+
// Note: there might be:
|
|
129306
|
+
// - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
|
|
129307
|
+
// - One node;
|
|
129308
|
+
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
|
|
129309
|
+
function (node) {
|
|
129310
|
+
var requiredModifiers = 0 /* None */;
|
|
129311
|
+
if (isAbstract) {
|
|
129312
|
+
requiredModifiers |= 128 /* Abstract */;
|
|
129313
|
+
}
|
|
129314
|
+
if (ts.isClassElement(node)
|
|
129315
|
+
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
|
|
129316
|
+
requiredModifiers |= 16384 /* Override */;
|
|
129317
|
+
}
|
|
129318
|
+
var presentModifiers = 0 /* None */;
|
|
129319
|
+
if (!completionNodes.length) {
|
|
129320
|
+
// Omit already present modifiers from the first completion node/signature.
|
|
129321
|
+
if (contextToken) {
|
|
129322
|
+
presentModifiers = getPresentModifiers(contextToken);
|
|
129323
|
+
}
|
|
129324
|
+
// Keep track of added missing required modifiers and modifiers already present.
|
|
129325
|
+
// This is needed when we have overloaded signatures,
|
|
129326
|
+
// so this callback will be called for multiple nodes/signatures,
|
|
129327
|
+
// and we need to make sure the modifiers are uniform for all nodes/signatures.
|
|
129328
|
+
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
|
|
129329
|
+
}
|
|
129330
|
+
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
129331
|
+
completionNodes.push(node);
|
|
129332
|
+
}, body, isAbstract);
|
|
129333
|
+
if (completionNodes.length) {
|
|
129334
|
+
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
129335
|
+
}
|
|
129336
|
+
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
|
|
129337
|
+
}
|
|
129338
|
+
function getPresentModifiers(contextToken) {
|
|
129339
|
+
var modifiers = 0 /* None */;
|
|
129340
|
+
var contextMod;
|
|
129341
|
+
/*
|
|
129342
|
+
Cases supported:
|
|
129343
|
+
In
|
|
129344
|
+
`class C {
|
|
129345
|
+
public abstract |
|
|
129346
|
+
}`
|
|
129347
|
+
`contextToken` is ``abstract`` (as an identifier),
|
|
129348
|
+
`contextToken.parent` is property declaration,
|
|
129349
|
+
`location` is class declaration ``class C { ... }``.
|
|
129350
|
+
In
|
|
129351
|
+
`class C {
|
|
129352
|
+
protected override m|
|
|
129353
|
+
}`
|
|
129354
|
+
`contextToken` is ``override`` (as a keyword),
|
|
129355
|
+
`contextToken.parent` is property declaration,
|
|
129356
|
+
`location` is identifier ``m``,
|
|
129357
|
+
`location.parent` is property declaration ``protected override m``,
|
|
129358
|
+
`location.parent.parent` is class declaration ``class C { ... }``.
|
|
129359
|
+
*/
|
|
129360
|
+
if (contextMod = isModifierLike(contextToken)) {
|
|
129361
|
+
modifiers |= ts.modifierToFlag(contextMod);
|
|
129362
|
+
}
|
|
129363
|
+
if (ts.isPropertyDeclaration(contextToken.parent)) {
|
|
129364
|
+
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
|
|
129365
|
+
}
|
|
129366
|
+
return modifiers;
|
|
129367
|
+
}
|
|
129368
|
+
function isModifierLike(node) {
|
|
129369
|
+
if (ts.isModifier(node)) {
|
|
129370
|
+
return node.kind;
|
|
129371
|
+
}
|
|
129372
|
+
if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
|
|
129373
|
+
return node.originalKeywordKind;
|
|
129374
|
+
}
|
|
129375
|
+
return undefined;
|
|
129376
|
+
}
|
|
129377
|
+
function createSnippetPrinter(printerOptions) {
|
|
129378
|
+
var printer = ts.createPrinter(printerOptions);
|
|
129379
|
+
var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
|
|
129380
|
+
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
|
|
129381
|
+
return {
|
|
129382
|
+
printSnippetList: printSnippetList,
|
|
129383
|
+
};
|
|
129384
|
+
/* Snippet-escaping version of `printer.printList`. */
|
|
129385
|
+
function printSnippetList(format, list, sourceFile) {
|
|
129386
|
+
writer.clear();
|
|
129387
|
+
printer.writeList(format, list, sourceFile, writer);
|
|
129388
|
+
return writer.getText();
|
|
129389
|
+
}
|
|
128957
129390
|
}
|
|
128958
129391
|
function originToCompletionEntryData(origin) {
|
|
128959
129392
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -129021,10 +129454,10 @@ var ts;
|
|
|
129021
129454
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
|
|
129022
129455
|
var suffix = useSemicolons ? ";" : "";
|
|
129023
129456
|
switch (importKind) {
|
|
129024
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129025
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129026
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129027
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129457
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129458
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129459
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129460
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129028
129461
|
}
|
|
129029
129462
|
}
|
|
129030
129463
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -129048,11 +129481,12 @@ var ts;
|
|
|
129048
129481
|
return CompletionSource.ThisProperty;
|
|
129049
129482
|
}
|
|
129050
129483
|
}
|
|
129051
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile,
|
|
129484
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129052
129485
|
var _a;
|
|
129053
129486
|
var start = ts.timestamp();
|
|
129054
129487
|
var variableDeclaration = getVariableDeclaration(location);
|
|
129055
129488
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
129489
|
+
var typeChecker = program.getTypeChecker();
|
|
129056
129490
|
// Tracks unique names.
|
|
129057
129491
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
129058
129492
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -129068,7 +129502,7 @@ var ts;
|
|
|
129068
129502
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129069
129503
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129070
129504
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129071
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
129505
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
129072
129506
|
if (!entry) {
|
|
129073
129507
|
continue;
|
|
129074
129508
|
}
|
|
@@ -129161,11 +129595,13 @@ var ts;
|
|
|
129161
129595
|
if (entryId.data) {
|
|
129162
129596
|
var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
|
|
129163
129597
|
if (autoImport) {
|
|
129598
|
+
var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken;
|
|
129164
129599
|
return {
|
|
129165
129600
|
type: "symbol",
|
|
129166
129601
|
symbol: autoImport.symbol,
|
|
129167
129602
|
location: ts.getTouchingPropertyName(sourceFile, position),
|
|
129168
|
-
previousToken:
|
|
129603
|
+
previousToken: previousToken_1,
|
|
129604
|
+
contextToken: contextToken_1,
|
|
129169
129605
|
isJsxInitializer: false,
|
|
129170
129606
|
isTypeOnlyLocation: false,
|
|
129171
129607
|
origin: autoImport.origin,
|
|
@@ -129180,7 +129616,7 @@ var ts;
|
|
|
129180
129616
|
if (completionData.kind !== 0 /* Data */) {
|
|
129181
129617
|
return { type: "request", request: completionData };
|
|
129182
129618
|
}
|
|
129183
|
-
var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
|
|
129619
|
+
var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
|
|
129184
129620
|
var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; });
|
|
129185
129621
|
if (literal !== undefined)
|
|
129186
129622
|
return { type: "literal", literal: literal };
|
|
@@ -129191,15 +129627,15 @@ var ts;
|
|
|
129191
129627
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
129192
129628
|
var origin = symbolToOriginInfoMap[index];
|
|
129193
129629
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
129194
|
-
return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
|
|
129195
|
-
? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
129630
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
|
|
129631
|
+
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
129196
129632
|
: undefined;
|
|
129197
129633
|
}) || { type: "none" };
|
|
129198
129634
|
}
|
|
129199
129635
|
function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
|
|
129200
129636
|
var typeChecker = program.getTypeChecker();
|
|
129201
129637
|
var compilerOptions = program.getCompilerOptions();
|
|
129202
|
-
var name = entryId.name;
|
|
129638
|
+
var name = entryId.name, source = entryId.source, data = entryId.data;
|
|
129203
129639
|
var contextToken = ts.findPrecedingToken(position, sourceFile);
|
|
129204
129640
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
129205
129641
|
return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
|
|
@@ -129223,8 +129659,8 @@ var ts;
|
|
|
129223
129659
|
}
|
|
129224
129660
|
}
|
|
129225
129661
|
case "symbol": {
|
|
129226
|
-
var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
|
|
129227
|
-
var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences,
|
|
129662
|
+
var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
|
|
129663
|
+
var _a = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken_2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
|
|
129228
129664
|
return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217
|
|
129229
129665
|
}
|
|
129230
129666
|
case "literal": {
|
|
@@ -129253,14 +129689,27 @@ var ts;
|
|
|
129253
129689
|
return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source };
|
|
129254
129690
|
}
|
|
129255
129691
|
Completions.createCompletionDetails = createCompletionDetails;
|
|
129256
|
-
function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) {
|
|
129692
|
+
function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
|
|
129257
129693
|
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
|
|
129258
|
-
var _a = getRelevantTokens(position, sourceFile),
|
|
129259
|
-
if (
|
|
129694
|
+
var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
|
|
129695
|
+
if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
|
|
129260
129696
|
// Import statement completion: 'import c|'
|
|
129261
129697
|
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
|
|
129262
129698
|
}
|
|
129263
129699
|
}
|
|
129700
|
+
if (source === CompletionSource.ClassMemberSnippet) {
|
|
129701
|
+
var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
|
|
129702
|
+
if (importAdder) {
|
|
129703
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
129704
|
+
return {
|
|
129705
|
+
sourceDisplay: undefined,
|
|
129706
|
+
codeActions: [{
|
|
129707
|
+
changes: changes,
|
|
129708
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
129709
|
+
}],
|
|
129710
|
+
};
|
|
129711
|
+
}
|
|
129712
|
+
}
|
|
129264
129713
|
if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
|
|
129265
129714
|
return { codeActions: undefined, sourceDisplay: undefined };
|
|
129266
129715
|
}
|
|
@@ -145101,7 +145550,7 @@ var ts;
|
|
|
145101
145550
|
/** Note: output node may be mutated input node. */
|
|
145102
145551
|
function getNonformattedText(node, sourceFile, newLineCharacter) {
|
|
145103
145552
|
var writer = createWriter(newLineCharacter);
|
|
145104
|
-
var newLine = newLineCharacter
|
|
145553
|
+
var newLine = ts.getNewLineKind(newLineCharacter);
|
|
145105
145554
|
ts.createPrinter({
|
|
145106
145555
|
newLine: newLine,
|
|
145107
145556
|
neverAsciiEscape: true,
|
|
@@ -145566,21 +146015,16 @@ var ts;
|
|
|
145566
146015
|
(function (codefix) {
|
|
145567
146016
|
var errorCodeToFixes = ts.createMultiMap();
|
|
145568
146017
|
var fixIdToRegistration = new ts.Map();
|
|
145569
|
-
function diagnosticToString(diag) {
|
|
145570
|
-
return ts.isArray(diag)
|
|
145571
|
-
? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
|
|
145572
|
-
: ts.getLocaleSpecificMessage(diag);
|
|
145573
|
-
}
|
|
145574
146018
|
function createCodeFixActionWithoutFixAll(fixName, changes, description) {
|
|
145575
|
-
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
|
|
146019
|
+
return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
|
|
145576
146020
|
}
|
|
145577
146021
|
codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll;
|
|
145578
146022
|
function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) {
|
|
145579
|
-
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
|
|
146023
|
+
return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, ts.diagnosticToString(fixAllDescription), command);
|
|
145580
146024
|
}
|
|
145581
146025
|
codefix.createCodeFixAction = createCodeFixAction;
|
|
145582
146026
|
function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) {
|
|
145583
|
-
return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
146027
|
+
return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, fixAllDescription && ts.diagnosticToString(fixAllDescription), command);
|
|
145584
146028
|
}
|
|
145585
146029
|
codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll;
|
|
145586
146030
|
function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) {
|
|
@@ -148341,7 +148785,7 @@ var ts;
|
|
|
148341
148785
|
var addToExisting = new ts.Map();
|
|
148342
148786
|
/** Use `getNewImportEntry` for access */
|
|
148343
148787
|
var newImports = new ts.Map();
|
|
148344
|
-
return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes };
|
|
148788
|
+
return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
|
|
148345
148789
|
function addImportFromDiagnostic(diagnostic, context) {
|
|
148346
148790
|
var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
|
|
148347
148791
|
if (!info || !info.fixes.length)
|
|
@@ -148492,6 +148936,9 @@ var ts;
|
|
|
148492
148936
|
ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
|
|
148493
148937
|
}
|
|
148494
148938
|
}
|
|
148939
|
+
function hasFixes() {
|
|
148940
|
+
return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
|
|
148941
|
+
}
|
|
148495
148942
|
}
|
|
148496
148943
|
// Sorted with the preferred fix coming first.
|
|
148497
148944
|
var ImportFixKind;
|
|
@@ -152702,7 +153149,7 @@ var ts;
|
|
|
152702
153149
|
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
|
|
152703
153150
|
var symbol = possiblyMissingSymbols_1[_i];
|
|
152704
153151
|
if (!classMembers.has(symbol.escapedName)) {
|
|
152705
|
-
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
|
|
153152
|
+
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
|
152706
153153
|
}
|
|
152707
153154
|
}
|
|
152708
153155
|
}
|
|
@@ -152715,9 +153162,11 @@ var ts;
|
|
|
152715
153162
|
}
|
|
152716
153163
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152717
153164
|
/**
|
|
152718
|
-
*
|
|
153165
|
+
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
153166
|
+
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152719
153167
|
*/
|
|
152720
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
|
|
153168
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
153169
|
+
if (isAmbient === void 0) { isAmbient = false; }
|
|
152721
153170
|
var declarations = symbol.getDeclarations();
|
|
152722
153171
|
if (!(declarations && declarations.length)) {
|
|
152723
153172
|
return undefined;
|
|
@@ -152730,7 +153179,7 @@ var ts;
|
|
|
152730
153179
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
152731
153180
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
152732
153181
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
152733
|
-
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
|
|
153182
|
+
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
|
|
152734
153183
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
152735
153184
|
switch (declaration.kind) {
|
|
152736
153185
|
case 165 /* PropertySignature */:
|
|
@@ -152766,14 +153215,14 @@ var ts;
|
|
|
152766
153215
|
var accessor = orderedAccessors_1[_i];
|
|
152767
153216
|
if (ts.isGetAccessorDeclaration(accessor)) {
|
|
152768
153217
|
addClassElement(ts.factory.createGetAccessorDeclaration(
|
|
152769
|
-
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153218
|
+
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152770
153219
|
}
|
|
152771
153220
|
else {
|
|
152772
153221
|
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
|
|
152773
153222
|
var parameter = ts.getSetAccessorValueParameter(accessor);
|
|
152774
153223
|
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
|
|
152775
153224
|
addClassElement(ts.factory.createSetAccessorDeclaration(
|
|
152776
|
-
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153225
|
+
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152777
153226
|
}
|
|
152778
153227
|
}
|
|
152779
153228
|
break;
|
|
@@ -152794,7 +153243,7 @@ var ts;
|
|
|
152794
153243
|
if (declarations.length === 1) {
|
|
152795
153244
|
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
|
|
152796
153245
|
var signature = signatures[0];
|
|
152797
|
-
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
|
|
153246
|
+
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
|
|
152798
153247
|
break;
|
|
152799
153248
|
}
|
|
152800
153249
|
for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
|
|
@@ -152805,11 +153254,11 @@ var ts;
|
|
|
152805
153254
|
if (!ambient) {
|
|
152806
153255
|
if (declarations.length > signatures.length) {
|
|
152807
153256
|
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
|
|
152808
|
-
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
|
|
153257
|
+
outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
|
|
152809
153258
|
}
|
|
152810
153259
|
else {
|
|
152811
153260
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152812
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
|
|
153261
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152813
153262
|
}
|
|
152814
153263
|
}
|
|
152815
153264
|
break;
|
|
@@ -152820,6 +153269,7 @@ var ts;
|
|
|
152820
153269
|
addClassElement(method);
|
|
152821
153270
|
}
|
|
152822
153271
|
}
|
|
153272
|
+
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
|
|
152823
153273
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
152824
153274
|
var program = context.program;
|
|
152825
153275
|
var checker = program.getTypeChecker();
|
|
@@ -152957,7 +153407,7 @@ var ts;
|
|
|
152957
153407
|
}
|
|
152958
153408
|
return parameters;
|
|
152959
153409
|
}
|
|
152960
|
-
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
|
|
153410
|
+
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
|
|
152961
153411
|
/** This is *a* signature with the maximal number of arguments,
|
|
152962
153412
|
* such that if there is a "maximal" signature without rest arguments,
|
|
152963
153413
|
* this is one of them.
|
|
@@ -152988,7 +153438,7 @@ var ts;
|
|
|
152988
153438
|
parameters.push(restParameter);
|
|
152989
153439
|
}
|
|
152990
153440
|
return createStubbedMethod(modifiers, name, optional,
|
|
152991
|
-
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
|
|
153441
|
+
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
|
|
152992
153442
|
}
|
|
152993
153443
|
function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
|
|
152994
153444
|
if (ts.length(signatures)) {
|
|
@@ -152996,10 +153446,10 @@ var ts;
|
|
|
152996
153446
|
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
|
|
152997
153447
|
}
|
|
152998
153448
|
}
|
|
152999
|
-
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
|
|
153449
|
+
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
|
|
153000
153450
|
return ts.factory.createMethodDeclaration(
|
|
153001
153451
|
/*decorators*/ undefined, modifiers,
|
|
153002
|
-
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
|
|
153452
|
+
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
|
|
153003
153453
|
}
|
|
153004
153454
|
function createStubbedMethodBody(quotePreference) {
|
|
153005
153455
|
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
|