typescript 4.7.0-dev.20220327 → 4.7.0-dev.20220330
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/de/diagnosticMessages.generated.json +1 -0
- package/lib/ja/diagnosticMessages.generated.json +1 -0
- package/lib/ko/diagnosticMessages.generated.json +1 -0
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/protocol.d.ts +7 -0
- package/lib/ru/diagnosticMessages.generated.json +1 -0
- package/lib/tr/diagnosticMessages.generated.json +1 -0
- package/lib/tsc.js +127 -134
- package/lib/tsserver.js +455 -271
- package/lib/tsserverlibrary.d.ts +8 -0
- package/lib/tsserverlibrary.js +455 -271
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +455 -271
- package/lib/typescriptServices.d.ts +1 -0
- package/lib/typescriptServices.js +455 -271
- package/lib/typingsInstaller.js +140 -147
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220330";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -13606,7 +13606,9 @@ var ts;
|
|
|
13606
13606
|
|| kind === 174 /* CallSignature */
|
|
13607
13607
|
|| kind === 166 /* PropertySignature */
|
|
13608
13608
|
|| kind === 168 /* MethodSignature */
|
|
13609
|
-
|| kind === 176 /* IndexSignature
|
|
13609
|
+
|| kind === 176 /* IndexSignature */
|
|
13610
|
+
|| kind === 172 /* GetAccessor */
|
|
13611
|
+
|| kind === 173 /* SetAccessor */;
|
|
13610
13612
|
}
|
|
13611
13613
|
ts.isTypeElement = isTypeElement;
|
|
13612
13614
|
function isClassOrTypeElement(node) {
|
|
@@ -47588,6 +47590,7 @@ var ts;
|
|
|
47588
47590
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47589
47591
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47590
47592
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47593
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47591
47594
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47592
47595
|
var CheckMode;
|
|
47593
47596
|
(function (CheckMode) {
|
|
@@ -47597,7 +47600,8 @@ var ts;
|
|
|
47597
47600
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47598
47601
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47599
47602
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47600
|
-
CheckMode[CheckMode["
|
|
47603
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47604
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47601
47605
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47602
47606
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47603
47607
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47935,26 +47939,10 @@ var ts;
|
|
|
47935
47939
|
if (!node) {
|
|
47936
47940
|
return undefined;
|
|
47937
47941
|
}
|
|
47938
|
-
|
|
47939
|
-
|
|
47940
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47941
|
-
var toMarkSkip = node;
|
|
47942
|
-
do {
|
|
47943
|
-
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47944
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47945
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47946
|
-
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47947
|
-
}
|
|
47948
|
-
var result = getContextualType(node, contextFlags);
|
|
47949
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47950
|
-
var toMarkSkip = node;
|
|
47951
|
-
do {
|
|
47952
|
-
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47953
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47954
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47955
|
-
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47942
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47943
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47956
47944
|
}
|
|
47957
|
-
return
|
|
47945
|
+
return getContextualType(node, contextFlags);
|
|
47958
47946
|
},
|
|
47959
47947
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47960
47948
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47974,6 +47962,9 @@ var ts;
|
|
|
47974
47962
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47975
47963
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47976
47964
|
},
|
|
47965
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47966
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47967
|
+
},
|
|
47977
47968
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47978
47969
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47979
47970
|
},
|
|
@@ -48126,10 +48117,34 @@ var ts;
|
|
|
48126
48117
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
48127
48118
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
48128
48119
|
};
|
|
48129
|
-
function
|
|
48120
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
48121
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
48122
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
48123
|
+
if (containingCall) {
|
|
48124
|
+
var toMarkSkip = node;
|
|
48125
|
+
do {
|
|
48126
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
48127
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48128
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48129
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
48130
|
+
}
|
|
48131
|
+
var result = fn();
|
|
48132
|
+
if (containingCall) {
|
|
48133
|
+
var toMarkSkip = node;
|
|
48134
|
+
do {
|
|
48135
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
48136
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48137
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48138
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
48139
|
+
}
|
|
48140
|
+
return result;
|
|
48141
|
+
}
|
|
48142
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
48130
48143
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
48131
48144
|
apparentArgumentCount = argumentCount;
|
|
48132
|
-
var res = node ?
|
|
48145
|
+
var res = !node ? undefined :
|
|
48146
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
48147
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
48133
48148
|
apparentArgumentCount = undefined;
|
|
48134
48149
|
return res;
|
|
48135
48150
|
}
|
|
@@ -49102,6 +49117,10 @@ var ts;
|
|
|
49102
49117
|
}
|
|
49103
49118
|
}
|
|
49104
49119
|
}
|
|
49120
|
+
function isConstAssertion(location) {
|
|
49121
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
49122
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
49123
|
+
}
|
|
49105
49124
|
/**
|
|
49106
49125
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
49107
49126
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -49127,6 +49146,11 @@ var ts;
|
|
|
49127
49146
|
var grandparent;
|
|
49128
49147
|
var isInExternalModule = false;
|
|
49129
49148
|
loop: while (location) {
|
|
49149
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
49150
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
49151
|
+
// (it refers to the constant type of the expression instead)
|
|
49152
|
+
return undefined;
|
|
49153
|
+
}
|
|
49130
49154
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
49131
49155
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
49132
49156
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -55075,6 +55099,8 @@ var ts;
|
|
|
55075
55099
|
return !!target.resolvedTypeArguments;
|
|
55076
55100
|
case 7 /* ResolvedBaseTypes */:
|
|
55077
55101
|
return !!target.baseTypesResolved;
|
|
55102
|
+
case 8 /* WriteType */:
|
|
55103
|
+
return !!getSymbolLinks(target).writeType;
|
|
55078
55104
|
}
|
|
55079
55105
|
return ts.Debug.assertNever(propertyName);
|
|
55080
55106
|
}
|
|
@@ -55252,7 +55278,7 @@ var ts;
|
|
|
55252
55278
|
}
|
|
55253
55279
|
/** Return the inferred type for a binding element */
|
|
55254
55280
|
function getTypeForBindingElement(declaration) {
|
|
55255
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55281
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55256
55282
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55257
55283
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55258
55284
|
}
|
|
@@ -55992,6 +56018,11 @@ var ts;
|
|
|
55992
56018
|
}
|
|
55993
56019
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55994
56020
|
}
|
|
56021
|
+
if (ts.isAccessor(declaration)) {
|
|
56022
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
56023
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
56024
|
+
return getTypeOfAccessors(symbol);
|
|
56025
|
+
}
|
|
55995
56026
|
// Handle variable, parameter or property
|
|
55996
56027
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55997
56028
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -56055,9 +56086,6 @@ var ts;
|
|
|
56055
56086
|
else if (ts.isEnumMember(declaration)) {
|
|
56056
56087
|
type = getTypeOfEnumMember(symbol);
|
|
56057
56088
|
}
|
|
56058
|
-
else if (ts.isAccessor(declaration)) {
|
|
56059
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
56060
|
-
}
|
|
56061
56089
|
else {
|
|
56062
56090
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
56063
56091
|
}
|
|
@@ -56096,87 +56124,61 @@ var ts;
|
|
|
56096
56124
|
}
|
|
56097
56125
|
function getTypeOfAccessors(symbol) {
|
|
56098
56126
|
var links = getSymbolLinks(symbol);
|
|
56099
|
-
|
|
56100
|
-
|
|
56101
|
-
|
|
56102
|
-
|
|
56103
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
|
|
56104
|
-
}
|
|
56105
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
56106
|
-
if (writing === void 0) { writing = false; }
|
|
56107
|
-
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
56108
|
-
return errorType;
|
|
56109
|
-
}
|
|
56110
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
56111
|
-
if (!popTypeResolution()) {
|
|
56127
|
+
if (!links.type) {
|
|
56128
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
56129
|
+
return errorType;
|
|
56130
|
+
}
|
|
56112
56131
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56132
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56133
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
56134
|
+
// body return type inference, in that order.
|
|
56135
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
56136
|
+
getAnnotatedAccessorType(getter) ||
|
|
56137
|
+
getAnnotatedAccessorType(setter) ||
|
|
56138
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
56139
|
+
if (!type) {
|
|
56140
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
56141
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
56142
|
+
}
|
|
56143
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
56144
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56145
|
+
}
|
|
56146
|
+
type = anyType;
|
|
56147
|
+
}
|
|
56148
|
+
if (!popTypeResolution()) {
|
|
56149
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
56150
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56151
|
+
}
|
|
56152
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56153
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56116
56154
|
}
|
|
56117
|
-
else if (noImplicitAny) {
|
|
56155
|
+
else if (getter && noImplicitAny) {
|
|
56118
56156
|
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));
|
|
56119
56157
|
}
|
|
56158
|
+
type = anyType;
|
|
56120
56159
|
}
|
|
56121
|
-
type =
|
|
56160
|
+
links.type = type;
|
|
56122
56161
|
}
|
|
56123
|
-
return type;
|
|
56162
|
+
return links.type;
|
|
56124
56163
|
}
|
|
56125
|
-
function
|
|
56126
|
-
|
|
56127
|
-
|
|
56128
|
-
|
|
56129
|
-
|
|
56130
|
-
if (writing) {
|
|
56131
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
56132
|
-
if (setterType_1) {
|
|
56133
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
56134
|
-
}
|
|
56135
|
-
}
|
|
56136
|
-
// Else defer to the getter type
|
|
56137
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
56138
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
56139
|
-
if (jsDocType) {
|
|
56140
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
56141
|
-
}
|
|
56142
|
-
}
|
|
56143
|
-
// Try to see if the user specified a return type on the get-accessor.
|
|
56144
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
56145
|
-
if (getterType) {
|
|
56146
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
56147
|
-
}
|
|
56148
|
-
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
56149
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
56150
|
-
if (setterType) {
|
|
56151
|
-
return setterType;
|
|
56152
|
-
}
|
|
56153
|
-
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
|
56154
|
-
if (getter && getter.body) {
|
|
56155
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
56156
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
56157
|
-
}
|
|
56158
|
-
// Otherwise, fall back to 'any'.
|
|
56159
|
-
if (setter) {
|
|
56160
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
56161
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
56162
|
-
}
|
|
56163
|
-
return anyType;
|
|
56164
|
-
}
|
|
56165
|
-
else if (getter) {
|
|
56166
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
56167
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
56168
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56164
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
56165
|
+
var links = getSymbolLinks(symbol);
|
|
56166
|
+
if (!links.writeType) {
|
|
56167
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
56168
|
+
return errorType;
|
|
56169
56169
|
}
|
|
56170
|
-
|
|
56171
|
-
|
|
56172
|
-
|
|
56173
|
-
|
|
56174
|
-
|
|
56175
|
-
|
|
56176
|
-
|
|
56170
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56171
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
56172
|
+
if (!popTypeResolution()) {
|
|
56173
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56174
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56175
|
+
}
|
|
56176
|
+
writeType = anyType;
|
|
56177
56177
|
}
|
|
56178
|
-
|
|
56178
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
56179
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
56179
56180
|
}
|
|
56181
|
+
return links.writeType;
|
|
56180
56182
|
}
|
|
56181
56183
|
function getBaseTypeVariableOfClass(symbol) {
|
|
56182
56184
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56258,17 +56260,11 @@ var ts;
|
|
|
56258
56260
|
}
|
|
56259
56261
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56260
56262
|
var links = getSymbolLinks(symbol);
|
|
56261
|
-
|
|
56262
|
-
|
|
56263
|
-
|
|
56264
|
-
|
|
56265
|
-
|
|
56266
|
-
if (!popTypeResolution()) {
|
|
56267
|
-
type = reportCircularityError(symbol);
|
|
56268
|
-
}
|
|
56269
|
-
links.type = type;
|
|
56270
|
-
}
|
|
56271
|
-
return links.type;
|
|
56263
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56264
|
+
}
|
|
56265
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56266
|
+
var links = getSymbolLinks(symbol);
|
|
56267
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56272
56268
|
}
|
|
56273
56269
|
function reportCircularityError(symbol) {
|
|
56274
56270
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56305,35 +56301,23 @@ var ts;
|
|
|
56305
56301
|
return links.writeType;
|
|
56306
56302
|
}
|
|
56307
56303
|
/**
|
|
56308
|
-
* Distinct write types come only from set accessors, but union and intersection
|
|
56309
|
-
* properties deriving from set accessors will either pre-compute or defer the
|
|
56310
|
-
*
|
|
56311
|
-
* this, we will assume that any deferred type or transient symbol may have a
|
|
56312
|
-
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
56313
|
-
* used before looking for set accessor declarations.
|
|
56304
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56305
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56306
|
+
* intersection of the writeTypes of their constituents.
|
|
56314
56307
|
*/
|
|
56315
56308
|
function getWriteTypeOfSymbol(symbol) {
|
|
56316
56309
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56317
|
-
if (
|
|
56318
|
-
|
|
56319
|
-
|
|
56320
|
-
|
|
56321
|
-
|
|
56322
|
-
|
|
56323
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56324
|
-
var writeType = symbol.writeType;
|
|
56325
|
-
if (writeType) {
|
|
56326
|
-
return writeType;
|
|
56327
|
-
}
|
|
56310
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56311
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56312
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56313
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56314
|
+
symbol.writeType || symbol.type :
|
|
56315
|
+
getTypeOfSymbol(symbol);
|
|
56328
56316
|
}
|
|
56329
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56330
|
-
}
|
|
56331
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56332
56317
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56333
|
-
|
|
56334
|
-
|
|
56335
|
-
|
|
56336
|
-
}
|
|
56318
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56319
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56320
|
+
getWriteTypeOfAccessors(symbol);
|
|
56337
56321
|
}
|
|
56338
56322
|
return getTypeOfSymbol(symbol);
|
|
56339
56323
|
}
|
|
@@ -68422,7 +68406,7 @@ var ts;
|
|
|
68422
68406
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68423
68407
|
var targetProp = properties_3[_i];
|
|
68424
68408
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68425
|
-
if (sourceProp) {
|
|
68409
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68426
68410
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68427
68411
|
}
|
|
68428
68412
|
}
|
|
@@ -70804,7 +70788,7 @@ var ts;
|
|
|
70804
70788
|
}
|
|
70805
70789
|
}
|
|
70806
70790
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70807
|
-
return
|
|
70791
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70808
70792
|
}
|
|
70809
70793
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70810
70794
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -70896,7 +70880,7 @@ var ts;
|
|
|
70896
70880
|
// as we want the type of a rest element to be generic when possible.
|
|
70897
70881
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70898
70882
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70899
|
-
(checkMode && checkMode &
|
|
70883
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70900
70884
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70901
70885
|
: getContextualType(node));
|
|
70902
70886
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -71835,7 +71819,7 @@ var ts;
|
|
|
71835
71819
|
var parent = declaration.parent.parent;
|
|
71836
71820
|
var name = declaration.propertyName || declaration.name;
|
|
71837
71821
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71838
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71822
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71839
71823
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71840
71824
|
return undefined;
|
|
71841
71825
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -74889,7 +74873,7 @@ var ts;
|
|
|
74889
74873
|
}
|
|
74890
74874
|
for (var i = 0; i < argCount; i++) {
|
|
74891
74875
|
var arg = args[i];
|
|
74892
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74876
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74893
74877
|
var paramType = getTypeAtPosition(signature, i);
|
|
74894
74878
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74895
74879
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75574,7 +75558,7 @@ var ts;
|
|
|
75574
75558
|
}
|
|
75575
75559
|
}
|
|
75576
75560
|
}
|
|
75577
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75561
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75578
75562
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75579
75563
|
var _a, _b;
|
|
75580
75564
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75675,14 +75659,14 @@ var ts;
|
|
|
75675
75659
|
}
|
|
75676
75660
|
}
|
|
75677
75661
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75678
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75662
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75679
75663
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75680
75664
|
checkNodeDeferred(node);
|
|
75681
75665
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75682
75666
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75683
75667
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75684
75668
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75685
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75669
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75686
75670
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75687
75671
|
}
|
|
75688
75672
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75730,7 +75714,7 @@ var ts;
|
|
|
75730
75714
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75731
75715
|
return createSymbolWithType(ts.first(sources), type);
|
|
75732
75716
|
}
|
|
75733
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75717
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75734
75718
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75735
75719
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75736
75720
|
// f({ |
|
|
@@ -75746,7 +75730,7 @@ var ts;
|
|
|
75746
75730
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75747
75731
|
var instantiated = typeArgumentNodes
|
|
75748
75732
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75749
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75733
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75750
75734
|
candidates[bestIndex] = instantiated;
|
|
75751
75735
|
return instantiated;
|
|
75752
75736
|
}
|
|
@@ -75760,9 +75744,9 @@ var ts;
|
|
|
75760
75744
|
}
|
|
75761
75745
|
return typeArguments;
|
|
75762
75746
|
}
|
|
75763
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75747
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75764
75748
|
var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
|
|
75765
|
-
var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75749
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75766
75750
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75767
75751
|
}
|
|
75768
75752
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81828,7 +81812,7 @@ var ts;
|
|
|
81828
81812
|
}
|
|
81829
81813
|
// check private/protected variable access
|
|
81830
81814
|
var parent = node.parent.parent;
|
|
81831
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81815
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81832
81816
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81833
81817
|
var name = node.propertyName || node.name;
|
|
81834
81818
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -82007,6 +81991,8 @@ var ts;
|
|
|
82007
81991
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
82008
81992
|
? condExpr.right
|
|
82009
81993
|
: condExpr;
|
|
81994
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81995
|
+
return;
|
|
82010
81996
|
var type = checkTruthinessExpression(location);
|
|
82011
81997
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82012
81998
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -116924,6 +116910,13 @@ var ts;
|
|
|
116924
116910
|
return "skip";
|
|
116925
116911
|
}
|
|
116926
116912
|
break;
|
|
116913
|
+
case 270 /* ImportSpecifier */:
|
|
116914
|
+
case 275 /* ExportSpecifier */:
|
|
116915
|
+
if (node.isTypeOnly) {
|
|
116916
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116917
|
+
return "skip";
|
|
116918
|
+
}
|
|
116919
|
+
break;
|
|
116927
116920
|
case 265 /* ImportEqualsDeclaration */:
|
|
116928
116921
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116929
116922
|
return "skip";
|
|
@@ -126684,12 +126677,8 @@ var ts;
|
|
|
126684
126677
|
}
|
|
126685
126678
|
}
|
|
126686
126679
|
ts.findNextToken = findNextToken;
|
|
126687
|
-
/**
|
|
126688
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126689
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126690
|
-
*/
|
|
126691
126680
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126692
|
-
var result = find(startNode || sourceFile);
|
|
126681
|
+
var result = find((startNode || sourceFile));
|
|
126693
126682
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126694
126683
|
return result;
|
|
126695
126684
|
function find(n) {
|
|
@@ -127789,6 +127778,14 @@ var ts;
|
|
|
127789
127778
|
});
|
|
127790
127779
|
}
|
|
127791
127780
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127781
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127782
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127783
|
+
return mapToDisplayParts(function (writer) {
|
|
127784
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127785
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127786
|
+
});
|
|
127787
|
+
}
|
|
127788
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127792
127789
|
function isImportOrExportSpecifierName(location) {
|
|
127793
127790
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127794
127791
|
}
|
|
@@ -130485,12 +130482,13 @@ var ts;
|
|
|
130485
130482
|
}
|
|
130486
130483
|
case 208 /* CallExpression */:
|
|
130487
130484
|
case 209 /* NewExpression */:
|
|
130485
|
+
case 285 /* JsxAttribute */:
|
|
130488
130486
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
130489
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
130487
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
130490
130488
|
// Get string literal completions from specialized signatures of the target
|
|
130491
130489
|
// i.e. declare function f(a: 'A');
|
|
130492
130490
|
// f("/*completion position*/")
|
|
130493
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
130491
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
130494
130492
|
}
|
|
130495
130493
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
130496
130494
|
case 266 /* ImportDeclaration */:
|
|
@@ -130527,15 +130525,22 @@ var ts;
|
|
|
130527
130525
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
130528
130526
|
});
|
|
130529
130527
|
}
|
|
130530
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
130528
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
130531
130529
|
var isNewIdentifier = false;
|
|
130532
130530
|
var uniques = new ts.Map();
|
|
130533
130531
|
var candidates = [];
|
|
130534
|
-
|
|
130532
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
130533
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
130535
130534
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
130536
130535
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
130537
130536
|
return;
|
|
130538
130537
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
130538
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
130539
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
130540
|
+
if (propType) {
|
|
130541
|
+
type = propType;
|
|
130542
|
+
}
|
|
130543
|
+
}
|
|
130539
130544
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
130540
130545
|
return getStringLiteralTypes(type, uniques);
|
|
130541
130546
|
});
|
|
@@ -131078,43 +131083,28 @@ var ts;
|
|
|
131078
131083
|
// Exported only for tests
|
|
131079
131084
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
131080
131085
|
Completions.moduleSpecifierResolutionCacheAttemptLimit = 1000;
|
|
131081
|
-
|
|
131082
|
-
|
|
131083
|
-
|
|
131084
|
-
|
|
131085
|
-
|
|
131086
|
-
|
|
131087
|
-
|
|
131088
|
-
|
|
131089
|
-
|
|
131090
|
-
|
|
131091
|
-
|
|
131092
|
-
|
|
131093
|
-
|
|
131094
|
-
|
|
131095
|
-
|
|
131096
|
-
|
|
131097
|
-
|
|
131098
|
-
|
|
131099
|
-
|
|
131100
|
-
|
|
131101
|
-
|
|
131102
|
-
}
|
|
131103
|
-
var SortTextId;
|
|
131104
|
-
(function (SortTextId) {
|
|
131105
|
-
SortTextId[SortTextId["LocalDeclarationPriority"] = 10] = "LocalDeclarationPriority";
|
|
131106
|
-
SortTextId[SortTextId["LocationPriority"] = 11] = "LocationPriority";
|
|
131107
|
-
SortTextId[SortTextId["OptionalMember"] = 12] = "OptionalMember";
|
|
131108
|
-
SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 13] = "MemberDeclaredBySpreadAssignment";
|
|
131109
|
-
SortTextId[SortTextId["SuggestedClassMembers"] = 14] = "SuggestedClassMembers";
|
|
131110
|
-
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
131111
|
-
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
131112
|
-
// Don't use these directly.
|
|
131113
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
131114
|
-
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
131115
|
-
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
131116
|
-
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
131117
|
-
})(SortTextId || (SortTextId = {}));
|
|
131086
|
+
Completions.SortText = {
|
|
131087
|
+
// Presets
|
|
131088
|
+
LocalDeclarationPriority: "10",
|
|
131089
|
+
LocationPriority: "11",
|
|
131090
|
+
OptionalMember: "12",
|
|
131091
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
131092
|
+
SuggestedClassMembers: "14",
|
|
131093
|
+
GlobalsOrKeywords: "15",
|
|
131094
|
+
AutoImportSuggestions: "16",
|
|
131095
|
+
ClassMemberSnippets: "17",
|
|
131096
|
+
JavascriptIdentifiers: "18",
|
|
131097
|
+
// Transformations
|
|
131098
|
+
Deprecated: function (sortText) {
|
|
131099
|
+
return "z" + sortText;
|
|
131100
|
+
},
|
|
131101
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
131102
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
131103
|
+
},
|
|
131104
|
+
SortBelow: function (sortText) {
|
|
131105
|
+
return sortText + "1";
|
|
131106
|
+
},
|
|
131107
|
+
};
|
|
131118
131108
|
/**
|
|
131119
131109
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
131120
131110
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -131134,6 +131124,8 @@ var ts;
|
|
|
131134
131124
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
131135
131125
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
131136
131126
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
131127
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
131128
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
131137
131129
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
131138
131130
|
var SymbolOriginInfoKind;
|
|
131139
131131
|
(function (SymbolOriginInfoKind) {
|
|
@@ -131144,6 +131136,7 @@ var ts;
|
|
|
131144
131136
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
131145
131137
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
131146
131138
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
131139
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
131147
131140
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
131148
131141
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
131149
131142
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -131174,6 +131167,9 @@ var ts;
|
|
|
131174
131167
|
function originIsTypeOnlyAlias(origin) {
|
|
131175
131168
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
131176
131169
|
}
|
|
131170
|
+
function originIsObjectLiteralMethod(origin) {
|
|
131171
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
131172
|
+
}
|
|
131177
131173
|
var KeywordCompletionFilters;
|
|
131178
131174
|
(function (KeywordCompletionFilters) {
|
|
131179
131175
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -131266,7 +131262,7 @@ var ts;
|
|
|
131266
131262
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
131267
131263
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
131268
131264
|
}
|
|
131269
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131265
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
131270
131266
|
if (!completionData) {
|
|
131271
131267
|
return undefined;
|
|
131272
131268
|
}
|
|
@@ -131364,7 +131360,7 @@ var ts;
|
|
|
131364
131360
|
name: ts.tokenToString(keyword),
|
|
131365
131361
|
kind: "keyword" /* keyword */,
|
|
131366
131362
|
kindModifiers: "" /* none */,
|
|
131367
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
131363
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
131368
131364
|
};
|
|
131369
131365
|
}
|
|
131370
131366
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -131393,7 +131389,7 @@ var ts;
|
|
|
131393
131389
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
131394
131390
|
}
|
|
131395
131391
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
131396
|
-
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,
|
|
131392
|
+
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;
|
|
131397
131393
|
// Verify if the file is JSX language variant
|
|
131398
131394
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
131399
131395
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -131404,7 +131400,7 @@ var ts;
|
|
|
131404
131400
|
var entries = ts.createSortedArray();
|
|
131405
131401
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
131406
131402
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
131407
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131403
|
+
/*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);
|
|
131408
131404
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
131409
131405
|
}
|
|
131410
131406
|
else {
|
|
@@ -131412,7 +131408,7 @@ var ts;
|
|
|
131412
131408
|
return undefined;
|
|
131413
131409
|
}
|
|
131414
131410
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
131415
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131411
|
+
/*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);
|
|
131416
131412
|
}
|
|
131417
131413
|
if (keywordFilters !== 0 /* None */) {
|
|
131418
131414
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -131493,7 +131489,7 @@ var ts;
|
|
|
131493
131489
|
name: fullClosingTag,
|
|
131494
131490
|
kind: "class" /* classElement */,
|
|
131495
131491
|
kindModifiers: undefined,
|
|
131496
|
-
sortText: SortText.LocationPriority,
|
|
131492
|
+
sortText: Completions.SortText.LocationPriority,
|
|
131497
131493
|
};
|
|
131498
131494
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
131499
131495
|
}
|
|
@@ -131512,7 +131508,7 @@ var ts;
|
|
|
131512
131508
|
name: realName,
|
|
131513
131509
|
kind: "warning" /* warning */,
|
|
131514
131510
|
kindModifiers: "",
|
|
131515
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
131511
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
131516
131512
|
isFromUncheckedFile: true
|
|
131517
131513
|
}, compareCompletionEntries);
|
|
131518
131514
|
}
|
|
@@ -131523,7 +131519,7 @@ var ts;
|
|
|
131523
131519
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
131524
131520
|
}
|
|
131525
131521
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
131526
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
131522
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
131527
131523
|
}
|
|
131528
131524
|
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
131529
131525
|
var _a, _b;
|
|
@@ -131594,12 +131590,21 @@ var ts;
|
|
|
131594
131590
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131595
131591
|
var importAdder = void 0;
|
|
131596
131592
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
131597
|
-
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131593
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131598
131594
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131599
131595
|
hasAction = true;
|
|
131600
131596
|
source = CompletionSource.ClassMemberSnippet;
|
|
131601
131597
|
}
|
|
131602
131598
|
}
|
|
131599
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131600
|
+
var importAdder = void 0;
|
|
131601
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, sourceDisplay = origin.sourceDisplay);
|
|
131602
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131603
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
131604
|
+
if (importAdder.hasFixes()) {
|
|
131605
|
+
hasAction = true;
|
|
131606
|
+
}
|
|
131607
|
+
}
|
|
131603
131608
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131604
131609
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
131605
131610
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131758,27 +131763,15 @@ var ts;
|
|
|
131758
131763
|
completionNodes.push(node);
|
|
131759
131764
|
}, body, 2 /* Property */, isAbstract);
|
|
131760
131765
|
if (completionNodes.length) {
|
|
131766
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131761
131767
|
replacementSpan = modifiersSpan;
|
|
131762
131768
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131763
131769
|
// and then format the printed text.
|
|
131764
131770
|
if (formatContext) {
|
|
131765
|
-
|
|
131766
|
-
text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
|
|
131767
|
-
getLineAndCharacterOfPosition: function (pos) {
|
|
131768
|
-
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131769
|
-
},
|
|
131770
|
-
};
|
|
131771
|
-
var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131772
|
-
var changes = ts.flatMap(completionNodes, function (node) {
|
|
131773
|
-
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131774
|
-
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
|
|
131775
|
-
/* indentation */ 0,
|
|
131776
|
-
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
|
|
131777
|
-
});
|
|
131778
|
-
insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
|
|
131771
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131779
131772
|
}
|
|
131780
131773
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131781
|
-
insertText = printer.printSnippetList(
|
|
131774
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131782
131775
|
}
|
|
131783
131776
|
}
|
|
131784
131777
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131828,12 +131821,103 @@ var ts;
|
|
|
131828
131821
|
}
|
|
131829
131822
|
return undefined;
|
|
131830
131823
|
}
|
|
131824
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131825
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131826
|
+
var insertText = name;
|
|
131827
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131828
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131829
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131830
|
+
if (!method) {
|
|
131831
|
+
return undefined;
|
|
131832
|
+
}
|
|
131833
|
+
var printer = createSnippetPrinter({
|
|
131834
|
+
removeComments: true,
|
|
131835
|
+
module: options.module,
|
|
131836
|
+
target: options.target,
|
|
131837
|
+
omitTrailingSemicolon: false,
|
|
131838
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131839
|
+
});
|
|
131840
|
+
if (formatContext) {
|
|
131841
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131842
|
+
}
|
|
131843
|
+
else {
|
|
131844
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131845
|
+
}
|
|
131846
|
+
var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131847
|
+
var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
|
|
131848
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
|
|
131849
|
+
}
|
|
131850
|
+
;
|
|
131851
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131852
|
+
var declarations = symbol.getDeclarations();
|
|
131853
|
+
if (!(declarations && declarations.length)) {
|
|
131854
|
+
return undefined;
|
|
131855
|
+
}
|
|
131856
|
+
var checker = program.getTypeChecker();
|
|
131857
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131858
|
+
var declaration = declarations[0];
|
|
131859
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131860
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131861
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131862
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131863
|
+
switch (declaration.kind) {
|
|
131864
|
+
case 166 /* PropertySignature */:
|
|
131865
|
+
case 167 /* PropertyDeclaration */:
|
|
131866
|
+
case 168 /* MethodSignature */:
|
|
131867
|
+
case 169 /* MethodDeclaration */: {
|
|
131868
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131869
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131870
|
+
: type;
|
|
131871
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131872
|
+
// Only offer the completion if there's a single function type component.
|
|
131873
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131874
|
+
if (functionTypes.length === 1) {
|
|
131875
|
+
effectiveType = functionTypes[0];
|
|
131876
|
+
}
|
|
131877
|
+
else {
|
|
131878
|
+
return undefined;
|
|
131879
|
+
}
|
|
131880
|
+
}
|
|
131881
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131882
|
+
if (signatures.length !== 1) {
|
|
131883
|
+
// We don't support overloads in object literals.
|
|
131884
|
+
return undefined;
|
|
131885
|
+
}
|
|
131886
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131887
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131888
|
+
return undefined;
|
|
131889
|
+
}
|
|
131890
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131891
|
+
if (importableReference) {
|
|
131892
|
+
typeNode = importableReference.typeNode;
|
|
131893
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131894
|
+
}
|
|
131895
|
+
var body = void 0;
|
|
131896
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131897
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131898
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131899
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131900
|
+
}
|
|
131901
|
+
else {
|
|
131902
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131903
|
+
}
|
|
131904
|
+
return ts.factory.createMethodDeclaration(
|
|
131905
|
+
/*decorators*/ undefined,
|
|
131906
|
+
/*modifiers*/ undefined,
|
|
131907
|
+
/*asteriskToken*/ undefined, name,
|
|
131908
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131909
|
+
}
|
|
131910
|
+
default:
|
|
131911
|
+
return undefined;
|
|
131912
|
+
}
|
|
131913
|
+
}
|
|
131831
131914
|
function createSnippetPrinter(printerOptions) {
|
|
131832
131915
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131833
131916
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131834
131917
|
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)); } });
|
|
131835
131918
|
return {
|
|
131836
131919
|
printSnippetList: printSnippetList,
|
|
131920
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131837
131921
|
};
|
|
131838
131922
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131839
131923
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131841,6 +131925,22 @@ var ts;
|
|
|
131841
131925
|
printer.writeList(format, list, sourceFile, writer);
|
|
131842
131926
|
return writer.getText();
|
|
131843
131927
|
}
|
|
131928
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131929
|
+
var syntheticFile = {
|
|
131930
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131931
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131932
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131933
|
+
},
|
|
131934
|
+
};
|
|
131935
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131936
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131937
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131938
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131939
|
+
/* indentation */ 0,
|
|
131940
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131941
|
+
});
|
|
131942
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131943
|
+
}
|
|
131844
131944
|
}
|
|
131845
131945
|
function originToCompletionEntryData(origin) {
|
|
131846
131946
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131938,7 +132038,7 @@ var ts;
|
|
|
131938
132038
|
return CompletionSource.TypeOnlyAlias;
|
|
131939
132039
|
}
|
|
131940
132040
|
}
|
|
131941
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
132041
|
+
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) {
|
|
131942
132042
|
var _a;
|
|
131943
132043
|
var start = ts.timestamp();
|
|
131944
132044
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131953,12 +132053,12 @@ var ts;
|
|
|
131953
132053
|
var symbol = symbols[i];
|
|
131954
132054
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131955
132055
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131956
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
132056
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131957
132057
|
continue;
|
|
131958
132058
|
}
|
|
131959
132059
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131960
|
-
var
|
|
131961
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
132060
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
132061
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131962
132062
|
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);
|
|
131963
132063
|
if (!entry) {
|
|
131964
132064
|
continue;
|
|
@@ -131976,7 +132076,7 @@ var ts;
|
|
|
131976
132076
|
has: function (name) { return uniques.has(name); },
|
|
131977
132077
|
add: function (name) { return uniques.set(name, true); },
|
|
131978
132078
|
};
|
|
131979
|
-
function shouldIncludeSymbol(symbol,
|
|
132079
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131980
132080
|
var allFlags = symbol.flags;
|
|
131981
132081
|
if (!ts.isSourceFile(location)) {
|
|
131982
132082
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131998,9 +132098,9 @@ var ts;
|
|
|
131998
132098
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131999
132099
|
if (!!sourceFile.externalModuleIndicator
|
|
132000
132100
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
132001
|
-
&&
|
|
132002
|
-
&& (
|
|
132003
|
-
||
|
|
132101
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
132102
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
132103
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
132004
132104
|
return false;
|
|
132005
132105
|
}
|
|
132006
132106
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -132040,7 +132140,7 @@ var ts;
|
|
|
132040
132140
|
name: name,
|
|
132041
132141
|
kindModifiers: "" /* none */,
|
|
132042
132142
|
kind: "label" /* label */,
|
|
132043
|
-
sortText: SortText.LocationPriority
|
|
132143
|
+
sortText: Completions.SortText.LocationPriority
|
|
132044
132144
|
});
|
|
132045
132145
|
}
|
|
132046
132146
|
}
|
|
@@ -132066,7 +132166,7 @@ var ts;
|
|
|
132066
132166
|
}
|
|
132067
132167
|
}
|
|
132068
132168
|
var compilerOptions = program.getCompilerOptions();
|
|
132069
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
132169
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
132070
132170
|
if (!completionData) {
|
|
132071
132171
|
return { type: "none" };
|
|
132072
132172
|
}
|
|
@@ -132084,7 +132184,9 @@ var ts;
|
|
|
132084
132184
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
132085
132185
|
var origin = symbolToOriginInfoMap[index];
|
|
132086
132186
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
132087
|
-
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
132187
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
132188
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
132189
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
132088
132190
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
132089
132191
|
: undefined;
|
|
132090
132192
|
}) || { type: "none" };
|
|
@@ -132166,6 +132268,20 @@ var ts;
|
|
|
132166
132268
|
};
|
|
132167
132269
|
}
|
|
132168
132270
|
}
|
|
132271
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132272
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132273
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132274
|
+
if (importAdder.hasFixes()) {
|
|
132275
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132276
|
+
return {
|
|
132277
|
+
sourceDisplay: undefined,
|
|
132278
|
+
codeActions: [{
|
|
132279
|
+
changes: changes,
|
|
132280
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132281
|
+
}],
|
|
132282
|
+
};
|
|
132283
|
+
}
|
|
132284
|
+
}
|
|
132169
132285
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132170
132286
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132171
132287
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -132258,8 +132374,9 @@ var ts;
|
|
|
132258
132374
|
var _a;
|
|
132259
132375
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
132260
132376
|
}
|
|
132261
|
-
function getCompletionData(program, log, sourceFile,
|
|
132377
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
132262
132378
|
var typeChecker = program.getTypeChecker();
|
|
132379
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
132263
132380
|
var start = ts.timestamp();
|
|
132264
132381
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
132265
132382
|
// We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
|
|
@@ -132502,7 +132619,7 @@ var ts;
|
|
|
132502
132619
|
// This also gets mutated in nested-functions after the return
|
|
132503
132620
|
var symbols = [];
|
|
132504
132621
|
var symbolToOriginInfoMap = [];
|
|
132505
|
-
var
|
|
132622
|
+
var symbolToSortTextMap = [];
|
|
132506
132623
|
var seenPropertySymbols = new ts.Map();
|
|
132507
132624
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
132508
132625
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -132557,7 +132674,7 @@ var ts;
|
|
|
132557
132674
|
contextToken: contextToken,
|
|
132558
132675
|
isJsxInitializer: isJsxInitializer,
|
|
132559
132676
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
132560
|
-
|
|
132677
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
132561
132678
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
132562
132679
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
132563
132680
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132671,7 +132788,7 @@ var ts;
|
|
|
132671
132788
|
isNewIdentifierLocation = true;
|
|
132672
132789
|
}
|
|
132673
132790
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132674
|
-
if (
|
|
132791
|
+
if (inUncheckedFile) {
|
|
132675
132792
|
// In javascript files, for union types, we don't just get the members that
|
|
132676
132793
|
// the individual types have in common, we also include all the members that
|
|
132677
132794
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132756,7 +132873,7 @@ var ts;
|
|
|
132756
132873
|
}
|
|
132757
132874
|
function addSymbolSortInfo(symbol) {
|
|
132758
132875
|
if (isStaticProperty(symbol)) {
|
|
132759
|
-
|
|
132876
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132760
132877
|
}
|
|
132761
132878
|
}
|
|
132762
132879
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132866,7 +132983,7 @@ var ts;
|
|
|
132866
132983
|
var symbol = symbols[i];
|
|
132867
132984
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132868
132985
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132869
|
-
|
|
132986
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132870
132987
|
}
|
|
132871
132988
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132872
132989
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132884,7 +133001,7 @@ var ts;
|
|
|
132884
133001
|
var symbol = _a[_i];
|
|
132885
133002
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132886
133003
|
symbols.push(symbol);
|
|
132887
|
-
|
|
133004
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132888
133005
|
}
|
|
132889
133006
|
}
|
|
132890
133007
|
}
|
|
@@ -132962,7 +133079,7 @@ var ts;
|
|
|
132962
133079
|
}
|
|
132963
133080
|
return false;
|
|
132964
133081
|
}
|
|
132965
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
133082
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132966
133083
|
function collectAutoImports() {
|
|
132967
133084
|
var _a, _b;
|
|
132968
133085
|
if (!shouldOfferImportCompletions())
|
|
@@ -133044,14 +133161,55 @@ var ts;
|
|
|
133044
133161
|
}
|
|
133045
133162
|
function pushAutoImportSymbol(symbol, origin) {
|
|
133046
133163
|
var symbolId = ts.getSymbolId(symbol);
|
|
133047
|
-
if (
|
|
133164
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
133048
133165
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
133049
133166
|
return;
|
|
133050
133167
|
}
|
|
133051
133168
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133052
|
-
|
|
133169
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
133053
133170
|
symbols.push(symbol);
|
|
133054
133171
|
}
|
|
133172
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
133173
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
133174
|
+
// TODO: support JS files.
|
|
133175
|
+
if (ts.isInJSFile(location)) {
|
|
133176
|
+
return;
|
|
133177
|
+
}
|
|
133178
|
+
members.forEach(function (member) {
|
|
133179
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
133180
|
+
return;
|
|
133181
|
+
}
|
|
133182
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
133183
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
133184
|
+
/*jsxIdentifierExpected*/ false);
|
|
133185
|
+
if (!displayName) {
|
|
133186
|
+
return;
|
|
133187
|
+
}
|
|
133188
|
+
var name = displayName.name;
|
|
133189
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
133190
|
+
if (!entryProps) {
|
|
133191
|
+
return;
|
|
133192
|
+
}
|
|
133193
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
133194
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133195
|
+
symbols.push(member);
|
|
133196
|
+
});
|
|
133197
|
+
}
|
|
133198
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
133199
|
+
/*
|
|
133200
|
+
For an object type
|
|
133201
|
+
`type Foo = {
|
|
133202
|
+
bar(x: number): void;
|
|
133203
|
+
foo: (x: string) => string;
|
|
133204
|
+
}`,
|
|
133205
|
+
`bar` will have symbol flag `Method`,
|
|
133206
|
+
`foo` will have symbol flag `Property`.
|
|
133207
|
+
*/
|
|
133208
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
133209
|
+
return false;
|
|
133210
|
+
}
|
|
133211
|
+
return true;
|
|
133212
|
+
}
|
|
133055
133213
|
/**
|
|
133056
133214
|
* Finds the first node that "embraces" the position, so that one may
|
|
133057
133215
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -133185,6 +133343,7 @@ var ts;
|
|
|
133185
133343
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
133186
133344
|
*/
|
|
133187
133345
|
function tryGetObjectLikeCompletionSymbols() {
|
|
133346
|
+
var symbolsStartIndex = symbols.length;
|
|
133188
133347
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
133189
133348
|
if (!objectLikeContainer)
|
|
133190
133349
|
return 0 /* Continue */;
|
|
@@ -133249,9 +133408,16 @@ var ts;
|
|
|
133249
133408
|
}
|
|
133250
133409
|
if (typeMembers && typeMembers.length > 0) {
|
|
133251
133410
|
// Add filtered items to the completion list
|
|
133252
|
-
|
|
133411
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
133412
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
133413
|
+
setSortTextToOptionalMember();
|
|
133414
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
133415
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
133416
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
133417
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
133418
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
133419
|
+
}
|
|
133253
133420
|
}
|
|
133254
|
-
setSortTextToOptionalMember();
|
|
133255
133421
|
return 1 /* Success */;
|
|
133256
133422
|
}
|
|
133257
133423
|
/**
|
|
@@ -133326,7 +133492,7 @@ var ts;
|
|
|
133326
133492
|
var _a, _b;
|
|
133327
133493
|
symbols.push(symbol);
|
|
133328
133494
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
133329
|
-
|
|
133495
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
133330
133496
|
}
|
|
133331
133497
|
});
|
|
133332
133498
|
return 1 /* Success */;
|
|
@@ -133381,29 +133547,6 @@ var ts;
|
|
|
133381
133547
|
}
|
|
133382
133548
|
return 1 /* Success */;
|
|
133383
133549
|
}
|
|
133384
|
-
/**
|
|
133385
|
-
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133386
|
-
* on the condition that one exists and that the context implies completion should be given.
|
|
133387
|
-
*/
|
|
133388
|
-
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133389
|
-
if (contextToken) {
|
|
133390
|
-
var parent = contextToken.parent;
|
|
133391
|
-
switch (contextToken.kind) {
|
|
133392
|
-
case 18 /* OpenBraceToken */: // const x = { |
|
|
133393
|
-
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133394
|
-
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133395
|
-
return parent;
|
|
133396
|
-
}
|
|
133397
|
-
break;
|
|
133398
|
-
case 41 /* AsteriskToken */:
|
|
133399
|
-
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
133400
|
-
case 79 /* Identifier */:
|
|
133401
|
-
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
133402
|
-
? contextToken.parent.parent : undefined;
|
|
133403
|
-
}
|
|
133404
|
-
}
|
|
133405
|
-
return undefined;
|
|
133406
|
-
}
|
|
133407
133550
|
function isConstructorParameterCompletion(node) {
|
|
133408
133551
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
133409
133552
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133740,7 +133883,7 @@ var ts;
|
|
|
133740
133883
|
var _a;
|
|
133741
133884
|
if (m.flags & 16777216 /* Optional */) {
|
|
133742
133885
|
var symbolId = ts.getSymbolId(m);
|
|
133743
|
-
|
|
133886
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133744
133887
|
}
|
|
133745
133888
|
});
|
|
133746
133889
|
}
|
|
@@ -133752,7 +133895,23 @@ var ts;
|
|
|
133752
133895
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133753
133896
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133754
133897
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133755
|
-
|
|
133898
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133899
|
+
}
|
|
133900
|
+
}
|
|
133901
|
+
}
|
|
133902
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133903
|
+
var _a;
|
|
133904
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133905
|
+
var symbol = symbols[i];
|
|
133906
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133907
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133908
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133909
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133910
|
+
/*jsxIdentifierExpected*/ false);
|
|
133911
|
+
if (displayName) {
|
|
133912
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133913
|
+
var name = displayName.name;
|
|
133914
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133756
133915
|
}
|
|
133757
133916
|
}
|
|
133758
133917
|
}
|
|
@@ -133826,6 +133985,29 @@ var ts;
|
|
|
133826
133985
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133827
133986
|
}
|
|
133828
133987
|
}
|
|
133988
|
+
/**
|
|
133989
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133990
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
133991
|
+
*/
|
|
133992
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133993
|
+
if (contextToken) {
|
|
133994
|
+
var parent = contextToken.parent;
|
|
133995
|
+
switch (contextToken.kind) {
|
|
133996
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
133997
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133998
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133999
|
+
return parent;
|
|
134000
|
+
}
|
|
134001
|
+
break;
|
|
134002
|
+
case 41 /* AsteriskToken */:
|
|
134003
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
134004
|
+
case 79 /* Identifier */:
|
|
134005
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
134006
|
+
? contextToken.parent.parent : undefined;
|
|
134007
|
+
}
|
|
134008
|
+
}
|
|
134009
|
+
return undefined;
|
|
134010
|
+
}
|
|
133829
134011
|
function getRelevantTokens(position, sourceFile) {
|
|
133830
134012
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133831
134013
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133891,7 +134073,7 @@ var ts;
|
|
|
133891
134073
|
name: ts.tokenToString(i),
|
|
133892
134074
|
kind: "keyword" /* keyword */,
|
|
133893
134075
|
kindModifiers: "" /* none */,
|
|
133894
|
-
sortText: SortText.GlobalsOrKeywords
|
|
134076
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133895
134077
|
});
|
|
133896
134078
|
}
|
|
133897
134079
|
return res;
|
|
@@ -134019,7 +134201,7 @@ var ts;
|
|
|
134019
134201
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
134020
134202
|
kind: "keyword" /* keyword */,
|
|
134021
134203
|
kindModifiers: "" /* none */,
|
|
134022
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
134204
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
134023
134205
|
});
|
|
134024
134206
|
}
|
|
134025
134207
|
}
|
|
@@ -145947,6 +146129,7 @@ var ts;
|
|
|
145947
146129
|
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); });
|
|
145948
146130
|
}
|
|
145949
146131
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
146132
|
+
var _b;
|
|
145950
146133
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145951
146134
|
// formatting context is used by rules provider
|
|
145952
146135
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145978,11 +146161,12 @@ var ts;
|
|
|
145978
146161
|
}
|
|
145979
146162
|
}
|
|
145980
146163
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145981
|
-
var
|
|
146164
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145982
146165
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145983
146166
|
undefined;
|
|
145984
|
-
if (
|
|
145985
|
-
|
|
146167
|
+
if (tokenInfo) {
|
|
146168
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
146169
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145986
146170
|
/*dynamicIndentation*/ undefined);
|
|
145987
146171
|
}
|
|
145988
146172
|
}
|