typescript 4.5.0-dev.20211025 → 4.5.0-dev.20211029
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/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 +261 -121
- package/lib/tsserver.js +572 -172
- package/lib/tsserverlibrary.d.ts +8 -0
- package/lib/tsserverlibrary.js +572 -172
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +572 -172
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +572 -172
- package/lib/typingsInstaller.js +316 -125
- 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.20211029";
|
|
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";
|
|
@@ -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";
|
|
@@ -9537,6 +9557,7 @@ var ts;
|
|
|
9537
9557
|
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
9558
|
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
9559
|
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."),
|
|
9560
|
+
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
9561
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9541
9562
|
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
9563
|
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."),
|
|
@@ -19833,6 +19854,8 @@ var ts;
|
|
|
19833
19854
|
case ts.ModuleKind.ES2020:
|
|
19834
19855
|
case ts.ModuleKind.ES2022:
|
|
19835
19856
|
case ts.ModuleKind.ESNext:
|
|
19857
|
+
case ts.ModuleKind.Node12:
|
|
19858
|
+
case ts.ModuleKind.NodeNext:
|
|
19836
19859
|
return true;
|
|
19837
19860
|
default:
|
|
19838
19861
|
return false;
|
|
@@ -20944,6 +20967,10 @@ var ts;
|
|
|
20944
20967
|
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20945
20968
|
}
|
|
20946
20969
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20970
|
+
function escapeSnippetText(text) {
|
|
20971
|
+
return text.replace(/\$/gm, "\\$");
|
|
20972
|
+
}
|
|
20973
|
+
ts.escapeSnippetText = escapeSnippetText;
|
|
20947
20974
|
})(ts || (ts = {}));
|
|
20948
20975
|
/* @internal */
|
|
20949
20976
|
var ts;
|
|
@@ -27147,6 +27174,25 @@ var ts;
|
|
|
27147
27174
|
}
|
|
27148
27175
|
}
|
|
27149
27176
|
ts.moveEmitHelpers = moveEmitHelpers;
|
|
27177
|
+
/**
|
|
27178
|
+
* Gets the SnippetElement of a node.
|
|
27179
|
+
*/
|
|
27180
|
+
/* @internal */
|
|
27181
|
+
function getSnippetElement(node) {
|
|
27182
|
+
var _a;
|
|
27183
|
+
return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
|
|
27184
|
+
}
|
|
27185
|
+
ts.getSnippetElement = getSnippetElement;
|
|
27186
|
+
/**
|
|
27187
|
+
* Sets the SnippetElement of a node.
|
|
27188
|
+
*/
|
|
27189
|
+
/* @internal */
|
|
27190
|
+
function setSnippetElement(node, snippet) {
|
|
27191
|
+
var emitNode = getOrCreateEmitNode(node);
|
|
27192
|
+
emitNode.snippetElement = snippet;
|
|
27193
|
+
return node;
|
|
27194
|
+
}
|
|
27195
|
+
ts.setSnippetElement = setSnippetElement;
|
|
27150
27196
|
/* @internal */
|
|
27151
27197
|
function ignoreSourceNewlines(node) {
|
|
27152
27198
|
getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
|
|
@@ -47272,6 +47318,7 @@ var ts;
|
|
|
47272
47318
|
isDeclarationVisible: isDeclarationVisible,
|
|
47273
47319
|
isPropertyAccessible: isPropertyAccessible,
|
|
47274
47320
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47321
|
+
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47275
47322
|
};
|
|
47276
47323
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
47277
47324
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -49018,6 +49065,10 @@ var ts;
|
|
|
49018
49065
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
49019
49066
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
49020
49067
|
}
|
|
49068
|
+
function isOnlyImportedAsDefault(usage) {
|
|
49069
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
49070
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
49071
|
+
}
|
|
49021
49072
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
49022
49073
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
49023
49074
|
if (file && usageMode !== undefined) {
|
|
@@ -49068,8 +49119,9 @@ var ts;
|
|
|
49068
49119
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
49069
49120
|
}
|
|
49070
49121
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49122
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
49071
49123
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
49072
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
49124
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
49073
49125
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
49074
49126
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
49075
49127
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -49083,7 +49135,7 @@ var ts;
|
|
|
49083
49135
|
reportNonDefaultExport(moduleSymbol, node);
|
|
49084
49136
|
}
|
|
49085
49137
|
}
|
|
49086
|
-
else if (hasSyntheticDefault) {
|
|
49138
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
49087
49139
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
49088
49140
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49089
49141
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49208,7 +49260,7 @@ var ts;
|
|
|
49208
49260
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49209
49261
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49210
49262
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49211
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49263
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49212
49264
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49213
49265
|
}
|
|
49214
49266
|
}
|
|
@@ -49602,21 +49654,28 @@ var ts;
|
|
|
49602
49654
|
var namespaceName = getFullyQualifiedName(namespace);
|
|
49603
49655
|
var declarationName = ts.declarationNameToString(right);
|
|
49604
49656
|
var suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace);
|
|
49605
|
-
var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
|
|
49606
|
-
var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
|
|
49607
|
-
var canSuggestTypeof = containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName);
|
|
49608
49657
|
if (suggestionForNonexistentModule) {
|
|
49609
49658
|
error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule));
|
|
49659
|
+
return undefined;
|
|
49610
49660
|
}
|
|
49611
|
-
|
|
49661
|
+
var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
|
|
49662
|
+
var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet
|
|
49663
|
+
&& (meaning & 788968 /* Type */)
|
|
49664
|
+
&& containingQualifiedName
|
|
49665
|
+
&& !ts.isTypeOfExpression(containingQualifiedName.parent)
|
|
49666
|
+
&& tryGetQualifiedNameAsValue(containingQualifiedName);
|
|
49667
|
+
if (canSuggestTypeof) {
|
|
49612
49668
|
error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName));
|
|
49669
|
+
return undefined;
|
|
49613
49670
|
}
|
|
49614
|
-
|
|
49615
|
-
|
|
49616
|
-
|
|
49617
|
-
|
|
49618
|
-
|
|
49671
|
+
if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) {
|
|
49672
|
+
var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
|
|
49673
|
+
if (exportedTypeSymbol) {
|
|
49674
|
+
error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText));
|
|
49675
|
+
return undefined;
|
|
49676
|
+
}
|
|
49619
49677
|
}
|
|
49678
|
+
error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
|
|
49620
49679
|
}
|
|
49621
49680
|
return undefined;
|
|
49622
49681
|
}
|
|
@@ -49752,6 +49811,9 @@ var ts;
|
|
|
49752
49811
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49753
49812
|
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);
|
|
49754
49813
|
}
|
|
49814
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49815
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49816
|
+
}
|
|
49755
49817
|
}
|
|
49756
49818
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49757
49819
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49890,40 +49952,50 @@ var ts;
|
|
|
49890
49952
|
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);
|
|
49891
49953
|
return symbol;
|
|
49892
49954
|
}
|
|
49893
|
-
|
|
49894
|
-
|
|
49895
|
-
|
|
49896
|
-
|
|
49897
|
-
|
|
49955
|
+
var referenceParent = referencingLocation.parent;
|
|
49956
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49957
|
+
ts.isImportCall(referenceParent)) {
|
|
49958
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49959
|
+
var type = getTypeOfSymbol(symbol);
|
|
49960
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49961
|
+
if (defaultOnlyType) {
|
|
49962
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49963
|
+
}
|
|
49964
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49898
49965
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49899
49966
|
if (!sigs || !sigs.length) {
|
|
49900
49967
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49901
49968
|
}
|
|
49902
|
-
if (sigs && sigs.length) {
|
|
49903
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49904
|
-
|
|
49905
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49906
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49907
|
-
result.parent = symbol.parent;
|
|
49908
|
-
result.target = symbol;
|
|
49909
|
-
result.originatingImport = referenceParent;
|
|
49910
|
-
if (symbol.valueDeclaration)
|
|
49911
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49912
|
-
if (symbol.constEnumOnlyModule)
|
|
49913
|
-
result.constEnumOnlyModule = true;
|
|
49914
|
-
if (symbol.members)
|
|
49915
|
-
result.members = new ts.Map(symbol.members);
|
|
49916
|
-
if (symbol.exports)
|
|
49917
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49918
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49919
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49920
|
-
return result;
|
|
49969
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49970
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49971
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49921
49972
|
}
|
|
49922
49973
|
}
|
|
49923
49974
|
}
|
|
49924
49975
|
}
|
|
49925
49976
|
return symbol;
|
|
49926
49977
|
}
|
|
49978
|
+
/**
|
|
49979
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
49980
|
+
*/
|
|
49981
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
49982
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49983
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49984
|
+
result.parent = symbol.parent;
|
|
49985
|
+
result.target = symbol;
|
|
49986
|
+
result.originatingImport = referenceParent;
|
|
49987
|
+
if (symbol.valueDeclaration)
|
|
49988
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
49989
|
+
if (symbol.constEnumOnlyModule)
|
|
49990
|
+
result.constEnumOnlyModule = true;
|
|
49991
|
+
if (symbol.members)
|
|
49992
|
+
result.members = new ts.Map(symbol.members);
|
|
49993
|
+
if (symbol.exports)
|
|
49994
|
+
result.exports = new ts.Map(symbol.exports);
|
|
49995
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49996
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49997
|
+
return result;
|
|
49998
|
+
}
|
|
49927
49999
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49928
50000
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49929
50001
|
}
|
|
@@ -59529,7 +59601,7 @@ var ts;
|
|
|
59529
59601
|
var _loop_16 = function () {
|
|
59530
59602
|
i--;
|
|
59531
59603
|
var t = types[i];
|
|
59532
|
-
if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return
|
|
59604
|
+
if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
|
|
59533
59605
|
ts.orderedRemoveItemAt(types, i);
|
|
59534
59606
|
}
|
|
59535
59607
|
};
|
|
@@ -61722,7 +61794,8 @@ var ts;
|
|
|
61722
61794
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61723
61795
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61724
61796
|
if (!type.declaration.nameType) {
|
|
61725
|
-
|
|
61797
|
+
var constraint = void 0;
|
|
61798
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61726
61799
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61727
61800
|
}
|
|
61728
61801
|
if (isGenericTupleType(t)) {
|
|
@@ -63262,13 +63335,12 @@ var ts;
|
|
|
63262
63335
|
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63263
63336
|
var result = 0 /* False */;
|
|
63264
63337
|
var saveErrorInfo = captureErrorCalculationState();
|
|
63265
|
-
|
|
63266
|
-
|
|
63267
|
-
|
|
63268
|
-
|
|
63269
|
-
|
|
63270
|
-
|
|
63271
|
-
structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63338
|
+
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63339
|
+
// We skip caching when source or target is a union with no more than three constituents.
|
|
63340
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63341
|
+
}
|
|
63342
|
+
else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
|
|
63343
|
+
result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
|
|
63272
63344
|
}
|
|
63273
63345
|
if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
|
|
63274
63346
|
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
|
|
@@ -63725,19 +63797,19 @@ var ts;
|
|
|
63725
63797
|
var maybeStart = maybeCount;
|
|
63726
63798
|
maybeKeys[maybeCount] = id;
|
|
63727
63799
|
maybeCount++;
|
|
63800
|
+
var saveExpandingFlags = expandingFlags;
|
|
63728
63801
|
if (recursionFlags & 1 /* Source */) {
|
|
63729
63802
|
sourceStack[sourceDepth] = source;
|
|
63730
63803
|
sourceDepth++;
|
|
63804
|
+
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63805
|
+
expandingFlags |= 1 /* Source */;
|
|
63731
63806
|
}
|
|
63732
63807
|
if (recursionFlags & 2 /* Target */) {
|
|
63733
63808
|
targetStack[targetDepth] = target;
|
|
63734
63809
|
targetDepth++;
|
|
63810
|
+
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63811
|
+
expandingFlags |= 2 /* Target */;
|
|
63735
63812
|
}
|
|
63736
|
-
var saveExpandingFlags = expandingFlags;
|
|
63737
|
-
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63738
|
-
expandingFlags |= 1 /* Source */;
|
|
63739
|
-
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63740
|
-
expandingFlags |= 2 /* Target */;
|
|
63741
63813
|
var originalHandler;
|
|
63742
63814
|
var propagatingVarianceFlags = 0;
|
|
63743
63815
|
if (outofbandVarianceMarkerHandler) {
|
|
@@ -63761,13 +63833,13 @@ var ts;
|
|
|
63761
63833
|
if (outofbandVarianceMarkerHandler) {
|
|
63762
63834
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
63763
63835
|
}
|
|
63764
|
-
expandingFlags = saveExpandingFlags;
|
|
63765
63836
|
if (recursionFlags & 1 /* Source */) {
|
|
63766
63837
|
sourceDepth--;
|
|
63767
63838
|
}
|
|
63768
63839
|
if (recursionFlags & 2 /* Target */) {
|
|
63769
63840
|
targetDepth--;
|
|
63770
63841
|
}
|
|
63842
|
+
expandingFlags = saveExpandingFlags;
|
|
63771
63843
|
if (result) {
|
|
63772
63844
|
if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
|
|
63773
63845
|
if (result === -1 /* True */ || result === 3 /* Maybe */) {
|
|
@@ -64105,8 +64177,7 @@ var ts;
|
|
|
64105
64177
|
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
|
|
64106
64178
|
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
64107
64179
|
}
|
|
64108
|
-
|
|
64109
|
-
if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) {
|
|
64180
|
+
if (isTypeMatchedByTemplateLiteralType(source, target)) {
|
|
64110
64181
|
return -1 /* True */;
|
|
64111
64182
|
}
|
|
64112
64183
|
}
|
|
@@ -64301,9 +64372,9 @@ var ts;
|
|
|
64301
64372
|
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
|
|
64302
64373
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64303
64374
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64304
|
-
var
|
|
64305
|
-
if (
|
|
64306
|
-
return
|
|
64375
|
+
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
64376
|
+
if (result_9) {
|
|
64377
|
+
return result_9;
|
|
64307
64378
|
}
|
|
64308
64379
|
}
|
|
64309
64380
|
}
|
|
@@ -64375,13 +64446,13 @@ var ts;
|
|
|
64375
64446
|
var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
|
|
64376
64447
|
getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
|
|
64377
64448
|
if (modifiersRelated) {
|
|
64378
|
-
var
|
|
64449
|
+
var result_10;
|
|
64379
64450
|
var targetConstraint = getConstraintTypeFromMappedType(target);
|
|
64380
64451
|
var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
|
|
64381
|
-
if (
|
|
64452
|
+
if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
|
|
64382
64453
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
|
|
64383
64454
|
if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
|
|
64384
|
-
return
|
|
64455
|
+
return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
|
|
64385
64456
|
}
|
|
64386
64457
|
}
|
|
64387
64458
|
}
|
|
@@ -66464,6 +66535,10 @@ var ts;
|
|
|
66464
66535
|
inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) :
|
|
66465
66536
|
undefined;
|
|
66466
66537
|
}
|
|
66538
|
+
function isTypeMatchedByTemplateLiteralType(source, target) {
|
|
66539
|
+
var inferences = inferTypesFromTemplateLiteralType(source, target);
|
|
66540
|
+
return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); });
|
|
66541
|
+
}
|
|
66467
66542
|
function getStringLikeTypeForType(type) {
|
|
66468
66543
|
return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
66469
66544
|
}
|
|
@@ -67367,8 +67442,11 @@ var ts;
|
|
|
67367
67442
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67368
67443
|
switch (node.kind) {
|
|
67369
67444
|
case 79 /* Identifier */:
|
|
67370
|
-
|
|
67371
|
-
|
|
67445
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67446
|
+
var symbol = getResolvedSymbol(node);
|
|
67447
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67448
|
+
}
|
|
67449
|
+
// falls through
|
|
67372
67450
|
case 108 /* ThisKeyword */:
|
|
67373
67451
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67374
67452
|
case 229 /* NonNullExpression */:
|
|
@@ -67999,7 +68077,7 @@ var ts;
|
|
|
67999
68077
|
mapType(type, mapper);
|
|
68000
68078
|
}
|
|
68001
68079
|
function getConstituentCount(type) {
|
|
68002
|
-
return type.flags &
|
|
68080
|
+
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68003
68081
|
}
|
|
68004
68082
|
function extractTypesOfKind(type, kind) {
|
|
68005
68083
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
@@ -69497,7 +69575,7 @@ var ts;
|
|
|
69497
69575
|
return parent.kind === 205 /* PropertyAccessExpression */ ||
|
|
69498
69576
|
parent.kind === 207 /* CallExpression */ && parent.expression === node ||
|
|
69499
69577
|
parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node &&
|
|
69500
|
-
!(
|
|
69578
|
+
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
69501
69579
|
}
|
|
69502
69580
|
function isGenericTypeWithUnionConstraint(type) {
|
|
69503
69581
|
return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
@@ -75097,11 +75175,33 @@ var ts;
|
|
|
75097
75175
|
if (moduleSymbol) {
|
|
75098
75176
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
75099
75177
|
if (esModuleSymbol) {
|
|
75100
|
-
return createPromiseReturnType(node,
|
|
75178
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
75179
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
75101
75180
|
}
|
|
75102
75181
|
}
|
|
75103
75182
|
return createPromiseReturnType(node, anyType);
|
|
75104
75183
|
}
|
|
75184
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
75185
|
+
var memberTable = ts.createSymbolTable();
|
|
75186
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75187
|
+
newSymbol.parent = originalSymbol;
|
|
75188
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
75189
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
75190
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
75191
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
75192
|
+
}
|
|
75193
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75194
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
75195
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75196
|
+
var synthType = type;
|
|
75197
|
+
if (!synthType.defaultOnlyType) {
|
|
75198
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75199
|
+
synthType.defaultOnlyType = type_4;
|
|
75200
|
+
}
|
|
75201
|
+
return synthType.defaultOnlyType;
|
|
75202
|
+
}
|
|
75203
|
+
return undefined;
|
|
75204
|
+
}
|
|
75105
75205
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75106
75206
|
var _a;
|
|
75107
75207
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -75110,14 +75210,8 @@ var ts;
|
|
|
75110
75210
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
75111
75211
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
75112
75212
|
if (hasSyntheticDefault) {
|
|
75113
|
-
var memberTable = ts.createSymbolTable();
|
|
75114
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
75115
|
-
newSymbol.parent = originalSymbol;
|
|
75116
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
75117
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
75118
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
75119
75213
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
75120
|
-
var defaultContainingObject =
|
|
75214
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
75121
75215
|
anonymousSymbol.type = defaultContainingObject;
|
|
75122
75216
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
75123
75217
|
}
|
|
@@ -75825,12 +75919,12 @@ var ts;
|
|
|
75825
75919
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75826
75920
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75827
75921
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75828
|
-
var
|
|
75922
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75829
75923
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75830
|
-
if (
|
|
75924
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75831
75925
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75832
75926
|
}
|
|
75833
|
-
return !!(filterType(
|
|
75927
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75834
75928
|
}
|
|
75835
75929
|
var type = getTypeOfExpression(node.expression);
|
|
75836
75930
|
if (!isLiteralType(type)) {
|
|
@@ -78926,12 +79020,12 @@ var ts;
|
|
|
78926
79020
|
case 264 /* ImportEqualsDeclaration */:
|
|
78927
79021
|
case 267 /* NamespaceImport */:
|
|
78928
79022
|
case 266 /* ImportClause */:
|
|
78929
|
-
var
|
|
79023
|
+
var result_11 = 0 /* None */;
|
|
78930
79024
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
78931
79025
|
ts.forEach(target.declarations, function (d) {
|
|
78932
|
-
|
|
79026
|
+
result_11 |= getDeclarationSpaces(d);
|
|
78933
79027
|
});
|
|
78934
|
-
return
|
|
79028
|
+
return result_11;
|
|
78935
79029
|
case 253 /* VariableDeclaration */:
|
|
78936
79030
|
case 202 /* BindingElement */:
|
|
78937
79031
|
case 255 /* FunctionDeclaration */:
|
|
@@ -81800,7 +81894,7 @@ var ts;
|
|
|
81800
81894
|
checkKindsOfPropertyMemberOverrides(type, baseType_1);
|
|
81801
81895
|
}
|
|
81802
81896
|
}
|
|
81803
|
-
|
|
81897
|
+
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
81804
81898
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
81805
81899
|
if (implementedTypeNodes) {
|
|
81806
81900
|
for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
|
|
@@ -81835,8 +81929,7 @@ var ts;
|
|
|
81835
81929
|
checkPropertyInitialization(node);
|
|
81836
81930
|
}
|
|
81837
81931
|
}
|
|
81838
|
-
function
|
|
81839
|
-
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81932
|
+
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
81840
81933
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81841
81934
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81842
81935
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
@@ -81848,46 +81941,71 @@ var ts;
|
|
|
81848
81941
|
if (ts.isConstructorDeclaration(member)) {
|
|
81849
81942
|
ts.forEach(member.parameters, function (param) {
|
|
81850
81943
|
if (ts.isParameterPropertyDeclaration(param, member)) {
|
|
81851
|
-
|
|
81944
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
|
|
81945
|
+
/* memberIsParameterProperty */ true);
|
|
81852
81946
|
}
|
|
81853
81947
|
});
|
|
81854
81948
|
}
|
|
81855
|
-
|
|
81949
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
|
|
81950
|
+
/* memberIsParameterProperty */ false);
|
|
81856
81951
|
};
|
|
81857
81952
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
81858
81953
|
var member = _a[_i];
|
|
81859
81954
|
_loop_29(member);
|
|
81860
81955
|
}
|
|
81861
|
-
|
|
81862
|
-
|
|
81863
|
-
|
|
81864
|
-
|
|
81865
|
-
|
|
81866
|
-
|
|
81867
|
-
|
|
81868
|
-
|
|
81869
|
-
|
|
81870
|
-
|
|
81871
|
-
|
|
81872
|
-
|
|
81873
|
-
|
|
81874
|
-
|
|
81875
|
-
|
|
81876
|
-
|
|
81956
|
+
}
|
|
81957
|
+
/**
|
|
81958
|
+
* @param member Existing member node to be checked.
|
|
81959
|
+
* Note: `member` cannot be a synthetic node.
|
|
81960
|
+
*/
|
|
81961
|
+
function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
|
|
81962
|
+
if (reportErrors === void 0) { reportErrors = true; }
|
|
81963
|
+
var declaredProp = member.name
|
|
81964
|
+
&& getSymbolAtLocation(member.name)
|
|
81965
|
+
|| getSymbolAtLocation(member);
|
|
81966
|
+
if (!declaredProp) {
|
|
81967
|
+
return 0 /* Ok */;
|
|
81968
|
+
}
|
|
81969
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
|
|
81970
|
+
}
|
|
81971
|
+
/**
|
|
81972
|
+
* Checks a class member declaration for either a missing or an invalid `override` modifier.
|
|
81973
|
+
* Note: this function can be used for speculative checking,
|
|
81974
|
+
* i.e. checking a member that does not yet exist in the program.
|
|
81975
|
+
* An example of that would be to call this function in a completions scenario,
|
|
81976
|
+
* when offering a method declaration as completion.
|
|
81977
|
+
* @param errorNode The node where we should report an error, or undefined if we should not report errors.
|
|
81978
|
+
*/
|
|
81979
|
+
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
81980
|
+
var isJs = ts.isInJSFile(node);
|
|
81981
|
+
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81982
|
+
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
81983
|
+
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
81984
|
+
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
81985
|
+
var baseType = memberIsStatic ? baseStaticType : baseWithThis;
|
|
81986
|
+
var prop = getPropertyOfType(thisType, memberEscapedName);
|
|
81987
|
+
var baseProp = getPropertyOfType(baseType, memberEscapedName);
|
|
81988
|
+
var baseClassName = typeToString(baseWithThis);
|
|
81989
|
+
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
81990
|
+
if (errorNode) {
|
|
81991
|
+
var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
|
|
81877
81992
|
suggestion ?
|
|
81878
|
-
error(
|
|
81993
|
+
error(errorNode, isJs ?
|
|
81879
81994
|
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 :
|
|
81880
81995
|
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)) :
|
|
81881
|
-
error(
|
|
81996
|
+
error(errorNode, isJs ?
|
|
81882
81997
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
|
|
81883
81998
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
|
|
81884
81999
|
}
|
|
81885
|
-
|
|
81886
|
-
|
|
81887
|
-
|
|
81888
|
-
|
|
81889
|
-
|
|
81890
|
-
|
|
82000
|
+
return 2 /* HasInvalidOverride */;
|
|
82001
|
+
}
|
|
82002
|
+
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
|
|
82003
|
+
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
|
|
82004
|
+
if (memberHasOverrideModifier) {
|
|
82005
|
+
return 0 /* Ok */;
|
|
82006
|
+
}
|
|
82007
|
+
if (!baseHasAbstract) {
|
|
82008
|
+
if (errorNode) {
|
|
81891
82009
|
var diag = memberIsParameterProperty ?
|
|
81892
82010
|
isJs ?
|
|
81893
82011
|
ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
@@ -81895,20 +82013,28 @@ var ts;
|
|
|
81895
82013
|
isJs ?
|
|
81896
82014
|
ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
81897
82015
|
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
81898
|
-
error(
|
|
82016
|
+
error(errorNode, diag, baseClassName);
|
|
81899
82017
|
}
|
|
81900
|
-
|
|
81901
|
-
|
|
82018
|
+
return 1 /* NeedsOverride */;
|
|
82019
|
+
}
|
|
82020
|
+
else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
82021
|
+
if (errorNode) {
|
|
82022
|
+
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);
|
|
81902
82023
|
}
|
|
82024
|
+
return 1 /* NeedsOverride */;
|
|
81903
82025
|
}
|
|
81904
82026
|
}
|
|
81905
|
-
|
|
82027
|
+
}
|
|
82028
|
+
else if (memberHasOverrideModifier) {
|
|
82029
|
+
if (errorNode) {
|
|
81906
82030
|
var className = typeToString(type);
|
|
81907
|
-
error(
|
|
82031
|
+
error(errorNode, isJs ?
|
|
81908
82032
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
|
|
81909
82033
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
|
|
81910
82034
|
}
|
|
82035
|
+
return 2 /* HasInvalidOverride */;
|
|
81911
82036
|
}
|
|
82037
|
+
return 0 /* Ok */;
|
|
81912
82038
|
}
|
|
81913
82039
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
81914
82040
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
@@ -81951,6 +82077,31 @@ var ts;
|
|
|
81951
82077
|
}
|
|
81952
82078
|
}
|
|
81953
82079
|
}
|
|
82080
|
+
/**
|
|
82081
|
+
* Checks a member declaration node to see if has a missing or invalid `override` modifier.
|
|
82082
|
+
* @param node Class-like node where the member is declared.
|
|
82083
|
+
* @param member Member declaration node.
|
|
82084
|
+
* Note: `member` can be a synthetic node without a parent.
|
|
82085
|
+
*/
|
|
82086
|
+
function getMemberOverrideModifierStatus(node, member) {
|
|
82087
|
+
if (!member.name) {
|
|
82088
|
+
return 0 /* Ok */;
|
|
82089
|
+
}
|
|
82090
|
+
var symbol = getSymbolOfNode(node);
|
|
82091
|
+
var type = getDeclaredTypeOfSymbol(symbol);
|
|
82092
|
+
var typeWithThis = getTypeWithThisArgument(type);
|
|
82093
|
+
var staticType = getTypeOfSymbol(symbol);
|
|
82094
|
+
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
82095
|
+
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
82096
|
+
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
82097
|
+
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
82098
|
+
var memberHasOverrideModifier = member.parent
|
|
82099
|
+
? ts.hasOverrideModifier(member)
|
|
82100
|
+
: ts.hasSyntacticModifier(member, 16384 /* Override */);
|
|
82101
|
+
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
|
|
82102
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
|
|
82103
|
+
/* memberIsParameterProperty */ false, memberName);
|
|
82104
|
+
}
|
|
81954
82105
|
function getTargetSymbol(s) {
|
|
81955
82106
|
// if symbol is instantiated its flags are not copied from the 'target'
|
|
81956
82107
|
// so we'll need to get back original 'target' symbol to work with correct set of flags
|
|
@@ -95104,8 +95255,8 @@ var ts;
|
|
|
95104
95255
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
95105
95256
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95106
95257
|
if (ts.length(nonWhitespaceChildren) === 1) {
|
|
95107
|
-
var
|
|
95108
|
-
return
|
|
95258
|
+
var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
95259
|
+
return result_12 && factory.createPropertyAssignment("children", result_12);
|
|
95109
95260
|
}
|
|
95110
95261
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
95111
95262
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -108255,7 +108406,14 @@ var ts;
|
|
|
108255
108406
|
// clear the parenthesizer rule as we ascend
|
|
108256
108407
|
currentParenthesizerRule = undefined;
|
|
108257
108408
|
}
|
|
108258
|
-
function pipelineEmitWithHintWorker(hint, node) {
|
|
108409
|
+
function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
|
|
108410
|
+
if (allowSnippets === void 0) { allowSnippets = true; }
|
|
108411
|
+
if (allowSnippets) {
|
|
108412
|
+
var snippet = ts.getSnippetElement(node);
|
|
108413
|
+
if (snippet) {
|
|
108414
|
+
return emitSnippetNode(hint, node, snippet);
|
|
108415
|
+
}
|
|
108416
|
+
}
|
|
108259
108417
|
if (hint === 0 /* SourceFile */)
|
|
108260
108418
|
return emitSourceFile(ts.cast(node, ts.isSourceFile));
|
|
108261
108419
|
if (hint === 2 /* IdentifierName */)
|
|
@@ -108864,6 +109022,28 @@ var ts;
|
|
|
108864
109022
|
}
|
|
108865
109023
|
}
|
|
108866
109024
|
//
|
|
109025
|
+
// Snippet Elements
|
|
109026
|
+
//
|
|
109027
|
+
function emitSnippetNode(hint, node, snippet) {
|
|
109028
|
+
switch (snippet.kind) {
|
|
109029
|
+
case 1 /* Placeholder */:
|
|
109030
|
+
emitPlaceholder(hint, node, snippet);
|
|
109031
|
+
break;
|
|
109032
|
+
case 0 /* TabStop */:
|
|
109033
|
+
emitTabStop(snippet);
|
|
109034
|
+
break;
|
|
109035
|
+
}
|
|
109036
|
+
}
|
|
109037
|
+
function emitPlaceholder(hint, node, snippet) {
|
|
109038
|
+
nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
|
|
109039
|
+
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
|
|
109040
|
+
nonEscapingWrite("}"); // `}`
|
|
109041
|
+
// `${2:...}`
|
|
109042
|
+
}
|
|
109043
|
+
function emitTabStop(snippet) {
|
|
109044
|
+
nonEscapingWrite("$" + snippet.order);
|
|
109045
|
+
}
|
|
109046
|
+
//
|
|
108867
109047
|
// Identifiers
|
|
108868
109048
|
//
|
|
108869
109049
|
function emitIdentifier(node) {
|
|
@@ -111102,6 +111282,15 @@ var ts;
|
|
|
111102
111282
|
function writeProperty(s) {
|
|
111103
111283
|
writer.writeProperty(s);
|
|
111104
111284
|
}
|
|
111285
|
+
function nonEscapingWrite(s) {
|
|
111286
|
+
// This should be defined in a snippet-escaping text writer.
|
|
111287
|
+
if (writer.nonEscapingWrite) {
|
|
111288
|
+
writer.nonEscapingWrite(s);
|
|
111289
|
+
}
|
|
111290
|
+
else {
|
|
111291
|
+
writer.write(s);
|
|
111292
|
+
}
|
|
111293
|
+
}
|
|
111105
111294
|
function writeLine(count) {
|
|
111106
111295
|
if (count === void 0) { count = 1; }
|
|
111107
111296
|
for (var i = 0; i < count; i++) {
|
|
@@ -113905,15 +114094,15 @@ var ts;
|
|
|
113905
114094
|
// which per above occurred during the current program creation.
|
|
113906
114095
|
// Since we assume the filesystem does not change during program creation,
|
|
113907
114096
|
// it is safe to reuse resolutions from the earlier call.
|
|
113908
|
-
var
|
|
114097
|
+
var result_13 = [];
|
|
113909
114098
|
var i = 0;
|
|
113910
114099
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
113911
114100
|
var moduleName = moduleNames_1[_i];
|
|
113912
114101
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113913
114102
|
i++;
|
|
113914
|
-
|
|
114103
|
+
result_13.push(resolvedModule);
|
|
113915
114104
|
}
|
|
113916
|
-
return
|
|
114105
|
+
return result_13;
|
|
113917
114106
|
}
|
|
113918
114107
|
// At this point, we know at least one of the following hold:
|
|
113919
114108
|
// - file has local declarations for ambient modules
|
|
@@ -115642,7 +115831,9 @@ var ts;
|
|
|
115642
115831
|
}
|
|
115643
115832
|
}
|
|
115644
115833
|
if (options.resolveJsonModule) {
|
|
115645
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115834
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115835
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115836
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115646
115837
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115647
115838
|
}
|
|
115648
115839
|
// Any emit other than common js, amd, es2015 or esnext is error
|
|
@@ -118975,9 +119166,9 @@ var ts;
|
|
|
118975
119166
|
if (!preferSymlinks) {
|
|
118976
119167
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
118977
119168
|
// so we only need to remove them from the realpath filenames.
|
|
118978
|
-
var
|
|
118979
|
-
if (
|
|
118980
|
-
return
|
|
119169
|
+
var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
119170
|
+
if (result_14)
|
|
119171
|
+
return result_14;
|
|
118981
119172
|
}
|
|
118982
119173
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
118983
119174
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -118997,10 +119188,10 @@ var ts;
|
|
|
118997
119188
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
118998
119189
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
118999
119190
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
119000
|
-
var
|
|
119191
|
+
var result_15 = cb(option, target === referenceRedirect);
|
|
119001
119192
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
119002
|
-
if (
|
|
119003
|
-
return
|
|
119193
|
+
if (result_15)
|
|
119194
|
+
return result_15;
|
|
119004
119195
|
}
|
|
119005
119196
|
});
|
|
119006
119197
|
});
|
|
@@ -126125,6 +126316,10 @@ var ts;
|
|
|
126125
126316
|
return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
|
|
126126
126317
|
}
|
|
126127
126318
|
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
|
|
126319
|
+
function getNewLineKind(newLineCharacter) {
|
|
126320
|
+
return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
|
|
126321
|
+
}
|
|
126322
|
+
ts.getNewLineKind = getNewLineKind;
|
|
126128
126323
|
// #endregion
|
|
126129
126324
|
})(ts || (ts = {}));
|
|
126130
126325
|
/*@internal*/
|
|
@@ -127722,7 +127917,7 @@ var ts;
|
|
|
127722
127917
|
(function (Completions) {
|
|
127723
127918
|
var StringCompletions;
|
|
127724
127919
|
(function (StringCompletions) {
|
|
127725
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken,
|
|
127920
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
127726
127921
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
127727
127922
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
127728
127923
|
return entries && convertPathCompletions(entries);
|
|
@@ -127730,12 +127925,12 @@ var ts;
|
|
|
127730
127925
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
127731
127926
|
if (!contextToken || !ts.isStringLiteralLike(contextToken))
|
|
127732
127927
|
return undefined;
|
|
127733
|
-
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
127734
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile,
|
|
127928
|
+
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
|
127929
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
|
|
127735
127930
|
}
|
|
127736
127931
|
}
|
|
127737
127932
|
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
|
|
127738
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile,
|
|
127933
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
|
|
127739
127934
|
if (completion === undefined) {
|
|
127740
127935
|
return undefined;
|
|
127741
127936
|
}
|
|
@@ -127745,7 +127940,7 @@ var ts;
|
|
|
127745
127940
|
return convertPathCompletions(completion.paths);
|
|
127746
127941
|
case 1 /* Properties */: {
|
|
127747
127942
|
var entries = [];
|
|
127748
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile,
|
|
127943
|
+
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
|
|
127749
127944
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127750
127945
|
}
|
|
127751
127946
|
case 2 /* Types */: {
|
|
@@ -128579,7 +128774,6 @@ var ts;
|
|
|
128579
128774
|
}
|
|
128580
128775
|
// If the request is a continuation of an earlier `isIncomplete` response,
|
|
128581
128776
|
// we can continue it from the cached previous response.
|
|
128582
|
-
var typeChecker = program.getTypeChecker();
|
|
128583
128777
|
var compilerOptions = program.getCompilerOptions();
|
|
128584
128778
|
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
|
|
128585
128779
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
|
|
@@ -128591,7 +128785,7 @@ var ts;
|
|
|
128591
128785
|
else {
|
|
128592
128786
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
|
|
128593
128787
|
}
|
|
128594
|
-
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken,
|
|
128788
|
+
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
|
|
128595
128789
|
if (stringCompletions) {
|
|
128596
128790
|
return stringCompletions;
|
|
128597
128791
|
}
|
|
@@ -128605,7 +128799,7 @@ var ts;
|
|
|
128605
128799
|
}
|
|
128606
128800
|
switch (completionData.kind) {
|
|
128607
128801
|
case 0 /* Data */:
|
|
128608
|
-
var response = completionInfoFromData(sourceFile,
|
|
128802
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128609
128803
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128610
128804
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128611
128805
|
}
|
|
@@ -128702,7 +128896,7 @@ var ts;
|
|
|
128702
128896
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128703
128897
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128704
128898
|
}
|
|
128705
|
-
function completionInfoFromData(sourceFile,
|
|
128899
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128706
128900
|
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;
|
|
128707
128901
|
// Verify if the file is JSX language variant
|
|
128708
128902
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128714,7 +128908,7 @@ var ts;
|
|
|
128714
128908
|
var entries = [];
|
|
128715
128909
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128716
128910
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128717
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128911
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128718
128912
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128719
128913
|
}
|
|
128720
128914
|
else {
|
|
@@ -128722,7 +128916,7 @@ var ts;
|
|
|
128722
128916
|
return undefined;
|
|
128723
128917
|
}
|
|
128724
128918
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128725
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128919
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128726
128920
|
}
|
|
128727
128921
|
if (keywordFilters !== 0 /* None */) {
|
|
128728
128922
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128828,14 +129022,15 @@ var ts;
|
|
|
128828
129022
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128829
129023
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128830
129024
|
}
|
|
128831
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128832
|
-
var _a;
|
|
129025
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
129026
|
+
var _a, _b;
|
|
128833
129027
|
var insertText;
|
|
128834
129028
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
128835
129029
|
var data;
|
|
128836
129030
|
var isSnippet;
|
|
128837
129031
|
var sourceDisplay;
|
|
128838
129032
|
var hasAction;
|
|
129033
|
+
var typeChecker = program.getTypeChecker();
|
|
128839
129034
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
128840
129035
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
128841
129036
|
if (origin && originIsThisType(origin)) {
|
|
@@ -128886,12 +129081,11 @@ var ts;
|
|
|
128886
129081
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
128887
129082
|
}
|
|
128888
129083
|
}
|
|
128889
|
-
if (
|
|
128890
|
-
|
|
128891
|
-
|
|
128892
|
-
|
|
128893
|
-
|
|
128894
|
-
hasAction = !importCompletionNode;
|
|
129084
|
+
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
129085
|
+
preferences.includeCompletionsWithInsertText &&
|
|
129086
|
+
completionKind === 3 /* MemberLike */ &&
|
|
129087
|
+
isClassLikeMemberCompletion(symbol, location)) {
|
|
129088
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
|
|
128895
129089
|
}
|
|
128896
129090
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128897
129091
|
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
@@ -128903,7 +129097,7 @@ var ts;
|
|
|
128903
129097
|
&& !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
|
|
128904
129098
|
if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
|
|
128905
129099
|
// If is string like or undefined use quotes
|
|
128906
|
-
insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
129100
|
+
insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128907
129101
|
isSnippet = true;
|
|
128908
129102
|
}
|
|
128909
129103
|
else {
|
|
@@ -128912,13 +129106,20 @@ var ts;
|
|
|
128912
129106
|
}
|
|
128913
129107
|
}
|
|
128914
129108
|
if (useBraces_1) {
|
|
128915
|
-
insertText = escapeSnippetText(name) + "={$1}";
|
|
129109
|
+
insertText = ts.escapeSnippetText(name) + "={$1}";
|
|
128916
129110
|
isSnippet = true;
|
|
128917
129111
|
}
|
|
128918
129112
|
if (isSnippet) {
|
|
128919
129113
|
replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
|
|
128920
129114
|
}
|
|
128921
129115
|
}
|
|
129116
|
+
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
|
129117
|
+
return undefined;
|
|
129118
|
+
}
|
|
129119
|
+
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
129120
|
+
data = originToCompletionEntryData(origin);
|
|
129121
|
+
hasAction = !importCompletionNode;
|
|
129122
|
+
}
|
|
128922
129123
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
128923
129124
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
128924
129125
|
// really we should consider passing the meaning for the node so that we don't report
|
|
@@ -128943,8 +129144,203 @@ var ts;
|
|
|
128943
129144
|
data: data,
|
|
128944
129145
|
};
|
|
128945
129146
|
}
|
|
128946
|
-
function
|
|
128947
|
-
|
|
129147
|
+
function isClassLikeMemberCompletion(symbol, location) {
|
|
129148
|
+
// TODO: support JS files.
|
|
129149
|
+
if (ts.isInJSFile(location)) {
|
|
129150
|
+
return false;
|
|
129151
|
+
}
|
|
129152
|
+
// Completion symbol must be for a class member.
|
|
129153
|
+
var memberFlags = 106500 /* ClassMember */
|
|
129154
|
+
& 900095 /* EnumMemberExcludes */;
|
|
129155
|
+
/* In
|
|
129156
|
+
`class C {
|
|
129157
|
+
|
|
|
129158
|
+
}`
|
|
129159
|
+
`location` is a class-like declaration.
|
|
129160
|
+
In
|
|
129161
|
+
`class C {
|
|
129162
|
+
m|
|
|
129163
|
+
}`
|
|
129164
|
+
`location` is an identifier,
|
|
129165
|
+
`location.parent` is a class element declaration,
|
|
129166
|
+
and `location.parent.parent` is a class-like declaration.
|
|
129167
|
+
In
|
|
129168
|
+
`abstract class C {
|
|
129169
|
+
abstract
|
|
129170
|
+
abstract m|
|
|
129171
|
+
}`
|
|
129172
|
+
`location` is a syntax list (with modifiers as children),
|
|
129173
|
+
and `location.parent` is a class-like declaration.
|
|
129174
|
+
*/
|
|
129175
|
+
return !!(symbol.flags & memberFlags) &&
|
|
129176
|
+
(ts.isClassLike(location) ||
|
|
129177
|
+
(location.parent &&
|
|
129178
|
+
location.parent.parent &&
|
|
129179
|
+
ts.isClassElement(location.parent) &&
|
|
129180
|
+
location === location.parent.name &&
|
|
129181
|
+
ts.isClassLike(location.parent.parent)) ||
|
|
129182
|
+
(location.parent &&
|
|
129183
|
+
ts.isSyntaxList(location) &&
|
|
129184
|
+
ts.isClassLike(location.parent)));
|
|
129185
|
+
}
|
|
129186
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
129187
|
+
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
129188
|
+
if (!classLikeDeclaration) {
|
|
129189
|
+
return { insertText: name };
|
|
129190
|
+
}
|
|
129191
|
+
var isSnippet;
|
|
129192
|
+
var insertText = name;
|
|
129193
|
+
var checker = program.getTypeChecker();
|
|
129194
|
+
var sourceFile = location.getSourceFile();
|
|
129195
|
+
var printer = createSnippetPrinter({
|
|
129196
|
+
removeComments: true,
|
|
129197
|
+
module: options.module,
|
|
129198
|
+
target: options.target,
|
|
129199
|
+
omitTrailingSemicolon: true,
|
|
129200
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
129201
|
+
});
|
|
129202
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
129203
|
+
var body;
|
|
129204
|
+
var tabstopStart = 1;
|
|
129205
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129206
|
+
isSnippet = true;
|
|
129207
|
+
// We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
|
|
129208
|
+
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
129209
|
+
var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
|
|
129210
|
+
ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
|
|
129211
|
+
tabstopStart = 2;
|
|
129212
|
+
body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
|
|
129213
|
+
}
|
|
129214
|
+
else {
|
|
129215
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
129216
|
+
}
|
|
129217
|
+
var modifiers = 0 /* None */;
|
|
129218
|
+
// Whether the suggested member should be abstract.
|
|
129219
|
+
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
|
|
129220
|
+
// Note: We are relying on checking if the context token is `abstract`,
|
|
129221
|
+
// since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
|
|
129222
|
+
// However, that is not true for the e.g. `override` modifier, so this check has its limitations.
|
|
129223
|
+
var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
|
|
129224
|
+
var completionNodes = [];
|
|
129225
|
+
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
|
|
129226
|
+
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
|
|
129227
|
+
// it adds for the given member symbol.
|
|
129228
|
+
// We store these member nodes in the `completionNodes` array.
|
|
129229
|
+
// Note: there might be:
|
|
129230
|
+
// - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
|
|
129231
|
+
// - One node;
|
|
129232
|
+
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
|
|
129233
|
+
function (node) {
|
|
129234
|
+
var requiredModifiers = 0 /* None */;
|
|
129235
|
+
if (isAbstract) {
|
|
129236
|
+
requiredModifiers |= 128 /* Abstract */;
|
|
129237
|
+
}
|
|
129238
|
+
if (ts.isClassElement(node)
|
|
129239
|
+
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
|
|
129240
|
+
requiredModifiers |= 16384 /* Override */;
|
|
129241
|
+
}
|
|
129242
|
+
var presentModifiers = 0 /* None */;
|
|
129243
|
+
if (!completionNodes.length) {
|
|
129244
|
+
// Omit already present modifiers from the first completion node/signature.
|
|
129245
|
+
if (contextToken) {
|
|
129246
|
+
presentModifiers = getPresentModifiers(contextToken);
|
|
129247
|
+
}
|
|
129248
|
+
// Keep track of added missing required modifiers and modifiers already present.
|
|
129249
|
+
// This is needed when we have overloaded signatures,
|
|
129250
|
+
// so this callback will be called for multiple nodes/signatures,
|
|
129251
|
+
// and we need to make sure the modifiers are uniform for all nodes/signatures.
|
|
129252
|
+
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
|
|
129253
|
+
}
|
|
129254
|
+
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
129255
|
+
completionNodes.push(node);
|
|
129256
|
+
}, body, isAbstract);
|
|
129257
|
+
if (completionNodes.length) {
|
|
129258
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129259
|
+
addSnippets(completionNodes, tabstopStart);
|
|
129260
|
+
}
|
|
129261
|
+
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
129262
|
+
}
|
|
129263
|
+
return { insertText: insertText, isSnippet: isSnippet };
|
|
129264
|
+
}
|
|
129265
|
+
function getPresentModifiers(contextToken) {
|
|
129266
|
+
var modifiers = 0 /* None */;
|
|
129267
|
+
var contextMod;
|
|
129268
|
+
/*
|
|
129269
|
+
Cases supported:
|
|
129270
|
+
In
|
|
129271
|
+
`class C {
|
|
129272
|
+
public abstract |
|
|
129273
|
+
}`
|
|
129274
|
+
`contextToken` is ``abstract`` (as an identifier),
|
|
129275
|
+
`contextToken.parent` is property declaration,
|
|
129276
|
+
`location` is class declaration ``class C { ... }``.
|
|
129277
|
+
In
|
|
129278
|
+
`class C {
|
|
129279
|
+
protected override m|
|
|
129280
|
+
}`
|
|
129281
|
+
`contextToken` is ``override`` (as a keyword),
|
|
129282
|
+
`contextToken.parent` is property declaration,
|
|
129283
|
+
`location` is identifier ``m``,
|
|
129284
|
+
`location.parent` is property declaration ``protected override m``,
|
|
129285
|
+
`location.parent.parent` is class declaration ``class C { ... }``.
|
|
129286
|
+
*/
|
|
129287
|
+
if (contextMod = isModifierLike(contextToken)) {
|
|
129288
|
+
modifiers |= ts.modifierToFlag(contextMod);
|
|
129289
|
+
}
|
|
129290
|
+
if (ts.isPropertyDeclaration(contextToken.parent)) {
|
|
129291
|
+
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
|
|
129292
|
+
}
|
|
129293
|
+
return modifiers;
|
|
129294
|
+
}
|
|
129295
|
+
function isModifierLike(node) {
|
|
129296
|
+
if (ts.isModifier(node)) {
|
|
129297
|
+
return node.kind;
|
|
129298
|
+
}
|
|
129299
|
+
if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
|
|
129300
|
+
return node.originalKeywordKind;
|
|
129301
|
+
}
|
|
129302
|
+
return undefined;
|
|
129303
|
+
}
|
|
129304
|
+
function addSnippets(nodes, orderStart) {
|
|
129305
|
+
var order = orderStart;
|
|
129306
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
129307
|
+
var node = nodes_1[_i];
|
|
129308
|
+
addSnippetsWorker(node, /*parent*/ undefined);
|
|
129309
|
+
}
|
|
129310
|
+
function addSnippetsWorker(node, parent) {
|
|
129311
|
+
if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
|
|
129312
|
+
// Placeholder
|
|
129313
|
+
ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
|
|
129314
|
+
order += 1;
|
|
129315
|
+
if (node.type) {
|
|
129316
|
+
ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
|
|
129317
|
+
order += 1;
|
|
129318
|
+
}
|
|
129319
|
+
}
|
|
129320
|
+
else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
129321
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
129322
|
+
order += 1;
|
|
129323
|
+
}
|
|
129324
|
+
else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
129325
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
129326
|
+
order += 1;
|
|
129327
|
+
}
|
|
129328
|
+
ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
|
|
129329
|
+
}
|
|
129330
|
+
}
|
|
129331
|
+
function createSnippetPrinter(printerOptions) {
|
|
129332
|
+
var printer = ts.createPrinter(printerOptions);
|
|
129333
|
+
var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
|
|
129334
|
+
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)); } });
|
|
129335
|
+
return {
|
|
129336
|
+
printSnippetList: printSnippetList,
|
|
129337
|
+
};
|
|
129338
|
+
/* Snippet-escaping version of `printer.printList`. */
|
|
129339
|
+
function printSnippetList(format, list, sourceFile) {
|
|
129340
|
+
writer.clear();
|
|
129341
|
+
printer.writeList(format, list, sourceFile, writer);
|
|
129342
|
+
return writer.getText();
|
|
129343
|
+
}
|
|
128948
129344
|
}
|
|
128949
129345
|
function originToCompletionEntryData(origin) {
|
|
128950
129346
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -129012,10 +129408,10 @@ var ts;
|
|
|
129012
129408
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
|
|
129013
129409
|
var suffix = useSemicolons ? ";" : "";
|
|
129014
129410
|
switch (importKind) {
|
|
129015
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129016
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129017
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129018
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129411
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
129412
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
129413
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
129414
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
129019
129415
|
}
|
|
129020
129416
|
}
|
|
129021
129417
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -129039,11 +129435,12 @@ var ts;
|
|
|
129039
129435
|
return CompletionSource.ThisProperty;
|
|
129040
129436
|
}
|
|
129041
129437
|
}
|
|
129042
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile,
|
|
129438
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129043
129439
|
var _a;
|
|
129044
129440
|
var start = ts.timestamp();
|
|
129045
129441
|
var variableDeclaration = getVariableDeclaration(location);
|
|
129046
129442
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
129443
|
+
var typeChecker = program.getTypeChecker();
|
|
129047
129444
|
// Tracks unique names.
|
|
129048
129445
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
129049
129446
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -129059,7 +129456,7 @@ var ts;
|
|
|
129059
129456
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129060
129457
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129061
129458
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129062
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
129459
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
129063
129460
|
if (!entry) {
|
|
129064
129461
|
continue;
|
|
129065
129462
|
}
|
|
@@ -144451,8 +144848,8 @@ var ts;
|
|
|
144451
144848
|
ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
|
|
144452
144849
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
144453
144850
|
// When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
|
|
144454
|
-
for (var _i = 0,
|
|
144455
|
-
var node =
|
|
144851
|
+
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
144852
|
+
var node = nodes_2[_i];
|
|
144456
144853
|
var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
|
|
144457
144854
|
var end = getAdjustedEndPosition(sourceFile, node, options);
|
|
144458
144855
|
this.deleteRange(sourceFile, { pos: pos, end: end });
|
|
@@ -145092,7 +145489,7 @@ var ts;
|
|
|
145092
145489
|
/** Note: output node may be mutated input node. */
|
|
145093
145490
|
function getNonformattedText(node, sourceFile, newLineCharacter) {
|
|
145094
145491
|
var writer = createWriter(newLineCharacter);
|
|
145095
|
-
var newLine = newLineCharacter
|
|
145492
|
+
var newLine = ts.getNewLineKind(newLineCharacter);
|
|
145096
145493
|
ts.createPrinter({
|
|
145097
145494
|
newLine: newLine,
|
|
145098
145495
|
neverAsciiEscape: true,
|
|
@@ -152693,7 +153090,7 @@ var ts;
|
|
|
152693
153090
|
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
|
|
152694
153091
|
var symbol = possiblyMissingSymbols_1[_i];
|
|
152695
153092
|
if (!classMembers.has(symbol.escapedName)) {
|
|
152696
|
-
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
|
|
153093
|
+
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
|
152697
153094
|
}
|
|
152698
153095
|
}
|
|
152699
153096
|
}
|
|
@@ -152706,9 +153103,11 @@ var ts;
|
|
|
152706
153103
|
}
|
|
152707
153104
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152708
153105
|
/**
|
|
152709
|
-
*
|
|
153106
|
+
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
153107
|
+
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152710
153108
|
*/
|
|
152711
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
|
|
153109
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
153110
|
+
if (isAmbient === void 0) { isAmbient = false; }
|
|
152712
153111
|
var declarations = symbol.getDeclarations();
|
|
152713
153112
|
if (!(declarations && declarations.length)) {
|
|
152714
153113
|
return undefined;
|
|
@@ -152721,7 +153120,7 @@ var ts;
|
|
|
152721
153120
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
152722
153121
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
152723
153122
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
152724
|
-
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
|
|
153123
|
+
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
|
|
152725
153124
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
152726
153125
|
switch (declaration.kind) {
|
|
152727
153126
|
case 165 /* PropertySignature */:
|
|
@@ -152757,14 +153156,14 @@ var ts;
|
|
|
152757
153156
|
var accessor = orderedAccessors_1[_i];
|
|
152758
153157
|
if (ts.isGetAccessorDeclaration(accessor)) {
|
|
152759
153158
|
addClassElement(ts.factory.createGetAccessorDeclaration(
|
|
152760
|
-
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153159
|
+
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152761
153160
|
}
|
|
152762
153161
|
else {
|
|
152763
153162
|
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
|
|
152764
153163
|
var parameter = ts.getSetAccessorValueParameter(accessor);
|
|
152765
153164
|
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
|
|
152766
153165
|
addClassElement(ts.factory.createSetAccessorDeclaration(
|
|
152767
|
-
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
153166
|
+
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152768
153167
|
}
|
|
152769
153168
|
}
|
|
152770
153169
|
break;
|
|
@@ -152785,7 +153184,7 @@ var ts;
|
|
|
152785
153184
|
if (declarations.length === 1) {
|
|
152786
153185
|
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
|
|
152787
153186
|
var signature = signatures[0];
|
|
152788
|
-
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
|
|
153187
|
+
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
|
|
152789
153188
|
break;
|
|
152790
153189
|
}
|
|
152791
153190
|
for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
|
|
@@ -152796,11 +153195,11 @@ var ts;
|
|
|
152796
153195
|
if (!ambient) {
|
|
152797
153196
|
if (declarations.length > signatures.length) {
|
|
152798
153197
|
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
|
|
152799
|
-
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
|
|
153198
|
+
outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
|
|
152800
153199
|
}
|
|
152801
153200
|
else {
|
|
152802
153201
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152803
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
|
|
153202
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152804
153203
|
}
|
|
152805
153204
|
}
|
|
152806
153205
|
break;
|
|
@@ -152811,6 +153210,7 @@ var ts;
|
|
|
152811
153210
|
addClassElement(method);
|
|
152812
153211
|
}
|
|
152813
153212
|
}
|
|
153213
|
+
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
|
|
152814
153214
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
152815
153215
|
var program = context.program;
|
|
152816
153216
|
var checker = program.getTypeChecker();
|
|
@@ -152948,7 +153348,7 @@ var ts;
|
|
|
152948
153348
|
}
|
|
152949
153349
|
return parameters;
|
|
152950
153350
|
}
|
|
152951
|
-
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
|
|
153351
|
+
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
|
|
152952
153352
|
/** This is *a* signature with the maximal number of arguments,
|
|
152953
153353
|
* such that if there is a "maximal" signature without rest arguments,
|
|
152954
153354
|
* this is one of them.
|
|
@@ -152979,7 +153379,7 @@ var ts;
|
|
|
152979
153379
|
parameters.push(restParameter);
|
|
152980
153380
|
}
|
|
152981
153381
|
return createStubbedMethod(modifiers, name, optional,
|
|
152982
|
-
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
|
|
153382
|
+
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
|
|
152983
153383
|
}
|
|
152984
153384
|
function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
|
|
152985
153385
|
if (ts.length(signatures)) {
|
|
@@ -152987,10 +153387,10 @@ var ts;
|
|
|
152987
153387
|
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
|
|
152988
153388
|
}
|
|
152989
153389
|
}
|
|
152990
|
-
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
|
|
153390
|
+
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
|
|
152991
153391
|
return ts.factory.createMethodDeclaration(
|
|
152992
153392
|
/*decorators*/ undefined, modifiers,
|
|
152993
|
-
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
|
|
153393
|
+
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
|
|
152994
153394
|
}
|
|
152995
153395
|
function createStubbedMethodBody(quotePreference) {
|
|
152996
153396
|
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
|
|
@@ -159001,8 +159401,8 @@ var ts;
|
|
|
159001
159401
|
var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
|
|
159002
159402
|
list._children = [];
|
|
159003
159403
|
var pos = nodes.pos;
|
|
159004
|
-
for (var _i = 0,
|
|
159005
|
-
var node =
|
|
159404
|
+
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
159405
|
+
var node = nodes_3[_i];
|
|
159006
159406
|
addSyntheticNodes(list._children, pos, node.pos, parent);
|
|
159007
159407
|
list._children.push(node);
|
|
159008
159408
|
pos = node.end;
|