typescript 4.7.0-dev.20220328 → 4.7.0-dev.20220331
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/protocol.d.ts +30 -0
- package/lib/tsc.js +163 -139
- package/lib/tsserver.js +618 -351
- package/lib/tsserverlibrary.d.ts +38 -0
- package/lib/tsserverlibrary.js +618 -351
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +600 -349
- package/lib/typescriptServices.d.ts +8 -0
- package/lib/typescriptServices.js +600 -349
- package/lib/typingsInstaller.js +181 -153
- 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.20220331";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -9495,6 +9495,7 @@ var ts;
|
|
|
9495
9495
|
An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
|
|
9496
9496
|
Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
|
|
9497
9497
|
true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
|
|
9498
|
+
List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
|
|
9498
9499
|
Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
|
|
9499
9500
|
Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
|
|
9500
9501
|
Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
|
|
@@ -13412,7 +13413,9 @@ var ts;
|
|
|
13412
13413
|
|| kind === 174 /* CallSignature */
|
|
13413
13414
|
|| kind === 166 /* PropertySignature */
|
|
13414
13415
|
|| kind === 168 /* MethodSignature */
|
|
13415
|
-
|| kind === 176 /* IndexSignature
|
|
13416
|
+
|| kind === 176 /* IndexSignature */
|
|
13417
|
+
|| kind === 172 /* GetAccessor */
|
|
13418
|
+
|| kind === 173 /* SetAccessor */;
|
|
13416
13419
|
}
|
|
13417
13420
|
ts.isTypeElement = isTypeElement;
|
|
13418
13421
|
function isClassOrTypeElement(node) {
|
|
@@ -39487,6 +39490,18 @@ var ts;
|
|
|
39487
39490
|
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
|
|
39488
39491
|
defaultValueDescription: false,
|
|
39489
39492
|
},
|
|
39493
|
+
{
|
|
39494
|
+
name: "moduleSuffixes",
|
|
39495
|
+
type: "list",
|
|
39496
|
+
element: {
|
|
39497
|
+
name: "suffix",
|
|
39498
|
+
type: "string",
|
|
39499
|
+
},
|
|
39500
|
+
listPreserveFalsyValues: true,
|
|
39501
|
+
affectsModuleResolution: true,
|
|
39502
|
+
category: ts.Diagnostics.Modules,
|
|
39503
|
+
description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
|
|
39504
|
+
},
|
|
39490
39505
|
// Source Maps
|
|
39491
39506
|
{
|
|
39492
39507
|
name: "sourceRoot",
|
|
@@ -41413,7 +41428,7 @@ var ts;
|
|
|
41413
41428
|
if (option.type === "list") {
|
|
41414
41429
|
var listOption_1 = option;
|
|
41415
41430
|
if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
|
|
41416
|
-
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
|
|
41431
|
+
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
|
|
41417
41432
|
}
|
|
41418
41433
|
return value;
|
|
41419
41434
|
}
|
|
@@ -41454,7 +41469,7 @@ var ts;
|
|
|
41454
41469
|
}
|
|
41455
41470
|
}
|
|
41456
41471
|
function convertJsonOptionOfListType(option, values, basePath, errors) {
|
|
41457
|
-
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
|
|
41472
|
+
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
|
|
41458
41473
|
}
|
|
41459
41474
|
/**
|
|
41460
41475
|
* Tests for a path that ends in a recursive directory wildcard.
|
|
@@ -43080,6 +43095,15 @@ var ts;
|
|
|
43080
43095
|
}
|
|
43081
43096
|
/** Return the file if it exists. */
|
|
43082
43097
|
function tryFile(fileName, onlyRecordFailures, state) {
|
|
43098
|
+
var _a, _b;
|
|
43099
|
+
if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
43100
|
+
return tryFileLookup(fileName, onlyRecordFailures, state);
|
|
43101
|
+
}
|
|
43102
|
+
var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
|
|
43103
|
+
var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
|
|
43104
|
+
return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
|
|
43105
|
+
}
|
|
43106
|
+
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
43083
43107
|
if (!onlyRecordFailures) {
|
|
43084
43108
|
if (state.host.fileExists(fileName)) {
|
|
43085
43109
|
if (state.traceEnabled) {
|
|
@@ -47394,6 +47418,7 @@ var ts;
|
|
|
47394
47418
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47395
47419
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47396
47420
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47421
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47397
47422
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47398
47423
|
var CheckMode;
|
|
47399
47424
|
(function (CheckMode) {
|
|
@@ -47403,7 +47428,8 @@ var ts;
|
|
|
47403
47428
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47404
47429
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47405
47430
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47406
|
-
CheckMode[CheckMode["
|
|
47431
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47432
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47407
47433
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47408
47434
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47409
47435
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47741,26 +47767,10 @@ var ts;
|
|
|
47741
47767
|
if (!node) {
|
|
47742
47768
|
return undefined;
|
|
47743
47769
|
}
|
|
47744
|
-
|
|
47745
|
-
|
|
47746
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47747
|
-
var toMarkSkip = node;
|
|
47748
|
-
do {
|
|
47749
|
-
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47750
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47751
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47752
|
-
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47753
|
-
}
|
|
47754
|
-
var result = getContextualType(node, contextFlags);
|
|
47755
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47756
|
-
var toMarkSkip = node;
|
|
47757
|
-
do {
|
|
47758
|
-
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47759
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47760
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47761
|
-
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47770
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47771
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47762
47772
|
}
|
|
47763
|
-
return
|
|
47773
|
+
return getContextualType(node, contextFlags);
|
|
47764
47774
|
},
|
|
47765
47775
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47766
47776
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47780,6 +47790,9 @@ var ts;
|
|
|
47780
47790
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47781
47791
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47782
47792
|
},
|
|
47793
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47794
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47795
|
+
},
|
|
47783
47796
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47784
47797
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47785
47798
|
},
|
|
@@ -47932,10 +47945,34 @@ var ts;
|
|
|
47932
47945
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47933
47946
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47934
47947
|
};
|
|
47935
|
-
function
|
|
47948
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
47949
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
47950
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
47951
|
+
if (containingCall) {
|
|
47952
|
+
var toMarkSkip = node;
|
|
47953
|
+
do {
|
|
47954
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47955
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47956
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47957
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47958
|
+
}
|
|
47959
|
+
var result = fn();
|
|
47960
|
+
if (containingCall) {
|
|
47961
|
+
var toMarkSkip = node;
|
|
47962
|
+
do {
|
|
47963
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47964
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47965
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47966
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47967
|
+
}
|
|
47968
|
+
return result;
|
|
47969
|
+
}
|
|
47970
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
47936
47971
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
47937
47972
|
apparentArgumentCount = argumentCount;
|
|
47938
|
-
var res = node ?
|
|
47973
|
+
var res = !node ? undefined :
|
|
47974
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
47975
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
47939
47976
|
apparentArgumentCount = undefined;
|
|
47940
47977
|
return res;
|
|
47941
47978
|
}
|
|
@@ -48908,6 +48945,10 @@ var ts;
|
|
|
48908
48945
|
}
|
|
48909
48946
|
}
|
|
48910
48947
|
}
|
|
48948
|
+
function isConstAssertion(location) {
|
|
48949
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
48950
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
48951
|
+
}
|
|
48911
48952
|
/**
|
|
48912
48953
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
48913
48954
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -48933,6 +48974,11 @@ var ts;
|
|
|
48933
48974
|
var grandparent;
|
|
48934
48975
|
var isInExternalModule = false;
|
|
48935
48976
|
loop: while (location) {
|
|
48977
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
48978
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
48979
|
+
// (it refers to the constant type of the expression instead)
|
|
48980
|
+
return undefined;
|
|
48981
|
+
}
|
|
48936
48982
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
48937
48983
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
48938
48984
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -52053,7 +52099,15 @@ var ts;
|
|
|
52053
52099
|
if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
|
|
52054
52100
|
return node;
|
|
52055
52101
|
}
|
|
52056
|
-
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
|
|
52102
|
+
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
|
|
52103
|
+
}
|
|
52104
|
+
function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
|
|
52105
|
+
if (nodes && nodes.length === 0) {
|
|
52106
|
+
// Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
|
|
52107
|
+
// which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
|
|
52108
|
+
return ts.setTextRange(ts.factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
|
|
52109
|
+
}
|
|
52110
|
+
return ts.visitNodes(nodes, visitor, test, start, count);
|
|
52057
52111
|
}
|
|
52058
52112
|
}
|
|
52059
52113
|
function createTypeNodeFromObjectType(type) {
|
|
@@ -54881,6 +54935,8 @@ var ts;
|
|
|
54881
54935
|
return !!target.resolvedTypeArguments;
|
|
54882
54936
|
case 7 /* ResolvedBaseTypes */:
|
|
54883
54937
|
return !!target.baseTypesResolved;
|
|
54938
|
+
case 8 /* WriteType */:
|
|
54939
|
+
return !!getSymbolLinks(target).writeType;
|
|
54884
54940
|
}
|
|
54885
54941
|
return ts.Debug.assertNever(propertyName);
|
|
54886
54942
|
}
|
|
@@ -55058,7 +55114,7 @@ var ts;
|
|
|
55058
55114
|
}
|
|
55059
55115
|
/** Return the inferred type for a binding element */
|
|
55060
55116
|
function getTypeForBindingElement(declaration) {
|
|
55061
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55117
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55062
55118
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55063
55119
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55064
55120
|
}
|
|
@@ -55798,6 +55854,11 @@ var ts;
|
|
|
55798
55854
|
}
|
|
55799
55855
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55800
55856
|
}
|
|
55857
|
+
if (ts.isAccessor(declaration)) {
|
|
55858
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
55859
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
55860
|
+
return getTypeOfAccessors(symbol);
|
|
55861
|
+
}
|
|
55801
55862
|
// Handle variable, parameter or property
|
|
55802
55863
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55803
55864
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -55861,9 +55922,6 @@ var ts;
|
|
|
55861
55922
|
else if (ts.isEnumMember(declaration)) {
|
|
55862
55923
|
type = getTypeOfEnumMember(symbol);
|
|
55863
55924
|
}
|
|
55864
|
-
else if (ts.isAccessor(declaration)) {
|
|
55865
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
55866
|
-
}
|
|
55867
55925
|
else {
|
|
55868
55926
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
55869
55927
|
}
|
|
@@ -55902,87 +55960,61 @@ var ts;
|
|
|
55902
55960
|
}
|
|
55903
55961
|
function getTypeOfAccessors(symbol) {
|
|
55904
55962
|
var links = getSymbolLinks(symbol);
|
|
55905
|
-
|
|
55906
|
-
|
|
55907
|
-
|
|
55908
|
-
|
|
55909
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
|
|
55910
|
-
}
|
|
55911
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
55912
|
-
if (writing === void 0) { writing = false; }
|
|
55913
|
-
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55914
|
-
return errorType;
|
|
55915
|
-
}
|
|
55916
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
55917
|
-
if (!popTypeResolution()) {
|
|
55963
|
+
if (!links.type) {
|
|
55964
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55965
|
+
return errorType;
|
|
55966
|
+
}
|
|
55918
55967
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
55919
|
-
|
|
55920
|
-
|
|
55921
|
-
|
|
55968
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55969
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
55970
|
+
// body return type inference, in that order.
|
|
55971
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
55972
|
+
getAnnotatedAccessorType(getter) ||
|
|
55973
|
+
getAnnotatedAccessorType(setter) ||
|
|
55974
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
55975
|
+
if (!type) {
|
|
55976
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
55977
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55978
|
+
}
|
|
55979
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
55980
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55981
|
+
}
|
|
55982
|
+
type = anyType;
|
|
55983
|
+
}
|
|
55984
|
+
if (!popTypeResolution()) {
|
|
55985
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
55986
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55922
55987
|
}
|
|
55923
|
-
else if (
|
|
55988
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55989
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55990
|
+
}
|
|
55991
|
+
else if (getter && noImplicitAny) {
|
|
55924
55992
|
error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
|
55925
55993
|
}
|
|
55994
|
+
type = anyType;
|
|
55926
55995
|
}
|
|
55927
|
-
type =
|
|
55996
|
+
links.type = type;
|
|
55928
55997
|
}
|
|
55929
|
-
return type;
|
|
55998
|
+
return links.type;
|
|
55930
55999
|
}
|
|
55931
|
-
function
|
|
55932
|
-
|
|
55933
|
-
|
|
55934
|
-
|
|
55935
|
-
|
|
55936
|
-
if (writing) {
|
|
55937
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55938
|
-
if (setterType_1) {
|
|
55939
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55940
|
-
}
|
|
55941
|
-
}
|
|
55942
|
-
// Else defer to the getter type
|
|
55943
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
55944
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
55945
|
-
if (jsDocType) {
|
|
55946
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
55947
|
-
}
|
|
55948
|
-
}
|
|
55949
|
-
// Try to see if the user specified a return type on the get-accessor.
|
|
55950
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
55951
|
-
if (getterType) {
|
|
55952
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55953
|
-
}
|
|
55954
|
-
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55955
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55956
|
-
if (setterType) {
|
|
55957
|
-
return setterType;
|
|
55958
|
-
}
|
|
55959
|
-
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
|
55960
|
-
if (getter && getter.body) {
|
|
55961
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
55962
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
55963
|
-
}
|
|
55964
|
-
// Otherwise, fall back to 'any'.
|
|
55965
|
-
if (setter) {
|
|
55966
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
55967
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55968
|
-
}
|
|
55969
|
-
return anyType;
|
|
55970
|
-
}
|
|
55971
|
-
else if (getter) {
|
|
55972
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
55973
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
55974
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56000
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
56001
|
+
var links = getSymbolLinks(symbol);
|
|
56002
|
+
if (!links.writeType) {
|
|
56003
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
56004
|
+
return errorType;
|
|
55975
56005
|
}
|
|
55976
|
-
|
|
55977
|
-
|
|
55978
|
-
|
|
55979
|
-
|
|
55980
|
-
|
|
55981
|
-
|
|
55982
|
-
|
|
56006
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56007
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
56008
|
+
if (!popTypeResolution()) {
|
|
56009
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56010
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56011
|
+
}
|
|
56012
|
+
writeType = anyType;
|
|
55983
56013
|
}
|
|
55984
|
-
|
|
56014
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
56015
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
55985
56016
|
}
|
|
56017
|
+
return links.writeType;
|
|
55986
56018
|
}
|
|
55987
56019
|
function getBaseTypeVariableOfClass(symbol) {
|
|
55988
56020
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56064,17 +56096,11 @@ var ts;
|
|
|
56064
56096
|
}
|
|
56065
56097
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56066
56098
|
var links = getSymbolLinks(symbol);
|
|
56067
|
-
|
|
56068
|
-
|
|
56069
|
-
|
|
56070
|
-
|
|
56071
|
-
|
|
56072
|
-
if (!popTypeResolution()) {
|
|
56073
|
-
type = reportCircularityError(symbol);
|
|
56074
|
-
}
|
|
56075
|
-
links.type = type;
|
|
56076
|
-
}
|
|
56077
|
-
return links.type;
|
|
56099
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56100
|
+
}
|
|
56101
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56102
|
+
var links = getSymbolLinks(symbol);
|
|
56103
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56078
56104
|
}
|
|
56079
56105
|
function reportCircularityError(symbol) {
|
|
56080
56106
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56111,35 +56137,23 @@ var ts;
|
|
|
56111
56137
|
return links.writeType;
|
|
56112
56138
|
}
|
|
56113
56139
|
/**
|
|
56114
|
-
* Distinct write types come only from set accessors, but union and intersection
|
|
56115
|
-
* properties deriving from set accessors will either pre-compute or defer the
|
|
56116
|
-
*
|
|
56117
|
-
* this, we will assume that any deferred type or transient symbol may have a
|
|
56118
|
-
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
56119
|
-
* used before looking for set accessor declarations.
|
|
56140
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56141
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56142
|
+
* intersection of the writeTypes of their constituents.
|
|
56120
56143
|
*/
|
|
56121
56144
|
function getWriteTypeOfSymbol(symbol) {
|
|
56122
56145
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56123
|
-
if (
|
|
56124
|
-
|
|
56125
|
-
|
|
56126
|
-
|
|
56127
|
-
|
|
56128
|
-
|
|
56129
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56130
|
-
var writeType = symbol.writeType;
|
|
56131
|
-
if (writeType) {
|
|
56132
|
-
return writeType;
|
|
56133
|
-
}
|
|
56146
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56147
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56148
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56149
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56150
|
+
symbol.writeType || symbol.type :
|
|
56151
|
+
getTypeOfSymbol(symbol);
|
|
56134
56152
|
}
|
|
56135
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56136
|
-
}
|
|
56137
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56138
56153
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56139
|
-
|
|
56140
|
-
|
|
56141
|
-
|
|
56142
|
-
}
|
|
56154
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56155
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56156
|
+
getWriteTypeOfAccessors(symbol);
|
|
56143
56157
|
}
|
|
56144
56158
|
return getTypeOfSymbol(symbol);
|
|
56145
56159
|
}
|
|
@@ -68228,7 +68242,7 @@ var ts;
|
|
|
68228
68242
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68229
68243
|
var targetProp = properties_3[_i];
|
|
68230
68244
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68231
|
-
if (sourceProp) {
|
|
68245
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68232
68246
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68233
68247
|
}
|
|
68234
68248
|
}
|
|
@@ -70610,7 +70624,7 @@ var ts;
|
|
|
70610
70624
|
}
|
|
70611
70625
|
}
|
|
70612
70626
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70613
|
-
return
|
|
70627
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70614
70628
|
}
|
|
70615
70629
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70616
70630
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -70702,7 +70716,7 @@ var ts;
|
|
|
70702
70716
|
// as we want the type of a rest element to be generic when possible.
|
|
70703
70717
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70704
70718
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70705
|
-
(checkMode && checkMode &
|
|
70719
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70706
70720
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70707
70721
|
: getContextualType(node));
|
|
70708
70722
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -70823,7 +70837,7 @@ var ts;
|
|
|
70823
70837
|
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
|
|
70824
70838
|
var contextualSignature = getContextualSignature(func);
|
|
70825
70839
|
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
|
|
70826
|
-
var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
|
|
70840
|
+
var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
|
|
70827
70841
|
if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
|
|
70828
70842
|
var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
|
|
70829
70843
|
var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
|
|
@@ -71641,7 +71655,7 @@ var ts;
|
|
|
71641
71655
|
var parent = declaration.parent.parent;
|
|
71642
71656
|
var name = declaration.propertyName || declaration.name;
|
|
71643
71657
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71644
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71658
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71645
71659
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71646
71660
|
return undefined;
|
|
71647
71661
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -72128,9 +72142,14 @@ var ts;
|
|
|
72128
72142
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72129
72143
|
}
|
|
72130
72144
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72131
|
-
// incorporate inferences made from the return type in a function call.
|
|
72145
|
+
// incorporate inferences made from the return type in a function call. We remove
|
|
72146
|
+
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72147
|
+
// literals actually end up widening to 'boolean' (see #48363).
|
|
72132
72148
|
if (inferenceContext.returnMapper) {
|
|
72133
|
-
|
|
72149
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72150
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72151
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72152
|
+
type;
|
|
72134
72153
|
}
|
|
72135
72154
|
}
|
|
72136
72155
|
}
|
|
@@ -74695,7 +74714,7 @@ var ts;
|
|
|
74695
74714
|
}
|
|
74696
74715
|
for (var i = 0; i < argCount; i++) {
|
|
74697
74716
|
var arg = args[i];
|
|
74698
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74717
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74699
74718
|
var paramType = getTypeAtPosition(signature, i);
|
|
74700
74719
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74701
74720
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75380,7 +75399,7 @@ var ts;
|
|
|
75380
75399
|
}
|
|
75381
75400
|
}
|
|
75382
75401
|
}
|
|
75383
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75402
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75384
75403
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75385
75404
|
var _a, _b;
|
|
75386
75405
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75481,14 +75500,14 @@ var ts;
|
|
|
75481
75500
|
}
|
|
75482
75501
|
}
|
|
75483
75502
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75484
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75503
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75485
75504
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75486
75505
|
checkNodeDeferred(node);
|
|
75487
75506
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75488
75507
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75489
75508
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75490
75509
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75491
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75510
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75492
75511
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75493
75512
|
}
|
|
75494
75513
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75536,7 +75555,7 @@ var ts;
|
|
|
75536
75555
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75537
75556
|
return createSymbolWithType(ts.first(sources), type);
|
|
75538
75557
|
}
|
|
75539
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75558
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75540
75559
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75541
75560
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75542
75561
|
// f({ |
|
|
@@ -75552,7 +75571,7 @@ var ts;
|
|
|
75552
75571
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75553
75572
|
var instantiated = typeArgumentNodes
|
|
75554
75573
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75555
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75574
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75556
75575
|
candidates[bestIndex] = instantiated;
|
|
75557
75576
|
return instantiated;
|
|
75558
75577
|
}
|
|
@@ -75566,9 +75585,9 @@ var ts;
|
|
|
75566
75585
|
}
|
|
75567
75586
|
return typeArguments;
|
|
75568
75587
|
}
|
|
75569
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75588
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75570
75589
|
var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
|
|
75571
|
-
var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75590
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75572
75591
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75573
75592
|
}
|
|
75574
75593
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81634,7 +81653,7 @@ var ts;
|
|
|
81634
81653
|
}
|
|
81635
81654
|
// check private/protected variable access
|
|
81636
81655
|
var parent = node.parent.parent;
|
|
81637
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81656
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81638
81657
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81639
81658
|
var name = node.propertyName || node.name;
|
|
81640
81659
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -81813,6 +81832,8 @@ var ts;
|
|
|
81813
81832
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81814
81833
|
? condExpr.right
|
|
81815
81834
|
: condExpr;
|
|
81835
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81836
|
+
return;
|
|
81816
81837
|
var type = checkTruthinessExpression(location);
|
|
81817
81838
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81818
81839
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -116730,6 +116751,13 @@ var ts;
|
|
|
116730
116751
|
return "skip";
|
|
116731
116752
|
}
|
|
116732
116753
|
break;
|
|
116754
|
+
case 270 /* ImportSpecifier */:
|
|
116755
|
+
case 275 /* ExportSpecifier */:
|
|
116756
|
+
if (node.isTypeOnly) {
|
|
116757
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116758
|
+
return "skip";
|
|
116759
|
+
}
|
|
116760
|
+
break;
|
|
116733
116761
|
case 265 /* ImportEqualsDeclaration */:
|
|
116734
116762
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116735
116763
|
return "skip";
|
|
@@ -126073,12 +126101,8 @@ var ts;
|
|
|
126073
126101
|
}
|
|
126074
126102
|
}
|
|
126075
126103
|
ts.findNextToken = findNextToken;
|
|
126076
|
-
/**
|
|
126077
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126078
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126079
|
-
*/
|
|
126080
126104
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126081
|
-
var result = find(startNode || sourceFile);
|
|
126105
|
+
var result = find((startNode || sourceFile));
|
|
126082
126106
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126083
126107
|
return result;
|
|
126084
126108
|
function find(n) {
|
|
@@ -127178,6 +127202,14 @@ var ts;
|
|
|
127178
127202
|
});
|
|
127179
127203
|
}
|
|
127180
127204
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127205
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127206
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127207
|
+
return mapToDisplayParts(function (writer) {
|
|
127208
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127209
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127210
|
+
});
|
|
127211
|
+
}
|
|
127212
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127181
127213
|
function isImportOrExportSpecifierName(location) {
|
|
127182
127214
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127183
127215
|
}
|
|
@@ -129874,12 +129906,13 @@ var ts;
|
|
|
129874
129906
|
}
|
|
129875
129907
|
case 208 /* CallExpression */:
|
|
129876
129908
|
case 209 /* NewExpression */:
|
|
129909
|
+
case 285 /* JsxAttribute */:
|
|
129877
129910
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
129878
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
129911
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
129879
129912
|
// Get string literal completions from specialized signatures of the target
|
|
129880
129913
|
// i.e. declare function f(a: 'A');
|
|
129881
129914
|
// f("/*completion position*/")
|
|
129882
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
129915
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
129883
129916
|
}
|
|
129884
129917
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
129885
129918
|
case 266 /* ImportDeclaration */:
|
|
@@ -129916,15 +129949,22 @@ var ts;
|
|
|
129916
129949
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
129917
129950
|
});
|
|
129918
129951
|
}
|
|
129919
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
129952
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
129920
129953
|
var isNewIdentifier = false;
|
|
129921
129954
|
var uniques = new ts.Map();
|
|
129922
129955
|
var candidates = [];
|
|
129923
|
-
|
|
129956
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
129957
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
129924
129958
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
129925
129959
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
129926
129960
|
return;
|
|
129927
129961
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
129962
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
129963
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
129964
|
+
if (propType) {
|
|
129965
|
+
type = propType;
|
|
129966
|
+
}
|
|
129967
|
+
}
|
|
129928
129968
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
129929
129969
|
return getStringLiteralTypes(type, uniques);
|
|
129930
129970
|
});
|
|
@@ -130467,43 +130507,28 @@ var ts;
|
|
|
130467
130507
|
// Exported only for tests
|
|
130468
130508
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
130469
130509
|
Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000;
|
|
130470
|
-
|
|
130471
|
-
|
|
130472
|
-
|
|
130473
|
-
|
|
130474
|
-
|
|
130475
|
-
|
|
130476
|
-
|
|
130477
|
-
|
|
130478
|
-
|
|
130479
|
-
|
|
130480
|
-
|
|
130481
|
-
|
|
130482
|
-
|
|
130483
|
-
|
|
130484
|
-
|
|
130485
|
-
|
|
130486
|
-
|
|
130487
|
-
|
|
130488
|
-
|
|
130489
|
-
|
|
130490
|
-
|
|
130491
|
-
}
|
|
130492
|
-
var SortTextId;
|
|
130493
|
-
(function (SortTextId) {
|
|
130494
|
-
SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority";
|
|
130495
|
-
SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority";
|
|
130496
|
-
SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember";
|
|
130497
|
-
SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment";
|
|
130498
|
-
SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers";
|
|
130499
|
-
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130500
|
-
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130501
|
-
// Don't use these directly.
|
|
130502
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
130503
|
-
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130504
|
-
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130505
|
-
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130506
|
-
})(SortTextId || (SortTextId = {}));
|
|
130510
|
+
Completions.SortText = {
|
|
130511
|
+
// Presets
|
|
130512
|
+
LocalDeclarationPriority: "10",
|
|
130513
|
+
LocationPriority: "11",
|
|
130514
|
+
OptionalMember: "12",
|
|
130515
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
130516
|
+
SuggestedClassMembers: "14",
|
|
130517
|
+
GlobalsOrKeywords: "15",
|
|
130518
|
+
AutoImportSuggestions: "16",
|
|
130519
|
+
ClassMemberSnippets: "17",
|
|
130520
|
+
JavascriptIdentifiers: "18",
|
|
130521
|
+
// Transformations
|
|
130522
|
+
Deprecated: function (sortText) {
|
|
130523
|
+
return "z" + sortText;
|
|
130524
|
+
},
|
|
130525
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
130526
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
130527
|
+
},
|
|
130528
|
+
SortBelow: function (sortText) {
|
|
130529
|
+
return sortText + "1";
|
|
130530
|
+
},
|
|
130531
|
+
};
|
|
130507
130532
|
/**
|
|
130508
130533
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
130509
130534
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -130523,6 +130548,8 @@ var ts;
|
|
|
130523
130548
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
130524
130549
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
130525
130550
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
130551
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
130552
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
130526
130553
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
130527
130554
|
var SymbolOriginInfoKind;
|
|
130528
130555
|
(function (SymbolOriginInfoKind) {
|
|
@@ -130533,6 +130560,7 @@ var ts;
|
|
|
130533
130560
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
130534
130561
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
130535
130562
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
130563
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
130536
130564
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
130537
130565
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
130538
130566
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -130563,6 +130591,9 @@ var ts;
|
|
|
130563
130591
|
function originIsTypeOnlyAlias(origin) {
|
|
130564
130592
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
130565
130593
|
}
|
|
130594
|
+
function originIsObjectLiteralMethod(origin) {
|
|
130595
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
130596
|
+
}
|
|
130566
130597
|
var KeywordCompletionFilters;
|
|
130567
130598
|
(function (KeywordCompletionFilters) {
|
|
130568
130599
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -130655,7 +130686,7 @@ var ts;
|
|
|
130655
130686
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
130656
130687
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
130657
130688
|
}
|
|
130658
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
130689
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
130659
130690
|
if (!completionData) {
|
|
130660
130691
|
return undefined;
|
|
130661
130692
|
}
|
|
@@ -130753,7 +130784,7 @@ var ts;
|
|
|
130753
130784
|
name: ts.tokenToString(keyword),
|
|
130754
130785
|
kind: "keyword" /* keyword */,
|
|
130755
130786
|
kindModifiers: "" /* none */,
|
|
130756
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
130787
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
130757
130788
|
};
|
|
130758
130789
|
}
|
|
130759
130790
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -130782,7 +130813,7 @@ var ts;
|
|
|
130782
130813
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
130783
130814
|
}
|
|
130784
130815
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
130785
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression,
|
|
130816
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
130786
130817
|
// Verify if the file is JSX language variant
|
|
130787
130818
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
130788
130819
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -130793,7 +130824,7 @@ var ts;
|
|
|
130793
130824
|
var entries = ts.createSortedArray();
|
|
130794
130825
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
130795
130826
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
130796
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
130827
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
130797
130828
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
130798
130829
|
}
|
|
130799
130830
|
else {
|
|
@@ -130801,7 +130832,7 @@ var ts;
|
|
|
130801
130832
|
return undefined;
|
|
130802
130833
|
}
|
|
130803
130834
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
130804
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
130835
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
130805
130836
|
}
|
|
130806
130837
|
if (keywordFilters !== 0 /* None */) {
|
|
130807
130838
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -130882,7 +130913,7 @@ var ts;
|
|
|
130882
130913
|
name: fullClosingTag,
|
|
130883
130914
|
kind: "class" /* classElement */,
|
|
130884
130915
|
kindModifiers: undefined,
|
|
130885
|
-
sortText: SortText.LocationPriority,
|
|
130916
|
+
sortText: Completions.SortText.LocationPriority,
|
|
130886
130917
|
};
|
|
130887
130918
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
130888
130919
|
}
|
|
@@ -130901,7 +130932,7 @@ var ts;
|
|
|
130901
130932
|
name: realName,
|
|
130902
130933
|
kind: "warning" /* warning */,
|
|
130903
130934
|
kindModifiers: "",
|
|
130904
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
130935
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
130905
130936
|
isFromUncheckedFile: true
|
|
130906
130937
|
}, compareCompletionEntries);
|
|
130907
130938
|
}
|
|
@@ -130912,7 +130943,7 @@ var ts;
|
|
|
130912
130943
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
130913
130944
|
}
|
|
130914
130945
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
130915
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
130946
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
130916
130947
|
}
|
|
130917
130948
|
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
130918
130949
|
var _a, _b;
|
|
@@ -130923,6 +130954,7 @@ var ts;
|
|
|
130923
130954
|
var source = getSourceFromOrigin(origin);
|
|
130924
130955
|
var sourceDisplay;
|
|
130925
130956
|
var hasAction;
|
|
130957
|
+
var labelDetails;
|
|
130926
130958
|
var typeChecker = program.getTypeChecker();
|
|
130927
130959
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
130928
130960
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
@@ -130983,12 +131015,25 @@ var ts;
|
|
|
130983
131015
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
130984
131016
|
var importAdder = void 0;
|
|
130985
131017
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
130986
|
-
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131018
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
130987
131019
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
130988
131020
|
hasAction = true;
|
|
130989
131021
|
source = CompletionSource.ClassMemberSnippet;
|
|
130990
131022
|
}
|
|
130991
131023
|
}
|
|
131024
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131025
|
+
var importAdder = void 0;
|
|
131026
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
131027
|
+
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131028
|
+
name = name + labelDetails.detail;
|
|
131029
|
+
labelDetails = undefined;
|
|
131030
|
+
}
|
|
131031
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131032
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
131033
|
+
if (importAdder.hasFixes()) {
|
|
131034
|
+
hasAction = true;
|
|
131035
|
+
}
|
|
131036
|
+
}
|
|
130992
131037
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
130993
131038
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
130994
131039
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131036,6 +131081,7 @@ var ts;
|
|
|
131036
131081
|
insertText: insertText,
|
|
131037
131082
|
replacementSpan: replacementSpan,
|
|
131038
131083
|
sourceDisplay: sourceDisplay,
|
|
131084
|
+
labelDetails: labelDetails,
|
|
131039
131085
|
isSnippet: isSnippet,
|
|
131040
131086
|
isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
|
|
131041
131087
|
isImportStatementCompletion: !!importCompletionNode || undefined,
|
|
@@ -131147,27 +131193,15 @@ var ts;
|
|
|
131147
131193
|
completionNodes.push(node);
|
|
131148
131194
|
}, body, 2 /* Property */, isAbstract);
|
|
131149
131195
|
if (completionNodes.length) {
|
|
131196
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131150
131197
|
replacementSpan = modifiersSpan;
|
|
131151
131198
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131152
131199
|
// and then format the printed text.
|
|
131153
131200
|
if (formatContext) {
|
|
131154
|
-
|
|
131155
|
-
text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
|
|
131156
|
-
getLineAndCharacterOfPosition: function (pos) {
|
|
131157
|
-
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131158
|
-
},
|
|
131159
|
-
};
|
|
131160
|
-
var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131161
|
-
var changes = ts.flatMap(completionNodes, function (node) {
|
|
131162
|
-
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131163
|
-
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
|
|
131164
|
-
/* indentation */ 0,
|
|
131165
|
-
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
|
|
131166
|
-
});
|
|
131167
|
-
insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
|
|
131201
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131168
131202
|
}
|
|
131169
131203
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131170
|
-
insertText = printer.printSnippetList(
|
|
131204
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131171
131205
|
}
|
|
131172
131206
|
}
|
|
131173
131207
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131217,12 +131251,113 @@ var ts;
|
|
|
131217
131251
|
}
|
|
131218
131252
|
return undefined;
|
|
131219
131253
|
}
|
|
131254
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131255
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131256
|
+
var insertText = name;
|
|
131257
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131258
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131259
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131260
|
+
if (!method) {
|
|
131261
|
+
return undefined;
|
|
131262
|
+
}
|
|
131263
|
+
var printer = createSnippetPrinter({
|
|
131264
|
+
removeComments: true,
|
|
131265
|
+
module: options.module,
|
|
131266
|
+
target: options.target,
|
|
131267
|
+
omitTrailingSemicolon: false,
|
|
131268
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131269
|
+
});
|
|
131270
|
+
if (formatContext) {
|
|
131271
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131272
|
+
}
|
|
131273
|
+
else {
|
|
131274
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131275
|
+
}
|
|
131276
|
+
var signaturePrinter = ts.createPrinter({
|
|
131277
|
+
removeComments: true,
|
|
131278
|
+
module: options.module,
|
|
131279
|
+
target: options.target,
|
|
131280
|
+
omitTrailingSemicolon: true,
|
|
131281
|
+
});
|
|
131282
|
+
// The `labelDetails.detail` will be displayed right beside the method name,
|
|
131283
|
+
// so we drop the name (and modifiers) from the signature.
|
|
131284
|
+
var methodSignature = ts.factory.createMethodSignature(
|
|
131285
|
+
/*modifiers*/ undefined,
|
|
131286
|
+
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131287
|
+
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
131288
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails };
|
|
131289
|
+
}
|
|
131290
|
+
;
|
|
131291
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131292
|
+
var declarations = symbol.getDeclarations();
|
|
131293
|
+
if (!(declarations && declarations.length)) {
|
|
131294
|
+
return undefined;
|
|
131295
|
+
}
|
|
131296
|
+
var checker = program.getTypeChecker();
|
|
131297
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131298
|
+
var declaration = declarations[0];
|
|
131299
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131300
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131301
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131302
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131303
|
+
switch (declaration.kind) {
|
|
131304
|
+
case 166 /* PropertySignature */:
|
|
131305
|
+
case 167 /* PropertyDeclaration */:
|
|
131306
|
+
case 168 /* MethodSignature */:
|
|
131307
|
+
case 169 /* MethodDeclaration */: {
|
|
131308
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131309
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131310
|
+
: type;
|
|
131311
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131312
|
+
// Only offer the completion if there's a single function type component.
|
|
131313
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131314
|
+
if (functionTypes.length === 1) {
|
|
131315
|
+
effectiveType = functionTypes[0];
|
|
131316
|
+
}
|
|
131317
|
+
else {
|
|
131318
|
+
return undefined;
|
|
131319
|
+
}
|
|
131320
|
+
}
|
|
131321
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131322
|
+
if (signatures.length !== 1) {
|
|
131323
|
+
// We don't support overloads in object literals.
|
|
131324
|
+
return undefined;
|
|
131325
|
+
}
|
|
131326
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131327
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131328
|
+
return undefined;
|
|
131329
|
+
}
|
|
131330
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131331
|
+
if (importableReference) {
|
|
131332
|
+
typeNode = importableReference.typeNode;
|
|
131333
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131334
|
+
}
|
|
131335
|
+
var body = void 0;
|
|
131336
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131337
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131338
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131339
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131340
|
+
}
|
|
131341
|
+
else {
|
|
131342
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131343
|
+
}
|
|
131344
|
+
return ts.factory.createMethodDeclaration(
|
|
131345
|
+
/*decorators*/ undefined,
|
|
131346
|
+
/*modifiers*/ undefined,
|
|
131347
|
+
/*asteriskToken*/ undefined, name,
|
|
131348
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131349
|
+
}
|
|
131350
|
+
default:
|
|
131351
|
+
return undefined;
|
|
131352
|
+
}
|
|
131353
|
+
}
|
|
131220
131354
|
function createSnippetPrinter(printerOptions) {
|
|
131221
131355
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131222
131356
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131223
131357
|
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)); } });
|
|
131224
131358
|
return {
|
|
131225
131359
|
printSnippetList: printSnippetList,
|
|
131360
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131226
131361
|
};
|
|
131227
131362
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131228
131363
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131230,6 +131365,22 @@ var ts;
|
|
|
131230
131365
|
printer.writeList(format, list, sourceFile, writer);
|
|
131231
131366
|
return writer.getText();
|
|
131232
131367
|
}
|
|
131368
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131369
|
+
var syntheticFile = {
|
|
131370
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131371
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131372
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131373
|
+
},
|
|
131374
|
+
};
|
|
131375
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131376
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131377
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131378
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131379
|
+
/* indentation */ 0,
|
|
131380
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131381
|
+
});
|
|
131382
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131383
|
+
}
|
|
131233
131384
|
}
|
|
131234
131385
|
function originToCompletionEntryData(origin) {
|
|
131235
131386
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131327,7 +131478,7 @@ var ts;
|
|
|
131327
131478
|
return CompletionSource.TypeOnlyAlias;
|
|
131328
131479
|
}
|
|
131329
131480
|
}
|
|
131330
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131481
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
131331
131482
|
var _a;
|
|
131332
131483
|
var start = ts.timestamp();
|
|
131333
131484
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131342,12 +131493,12 @@ var ts;
|
|
|
131342
131493
|
var symbol = symbols[i];
|
|
131343
131494
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131344
131495
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131345
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
131496
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131346
131497
|
continue;
|
|
131347
131498
|
}
|
|
131348
131499
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131349
|
-
var
|
|
131350
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131500
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
131501
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131351
131502
|
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
131352
131503
|
if (!entry) {
|
|
131353
131504
|
continue;
|
|
@@ -131365,7 +131516,7 @@ var ts;
|
|
|
131365
131516
|
has: function (name) { return uniques.has(name); },
|
|
131366
131517
|
add: function (name) { return uniques.set(name, true); },
|
|
131367
131518
|
};
|
|
131368
|
-
function shouldIncludeSymbol(symbol,
|
|
131519
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131369
131520
|
var allFlags = symbol.flags;
|
|
131370
131521
|
if (!ts.isSourceFile(location)) {
|
|
131371
131522
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131387,9 +131538,9 @@ var ts;
|
|
|
131387
131538
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131388
131539
|
if (!!sourceFile.externalModuleIndicator
|
|
131389
131540
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
131390
|
-
&&
|
|
131391
|
-
&& (
|
|
131392
|
-
||
|
|
131541
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
131542
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
131543
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
131393
131544
|
return false;
|
|
131394
131545
|
}
|
|
131395
131546
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -131429,7 +131580,7 @@ var ts;
|
|
|
131429
131580
|
name: name,
|
|
131430
131581
|
kindModifiers: "" /* none */,
|
|
131431
131582
|
kind: "label" /* label */,
|
|
131432
|
-
sortText: SortText.LocationPriority
|
|
131583
|
+
sortText: Completions.SortText.LocationPriority
|
|
131433
131584
|
});
|
|
131434
131585
|
}
|
|
131435
131586
|
}
|
|
@@ -131455,7 +131606,7 @@ var ts;
|
|
|
131455
131606
|
}
|
|
131456
131607
|
}
|
|
131457
131608
|
var compilerOptions = program.getCompilerOptions();
|
|
131458
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131609
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
131459
131610
|
if (!completionData) {
|
|
131460
131611
|
return { type: "none" };
|
|
131461
131612
|
}
|
|
@@ -131473,7 +131624,9 @@ var ts;
|
|
|
131473
131624
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
131474
131625
|
var origin = symbolToOriginInfoMap[index];
|
|
131475
131626
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
131476
|
-
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
131627
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
131628
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
131629
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
131477
131630
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
131478
131631
|
: undefined;
|
|
131479
131632
|
}) || { type: "none" };
|
|
@@ -131555,6 +131708,20 @@ var ts;
|
|
|
131555
131708
|
};
|
|
131556
131709
|
}
|
|
131557
131710
|
}
|
|
131711
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
131712
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
131713
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
131714
|
+
if (importAdder.hasFixes()) {
|
|
131715
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
131716
|
+
return {
|
|
131717
|
+
sourceDisplay: undefined,
|
|
131718
|
+
codeActions: [{
|
|
131719
|
+
changes: changes,
|
|
131720
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
131721
|
+
}],
|
|
131722
|
+
};
|
|
131723
|
+
}
|
|
131724
|
+
}
|
|
131558
131725
|
if (originIsTypeOnlyAlias(origin)) {
|
|
131559
131726
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
131560
131727
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -131647,8 +131814,9 @@ var ts;
|
|
|
131647
131814
|
var _a;
|
|
131648
131815
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
131649
131816
|
}
|
|
131650
|
-
function getCompletionData(program, log, sourceFile,
|
|
131817
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
131651
131818
|
var typeChecker = program.getTypeChecker();
|
|
131819
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
131652
131820
|
var start = ts.timestamp();
|
|
131653
131821
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
131654
131822
|
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
|
|
@@ -131891,7 +132059,7 @@ var ts;
|
|
|
131891
132059
|
// This also gets mutated in nested-functions after the return
|
|
131892
132060
|
var symbols = [];
|
|
131893
132061
|
var symbolToOriginInfoMap = [];
|
|
131894
|
-
var
|
|
132062
|
+
var symbolToSortTextMap = [];
|
|
131895
132063
|
var seenPropertySymbols = new ts.Map();
|
|
131896
132064
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
131897
132065
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -131946,7 +132114,7 @@ var ts;
|
|
|
131946
132114
|
contextToken: contextToken,
|
|
131947
132115
|
isJsxInitializer: isJsxInitializer,
|
|
131948
132116
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
131949
|
-
|
|
132117
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
131950
132118
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
131951
132119
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
131952
132120
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132060,7 +132228,7 @@ var ts;
|
|
|
132060
132228
|
isNewIdentifierLocation = true;
|
|
132061
132229
|
}
|
|
132062
132230
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132063
|
-
if (
|
|
132231
|
+
if (inUncheckedFile) {
|
|
132064
132232
|
// In javascript files, for union types, we don't just get the members that
|
|
132065
132233
|
// the individual types have in common, we also include all the members that
|
|
132066
132234
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132145,7 +132313,7 @@ var ts;
|
|
|
132145
132313
|
}
|
|
132146
132314
|
function addSymbolSortInfo(symbol) {
|
|
132147
132315
|
if (isStaticProperty(symbol)) {
|
|
132148
|
-
|
|
132316
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132149
132317
|
}
|
|
132150
132318
|
}
|
|
132151
132319
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132255,7 +132423,7 @@ var ts;
|
|
|
132255
132423
|
var symbol = symbols[i];
|
|
132256
132424
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132257
132425
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132258
|
-
|
|
132426
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132259
132427
|
}
|
|
132260
132428
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132261
132429
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132273,7 +132441,7 @@ var ts;
|
|
|
132273
132441
|
var symbol = _a[_i];
|
|
132274
132442
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132275
132443
|
symbols.push(symbol);
|
|
132276
|
-
|
|
132444
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132277
132445
|
}
|
|
132278
132446
|
}
|
|
132279
132447
|
}
|
|
@@ -132351,7 +132519,7 @@ var ts;
|
|
|
132351
132519
|
}
|
|
132352
132520
|
return false;
|
|
132353
132521
|
}
|
|
132354
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
132522
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132355
132523
|
function collectAutoImports() {
|
|
132356
132524
|
var _a, _b;
|
|
132357
132525
|
if (!shouldOfferImportCompletions())
|
|
@@ -132433,14 +132601,55 @@ var ts;
|
|
|
132433
132601
|
}
|
|
132434
132602
|
function pushAutoImportSymbol(symbol, origin) {
|
|
132435
132603
|
var symbolId = ts.getSymbolId(symbol);
|
|
132436
|
-
if (
|
|
132604
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
132437
132605
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
132438
132606
|
return;
|
|
132439
132607
|
}
|
|
132440
132608
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132441
|
-
|
|
132609
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
132442
132610
|
symbols.push(symbol);
|
|
132443
132611
|
}
|
|
132612
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
132613
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
132614
|
+
// TODO: support JS files.
|
|
132615
|
+
if (ts.isInJSFile(location)) {
|
|
132616
|
+
return;
|
|
132617
|
+
}
|
|
132618
|
+
members.forEach(function (member) {
|
|
132619
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
132620
|
+
return;
|
|
132621
|
+
}
|
|
132622
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
132623
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
132624
|
+
/*jsxIdentifierExpected*/ false);
|
|
132625
|
+
if (!displayName) {
|
|
132626
|
+
return;
|
|
132627
|
+
}
|
|
132628
|
+
var name = displayName.name;
|
|
132629
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
132630
|
+
if (!entryProps) {
|
|
132631
|
+
return;
|
|
132632
|
+
}
|
|
132633
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
132634
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132635
|
+
symbols.push(member);
|
|
132636
|
+
});
|
|
132637
|
+
}
|
|
132638
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
132639
|
+
/*
|
|
132640
|
+
For an object type
|
|
132641
|
+
`type Foo = {
|
|
132642
|
+
bar(x: number): void;
|
|
132643
|
+
foo: (x: string) => string;
|
|
132644
|
+
}`,
|
|
132645
|
+
`bar` will have symbol flag `Method`,
|
|
132646
|
+
`foo` will have symbol flag `Property`.
|
|
132647
|
+
*/
|
|
132648
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
132649
|
+
return false;
|
|
132650
|
+
}
|
|
132651
|
+
return true;
|
|
132652
|
+
}
|
|
132444
132653
|
/**
|
|
132445
132654
|
* Finds the first node that "embraces" the position, so that one may
|
|
132446
132655
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -132574,6 +132783,7 @@ var ts;
|
|
|
132574
132783
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
132575
132784
|
*/
|
|
132576
132785
|
function tryGetObjectLikeCompletionSymbols() {
|
|
132786
|
+
var symbolsStartIndex = symbols.length;
|
|
132577
132787
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132578
132788
|
if (!objectLikeContainer)
|
|
132579
132789
|
return 0 /* Continue */;
|
|
@@ -132638,9 +132848,16 @@ var ts;
|
|
|
132638
132848
|
}
|
|
132639
132849
|
if (typeMembers && typeMembers.length > 0) {
|
|
132640
132850
|
// Add filtered items to the completion list
|
|
132641
|
-
|
|
132851
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
132852
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
132853
|
+
setSortTextToOptionalMember();
|
|
132854
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
132855
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
132856
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
132857
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
132858
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
132859
|
+
}
|
|
132642
132860
|
}
|
|
132643
|
-
setSortTextToOptionalMember();
|
|
132644
132861
|
return 1 /* Success */;
|
|
132645
132862
|
}
|
|
132646
132863
|
/**
|
|
@@ -132715,7 +132932,7 @@ var ts;
|
|
|
132715
132932
|
var _a, _b;
|
|
132716
132933
|
symbols.push(symbol);
|
|
132717
132934
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
132718
|
-
|
|
132935
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
132719
132936
|
}
|
|
132720
132937
|
});
|
|
132721
132938
|
return 1 /* Success */;
|
|
@@ -132770,29 +132987,6 @@ var ts;
|
|
|
132770
132987
|
}
|
|
132771
132988
|
return 1 /* Success */;
|
|
132772
132989
|
}
|
|
132773
|
-
/**
|
|
132774
|
-
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
132775
|
-
* on the condition that one exists and that the context implies completion should be given.
|
|
132776
|
-
*/
|
|
132777
|
-
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
132778
|
-
if (contextToken) {
|
|
132779
|
-
var parent = contextToken.parent;
|
|
132780
|
-
switch (contextToken.kind) {
|
|
132781
|
-
case 18 /* OpenBraceToken */: // const x = { |
|
|
132782
|
-
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
132783
|
-
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
132784
|
-
return parent;
|
|
132785
|
-
}
|
|
132786
|
-
break;
|
|
132787
|
-
case 41 /* AsteriskToken */:
|
|
132788
|
-
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
132789
|
-
case 79 /* Identifier */:
|
|
132790
|
-
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
132791
|
-
? contextToken.parent.parent : undefined;
|
|
132792
|
-
}
|
|
132793
|
-
}
|
|
132794
|
-
return undefined;
|
|
132795
|
-
}
|
|
132796
132990
|
function isConstructorParameterCompletion(node) {
|
|
132797
132991
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
132798
132992
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133129,7 +133323,7 @@ var ts;
|
|
|
133129
133323
|
var _a;
|
|
133130
133324
|
if (m.flags & 16777216 /* Optional */) {
|
|
133131
133325
|
var symbolId = ts.getSymbolId(m);
|
|
133132
|
-
|
|
133326
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133133
133327
|
}
|
|
133134
133328
|
});
|
|
133135
133329
|
}
|
|
@@ -133141,7 +133335,23 @@ var ts;
|
|
|
133141
133335
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133142
133336
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133143
133337
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133144
|
-
|
|
133338
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133339
|
+
}
|
|
133340
|
+
}
|
|
133341
|
+
}
|
|
133342
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133343
|
+
var _a;
|
|
133344
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133345
|
+
var symbol = symbols[i];
|
|
133346
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133347
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133348
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133349
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133350
|
+
/*jsxIdentifierExpected*/ false);
|
|
133351
|
+
if (displayName) {
|
|
133352
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133353
|
+
var name = displayName.name;
|
|
133354
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133145
133355
|
}
|
|
133146
133356
|
}
|
|
133147
133357
|
}
|
|
@@ -133215,6 +133425,29 @@ var ts;
|
|
|
133215
133425
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133216
133426
|
}
|
|
133217
133427
|
}
|
|
133428
|
+
/**
|
|
133429
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133430
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
133431
|
+
*/
|
|
133432
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133433
|
+
if (contextToken) {
|
|
133434
|
+
var parent = contextToken.parent;
|
|
133435
|
+
switch (contextToken.kind) {
|
|
133436
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
133437
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133438
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133439
|
+
return parent;
|
|
133440
|
+
}
|
|
133441
|
+
break;
|
|
133442
|
+
case 41 /* AsteriskToken */:
|
|
133443
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
133444
|
+
case 79 /* Identifier */:
|
|
133445
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
133446
|
+
? contextToken.parent.parent : undefined;
|
|
133447
|
+
}
|
|
133448
|
+
}
|
|
133449
|
+
return undefined;
|
|
133450
|
+
}
|
|
133218
133451
|
function getRelevantTokens(position, sourceFile) {
|
|
133219
133452
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133220
133453
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133280,7 +133513,7 @@ var ts;
|
|
|
133280
133513
|
name: ts.tokenToString(i),
|
|
133281
133514
|
kind: "keyword" /* keyword */,
|
|
133282
133515
|
kindModifiers: "" /* none */,
|
|
133283
|
-
sortText: SortText.GlobalsOrKeywords
|
|
133516
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133284
133517
|
});
|
|
133285
133518
|
}
|
|
133286
133519
|
return res;
|
|
@@ -133408,7 +133641,7 @@ var ts;
|
|
|
133408
133641
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
133409
133642
|
kind: "keyword" /* keyword */,
|
|
133410
133643
|
kindModifiers: "" /* none */,
|
|
133411
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
133644
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
133412
133645
|
});
|
|
133413
133646
|
}
|
|
133414
133647
|
}
|
|
@@ -138601,7 +138834,8 @@ var ts;
|
|
|
138601
138834
|
return undefined;
|
|
138602
138835
|
}
|
|
138603
138836
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
138604
|
-
|
|
138837
|
+
var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined;
|
|
138838
|
+
if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) {
|
|
138605
138839
|
return undefined;
|
|
138606
138840
|
}
|
|
138607
138841
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -145336,6 +145570,7 @@ var ts;
|
|
|
145336
145570
|
return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); });
|
|
145337
145571
|
}
|
|
145338
145572
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
145573
|
+
var _b;
|
|
145339
145574
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145340
145575
|
// formatting context is used by rules provider
|
|
145341
145576
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145367,11 +145602,12 @@ var ts;
|
|
|
145367
145602
|
}
|
|
145368
145603
|
}
|
|
145369
145604
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145370
|
-
var
|
|
145605
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145371
145606
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145372
145607
|
undefined;
|
|
145373
|
-
if (
|
|
145374
|
-
|
|
145608
|
+
if (tokenInfo) {
|
|
145609
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
145610
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145375
145611
|
/*dynamicIndentation*/ undefined);
|
|
145376
145612
|
}
|
|
145377
145613
|
}
|
|
@@ -147293,25 +147529,25 @@ var ts;
|
|
|
147293
147529
|
suffix: this.newLineCharacter
|
|
147294
147530
|
});
|
|
147295
147531
|
};
|
|
147296
|
-
ChangeTracker.prototype.
|
|
147297
|
-
this.insertNodeAtStartWorker(sourceFile,
|
|
147532
|
+
ChangeTracker.prototype.insertMemberAtStart = function (sourceFile, node, newElement) {
|
|
147533
|
+
this.insertNodeAtStartWorker(sourceFile, node, newElement);
|
|
147298
147534
|
};
|
|
147299
147535
|
ChangeTracker.prototype.insertNodeAtObjectStart = function (sourceFile, obj, newElement) {
|
|
147300
147536
|
this.insertNodeAtStartWorker(sourceFile, obj, newElement);
|
|
147301
147537
|
};
|
|
147302
|
-
ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile,
|
|
147538
|
+
ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile, node, newElement) {
|
|
147303
147539
|
var _a;
|
|
147304
|
-
var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile,
|
|
147305
|
-
this.insertNodeAt(sourceFile, getMembersOrProperties(
|
|
147540
|
+
var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile, node)) !== null && _a !== void 0 ? _a : this.computeIndentationForNewMember(sourceFile, node);
|
|
147541
|
+
this.insertNodeAt(sourceFile, getMembersOrProperties(node).pos, newElement, this.getInsertNodeAtStartInsertOptions(sourceFile, node, indentation));
|
|
147306
147542
|
};
|
|
147307
147543
|
/**
|
|
147308
147544
|
* Tries to guess the indentation from the existing members of a class/interface/object. All members must be on
|
|
147309
147545
|
* new lines and must share the same indentation.
|
|
147310
147546
|
*/
|
|
147311
|
-
ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile,
|
|
147547
|
+
ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile, node) {
|
|
147312
147548
|
var indentation;
|
|
147313
|
-
var lastRange =
|
|
147314
|
-
for (var _i = 0, _a = getMembersOrProperties(
|
|
147549
|
+
var lastRange = node;
|
|
147550
|
+
for (var _i = 0, _a = getMembersOrProperties(node); _i < _a.length; _i++) {
|
|
147315
147551
|
var member = _a[_i];
|
|
147316
147552
|
if (ts.rangeStartPositionsAreOnSameLine(lastRange, member, sourceFile)) {
|
|
147317
147553
|
// each indented member must be on a new line
|
|
@@ -147330,13 +147566,13 @@ var ts;
|
|
|
147330
147566
|
}
|
|
147331
147567
|
return indentation;
|
|
147332
147568
|
};
|
|
147333
|
-
ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile,
|
|
147569
|
+
ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile, node) {
|
|
147334
147570
|
var _a;
|
|
147335
|
-
var
|
|
147336
|
-
return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(
|
|
147571
|
+
var nodeStart = node.getStart(sourceFile);
|
|
147572
|
+
return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(nodeStart, sourceFile), nodeStart, sourceFile, this.formatContext.options)
|
|
147337
147573
|
+ ((_a = this.formatContext.options.indentSize) !== null && _a !== void 0 ? _a : 4);
|
|
147338
147574
|
};
|
|
147339
|
-
ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile,
|
|
147575
|
+
ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile, node, indentation) {
|
|
147340
147576
|
// Rules:
|
|
147341
147577
|
// - Always insert leading newline.
|
|
147342
147578
|
// - For object literals:
|
|
@@ -147346,11 +147582,11 @@ var ts;
|
|
|
147346
147582
|
// and the node is empty (because we didn't add a trailing comma per the previous rule).
|
|
147347
147583
|
// - Only insert a trailing newline if body is single-line and there are no other insertions for the node.
|
|
147348
147584
|
// NOTE: This is handled in `finishClassesWithNodesInsertedAtStart`.
|
|
147349
|
-
var members = getMembersOrProperties(
|
|
147585
|
+
var members = getMembersOrProperties(node);
|
|
147350
147586
|
var isEmpty = members.length === 0;
|
|
147351
|
-
var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(
|
|
147352
|
-
var insertTrailingComma = ts.isObjectLiteralExpression(
|
|
147353
|
-
var insertLeadingComma = ts.isObjectLiteralExpression(
|
|
147587
|
+
var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(node), { node: node, sourceFile: sourceFile });
|
|
147588
|
+
var insertTrailingComma = ts.isObjectLiteralExpression(node) && (!ts.isJsonSourceFile(sourceFile) || !isEmpty);
|
|
147589
|
+
var insertLeadingComma = ts.isObjectLiteralExpression(node) && ts.isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
|
|
147354
147590
|
return {
|
|
147355
147591
|
indentation: indentation,
|
|
147356
147592
|
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
|
|
@@ -147644,8 +147880,8 @@ var ts;
|
|
|
147644
147880
|
var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile);
|
|
147645
147881
|
return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end];
|
|
147646
147882
|
}
|
|
147647
|
-
function getMembersOrProperties(
|
|
147648
|
-
return ts.isObjectLiteralExpression(
|
|
147883
|
+
function getMembersOrProperties(node) {
|
|
147884
|
+
return ts.isObjectLiteralExpression(node) ? node.properties : node.members;
|
|
147649
147885
|
}
|
|
147650
147886
|
function getNewFileText(statements, scriptKind, newLineCharacter, formatContext) {
|
|
147651
147887
|
return changesToText.newFileChangesWorker(/*oldFile*/ undefined, scriptKind, statements, newLineCharacter, formatContext);
|
|
@@ -150928,7 +151164,7 @@ var ts;
|
|
|
150928
151164
|
changeTracker.insertNodeAfter(sourceFile, constructor, newElement);
|
|
150929
151165
|
}
|
|
150930
151166
|
else {
|
|
150931
|
-
changeTracker.
|
|
151167
|
+
changeTracker.insertMemberAtStart(sourceFile, cls, newElement);
|
|
150932
151168
|
}
|
|
150933
151169
|
}
|
|
150934
151170
|
}
|
|
@@ -152712,7 +152948,7 @@ var ts;
|
|
|
152712
152948
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
|
|
152713
152949
|
return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
|
|
152714
152950
|
}
|
|
152715
|
-
if (info.kind ===
|
|
152951
|
+
if (info.kind === 1 /* Enum */) {
|
|
152716
152952
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
|
|
152717
152953
|
return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
|
|
152718
152954
|
}
|
|
@@ -152740,10 +152976,10 @@ var ts;
|
|
|
152740
152976
|
addJsxAttributes(changes, context, info);
|
|
152741
152977
|
}
|
|
152742
152978
|
else {
|
|
152743
|
-
if (info.kind ===
|
|
152979
|
+
if (info.kind === 1 /* Enum */) {
|
|
152744
152980
|
addEnumMemberDeclaration(changes, checker, info);
|
|
152745
152981
|
}
|
|
152746
|
-
if (info.kind ===
|
|
152982
|
+
if (info.kind === 0 /* TypeLikeDeclaration */) {
|
|
152747
152983
|
var parentDeclaration = info.parentDeclaration, token_1 = info.token;
|
|
152748
152984
|
var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
|
|
152749
152985
|
if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
|
|
@@ -152752,11 +152988,11 @@ var ts;
|
|
|
152752
152988
|
}
|
|
152753
152989
|
}
|
|
152754
152990
|
});
|
|
152755
|
-
typeDeclToMembers.forEach(function (infos,
|
|
152756
|
-
var supers = codefix.getAllSupers(
|
|
152991
|
+
typeDeclToMembers.forEach(function (infos, declaration) {
|
|
152992
|
+
var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
|
|
152757
152993
|
var _loop_15 = function (info) {
|
|
152758
152994
|
// If some superclass added this property, don't add it again.
|
|
152759
|
-
if (supers.some(function (superClassOrInterface) {
|
|
152995
|
+
if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
|
|
152760
152996
|
var superInfos = typeDeclToMembers.get(superClassOrInterface);
|
|
152761
152997
|
return !!superInfos && superInfos.some(function (_a) {
|
|
152762
152998
|
var token = _a.token;
|
|
@@ -152770,11 +153006,11 @@ var ts;
|
|
|
152770
153006
|
addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile);
|
|
152771
153007
|
}
|
|
152772
153008
|
else {
|
|
152773
|
-
if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration)) {
|
|
153009
|
+
if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) {
|
|
152774
153010
|
addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */));
|
|
152775
153011
|
}
|
|
152776
153012
|
else {
|
|
152777
|
-
var typeNode = getTypeNode(
|
|
153013
|
+
var typeNode = getTypeNode(checker, parentDeclaration, token);
|
|
152778
153014
|
addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */);
|
|
152779
153015
|
}
|
|
152780
153016
|
}
|
|
@@ -152789,8 +153025,8 @@ var ts;
|
|
|
152789
153025
|
});
|
|
152790
153026
|
var InfoKind;
|
|
152791
153027
|
(function (InfoKind) {
|
|
152792
|
-
InfoKind[InfoKind["
|
|
152793
|
-
InfoKind[InfoKind["
|
|
153028
|
+
InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
|
|
153029
|
+
InfoKind[InfoKind["Enum"] = 1] = "Enum";
|
|
152794
153030
|
InfoKind[InfoKind["Function"] = 2] = "Function";
|
|
152795
153031
|
InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
|
|
152796
153032
|
InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
|
|
@@ -152860,20 +153096,21 @@ var ts;
|
|
|
152860
153096
|
if (!classDeclaration && ts.isPrivateIdentifier(token))
|
|
152861
153097
|
return undefined;
|
|
152862
153098
|
// Prefer to change the class instead of the interface if they are merged
|
|
152863
|
-
var
|
|
152864
|
-
if (
|
|
152865
|
-
var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
152866
|
-
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(
|
|
153099
|
+
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
153100
|
+
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
153101
|
+
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
153102
|
+
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
152867
153103
|
return undefined;
|
|
152868
|
-
var declSourceFile =
|
|
152869
|
-
var modifierFlags =
|
|
153104
|
+
var declSourceFile = declaration.getSourceFile();
|
|
153105
|
+
var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ :
|
|
153106
|
+
(makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
|
|
152870
153107
|
var isJSFile = ts.isSourceFileJS(declSourceFile);
|
|
152871
153108
|
var call = ts.tryCast(parent.parent, ts.isCallExpression);
|
|
152872
|
-
return { kind:
|
|
153109
|
+
return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
152873
153110
|
}
|
|
152874
153111
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
152875
153112
|
if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
152876
|
-
return { kind:
|
|
153113
|
+
return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
|
|
152877
153114
|
}
|
|
152878
153115
|
return undefined;
|
|
152879
153116
|
}
|
|
@@ -152886,7 +153123,7 @@ var ts;
|
|
|
152886
153123
|
}
|
|
152887
153124
|
function createActionForAddMissingMemberInJavascriptFile(context, _a) {
|
|
152888
153125
|
var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token;
|
|
152889
|
-
if (ts.isInterfaceDeclaration(parentDeclaration)) {
|
|
153126
|
+
if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) {
|
|
152890
153127
|
return undefined;
|
|
152891
153128
|
}
|
|
152892
153129
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); });
|
|
@@ -152897,7 +153134,7 @@ var ts;
|
|
|
152897
153134
|
ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor;
|
|
152898
153135
|
return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members);
|
|
152899
153136
|
}
|
|
152900
|
-
function addMissingMemberInJs(changeTracker,
|
|
153137
|
+
function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) {
|
|
152901
153138
|
var tokenName = token.text;
|
|
152902
153139
|
if (makeStatic) {
|
|
152903
153140
|
if (classDeclaration.kind === 226 /* ClassExpression */) {
|
|
@@ -152905,7 +153142,7 @@ var ts;
|
|
|
152905
153142
|
}
|
|
152906
153143
|
var className = classDeclaration.name.getText();
|
|
152907
153144
|
var staticInitialization = initializePropertyToUndefined(ts.factory.createIdentifier(className), tokenName);
|
|
152908
|
-
changeTracker.insertNodeAfter(
|
|
153145
|
+
changeTracker.insertNodeAfter(sourceFile, classDeclaration, staticInitialization);
|
|
152909
153146
|
}
|
|
152910
153147
|
else if (ts.isPrivateIdentifier(token)) {
|
|
152911
153148
|
var property = ts.factory.createPropertyDeclaration(
|
|
@@ -152916,10 +153153,10 @@ var ts;
|
|
|
152916
153153
|
/*initializer*/ undefined);
|
|
152917
153154
|
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
|
|
152918
153155
|
if (lastProp) {
|
|
152919
|
-
changeTracker.insertNodeAfter(
|
|
153156
|
+
changeTracker.insertNodeAfter(sourceFile, lastProp, property);
|
|
152920
153157
|
}
|
|
152921
153158
|
else {
|
|
152922
|
-
changeTracker.
|
|
153159
|
+
changeTracker.insertMemberAtStart(sourceFile, classDeclaration, property);
|
|
152923
153160
|
}
|
|
152924
153161
|
}
|
|
152925
153162
|
else {
|
|
@@ -152928,7 +153165,7 @@ var ts;
|
|
|
152928
153165
|
return;
|
|
152929
153166
|
}
|
|
152930
153167
|
var propertyInitialization = initializePropertyToUndefined(ts.factory.createThis(), tokenName);
|
|
152931
|
-
changeTracker.insertNodeAtConstructorEnd(
|
|
153168
|
+
changeTracker.insertNodeAtConstructorEnd(sourceFile, classConstructor, propertyInitialization);
|
|
152932
153169
|
}
|
|
152933
153170
|
}
|
|
152934
153171
|
function initializePropertyToUndefined(obj, propertyName) {
|
|
@@ -152950,13 +153187,13 @@ var ts;
|
|
|
152950
153187
|
actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode));
|
|
152951
153188
|
return actions;
|
|
152952
153189
|
}
|
|
152953
|
-
function getTypeNode(checker,
|
|
153190
|
+
function getTypeNode(checker, node, token) {
|
|
152954
153191
|
var typeNode;
|
|
152955
153192
|
if (token.parent.parent.kind === 221 /* BinaryExpression */) {
|
|
152956
153193
|
var binaryExpression = token.parent.parent;
|
|
152957
153194
|
var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
|
|
152958
153195
|
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
|
|
152959
|
-
typeNode = checker.typeToTypeNode(widenedType,
|
|
153196
|
+
typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */);
|
|
152960
153197
|
}
|
|
152961
153198
|
else {
|
|
152962
153199
|
var contextualType = checker.getContextualType(token.parent);
|
|
@@ -152964,24 +153201,23 @@ var ts;
|
|
|
152964
153201
|
}
|
|
152965
153202
|
return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
|
|
152966
153203
|
}
|
|
152967
|
-
function addPropertyDeclaration(changeTracker,
|
|
152968
|
-
var
|
|
152969
|
-
|
|
152970
|
-
|
|
152971
|
-
|
|
152972
|
-
|
|
152973
|
-
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
|
|
153204
|
+
function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) {
|
|
153205
|
+
var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
|
|
153206
|
+
var property = ts.isClassLike(node)
|
|
153207
|
+
? ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined)
|
|
153208
|
+
: ts.factory.createPropertySignature(/*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, typeNode);
|
|
153209
|
+
var lastProp = getNodeToInsertPropertyAfter(node);
|
|
152974
153210
|
if (lastProp) {
|
|
152975
|
-
changeTracker.insertNodeAfter(
|
|
153211
|
+
changeTracker.insertNodeAfter(sourceFile, lastProp, property);
|
|
152976
153212
|
}
|
|
152977
153213
|
else {
|
|
152978
|
-
changeTracker.
|
|
153214
|
+
changeTracker.insertMemberAtStart(sourceFile, node, property);
|
|
152979
153215
|
}
|
|
152980
153216
|
}
|
|
152981
153217
|
// Gets the last of the first run of PropertyDeclarations, or undefined if the class does not start with a PropertyDeclaration.
|
|
152982
|
-
function getNodeToInsertPropertyAfter(
|
|
153218
|
+
function getNodeToInsertPropertyAfter(node) {
|
|
152983
153219
|
var res;
|
|
152984
|
-
for (var _i = 0, _a =
|
|
153220
|
+
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
152985
153221
|
var member = _a[_i];
|
|
152986
153222
|
if (!ts.isPropertyDeclaration(member))
|
|
152987
153223
|
break;
|
|
@@ -152989,7 +153225,7 @@ var ts;
|
|
|
152989
153225
|
}
|
|
152990
153226
|
return res;
|
|
152991
153227
|
}
|
|
152992
|
-
function createAddIndexSignatureAction(context,
|
|
153228
|
+
function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) {
|
|
152993
153229
|
// Index signatures cannot have the static modifier.
|
|
152994
153230
|
var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */);
|
|
152995
153231
|
var indexingParameter = ts.factory.createParameterDeclaration(
|
|
@@ -153001,7 +153237,7 @@ var ts;
|
|
|
153001
153237
|
var indexSignature = ts.factory.createIndexSignature(
|
|
153002
153238
|
/*decorators*/ undefined,
|
|
153003
153239
|
/*modifiers*/ undefined, [indexingParameter], typeNode);
|
|
153004
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.
|
|
153240
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.insertMemberAtStart(sourceFile, node, indexSignature); });
|
|
153005
153241
|
// No fixId here because code-fix-all currently only works on adding individual named properties.
|
|
153006
153242
|
return codefix.createCodeFixActionWithoutFixAll(fixMissingMember, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
|
|
153007
153243
|
}
|
|
@@ -153024,13 +153260,14 @@ var ts;
|
|
|
153024
153260
|
}
|
|
153025
153261
|
function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) {
|
|
153026
153262
|
var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host);
|
|
153027
|
-
var
|
|
153028
|
-
var
|
|
153029
|
-
|
|
153030
|
-
|
|
153263
|
+
var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */;
|
|
153264
|
+
var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration);
|
|
153265
|
+
var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression);
|
|
153266
|
+
if (containingMethodDeclaration) {
|
|
153267
|
+
changes.insertNodeAfter(sourceFile, containingMethodDeclaration, signatureDeclaration);
|
|
153031
153268
|
}
|
|
153032
153269
|
else {
|
|
153033
|
-
changes.
|
|
153270
|
+
changes.insertMemberAtStart(sourceFile, parentDeclaration, signatureDeclaration);
|
|
153034
153271
|
}
|
|
153035
153272
|
importAdder.writeFixes(changes);
|
|
153036
153273
|
}
|
|
@@ -153193,6 +153430,13 @@ var ts;
|
|
|
153193
153430
|
return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
153194
153431
|
});
|
|
153195
153432
|
}
|
|
153433
|
+
function tryGetContainingMethodDeclaration(node, callExpression) {
|
|
153434
|
+
if (ts.isTypeLiteralNode(node)) {
|
|
153435
|
+
return undefined;
|
|
153436
|
+
}
|
|
153437
|
+
var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); });
|
|
153438
|
+
return declaration && declaration.parent === node ? declaration : undefined;
|
|
153439
|
+
}
|
|
153196
153440
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
153197
153441
|
})(ts || (ts = {}));
|
|
153198
153442
|
/* @internal */
|
|
@@ -153336,7 +153580,7 @@ var ts;
|
|
|
153336
153580
|
// so duplicates cannot occur.
|
|
153337
153581
|
var abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember);
|
|
153338
153582
|
var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
|
|
153339
|
-
codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.
|
|
153583
|
+
codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.insertMemberAtStart(sourceFile, classDeclaration, member); });
|
|
153340
153584
|
importAdder.writeFixes(changeTracker);
|
|
153341
153585
|
}
|
|
153342
153586
|
function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
@@ -155909,13 +156153,20 @@ var ts;
|
|
|
155909
156153
|
var type = isJs || contextualType === undefined
|
|
155910
156154
|
? undefined
|
|
155911
156155
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
155912
|
-
|
|
155913
|
-
|
|
155914
|
-
|
|
155915
|
-
|
|
156156
|
+
switch (kind) {
|
|
156157
|
+
case 169 /* MethodDeclaration */:
|
|
156158
|
+
return ts.factory.createMethodDeclaration(
|
|
156159
|
+
/*decorators*/ undefined, modifiers, asteriskToken, name,
|
|
156160
|
+
/*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
|
|
156161
|
+
case 168 /* MethodSignature */:
|
|
156162
|
+
return ts.factory.createMethodSignature(modifiers, name,
|
|
156163
|
+
/*questionToken*/ undefined, typeParameters, parameters, type);
|
|
156164
|
+
case 256 /* FunctionDeclaration */:
|
|
156165
|
+
return ts.factory.createFunctionDeclaration(
|
|
156166
|
+
/*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
|
|
156167
|
+
default:
|
|
156168
|
+
ts.Debug.fail("Unexpected kind");
|
|
155916
156169
|
}
|
|
155917
|
-
return ts.factory.createFunctionDeclaration(
|
|
155918
|
-
/*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
|
|
155919
156170
|
}
|
|
155920
156171
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
155921
156172
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
@@ -156241,7 +156492,7 @@ var ts;
|
|
|
156241
156492
|
}
|
|
156242
156493
|
}
|
|
156243
156494
|
function insertAccessor(changeTracker, file, accessor, declaration, container) {
|
|
156244
|
-
ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.
|
|
156495
|
+
ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertMemberAtStart(file, container, accessor) :
|
|
156245
156496
|
ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) :
|
|
156246
156497
|
changeTracker.insertNodeAfter(file, declaration, accessor);
|
|
156247
156498
|
}
|
|
@@ -174851,10 +175102,26 @@ var ts;
|
|
|
174851
175102
|
var prefix = args.prefix || "";
|
|
174852
175103
|
var entries = ts.mapDefined(completions.entries, function (entry) {
|
|
174853
175104
|
if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) {
|
|
174854
|
-
var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data;
|
|
175105
|
+
var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, labelDetails = entry.labelDetails, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data;
|
|
174855
175106
|
var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined;
|
|
174856
175107
|
// Use `hasAction || undefined` to avoid serializing `false`.
|
|
174857
|
-
return {
|
|
175108
|
+
return {
|
|
175109
|
+
name: name,
|
|
175110
|
+
kind: kind_1,
|
|
175111
|
+
kindModifiers: kindModifiers,
|
|
175112
|
+
sortText: sortText,
|
|
175113
|
+
insertText: insertText,
|
|
175114
|
+
replacementSpan: convertedSpan,
|
|
175115
|
+
isSnippet: isSnippet,
|
|
175116
|
+
hasAction: hasAction || undefined,
|
|
175117
|
+
source: source,
|
|
175118
|
+
sourceDisplay: sourceDisplay,
|
|
175119
|
+
labelDetails: labelDetails,
|
|
175120
|
+
isRecommended: isRecommended,
|
|
175121
|
+
isPackageJsonImport: isPackageJsonImport,
|
|
175122
|
+
isImportStatementCompletion: isImportStatementCompletion,
|
|
175123
|
+
data: data
|
|
175124
|
+
};
|
|
174858
175125
|
}
|
|
174859
175126
|
});
|
|
174860
175127
|
if (kind === "completions" /* Completions */) {
|