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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20211029";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -2551,6 +2551,10 @@ var ts;
|
|
|
2551
2551
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
2552
2552
|
}
|
|
2553
2553
|
Debug.formatSyntaxKind = formatSyntaxKind;
|
|
2554
|
+
function formatSnippetKind(kind) {
|
|
2555
|
+
return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false);
|
|
2556
|
+
}
|
|
2557
|
+
Debug.formatSnippetKind = formatSnippetKind;
|
|
2554
2558
|
function formatNodeFlags(flags) {
|
|
2555
2559
|
return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
|
|
2556
2560
|
}
|
|
@@ -4467,6 +4471,13 @@ var ts;
|
|
|
4467
4471
|
ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
|
|
4468
4472
|
})(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
|
|
4469
4473
|
/* @internal */
|
|
4474
|
+
var MemberOverrideStatus;
|
|
4475
|
+
(function (MemberOverrideStatus) {
|
|
4476
|
+
MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok";
|
|
4477
|
+
MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride";
|
|
4478
|
+
MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride";
|
|
4479
|
+
})(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {}));
|
|
4480
|
+
/* @internal */
|
|
4470
4481
|
var UnionReduction;
|
|
4471
4482
|
(function (UnionReduction) {
|
|
4472
4483
|
UnionReduction[UnionReduction["None"] = 0] = "None";
|
|
@@ -5448,6 +5459,15 @@ var ts;
|
|
|
5448
5459
|
// Masks
|
|
5449
5460
|
// - Additional bitmasks
|
|
5450
5461
|
})(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
|
|
5462
|
+
// Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
|
|
5463
|
+
/* @internal */
|
|
5464
|
+
var SnippetKind;
|
|
5465
|
+
(function (SnippetKind) {
|
|
5466
|
+
SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop";
|
|
5467
|
+
SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder";
|
|
5468
|
+
SnippetKind[SnippetKind["Choice"] = 2] = "Choice";
|
|
5469
|
+
SnippetKind[SnippetKind["Variable"] = 3] = "Variable";
|
|
5470
|
+
})(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {}));
|
|
5451
5471
|
var EmitFlags;
|
|
5452
5472
|
(function (EmitFlags) {
|
|
5453
5473
|
EmitFlags[EmitFlags["None"] = 0] = "None";
|
|
@@ -9343,6 +9363,7 @@ var ts;
|
|
|
9343
9363
|
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."),
|
|
9344
9364
|
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."),
|
|
9345
9365
|
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."),
|
|
9366
|
+
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."),
|
|
9346
9367
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9347
9368
|
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."),
|
|
9348
9369
|
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."),
|
|
@@ -19639,6 +19660,8 @@ var ts;
|
|
|
19639
19660
|
case ts.ModuleKind.ES2020:
|
|
19640
19661
|
case ts.ModuleKind.ES2022:
|
|
19641
19662
|
case ts.ModuleKind.ESNext:
|
|
19663
|
+
case ts.ModuleKind.Node12:
|
|
19664
|
+
case ts.ModuleKind.NodeNext:
|
|
19642
19665
|
return true;
|
|
19643
19666
|
default:
|
|
19644
19667
|
return false;
|
|
@@ -20750,6 +20773,10 @@ var ts;
|
|
|
20750
20773
|
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20751
20774
|
}
|
|
20752
20775
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20776
|
+
function escapeSnippetText(text) {
|
|
20777
|
+
return text.replace(/\$/gm, "\\$");
|
|
20778
|
+
}
|
|
20779
|
+
ts.escapeSnippetText = escapeSnippetText;
|
|
20753
20780
|
})(ts || (ts = {}));
|
|
20754
20781
|
/* @internal */
|
|
20755
20782
|
var ts;
|
|
@@ -26953,6 +26980,25 @@ var ts;
|
|
|
26953
26980
|
}
|
|
26954
26981
|
}
|
|
26955
26982
|
ts.moveEmitHelpers = moveEmitHelpers;
|
|
26983
|
+
/**
|
|
26984
|
+
* Gets the SnippetElement of a node.
|
|
26985
|
+
*/
|
|
26986
|
+
/* @internal */
|
|
26987
|
+
function getSnippetElement(node) {
|
|
26988
|
+
var _a;
|
|
26989
|
+
return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
|
|
26990
|
+
}
|
|
26991
|
+
ts.getSnippetElement = getSnippetElement;
|
|
26992
|
+
/**
|
|
26993
|
+
* Sets the SnippetElement of a node.
|
|
26994
|
+
*/
|
|
26995
|
+
/* @internal */
|
|
26996
|
+
function setSnippetElement(node, snippet) {
|
|
26997
|
+
var emitNode = getOrCreateEmitNode(node);
|
|
26998
|
+
emitNode.snippetElement = snippet;
|
|
26999
|
+
return node;
|
|
27000
|
+
}
|
|
27001
|
+
ts.setSnippetElement = setSnippetElement;
|
|
26956
27002
|
/* @internal */
|
|
26957
27003
|
function ignoreSourceNewlines(node) {
|
|
26958
27004
|
getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
|
|
@@ -47078,6 +47124,7 @@ var ts;
|
|
|
47078
47124
|
isDeclarationVisible: isDeclarationVisible,
|
|
47079
47125
|
isPropertyAccessible: isPropertyAccessible,
|
|
47080
47126
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47127
|
+
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47081
47128
|
};
|
|
47082
47129
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
47083
47130
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -48824,6 +48871,10 @@ var ts;
|
|
|
48824
48871
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48825
48872
|
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48826
48873
|
}
|
|
48874
|
+
function isOnlyImportedAsDefault(usage) {
|
|
48875
|
+
var usageMode = getUsageModeForExpression(usage);
|
|
48876
|
+
return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
|
|
48877
|
+
}
|
|
48827
48878
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48828
48879
|
var usageMode = file && getUsageModeForExpression(usage);
|
|
48829
48880
|
if (file && usageMode !== undefined) {
|
|
@@ -48874,8 +48925,9 @@ var ts;
|
|
|
48874
48925
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48875
48926
|
}
|
|
48876
48927
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48928
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
|
|
48877
48929
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48878
|
-
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48930
|
+
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
48879
48931
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48880
48932
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
48881
48933
|
var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
@@ -48889,7 +48941,7 @@ var ts;
|
|
|
48889
48941
|
reportNonDefaultExport(moduleSymbol, node);
|
|
48890
48942
|
}
|
|
48891
48943
|
}
|
|
48892
|
-
else if (hasSyntheticDefault) {
|
|
48944
|
+
else if (hasSyntheticDefault || hasDefaultOnly) {
|
|
48893
48945
|
// per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
|
|
48894
48946
|
var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48895
48947
|
markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
|
|
@@ -49014,7 +49066,7 @@ var ts;
|
|
|
49014
49066
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
49015
49067
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
49016
49068
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
49017
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49069
|
+
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
49018
49070
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
49019
49071
|
}
|
|
49020
49072
|
}
|
|
@@ -49408,21 +49460,28 @@ var ts;
|
|
|
49408
49460
|
var namespaceName = getFullyQualifiedName(namespace);
|
|
49409
49461
|
var declarationName = ts.declarationNameToString(right);
|
|
49410
49462
|
var suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace);
|
|
49411
|
-
var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
|
|
49412
|
-
var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
|
|
49413
|
-
var canSuggestTypeof = containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName);
|
|
49414
49463
|
if (suggestionForNonexistentModule) {
|
|
49415
49464
|
error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule));
|
|
49465
|
+
return undefined;
|
|
49416
49466
|
}
|
|
49417
|
-
|
|
49467
|
+
var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name);
|
|
49468
|
+
var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet
|
|
49469
|
+
&& (meaning & 788968 /* Type */)
|
|
49470
|
+
&& containingQualifiedName
|
|
49471
|
+
&& !ts.isTypeOfExpression(containingQualifiedName.parent)
|
|
49472
|
+
&& tryGetQualifiedNameAsValue(containingQualifiedName);
|
|
49473
|
+
if (canSuggestTypeof) {
|
|
49418
49474
|
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));
|
|
49475
|
+
return undefined;
|
|
49419
49476
|
}
|
|
49420
|
-
|
|
49421
|
-
|
|
49422
|
-
|
|
49423
|
-
|
|
49424
|
-
|
|
49477
|
+
if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) {
|
|
49478
|
+
var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */));
|
|
49479
|
+
if (exportedTypeSymbol) {
|
|
49480
|
+
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));
|
|
49481
|
+
return undefined;
|
|
49482
|
+
}
|
|
49425
49483
|
}
|
|
49484
|
+
error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
|
|
49426
49485
|
}
|
|
49427
49486
|
return undefined;
|
|
49428
49487
|
}
|
|
@@ -49558,6 +49617,9 @@ var ts;
|
|
|
49558
49617
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49559
49618
|
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);
|
|
49560
49619
|
}
|
|
49620
|
+
if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
|
|
49621
|
+
error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
|
|
49622
|
+
}
|
|
49561
49623
|
}
|
|
49562
49624
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49563
49625
|
return getMergedSymbol(sourceFile.symbol);
|
|
@@ -49696,40 +49758,50 @@ var ts;
|
|
|
49696
49758
|
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);
|
|
49697
49759
|
return symbol;
|
|
49698
49760
|
}
|
|
49699
|
-
|
|
49700
|
-
|
|
49701
|
-
|
|
49702
|
-
|
|
49703
|
-
|
|
49761
|
+
var referenceParent = referencingLocation.parent;
|
|
49762
|
+
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49763
|
+
ts.isImportCall(referenceParent)) {
|
|
49764
|
+
var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
|
|
49765
|
+
var type = getTypeOfSymbol(symbol);
|
|
49766
|
+
var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
|
|
49767
|
+
if (defaultOnlyType) {
|
|
49768
|
+
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
|
49769
|
+
}
|
|
49770
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49704
49771
|
var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
|
49705
49772
|
if (!sigs || !sigs.length) {
|
|
49706
49773
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49707
49774
|
}
|
|
49708
|
-
if (sigs && sigs.length) {
|
|
49709
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol,
|
|
49710
|
-
|
|
49711
|
-
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49712
|
-
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49713
|
-
result.parent = symbol.parent;
|
|
49714
|
-
result.target = symbol;
|
|
49715
|
-
result.originatingImport = referenceParent;
|
|
49716
|
-
if (symbol.valueDeclaration)
|
|
49717
|
-
result.valueDeclaration = symbol.valueDeclaration;
|
|
49718
|
-
if (symbol.constEnumOnlyModule)
|
|
49719
|
-
result.constEnumOnlyModule = true;
|
|
49720
|
-
if (symbol.members)
|
|
49721
|
-
result.members = new ts.Map(symbol.members);
|
|
49722
|
-
if (symbol.exports)
|
|
49723
|
-
result.exports = new ts.Map(symbol.exports);
|
|
49724
|
-
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49725
|
-
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49726
|
-
return result;
|
|
49775
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49776
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49777
|
+
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49727
49778
|
}
|
|
49728
49779
|
}
|
|
49729
49780
|
}
|
|
49730
49781
|
}
|
|
49731
49782
|
return symbol;
|
|
49732
49783
|
}
|
|
49784
|
+
/**
|
|
49785
|
+
* Create a new symbol which has the module's type less the call and construct signatures
|
|
49786
|
+
*/
|
|
49787
|
+
function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
|
|
49788
|
+
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49789
|
+
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
49790
|
+
result.parent = symbol.parent;
|
|
49791
|
+
result.target = symbol;
|
|
49792
|
+
result.originatingImport = referenceParent;
|
|
49793
|
+
if (symbol.valueDeclaration)
|
|
49794
|
+
result.valueDeclaration = symbol.valueDeclaration;
|
|
49795
|
+
if (symbol.constEnumOnlyModule)
|
|
49796
|
+
result.constEnumOnlyModule = true;
|
|
49797
|
+
if (symbol.members)
|
|
49798
|
+
result.members = new ts.Map(symbol.members);
|
|
49799
|
+
if (symbol.exports)
|
|
49800
|
+
result.exports = new ts.Map(symbol.exports);
|
|
49801
|
+
var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
|
|
49802
|
+
result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
|
|
49803
|
+
return result;
|
|
49804
|
+
}
|
|
49733
49805
|
function hasExportAssignmentSymbol(moduleSymbol) {
|
|
49734
49806
|
return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
|
|
49735
49807
|
}
|
|
@@ -59335,7 +59407,7 @@ var ts;
|
|
|
59335
59407
|
var _loop_16 = function () {
|
|
59336
59408
|
i--;
|
|
59337
59409
|
var t = types[i];
|
|
59338
|
-
if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return
|
|
59410
|
+
if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
|
|
59339
59411
|
ts.orderedRemoveItemAt(types, i);
|
|
59340
59412
|
}
|
|
59341
59413
|
};
|
|
@@ -61528,7 +61600,8 @@ var ts;
|
|
|
61528
61600
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61529
61601
|
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61530
61602
|
if (!type.declaration.nameType) {
|
|
61531
|
-
|
|
61603
|
+
var constraint = void 0;
|
|
61604
|
+
if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
|
|
61532
61605
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
61533
61606
|
}
|
|
61534
61607
|
if (isGenericTupleType(t)) {
|
|
@@ -63068,13 +63141,12 @@ var ts;
|
|
|
63068
63141
|
traceUnionsOrIntersectionsTooLarge(source, target);
|
|
63069
63142
|
var result = 0 /* False */;
|
|
63070
63143
|
var saveErrorInfo = captureErrorCalculationState();
|
|
63071
|
-
|
|
63072
|
-
|
|
63073
|
-
|
|
63074
|
-
|
|
63075
|
-
|
|
63076
|
-
|
|
63077
|
-
structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63144
|
+
if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
|
|
63145
|
+
// We skip caching when source or target is a union with no more than three constituents.
|
|
63146
|
+
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
63147
|
+
}
|
|
63148
|
+
else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
|
|
63149
|
+
result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
|
|
63078
63150
|
}
|
|
63079
63151
|
if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
|
|
63080
63152
|
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
|
|
@@ -63531,19 +63603,19 @@ var ts;
|
|
|
63531
63603
|
var maybeStart = maybeCount;
|
|
63532
63604
|
maybeKeys[maybeCount] = id;
|
|
63533
63605
|
maybeCount++;
|
|
63606
|
+
var saveExpandingFlags = expandingFlags;
|
|
63534
63607
|
if (recursionFlags & 1 /* Source */) {
|
|
63535
63608
|
sourceStack[sourceDepth] = source;
|
|
63536
63609
|
sourceDepth++;
|
|
63610
|
+
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63611
|
+
expandingFlags |= 1 /* Source */;
|
|
63537
63612
|
}
|
|
63538
63613
|
if (recursionFlags & 2 /* Target */) {
|
|
63539
63614
|
targetStack[targetDepth] = target;
|
|
63540
63615
|
targetDepth++;
|
|
63616
|
+
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63617
|
+
expandingFlags |= 2 /* Target */;
|
|
63541
63618
|
}
|
|
63542
|
-
var saveExpandingFlags = expandingFlags;
|
|
63543
|
-
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63544
|
-
expandingFlags |= 1 /* Source */;
|
|
63545
|
-
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63546
|
-
expandingFlags |= 2 /* Target */;
|
|
63547
63619
|
var originalHandler;
|
|
63548
63620
|
var propagatingVarianceFlags = 0;
|
|
63549
63621
|
if (outofbandVarianceMarkerHandler) {
|
|
@@ -63567,13 +63639,13 @@ var ts;
|
|
|
63567
63639
|
if (outofbandVarianceMarkerHandler) {
|
|
63568
63640
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
63569
63641
|
}
|
|
63570
|
-
expandingFlags = saveExpandingFlags;
|
|
63571
63642
|
if (recursionFlags & 1 /* Source */) {
|
|
63572
63643
|
sourceDepth--;
|
|
63573
63644
|
}
|
|
63574
63645
|
if (recursionFlags & 2 /* Target */) {
|
|
63575
63646
|
targetDepth--;
|
|
63576
63647
|
}
|
|
63648
|
+
expandingFlags = saveExpandingFlags;
|
|
63577
63649
|
if (result) {
|
|
63578
63650
|
if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
|
|
63579
63651
|
if (result === -1 /* True */ || result === 3 /* Maybe */) {
|
|
@@ -63911,8 +63983,7 @@ var ts;
|
|
|
63911
63983
|
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
|
|
63912
63984
|
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
63913
63985
|
}
|
|
63914
|
-
|
|
63915
|
-
if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) {
|
|
63986
|
+
if (isTypeMatchedByTemplateLiteralType(source, target)) {
|
|
63916
63987
|
return -1 /* True */;
|
|
63917
63988
|
}
|
|
63918
63989
|
}
|
|
@@ -64107,9 +64178,9 @@ var ts;
|
|
|
64107
64178
|
if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
|
|
64108
64179
|
var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
|
|
64109
64180
|
if (objectOnlyTarget.flags & 1048576 /* Union */) {
|
|
64110
|
-
var
|
|
64111
|
-
if (
|
|
64112
|
-
return
|
|
64181
|
+
var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
|
|
64182
|
+
if (result_9) {
|
|
64183
|
+
return result_9;
|
|
64113
64184
|
}
|
|
64114
64185
|
}
|
|
64115
64186
|
}
|
|
@@ -64181,13 +64252,13 @@ var ts;
|
|
|
64181
64252
|
var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
|
|
64182
64253
|
getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
|
|
64183
64254
|
if (modifiersRelated) {
|
|
64184
|
-
var
|
|
64255
|
+
var result_10;
|
|
64185
64256
|
var targetConstraint = getConstraintTypeFromMappedType(target);
|
|
64186
64257
|
var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
|
|
64187
|
-
if (
|
|
64258
|
+
if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
|
|
64188
64259
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
|
|
64189
64260
|
if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
|
|
64190
|
-
return
|
|
64261
|
+
return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
|
|
64191
64262
|
}
|
|
64192
64263
|
}
|
|
64193
64264
|
}
|
|
@@ -66270,6 +66341,10 @@ var ts;
|
|
|
66270
66341
|
inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) :
|
|
66271
66342
|
undefined;
|
|
66272
66343
|
}
|
|
66344
|
+
function isTypeMatchedByTemplateLiteralType(source, target) {
|
|
66345
|
+
var inferences = inferTypesFromTemplateLiteralType(source, target);
|
|
66346
|
+
return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); });
|
|
66347
|
+
}
|
|
66273
66348
|
function getStringLikeTypeForType(type) {
|
|
66274
66349
|
return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
|
|
66275
66350
|
}
|
|
@@ -67173,8 +67248,11 @@ var ts;
|
|
|
67173
67248
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
67174
67249
|
switch (node.kind) {
|
|
67175
67250
|
case 79 /* Identifier */:
|
|
67176
|
-
|
|
67177
|
-
|
|
67251
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
67252
|
+
var symbol = getResolvedSymbol(node);
|
|
67253
|
+
return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
|
|
67254
|
+
}
|
|
67255
|
+
// falls through
|
|
67178
67256
|
case 108 /* ThisKeyword */:
|
|
67179
67257
|
return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
|
|
67180
67258
|
case 229 /* NonNullExpression */:
|
|
@@ -67805,7 +67883,7 @@ var ts;
|
|
|
67805
67883
|
mapType(type, mapper);
|
|
67806
67884
|
}
|
|
67807
67885
|
function getConstituentCount(type) {
|
|
67808
|
-
return type.flags &
|
|
67886
|
+
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
67809
67887
|
}
|
|
67810
67888
|
function extractTypesOfKind(type, kind) {
|
|
67811
67889
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
@@ -69303,7 +69381,7 @@ var ts;
|
|
|
69303
69381
|
return parent.kind === 205 /* PropertyAccessExpression */ ||
|
|
69304
69382
|
parent.kind === 207 /* CallExpression */ && parent.expression === node ||
|
|
69305
69383
|
parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node &&
|
|
69306
|
-
!(
|
|
69384
|
+
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
69307
69385
|
}
|
|
69308
69386
|
function isGenericTypeWithUnionConstraint(type) {
|
|
69309
69387
|
return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
|
|
@@ -74903,11 +74981,33 @@ var ts;
|
|
|
74903
74981
|
if (moduleSymbol) {
|
|
74904
74982
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74905
74983
|
if (esModuleSymbol) {
|
|
74906
|
-
return createPromiseReturnType(node,
|
|
74984
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
|
|
74985
|
+
getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74907
74986
|
}
|
|
74908
74987
|
}
|
|
74909
74988
|
return createPromiseReturnType(node, anyType);
|
|
74910
74989
|
}
|
|
74990
|
+
function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
|
|
74991
|
+
var memberTable = ts.createSymbolTable();
|
|
74992
|
+
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74993
|
+
newSymbol.parent = originalSymbol;
|
|
74994
|
+
newSymbol.nameType = getStringLiteralType("default");
|
|
74995
|
+
newSymbol.target = resolveSymbol(symbol);
|
|
74996
|
+
memberTable.set("default" /* Default */, newSymbol);
|
|
74997
|
+
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
74998
|
+
}
|
|
74999
|
+
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
|
75000
|
+
var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
|
75001
|
+
if (hasDefaultOnly && type && !isErrorType(type)) {
|
|
75002
|
+
var synthType = type;
|
|
75003
|
+
if (!synthType.defaultOnlyType) {
|
|
75004
|
+
var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
|
|
75005
|
+
synthType.defaultOnlyType = type_4;
|
|
75006
|
+
}
|
|
75007
|
+
return synthType.defaultOnlyType;
|
|
75008
|
+
}
|
|
75009
|
+
return undefined;
|
|
75010
|
+
}
|
|
74911
75011
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74912
75012
|
var _a;
|
|
74913
75013
|
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
@@ -74916,14 +75016,8 @@ var ts;
|
|
|
74916
75016
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74917
75017
|
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74918
75018
|
if (hasSyntheticDefault) {
|
|
74919
|
-
var memberTable = ts.createSymbolTable();
|
|
74920
|
-
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
74921
|
-
newSymbol.parent = originalSymbol;
|
|
74922
|
-
newSymbol.nameType = getStringLiteralType("default");
|
|
74923
|
-
newSymbol.target = resolveSymbol(symbol);
|
|
74924
|
-
memberTable.set("default" /* Default */, newSymbol);
|
|
74925
75019
|
var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
|
|
74926
|
-
var defaultContainingObject =
|
|
75020
|
+
var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
|
|
74927
75021
|
anonymousSymbol.type = defaultContainingObject;
|
|
74928
75022
|
synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
|
|
74929
75023
|
}
|
|
@@ -75631,12 +75725,12 @@ var ts;
|
|
|
75631
75725
|
var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
|
|
75632
75726
|
// notEqualFacts states that the type of the switched value is not equal to every type in the switch.
|
|
75633
75727
|
var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
|
|
75634
|
-
var
|
|
75728
|
+
var type_5 = getBaseConstraintOfType(operandType) || operandType;
|
|
75635
75729
|
// Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
|
|
75636
|
-
if (
|
|
75730
|
+
if (type_5.flags & 3 /* AnyOrUnknown */) {
|
|
75637
75731
|
return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
|
|
75638
75732
|
}
|
|
75639
|
-
return !!(filterType(
|
|
75733
|
+
return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
|
|
75640
75734
|
}
|
|
75641
75735
|
var type = getTypeOfExpression(node.expression);
|
|
75642
75736
|
if (!isLiteralType(type)) {
|
|
@@ -78732,12 +78826,12 @@ var ts;
|
|
|
78732
78826
|
case 264 /* ImportEqualsDeclaration */:
|
|
78733
78827
|
case 267 /* NamespaceImport */:
|
|
78734
78828
|
case 266 /* ImportClause */:
|
|
78735
|
-
var
|
|
78829
|
+
var result_11 = 0 /* None */;
|
|
78736
78830
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
78737
78831
|
ts.forEach(target.declarations, function (d) {
|
|
78738
|
-
|
|
78832
|
+
result_11 |= getDeclarationSpaces(d);
|
|
78739
78833
|
});
|
|
78740
|
-
return
|
|
78834
|
+
return result_11;
|
|
78741
78835
|
case 253 /* VariableDeclaration */:
|
|
78742
78836
|
case 202 /* BindingElement */:
|
|
78743
78837
|
case 255 /* FunctionDeclaration */:
|
|
@@ -81606,7 +81700,7 @@ var ts;
|
|
|
81606
81700
|
checkKindsOfPropertyMemberOverrides(type, baseType_1);
|
|
81607
81701
|
}
|
|
81608
81702
|
}
|
|
81609
|
-
|
|
81703
|
+
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
81610
81704
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
81611
81705
|
if (implementedTypeNodes) {
|
|
81612
81706
|
for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
|
|
@@ -81641,8 +81735,7 @@ var ts;
|
|
|
81641
81735
|
checkPropertyInitialization(node);
|
|
81642
81736
|
}
|
|
81643
81737
|
}
|
|
81644
|
-
function
|
|
81645
|
-
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81738
|
+
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
81646
81739
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81647
81740
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81648
81741
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
@@ -81654,46 +81747,71 @@ var ts;
|
|
|
81654
81747
|
if (ts.isConstructorDeclaration(member)) {
|
|
81655
81748
|
ts.forEach(member.parameters, function (param) {
|
|
81656
81749
|
if (ts.isParameterPropertyDeclaration(param, member)) {
|
|
81657
|
-
|
|
81750
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
|
|
81751
|
+
/* memberIsParameterProperty */ true);
|
|
81658
81752
|
}
|
|
81659
81753
|
});
|
|
81660
81754
|
}
|
|
81661
|
-
|
|
81755
|
+
checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
|
|
81756
|
+
/* memberIsParameterProperty */ false);
|
|
81662
81757
|
};
|
|
81663
81758
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
81664
81759
|
var member = _a[_i];
|
|
81665
81760
|
_loop_29(member);
|
|
81666
81761
|
}
|
|
81667
|
-
|
|
81668
|
-
|
|
81669
|
-
|
|
81670
|
-
|
|
81671
|
-
|
|
81672
|
-
|
|
81673
|
-
|
|
81674
|
-
|
|
81675
|
-
|
|
81676
|
-
|
|
81677
|
-
|
|
81678
|
-
|
|
81679
|
-
|
|
81680
|
-
|
|
81681
|
-
|
|
81682
|
-
|
|
81762
|
+
}
|
|
81763
|
+
/**
|
|
81764
|
+
* @param member Existing member node to be checked.
|
|
81765
|
+
* Note: `member` cannot be a synthetic node.
|
|
81766
|
+
*/
|
|
81767
|
+
function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
|
|
81768
|
+
if (reportErrors === void 0) { reportErrors = true; }
|
|
81769
|
+
var declaredProp = member.name
|
|
81770
|
+
&& getSymbolAtLocation(member.name)
|
|
81771
|
+
|| getSymbolAtLocation(member);
|
|
81772
|
+
if (!declaredProp) {
|
|
81773
|
+
return 0 /* Ok */;
|
|
81774
|
+
}
|
|
81775
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
|
|
81776
|
+
}
|
|
81777
|
+
/**
|
|
81778
|
+
* Checks a class member declaration for either a missing or an invalid `override` modifier.
|
|
81779
|
+
* Note: this function can be used for speculative checking,
|
|
81780
|
+
* i.e. checking a member that does not yet exist in the program.
|
|
81781
|
+
* An example of that would be to call this function in a completions scenario,
|
|
81782
|
+
* when offering a method declaration as completion.
|
|
81783
|
+
* @param errorNode The node where we should report an error, or undefined if we should not report errors.
|
|
81784
|
+
*/
|
|
81785
|
+
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
81786
|
+
var isJs = ts.isInJSFile(node);
|
|
81787
|
+
var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
|
|
81788
|
+
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
81789
|
+
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
81790
|
+
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
81791
|
+
var baseType = memberIsStatic ? baseStaticType : baseWithThis;
|
|
81792
|
+
var prop = getPropertyOfType(thisType, memberEscapedName);
|
|
81793
|
+
var baseProp = getPropertyOfType(baseType, memberEscapedName);
|
|
81794
|
+
var baseClassName = typeToString(baseWithThis);
|
|
81795
|
+
if (prop && !baseProp && memberHasOverrideModifier) {
|
|
81796
|
+
if (errorNode) {
|
|
81797
|
+
var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
|
|
81683
81798
|
suggestion ?
|
|
81684
|
-
error(
|
|
81799
|
+
error(errorNode, isJs ?
|
|
81685
81800
|
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 :
|
|
81686
81801
|
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)) :
|
|
81687
|
-
error(
|
|
81802
|
+
error(errorNode, isJs ?
|
|
81688
81803
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
|
|
81689
81804
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
|
|
81690
81805
|
}
|
|
81691
|
-
|
|
81692
|
-
|
|
81693
|
-
|
|
81694
|
-
|
|
81695
|
-
|
|
81696
|
-
|
|
81806
|
+
return 2 /* HasInvalidOverride */;
|
|
81807
|
+
}
|
|
81808
|
+
else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
|
|
81809
|
+
var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
|
|
81810
|
+
if (memberHasOverrideModifier) {
|
|
81811
|
+
return 0 /* Ok */;
|
|
81812
|
+
}
|
|
81813
|
+
if (!baseHasAbstract) {
|
|
81814
|
+
if (errorNode) {
|
|
81697
81815
|
var diag = memberIsParameterProperty ?
|
|
81698
81816
|
isJs ?
|
|
81699
81817
|
ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
@@ -81701,20 +81819,28 @@ var ts;
|
|
|
81701
81819
|
isJs ?
|
|
81702
81820
|
ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
|
|
81703
81821
|
ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
|
|
81704
|
-
error(
|
|
81822
|
+
error(errorNode, diag, baseClassName);
|
|
81705
81823
|
}
|
|
81706
|
-
|
|
81707
|
-
|
|
81824
|
+
return 1 /* NeedsOverride */;
|
|
81825
|
+
}
|
|
81826
|
+
else if (memberHasAbstractModifier && baseHasAbstract) {
|
|
81827
|
+
if (errorNode) {
|
|
81828
|
+
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);
|
|
81708
81829
|
}
|
|
81830
|
+
return 1 /* NeedsOverride */;
|
|
81709
81831
|
}
|
|
81710
81832
|
}
|
|
81711
|
-
|
|
81833
|
+
}
|
|
81834
|
+
else if (memberHasOverrideModifier) {
|
|
81835
|
+
if (errorNode) {
|
|
81712
81836
|
var className = typeToString(type);
|
|
81713
|
-
error(
|
|
81837
|
+
error(errorNode, isJs ?
|
|
81714
81838
|
ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
|
|
81715
81839
|
ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
|
|
81716
81840
|
}
|
|
81841
|
+
return 2 /* HasInvalidOverride */;
|
|
81717
81842
|
}
|
|
81843
|
+
return 0 /* Ok */;
|
|
81718
81844
|
}
|
|
81719
81845
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
81720
81846
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
@@ -81757,6 +81883,31 @@ var ts;
|
|
|
81757
81883
|
}
|
|
81758
81884
|
}
|
|
81759
81885
|
}
|
|
81886
|
+
/**
|
|
81887
|
+
* Checks a member declaration node to see if has a missing or invalid `override` modifier.
|
|
81888
|
+
* @param node Class-like node where the member is declared.
|
|
81889
|
+
* @param member Member declaration node.
|
|
81890
|
+
* Note: `member` can be a synthetic node without a parent.
|
|
81891
|
+
*/
|
|
81892
|
+
function getMemberOverrideModifierStatus(node, member) {
|
|
81893
|
+
if (!member.name) {
|
|
81894
|
+
return 0 /* Ok */;
|
|
81895
|
+
}
|
|
81896
|
+
var symbol = getSymbolOfNode(node);
|
|
81897
|
+
var type = getDeclaredTypeOfSymbol(symbol);
|
|
81898
|
+
var typeWithThis = getTypeWithThisArgument(type);
|
|
81899
|
+
var staticType = getTypeOfSymbol(symbol);
|
|
81900
|
+
var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
|
|
81901
|
+
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
81902
|
+
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
81903
|
+
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
81904
|
+
var memberHasOverrideModifier = member.parent
|
|
81905
|
+
? ts.hasOverrideModifier(member)
|
|
81906
|
+
: ts.hasSyntacticModifier(member, 16384 /* Override */);
|
|
81907
|
+
var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
|
|
81908
|
+
return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
|
|
81909
|
+
/* memberIsParameterProperty */ false, memberName);
|
|
81910
|
+
}
|
|
81760
81911
|
function getTargetSymbol(s) {
|
|
81761
81912
|
// if symbol is instantiated its flags are not copied from the 'target'
|
|
81762
81913
|
// so we'll need to get back original 'target' symbol to work with correct set of flags
|
|
@@ -94910,8 +95061,8 @@ var ts;
|
|
|
94910
95061
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
94911
95062
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
94912
95063
|
if (ts.length(nonWhitespaceChildren) === 1) {
|
|
94913
|
-
var
|
|
94914
|
-
return
|
|
95064
|
+
var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
95065
|
+
return result_12 && factory.createPropertyAssignment("children", result_12);
|
|
94915
95066
|
}
|
|
94916
95067
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
94917
95068
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -108061,7 +108212,14 @@ var ts;
|
|
|
108061
108212
|
// clear the parenthesizer rule as we ascend
|
|
108062
108213
|
currentParenthesizerRule = undefined;
|
|
108063
108214
|
}
|
|
108064
|
-
function pipelineEmitWithHintWorker(hint, node) {
|
|
108215
|
+
function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
|
|
108216
|
+
if (allowSnippets === void 0) { allowSnippets = true; }
|
|
108217
|
+
if (allowSnippets) {
|
|
108218
|
+
var snippet = ts.getSnippetElement(node);
|
|
108219
|
+
if (snippet) {
|
|
108220
|
+
return emitSnippetNode(hint, node, snippet);
|
|
108221
|
+
}
|
|
108222
|
+
}
|
|
108065
108223
|
if (hint === 0 /* SourceFile */)
|
|
108066
108224
|
return emitSourceFile(ts.cast(node, ts.isSourceFile));
|
|
108067
108225
|
if (hint === 2 /* IdentifierName */)
|
|
@@ -108670,6 +108828,28 @@ var ts;
|
|
|
108670
108828
|
}
|
|
108671
108829
|
}
|
|
108672
108830
|
//
|
|
108831
|
+
// Snippet Elements
|
|
108832
|
+
//
|
|
108833
|
+
function emitSnippetNode(hint, node, snippet) {
|
|
108834
|
+
switch (snippet.kind) {
|
|
108835
|
+
case 1 /* Placeholder */:
|
|
108836
|
+
emitPlaceholder(hint, node, snippet);
|
|
108837
|
+
break;
|
|
108838
|
+
case 0 /* TabStop */:
|
|
108839
|
+
emitTabStop(snippet);
|
|
108840
|
+
break;
|
|
108841
|
+
}
|
|
108842
|
+
}
|
|
108843
|
+
function emitPlaceholder(hint, node, snippet) {
|
|
108844
|
+
nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
|
|
108845
|
+
pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
|
|
108846
|
+
nonEscapingWrite("}"); // `}`
|
|
108847
|
+
// `${2:...}`
|
|
108848
|
+
}
|
|
108849
|
+
function emitTabStop(snippet) {
|
|
108850
|
+
nonEscapingWrite("$" + snippet.order);
|
|
108851
|
+
}
|
|
108852
|
+
//
|
|
108673
108853
|
// Identifiers
|
|
108674
108854
|
//
|
|
108675
108855
|
function emitIdentifier(node) {
|
|
@@ -110908,6 +111088,15 @@ var ts;
|
|
|
110908
111088
|
function writeProperty(s) {
|
|
110909
111089
|
writer.writeProperty(s);
|
|
110910
111090
|
}
|
|
111091
|
+
function nonEscapingWrite(s) {
|
|
111092
|
+
// This should be defined in a snippet-escaping text writer.
|
|
111093
|
+
if (writer.nonEscapingWrite) {
|
|
111094
|
+
writer.nonEscapingWrite(s);
|
|
111095
|
+
}
|
|
111096
|
+
else {
|
|
111097
|
+
writer.write(s);
|
|
111098
|
+
}
|
|
111099
|
+
}
|
|
110911
111100
|
function writeLine(count) {
|
|
110912
111101
|
if (count === void 0) { count = 1; }
|
|
110913
111102
|
for (var i = 0; i < count; i++) {
|
|
@@ -113711,15 +113900,15 @@ var ts;
|
|
|
113711
113900
|
// which per above occurred during the current program creation.
|
|
113712
113901
|
// Since we assume the filesystem does not change during program creation,
|
|
113713
113902
|
// it is safe to reuse resolutions from the earlier call.
|
|
113714
|
-
var
|
|
113903
|
+
var result_13 = [];
|
|
113715
113904
|
var i = 0;
|
|
113716
113905
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
113717
113906
|
var moduleName = moduleNames_1[_i];
|
|
113718
113907
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113719
113908
|
i++;
|
|
113720
|
-
|
|
113909
|
+
result_13.push(resolvedModule);
|
|
113721
113910
|
}
|
|
113722
|
-
return
|
|
113911
|
+
return result_13;
|
|
113723
113912
|
}
|
|
113724
113913
|
// At this point, we know at least one of the following hold:
|
|
113725
113914
|
// - file has local declarations for ambient modules
|
|
@@ -115448,7 +115637,9 @@ var ts;
|
|
|
115448
115637
|
}
|
|
115449
115638
|
}
|
|
115450
115639
|
if (options.resolveJsonModule) {
|
|
115451
|
-
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs
|
|
115640
|
+
if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
|
|
115641
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
|
|
115642
|
+
ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
115452
115643
|
createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
|
|
115453
115644
|
}
|
|
115454
115645
|
// Any emit other than common js, amd, es2015 or esnext is error
|
|
@@ -118781,9 +118972,9 @@ var ts;
|
|
|
118781
118972
|
if (!preferSymlinks) {
|
|
118782
118973
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
118783
118974
|
// so we only need to remove them from the realpath filenames.
|
|
118784
|
-
var
|
|
118785
|
-
if (
|
|
118786
|
-
return
|
|
118975
|
+
var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
118976
|
+
if (result_14)
|
|
118977
|
+
return result_14;
|
|
118787
118978
|
}
|
|
118788
118979
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
118789
118980
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -118803,10 +118994,10 @@ var ts;
|
|
|
118803
118994
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
118804
118995
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
118805
118996
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
118806
|
-
var
|
|
118997
|
+
var result_15 = cb(option, target === referenceRedirect);
|
|
118807
118998
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
118808
|
-
if (
|
|
118809
|
-
return
|
|
118999
|
+
if (result_15)
|
|
119000
|
+
return result_15;
|
|
118810
119001
|
}
|
|
118811
119002
|
});
|
|
118812
119003
|
});
|
|
@@ -125543,6 +125734,10 @@ var ts;
|
|
|
125543
125734
|
return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
|
|
125544
125735
|
}
|
|
125545
125736
|
ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
|
|
125737
|
+
function getNewLineKind(newLineCharacter) {
|
|
125738
|
+
return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
|
|
125739
|
+
}
|
|
125740
|
+
ts.getNewLineKind = getNewLineKind;
|
|
125546
125741
|
// #endregion
|
|
125547
125742
|
})(ts || (ts = {}));
|
|
125548
125743
|
/*@internal*/
|
|
@@ -127140,7 +127335,7 @@ var ts;
|
|
|
127140
127335
|
(function (Completions) {
|
|
127141
127336
|
var StringCompletions;
|
|
127142
127337
|
(function (StringCompletions) {
|
|
127143
|
-
function getStringLiteralCompletions(sourceFile, position, contextToken,
|
|
127338
|
+
function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
|
|
127144
127339
|
if (ts.isInReferenceComment(sourceFile, position)) {
|
|
127145
127340
|
var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
|
|
127146
127341
|
return entries && convertPathCompletions(entries);
|
|
@@ -127148,12 +127343,12 @@ var ts;
|
|
|
127148
127343
|
if (ts.isInString(sourceFile, position, contextToken)) {
|
|
127149
127344
|
if (!contextToken || !ts.isStringLiteralLike(contextToken))
|
|
127150
127345
|
return undefined;
|
|
127151
|
-
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
127152
|
-
return convertStringLiteralCompletions(entries, contextToken, sourceFile,
|
|
127346
|
+
var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
|
|
127347
|
+
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
|
|
127153
127348
|
}
|
|
127154
127349
|
}
|
|
127155
127350
|
StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
|
|
127156
|
-
function convertStringLiteralCompletions(completion, contextToken, sourceFile,
|
|
127351
|
+
function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
|
|
127157
127352
|
if (completion === undefined) {
|
|
127158
127353
|
return undefined;
|
|
127159
127354
|
}
|
|
@@ -127163,7 +127358,7 @@ var ts;
|
|
|
127163
127358
|
return convertPathCompletions(completion.paths);
|
|
127164
127359
|
case 1 /* Properties */: {
|
|
127165
127360
|
var entries = [];
|
|
127166
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile,
|
|
127361
|
+
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
|
|
127167
127362
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127168
127363
|
}
|
|
127169
127364
|
case 2 /* Types */: {
|
|
@@ -127997,7 +128192,6 @@ var ts;
|
|
|
127997
128192
|
}
|
|
127998
128193
|
// If the request is a continuation of an earlier `isIncomplete` response,
|
|
127999
128194
|
// we can continue it from the cached previous response.
|
|
128000
|
-
var typeChecker = program.getTypeChecker();
|
|
128001
128195
|
var compilerOptions = program.getCompilerOptions();
|
|
128002
128196
|
var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
|
|
128003
128197
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
|
|
@@ -128009,7 +128203,7 @@ var ts;
|
|
|
128009
128203
|
else {
|
|
128010
128204
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
|
|
128011
128205
|
}
|
|
128012
|
-
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken,
|
|
128206
|
+
var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
|
|
128013
128207
|
if (stringCompletions) {
|
|
128014
128208
|
return stringCompletions;
|
|
128015
128209
|
}
|
|
@@ -128023,7 +128217,7 @@ var ts;
|
|
|
128023
128217
|
}
|
|
128024
128218
|
switch (completionData.kind) {
|
|
128025
128219
|
case 0 /* Data */:
|
|
128026
|
-
var response = completionInfoFromData(sourceFile,
|
|
128220
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128027
128221
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128028
128222
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128029
128223
|
}
|
|
@@ -128120,7 +128314,7 @@ var ts;
|
|
|
128120
128314
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128121
128315
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128122
128316
|
}
|
|
128123
|
-
function completionInfoFromData(sourceFile,
|
|
128317
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128124
128318
|
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;
|
|
128125
128319
|
// Verify if the file is JSX language variant
|
|
128126
128320
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128132,7 +128326,7 @@ var ts;
|
|
|
128132
128326
|
var entries = [];
|
|
128133
128327
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128134
128328
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128135
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128329
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128136
128330
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128137
128331
|
}
|
|
128138
128332
|
else {
|
|
@@ -128140,7 +128334,7 @@ var ts;
|
|
|
128140
128334
|
return undefined;
|
|
128141
128335
|
}
|
|
128142
128336
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128143
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile,
|
|
128337
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128144
128338
|
}
|
|
128145
128339
|
if (keywordFilters !== 0 /* None */) {
|
|
128146
128340
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128246,14 +128440,15 @@ var ts;
|
|
|
128246
128440
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128247
128441
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128248
128442
|
}
|
|
128249
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128250
|
-
var _a;
|
|
128443
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
128444
|
+
var _a, _b;
|
|
128251
128445
|
var insertText;
|
|
128252
128446
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
128253
128447
|
var data;
|
|
128254
128448
|
var isSnippet;
|
|
128255
128449
|
var sourceDisplay;
|
|
128256
128450
|
var hasAction;
|
|
128451
|
+
var typeChecker = program.getTypeChecker();
|
|
128257
128452
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
128258
128453
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
128259
128454
|
if (origin && originIsThisType(origin)) {
|
|
@@ -128304,12 +128499,11 @@ var ts;
|
|
|
128304
128499
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
128305
128500
|
}
|
|
128306
128501
|
}
|
|
128307
|
-
if (
|
|
128308
|
-
|
|
128309
|
-
|
|
128310
|
-
|
|
128311
|
-
|
|
128312
|
-
hasAction = !importCompletionNode;
|
|
128502
|
+
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
128503
|
+
preferences.includeCompletionsWithInsertText &&
|
|
128504
|
+
completionKind === 3 /* MemberLike */ &&
|
|
128505
|
+
isClassLikeMemberCompletion(symbol, location)) {
|
|
128506
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
|
|
128313
128507
|
}
|
|
128314
128508
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128315
128509
|
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
@@ -128321,7 +128515,7 @@ var ts;
|
|
|
128321
128515
|
&& !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
|
|
128322
128516
|
if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
|
|
128323
128517
|
// If is string like or undefined use quotes
|
|
128324
|
-
insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128518
|
+
insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
|
|
128325
128519
|
isSnippet = true;
|
|
128326
128520
|
}
|
|
128327
128521
|
else {
|
|
@@ -128330,13 +128524,20 @@ var ts;
|
|
|
128330
128524
|
}
|
|
128331
128525
|
}
|
|
128332
128526
|
if (useBraces_1) {
|
|
128333
|
-
insertText = escapeSnippetText(name) + "={$1}";
|
|
128527
|
+
insertText = ts.escapeSnippetText(name) + "={$1}";
|
|
128334
128528
|
isSnippet = true;
|
|
128335
128529
|
}
|
|
128336
128530
|
if (isSnippet) {
|
|
128337
128531
|
replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
|
|
128338
128532
|
}
|
|
128339
128533
|
}
|
|
128534
|
+
if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
|
|
128535
|
+
return undefined;
|
|
128536
|
+
}
|
|
128537
|
+
if (originIsExport(origin) || originIsResolvedExport(origin)) {
|
|
128538
|
+
data = originToCompletionEntryData(origin);
|
|
128539
|
+
hasAction = !importCompletionNode;
|
|
128540
|
+
}
|
|
128340
128541
|
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
|
128341
128542
|
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
|
128342
128543
|
// really we should consider passing the meaning for the node so that we don't report
|
|
@@ -128361,8 +128562,203 @@ var ts;
|
|
|
128361
128562
|
data: data,
|
|
128362
128563
|
};
|
|
128363
128564
|
}
|
|
128364
|
-
function
|
|
128365
|
-
|
|
128565
|
+
function isClassLikeMemberCompletion(symbol, location) {
|
|
128566
|
+
// TODO: support JS files.
|
|
128567
|
+
if (ts.isInJSFile(location)) {
|
|
128568
|
+
return false;
|
|
128569
|
+
}
|
|
128570
|
+
// Completion symbol must be for a class member.
|
|
128571
|
+
var memberFlags = 106500 /* ClassMember */
|
|
128572
|
+
& 900095 /* EnumMemberExcludes */;
|
|
128573
|
+
/* In
|
|
128574
|
+
`class C {
|
|
128575
|
+
|
|
|
128576
|
+
}`
|
|
128577
|
+
`location` is a class-like declaration.
|
|
128578
|
+
In
|
|
128579
|
+
`class C {
|
|
128580
|
+
m|
|
|
128581
|
+
}`
|
|
128582
|
+
`location` is an identifier,
|
|
128583
|
+
`location.parent` is a class element declaration,
|
|
128584
|
+
and `location.parent.parent` is a class-like declaration.
|
|
128585
|
+
In
|
|
128586
|
+
`abstract class C {
|
|
128587
|
+
abstract
|
|
128588
|
+
abstract m|
|
|
128589
|
+
}`
|
|
128590
|
+
`location` is a syntax list (with modifiers as children),
|
|
128591
|
+
and `location.parent` is a class-like declaration.
|
|
128592
|
+
*/
|
|
128593
|
+
return !!(symbol.flags & memberFlags) &&
|
|
128594
|
+
(ts.isClassLike(location) ||
|
|
128595
|
+
(location.parent &&
|
|
128596
|
+
location.parent.parent &&
|
|
128597
|
+
ts.isClassElement(location.parent) &&
|
|
128598
|
+
location === location.parent.name &&
|
|
128599
|
+
ts.isClassLike(location.parent.parent)) ||
|
|
128600
|
+
(location.parent &&
|
|
128601
|
+
ts.isSyntaxList(location) &&
|
|
128602
|
+
ts.isClassLike(location.parent)));
|
|
128603
|
+
}
|
|
128604
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
128605
|
+
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
128606
|
+
if (!classLikeDeclaration) {
|
|
128607
|
+
return { insertText: name };
|
|
128608
|
+
}
|
|
128609
|
+
var isSnippet;
|
|
128610
|
+
var insertText = name;
|
|
128611
|
+
var checker = program.getTypeChecker();
|
|
128612
|
+
var sourceFile = location.getSourceFile();
|
|
128613
|
+
var printer = createSnippetPrinter({
|
|
128614
|
+
removeComments: true,
|
|
128615
|
+
module: options.module,
|
|
128616
|
+
target: options.target,
|
|
128617
|
+
omitTrailingSemicolon: true,
|
|
128618
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
128619
|
+
});
|
|
128620
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
128621
|
+
var body;
|
|
128622
|
+
var tabstopStart = 1;
|
|
128623
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
128624
|
+
isSnippet = true;
|
|
128625
|
+
// We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
|
|
128626
|
+
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
128627
|
+
var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
|
|
128628
|
+
ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
|
|
128629
|
+
tabstopStart = 2;
|
|
128630
|
+
body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
|
|
128631
|
+
}
|
|
128632
|
+
else {
|
|
128633
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
128634
|
+
}
|
|
128635
|
+
var modifiers = 0 /* None */;
|
|
128636
|
+
// Whether the suggested member should be abstract.
|
|
128637
|
+
// e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
|
|
128638
|
+
// Note: We are relying on checking if the context token is `abstract`,
|
|
128639
|
+
// since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
|
|
128640
|
+
// However, that is not true for the e.g. `override` modifier, so this check has its limitations.
|
|
128641
|
+
var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
|
|
128642
|
+
var completionNodes = [];
|
|
128643
|
+
ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
|
|
128644
|
+
// `addNewNodeForMemberSymbol` calls this callback function for each new member node
|
|
128645
|
+
// it adds for the given member symbol.
|
|
128646
|
+
// We store these member nodes in the `completionNodes` array.
|
|
128647
|
+
// Note: there might be:
|
|
128648
|
+
// - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
|
|
128649
|
+
// - One node;
|
|
128650
|
+
// - More than one node if the member is overloaded (e.g. a method with overload signatures).
|
|
128651
|
+
function (node) {
|
|
128652
|
+
var requiredModifiers = 0 /* None */;
|
|
128653
|
+
if (isAbstract) {
|
|
128654
|
+
requiredModifiers |= 128 /* Abstract */;
|
|
128655
|
+
}
|
|
128656
|
+
if (ts.isClassElement(node)
|
|
128657
|
+
&& checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
|
|
128658
|
+
requiredModifiers |= 16384 /* Override */;
|
|
128659
|
+
}
|
|
128660
|
+
var presentModifiers = 0 /* None */;
|
|
128661
|
+
if (!completionNodes.length) {
|
|
128662
|
+
// Omit already present modifiers from the first completion node/signature.
|
|
128663
|
+
if (contextToken) {
|
|
128664
|
+
presentModifiers = getPresentModifiers(contextToken);
|
|
128665
|
+
}
|
|
128666
|
+
// Keep track of added missing required modifiers and modifiers already present.
|
|
128667
|
+
// This is needed when we have overloaded signatures,
|
|
128668
|
+
// so this callback will be called for multiple nodes/signatures,
|
|
128669
|
+
// and we need to make sure the modifiers are uniform for all nodes/signatures.
|
|
128670
|
+
modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
|
|
128671
|
+
}
|
|
128672
|
+
node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
|
|
128673
|
+
completionNodes.push(node);
|
|
128674
|
+
}, body, isAbstract);
|
|
128675
|
+
if (completionNodes.length) {
|
|
128676
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
128677
|
+
addSnippets(completionNodes, tabstopStart);
|
|
128678
|
+
}
|
|
128679
|
+
insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
128680
|
+
}
|
|
128681
|
+
return { insertText: insertText, isSnippet: isSnippet };
|
|
128682
|
+
}
|
|
128683
|
+
function getPresentModifiers(contextToken) {
|
|
128684
|
+
var modifiers = 0 /* None */;
|
|
128685
|
+
var contextMod;
|
|
128686
|
+
/*
|
|
128687
|
+
Cases supported:
|
|
128688
|
+
In
|
|
128689
|
+
`class C {
|
|
128690
|
+
public abstract |
|
|
128691
|
+
}`
|
|
128692
|
+
`contextToken` is ``abstract`` (as an identifier),
|
|
128693
|
+
`contextToken.parent` is property declaration,
|
|
128694
|
+
`location` is class declaration ``class C { ... }``.
|
|
128695
|
+
In
|
|
128696
|
+
`class C {
|
|
128697
|
+
protected override m|
|
|
128698
|
+
}`
|
|
128699
|
+
`contextToken` is ``override`` (as a keyword),
|
|
128700
|
+
`contextToken.parent` is property declaration,
|
|
128701
|
+
`location` is identifier ``m``,
|
|
128702
|
+
`location.parent` is property declaration ``protected override m``,
|
|
128703
|
+
`location.parent.parent` is class declaration ``class C { ... }``.
|
|
128704
|
+
*/
|
|
128705
|
+
if (contextMod = isModifierLike(contextToken)) {
|
|
128706
|
+
modifiers |= ts.modifierToFlag(contextMod);
|
|
128707
|
+
}
|
|
128708
|
+
if (ts.isPropertyDeclaration(contextToken.parent)) {
|
|
128709
|
+
modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
|
|
128710
|
+
}
|
|
128711
|
+
return modifiers;
|
|
128712
|
+
}
|
|
128713
|
+
function isModifierLike(node) {
|
|
128714
|
+
if (ts.isModifier(node)) {
|
|
128715
|
+
return node.kind;
|
|
128716
|
+
}
|
|
128717
|
+
if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
|
|
128718
|
+
return node.originalKeywordKind;
|
|
128719
|
+
}
|
|
128720
|
+
return undefined;
|
|
128721
|
+
}
|
|
128722
|
+
function addSnippets(nodes, orderStart) {
|
|
128723
|
+
var order = orderStart;
|
|
128724
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
128725
|
+
var node = nodes_1[_i];
|
|
128726
|
+
addSnippetsWorker(node, /*parent*/ undefined);
|
|
128727
|
+
}
|
|
128728
|
+
function addSnippetsWorker(node, parent) {
|
|
128729
|
+
if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
|
|
128730
|
+
// Placeholder
|
|
128731
|
+
ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
|
|
128732
|
+
order += 1;
|
|
128733
|
+
if (node.type) {
|
|
128734
|
+
ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
|
|
128735
|
+
order += 1;
|
|
128736
|
+
}
|
|
128737
|
+
}
|
|
128738
|
+
else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
128739
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
128740
|
+
order += 1;
|
|
128741
|
+
}
|
|
128742
|
+
else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
|
|
128743
|
+
ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
|
|
128744
|
+
order += 1;
|
|
128745
|
+
}
|
|
128746
|
+
ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
|
|
128747
|
+
}
|
|
128748
|
+
}
|
|
128749
|
+
function createSnippetPrinter(printerOptions) {
|
|
128750
|
+
var printer = ts.createPrinter(printerOptions);
|
|
128751
|
+
var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
|
|
128752
|
+
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)); } });
|
|
128753
|
+
return {
|
|
128754
|
+
printSnippetList: printSnippetList,
|
|
128755
|
+
};
|
|
128756
|
+
/* Snippet-escaping version of `printer.printList`. */
|
|
128757
|
+
function printSnippetList(format, list, sourceFile) {
|
|
128758
|
+
writer.clear();
|
|
128759
|
+
printer.writeList(format, list, sourceFile, writer);
|
|
128760
|
+
return writer.getText();
|
|
128761
|
+
}
|
|
128366
128762
|
}
|
|
128367
128763
|
function originToCompletionEntryData(origin) {
|
|
128368
128764
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -128430,10 +128826,10 @@ var ts;
|
|
|
128430
128826
|
var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
|
|
128431
128827
|
var suffix = useSemicolons ? ";" : "";
|
|
128432
128828
|
switch (importKind) {
|
|
128433
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
128434
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
128435
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
128436
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
128829
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
128830
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
128831
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
128832
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
128437
128833
|
}
|
|
128438
128834
|
}
|
|
128439
128835
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -128457,11 +128853,12 @@ var ts;
|
|
|
128457
128853
|
return CompletionSource.ThisProperty;
|
|
128458
128854
|
}
|
|
128459
128855
|
}
|
|
128460
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile,
|
|
128856
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
128461
128857
|
var _a;
|
|
128462
128858
|
var start = ts.timestamp();
|
|
128463
128859
|
var variableDeclaration = getVariableDeclaration(location);
|
|
128464
128860
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
128861
|
+
var typeChecker = program.getTypeChecker();
|
|
128465
128862
|
// Tracks unique names.
|
|
128466
128863
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
128467
128864
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -128477,7 +128874,7 @@ var ts;
|
|
|
128477
128874
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
128478
128875
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
128479
128876
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
128480
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile,
|
|
128877
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
128481
128878
|
if (!entry) {
|
|
128482
128879
|
continue;
|
|
128483
128880
|
}
|
|
@@ -143869,8 +144266,8 @@ var ts;
|
|
|
143869
144266
|
ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
|
|
143870
144267
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
143871
144268
|
// When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
|
|
143872
|
-
for (var _i = 0,
|
|
143873
|
-
var node =
|
|
144269
|
+
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
144270
|
+
var node = nodes_2[_i];
|
|
143874
144271
|
var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
|
|
143875
144272
|
var end = getAdjustedEndPosition(sourceFile, node, options);
|
|
143876
144273
|
this.deleteRange(sourceFile, { pos: pos, end: end });
|
|
@@ -144510,7 +144907,7 @@ var ts;
|
|
|
144510
144907
|
/** Note: output node may be mutated input node. */
|
|
144511
144908
|
function getNonformattedText(node, sourceFile, newLineCharacter) {
|
|
144512
144909
|
var writer = createWriter(newLineCharacter);
|
|
144513
|
-
var newLine = newLineCharacter
|
|
144910
|
+
var newLine = ts.getNewLineKind(newLineCharacter);
|
|
144514
144911
|
ts.createPrinter({
|
|
144515
144912
|
newLine: newLine,
|
|
144516
144913
|
neverAsciiEscape: true,
|
|
@@ -152111,7 +152508,7 @@ var ts;
|
|
|
152111
152508
|
for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
|
|
152112
152509
|
var symbol = possiblyMissingSymbols_1[_i];
|
|
152113
152510
|
if (!classMembers.has(symbol.escapedName)) {
|
|
152114
|
-
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
|
|
152511
|
+
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
|
|
152115
152512
|
}
|
|
152116
152513
|
}
|
|
152117
152514
|
}
|
|
@@ -152124,9 +152521,11 @@ var ts;
|
|
|
152124
152521
|
}
|
|
152125
152522
|
codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
|
|
152126
152523
|
/**
|
|
152127
|
-
*
|
|
152524
|
+
* `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
|
|
152525
|
+
* @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
|
|
152128
152526
|
*/
|
|
152129
|
-
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
|
|
152527
|
+
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
|
|
152528
|
+
if (isAmbient === void 0) { isAmbient = false; }
|
|
152130
152529
|
var declarations = symbol.getDeclarations();
|
|
152131
152530
|
if (!(declarations && declarations.length)) {
|
|
152132
152531
|
return undefined;
|
|
@@ -152139,7 +152538,7 @@ var ts;
|
|
|
152139
152538
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
152140
152539
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
152141
152540
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
152142
|
-
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
|
|
152541
|
+
var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
|
|
152143
152542
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
152144
152543
|
switch (declaration.kind) {
|
|
152145
152544
|
case 165 /* PropertySignature */:
|
|
@@ -152175,14 +152574,14 @@ var ts;
|
|
|
152175
152574
|
var accessor = orderedAccessors_1[_i];
|
|
152176
152575
|
if (ts.isGetAccessorDeclaration(accessor)) {
|
|
152177
152576
|
addClassElement(ts.factory.createGetAccessorDeclaration(
|
|
152178
|
-
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
152577
|
+
/*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152179
152578
|
}
|
|
152180
152579
|
else {
|
|
152181
152580
|
ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
|
|
152182
152581
|
var parameter = ts.getSetAccessorValueParameter(accessor);
|
|
152183
152582
|
var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
|
|
152184
152583
|
addClassElement(ts.factory.createSetAccessorDeclaration(
|
|
152185
|
-
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
|
|
152584
|
+
/*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
|
|
152186
152585
|
}
|
|
152187
152586
|
}
|
|
152188
152587
|
break;
|
|
@@ -152203,7 +152602,7 @@ var ts;
|
|
|
152203
152602
|
if (declarations.length === 1) {
|
|
152204
152603
|
ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
|
|
152205
152604
|
var signature = signatures[0];
|
|
152206
|
-
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
|
|
152605
|
+
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
|
|
152207
152606
|
break;
|
|
152208
152607
|
}
|
|
152209
152608
|
for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
|
|
@@ -152214,11 +152613,11 @@ var ts;
|
|
|
152214
152613
|
if (!ambient) {
|
|
152215
152614
|
if (declarations.length > signatures.length) {
|
|
152216
152615
|
var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
|
|
152217
|
-
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
|
|
152616
|
+
outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
|
|
152218
152617
|
}
|
|
152219
152618
|
else {
|
|
152220
152619
|
ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
|
|
152221
|
-
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
|
|
152620
|
+
addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
|
|
152222
152621
|
}
|
|
152223
152622
|
}
|
|
152224
152623
|
break;
|
|
@@ -152229,6 +152628,7 @@ var ts;
|
|
|
152229
152628
|
addClassElement(method);
|
|
152230
152629
|
}
|
|
152231
152630
|
}
|
|
152631
|
+
codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
|
|
152232
152632
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
152233
152633
|
var program = context.program;
|
|
152234
152634
|
var checker = program.getTypeChecker();
|
|
@@ -152366,7 +152766,7 @@ var ts;
|
|
|
152366
152766
|
}
|
|
152367
152767
|
return parameters;
|
|
152368
152768
|
}
|
|
152369
|
-
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
|
|
152769
|
+
function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
|
|
152370
152770
|
/** This is *a* signature with the maximal number of arguments,
|
|
152371
152771
|
* such that if there is a "maximal" signature without rest arguments,
|
|
152372
152772
|
* this is one of them.
|
|
@@ -152397,7 +152797,7 @@ var ts;
|
|
|
152397
152797
|
parameters.push(restParameter);
|
|
152398
152798
|
}
|
|
152399
152799
|
return createStubbedMethod(modifiers, name, optional,
|
|
152400
|
-
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
|
|
152800
|
+
/*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
|
|
152401
152801
|
}
|
|
152402
152802
|
function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
|
|
152403
152803
|
if (ts.length(signatures)) {
|
|
@@ -152405,10 +152805,10 @@ var ts;
|
|
|
152405
152805
|
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
|
|
152406
152806
|
}
|
|
152407
152807
|
}
|
|
152408
|
-
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
|
|
152808
|
+
function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
|
|
152409
152809
|
return ts.factory.createMethodDeclaration(
|
|
152410
152810
|
/*decorators*/ undefined, modifiers,
|
|
152411
|
-
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
|
|
152811
|
+
/*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
|
|
152412
152812
|
}
|
|
152413
152813
|
function createStubbedMethodBody(quotePreference) {
|
|
152414
152814
|
return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);
|
|
@@ -158419,8 +158819,8 @@ var ts;
|
|
|
158419
158819
|
var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
|
|
158420
158820
|
list._children = [];
|
|
158421
158821
|
var pos = nodes.pos;
|
|
158422
|
-
for (var _i = 0,
|
|
158423
|
-
var node =
|
|
158822
|
+
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
158823
|
+
var node = nodes_3[_i];
|
|
158424
158824
|
addSyntheticNodes(list._children, pos, node.pos, parent);
|
|
158425
158825
|
list._children.push(node);
|
|
158426
158826
|
pos = node.end;
|