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
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.20220330";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -13412,7 +13412,9 @@ var ts;
|
|
|
13412
13412
|
|| kind === 174 /* CallSignature */
|
|
13413
13413
|
|| kind === 166 /* PropertySignature */
|
|
13414
13414
|
|| kind === 168 /* MethodSignature */
|
|
13415
|
-
|| kind === 176 /* IndexSignature
|
|
13415
|
+
|| kind === 176 /* IndexSignature */
|
|
13416
|
+
|| kind === 172 /* GetAccessor */
|
|
13417
|
+
|| kind === 173 /* SetAccessor */;
|
|
13416
13418
|
}
|
|
13417
13419
|
ts.isTypeElement = isTypeElement;
|
|
13418
13420
|
function isClassOrTypeElement(node) {
|
|
@@ -47394,6 +47396,7 @@ var ts;
|
|
|
47394
47396
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47395
47397
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47396
47398
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47399
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47397
47400
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47398
47401
|
var CheckMode;
|
|
47399
47402
|
(function (CheckMode) {
|
|
@@ -47403,7 +47406,8 @@ var ts;
|
|
|
47403
47406
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47404
47407
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47405
47408
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47406
|
-
CheckMode[CheckMode["
|
|
47409
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47410
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47407
47411
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47408
47412
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47409
47413
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47741,26 +47745,10 @@ var ts;
|
|
|
47741
47745
|
if (!node) {
|
|
47742
47746
|
return undefined;
|
|
47743
47747
|
}
|
|
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;
|
|
47748
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47749
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47762
47750
|
}
|
|
47763
|
-
return
|
|
47751
|
+
return getContextualType(node, contextFlags);
|
|
47764
47752
|
},
|
|
47765
47753
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47766
47754
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47780,6 +47768,9 @@ var ts;
|
|
|
47780
47768
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47781
47769
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47782
47770
|
},
|
|
47771
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47772
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47773
|
+
},
|
|
47783
47774
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47784
47775
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47785
47776
|
},
|
|
@@ -47932,10 +47923,34 @@ var ts;
|
|
|
47932
47923
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47933
47924
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47934
47925
|
};
|
|
47935
|
-
function
|
|
47926
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
47927
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
47928
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
47929
|
+
if (containingCall) {
|
|
47930
|
+
var toMarkSkip = node;
|
|
47931
|
+
do {
|
|
47932
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47933
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47934
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47935
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47936
|
+
}
|
|
47937
|
+
var result = fn();
|
|
47938
|
+
if (containingCall) {
|
|
47939
|
+
var toMarkSkip = node;
|
|
47940
|
+
do {
|
|
47941
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47942
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47943
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47944
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47945
|
+
}
|
|
47946
|
+
return result;
|
|
47947
|
+
}
|
|
47948
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
47936
47949
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
47937
47950
|
apparentArgumentCount = argumentCount;
|
|
47938
|
-
var res = node ?
|
|
47951
|
+
var res = !node ? undefined :
|
|
47952
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
47953
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
47939
47954
|
apparentArgumentCount = undefined;
|
|
47940
47955
|
return res;
|
|
47941
47956
|
}
|
|
@@ -48908,6 +48923,10 @@ var ts;
|
|
|
48908
48923
|
}
|
|
48909
48924
|
}
|
|
48910
48925
|
}
|
|
48926
|
+
function isConstAssertion(location) {
|
|
48927
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
48928
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
48929
|
+
}
|
|
48911
48930
|
/**
|
|
48912
48931
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
48913
48932
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -48933,6 +48952,11 @@ var ts;
|
|
|
48933
48952
|
var grandparent;
|
|
48934
48953
|
var isInExternalModule = false;
|
|
48935
48954
|
loop: while (location) {
|
|
48955
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
48956
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
48957
|
+
// (it refers to the constant type of the expression instead)
|
|
48958
|
+
return undefined;
|
|
48959
|
+
}
|
|
48936
48960
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
48937
48961
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
48938
48962
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -54881,6 +54905,8 @@ var ts;
|
|
|
54881
54905
|
return !!target.resolvedTypeArguments;
|
|
54882
54906
|
case 7 /* ResolvedBaseTypes */:
|
|
54883
54907
|
return !!target.baseTypesResolved;
|
|
54908
|
+
case 8 /* WriteType */:
|
|
54909
|
+
return !!getSymbolLinks(target).writeType;
|
|
54884
54910
|
}
|
|
54885
54911
|
return ts.Debug.assertNever(propertyName);
|
|
54886
54912
|
}
|
|
@@ -55058,7 +55084,7 @@ var ts;
|
|
|
55058
55084
|
}
|
|
55059
55085
|
/** Return the inferred type for a binding element */
|
|
55060
55086
|
function getTypeForBindingElement(declaration) {
|
|
55061
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55087
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55062
55088
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55063
55089
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55064
55090
|
}
|
|
@@ -55798,6 +55824,11 @@ var ts;
|
|
|
55798
55824
|
}
|
|
55799
55825
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55800
55826
|
}
|
|
55827
|
+
if (ts.isAccessor(declaration)) {
|
|
55828
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
55829
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
55830
|
+
return getTypeOfAccessors(symbol);
|
|
55831
|
+
}
|
|
55801
55832
|
// Handle variable, parameter or property
|
|
55802
55833
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55803
55834
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -55861,9 +55892,6 @@ var ts;
|
|
|
55861
55892
|
else if (ts.isEnumMember(declaration)) {
|
|
55862
55893
|
type = getTypeOfEnumMember(symbol);
|
|
55863
55894
|
}
|
|
55864
|
-
else if (ts.isAccessor(declaration)) {
|
|
55865
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
55866
|
-
}
|
|
55867
55895
|
else {
|
|
55868
55896
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
55869
55897
|
}
|
|
@@ -55902,87 +55930,61 @@ var ts;
|
|
|
55902
55930
|
}
|
|
55903
55931
|
function getTypeOfAccessors(symbol) {
|
|
55904
55932
|
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()) {
|
|
55933
|
+
if (!links.type) {
|
|
55934
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55935
|
+
return errorType;
|
|
55936
|
+
}
|
|
55918
55937
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
55919
|
-
|
|
55920
|
-
|
|
55921
|
-
|
|
55938
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55939
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
55940
|
+
// body return type inference, in that order.
|
|
55941
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
55942
|
+
getAnnotatedAccessorType(getter) ||
|
|
55943
|
+
getAnnotatedAccessorType(setter) ||
|
|
55944
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
55945
|
+
if (!type) {
|
|
55946
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
55947
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55948
|
+
}
|
|
55949
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
55950
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55951
|
+
}
|
|
55952
|
+
type = anyType;
|
|
55953
|
+
}
|
|
55954
|
+
if (!popTypeResolution()) {
|
|
55955
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
55956
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55922
55957
|
}
|
|
55923
|
-
else if (
|
|
55958
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55959
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55960
|
+
}
|
|
55961
|
+
else if (getter && noImplicitAny) {
|
|
55924
55962
|
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
55963
|
}
|
|
55964
|
+
type = anyType;
|
|
55926
55965
|
}
|
|
55927
|
-
type =
|
|
55966
|
+
links.type = type;
|
|
55928
55967
|
}
|
|
55929
|
-
return type;
|
|
55968
|
+
return links.type;
|
|
55930
55969
|
}
|
|
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));
|
|
55970
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
55971
|
+
var links = getSymbolLinks(symbol);
|
|
55972
|
+
if (!links.writeType) {
|
|
55973
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
55974
|
+
return errorType;
|
|
55975
55975
|
}
|
|
55976
|
-
|
|
55977
|
-
|
|
55978
|
-
|
|
55979
|
-
|
|
55980
|
-
|
|
55981
|
-
|
|
55982
|
-
|
|
55976
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55977
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
55978
|
+
if (!popTypeResolution()) {
|
|
55979
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55980
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55981
|
+
}
|
|
55982
|
+
writeType = anyType;
|
|
55983
55983
|
}
|
|
55984
|
-
|
|
55984
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
55985
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
55985
55986
|
}
|
|
55987
|
+
return links.writeType;
|
|
55986
55988
|
}
|
|
55987
55989
|
function getBaseTypeVariableOfClass(symbol) {
|
|
55988
55990
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56064,17 +56066,11 @@ var ts;
|
|
|
56064
56066
|
}
|
|
56065
56067
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56066
56068
|
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;
|
|
56069
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56070
|
+
}
|
|
56071
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56072
|
+
var links = getSymbolLinks(symbol);
|
|
56073
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56078
56074
|
}
|
|
56079
56075
|
function reportCircularityError(symbol) {
|
|
56080
56076
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56111,35 +56107,23 @@ var ts;
|
|
|
56111
56107
|
return links.writeType;
|
|
56112
56108
|
}
|
|
56113
56109
|
/**
|
|
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.
|
|
56110
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56111
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56112
|
+
* intersection of the writeTypes of their constituents.
|
|
56120
56113
|
*/
|
|
56121
56114
|
function getWriteTypeOfSymbol(symbol) {
|
|
56122
56115
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56123
|
-
if (
|
|
56124
|
-
|
|
56125
|
-
|
|
56126
|
-
|
|
56127
|
-
|
|
56116
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56117
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56118
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56119
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56120
|
+
symbol.writeType || symbol.type :
|
|
56121
|
+
getTypeOfSymbol(symbol);
|
|
56128
56122
|
}
|
|
56129
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56130
|
-
var writeType = symbol.writeType;
|
|
56131
|
-
if (writeType) {
|
|
56132
|
-
return writeType;
|
|
56133
|
-
}
|
|
56134
|
-
}
|
|
56135
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56136
|
-
}
|
|
56137
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56138
56123
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56139
|
-
|
|
56140
|
-
|
|
56141
|
-
|
|
56142
|
-
}
|
|
56124
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56125
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56126
|
+
getWriteTypeOfAccessors(symbol);
|
|
56143
56127
|
}
|
|
56144
56128
|
return getTypeOfSymbol(symbol);
|
|
56145
56129
|
}
|
|
@@ -68228,7 +68212,7 @@ var ts;
|
|
|
68228
68212
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68229
68213
|
var targetProp = properties_3[_i];
|
|
68230
68214
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68231
|
-
if (sourceProp) {
|
|
68215
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68232
68216
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68233
68217
|
}
|
|
68234
68218
|
}
|
|
@@ -70610,7 +70594,7 @@ var ts;
|
|
|
70610
70594
|
}
|
|
70611
70595
|
}
|
|
70612
70596
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70613
|
-
return
|
|
70597
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70614
70598
|
}
|
|
70615
70599
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70616
70600
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -70702,7 +70686,7 @@ var ts;
|
|
|
70702
70686
|
// as we want the type of a rest element to be generic when possible.
|
|
70703
70687
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70704
70688
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70705
|
-
(checkMode && checkMode &
|
|
70689
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70706
70690
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70707
70691
|
: getContextualType(node));
|
|
70708
70692
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -71641,7 +71625,7 @@ var ts;
|
|
|
71641
71625
|
var parent = declaration.parent.parent;
|
|
71642
71626
|
var name = declaration.propertyName || declaration.name;
|
|
71643
71627
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71644
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71628
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71645
71629
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71646
71630
|
return undefined;
|
|
71647
71631
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -74695,7 +74679,7 @@ var ts;
|
|
|
74695
74679
|
}
|
|
74696
74680
|
for (var i = 0; i < argCount; i++) {
|
|
74697
74681
|
var arg = args[i];
|
|
74698
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74682
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74699
74683
|
var paramType = getTypeAtPosition(signature, i);
|
|
74700
74684
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74701
74685
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75380,7 +75364,7 @@ var ts;
|
|
|
75380
75364
|
}
|
|
75381
75365
|
}
|
|
75382
75366
|
}
|
|
75383
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75367
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75384
75368
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75385
75369
|
var _a, _b;
|
|
75386
75370
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75481,14 +75465,14 @@ var ts;
|
|
|
75481
75465
|
}
|
|
75482
75466
|
}
|
|
75483
75467
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75484
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75468
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75485
75469
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75486
75470
|
checkNodeDeferred(node);
|
|
75487
75471
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75488
75472
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75489
75473
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75490
75474
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75491
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75475
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75492
75476
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75493
75477
|
}
|
|
75494
75478
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75536,7 +75520,7 @@ var ts;
|
|
|
75536
75520
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75537
75521
|
return createSymbolWithType(ts.first(sources), type);
|
|
75538
75522
|
}
|
|
75539
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75523
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75540
75524
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75541
75525
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75542
75526
|
// f({ |
|
|
@@ -75552,7 +75536,7 @@ var ts;
|
|
|
75552
75536
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75553
75537
|
var instantiated = typeArgumentNodes
|
|
75554
75538
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75555
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75539
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75556
75540
|
candidates[bestIndex] = instantiated;
|
|
75557
75541
|
return instantiated;
|
|
75558
75542
|
}
|
|
@@ -75566,9 +75550,9 @@ var ts;
|
|
|
75566
75550
|
}
|
|
75567
75551
|
return typeArguments;
|
|
75568
75552
|
}
|
|
75569
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75553
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75570
75554
|
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);
|
|
75555
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75572
75556
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75573
75557
|
}
|
|
75574
75558
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81634,7 +81618,7 @@ var ts;
|
|
|
81634
81618
|
}
|
|
81635
81619
|
// check private/protected variable access
|
|
81636
81620
|
var parent = node.parent.parent;
|
|
81637
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81621
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81638
81622
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81639
81623
|
var name = node.propertyName || node.name;
|
|
81640
81624
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -81813,6 +81797,8 @@ var ts;
|
|
|
81813
81797
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81814
81798
|
? condExpr.right
|
|
81815
81799
|
: condExpr;
|
|
81800
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81801
|
+
return;
|
|
81816
81802
|
var type = checkTruthinessExpression(location);
|
|
81817
81803
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81818
81804
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -116730,6 +116716,13 @@ var ts;
|
|
|
116730
116716
|
return "skip";
|
|
116731
116717
|
}
|
|
116732
116718
|
break;
|
|
116719
|
+
case 270 /* ImportSpecifier */:
|
|
116720
|
+
case 275 /* ExportSpecifier */:
|
|
116721
|
+
if (node.isTypeOnly) {
|
|
116722
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116723
|
+
return "skip";
|
|
116724
|
+
}
|
|
116725
|
+
break;
|
|
116733
116726
|
case 265 /* ImportEqualsDeclaration */:
|
|
116734
116727
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116735
116728
|
return "skip";
|
|
@@ -126073,12 +126066,8 @@ var ts;
|
|
|
126073
126066
|
}
|
|
126074
126067
|
}
|
|
126075
126068
|
ts.findNextToken = findNextToken;
|
|
126076
|
-
/**
|
|
126077
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126078
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126079
|
-
*/
|
|
126080
126069
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126081
|
-
var result = find(startNode || sourceFile);
|
|
126070
|
+
var result = find((startNode || sourceFile));
|
|
126082
126071
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126083
126072
|
return result;
|
|
126084
126073
|
function find(n) {
|
|
@@ -127178,6 +127167,14 @@ var ts;
|
|
|
127178
127167
|
});
|
|
127179
127168
|
}
|
|
127180
127169
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127170
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127171
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127172
|
+
return mapToDisplayParts(function (writer) {
|
|
127173
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127174
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127175
|
+
});
|
|
127176
|
+
}
|
|
127177
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127181
127178
|
function isImportOrExportSpecifierName(location) {
|
|
127182
127179
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127183
127180
|
}
|
|
@@ -129874,12 +129871,13 @@ var ts;
|
|
|
129874
129871
|
}
|
|
129875
129872
|
case 208 /* CallExpression */:
|
|
129876
129873
|
case 209 /* NewExpression */:
|
|
129874
|
+
case 285 /* JsxAttribute */:
|
|
129877
129875
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
129878
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
129876
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
129879
129877
|
// Get string literal completions from specialized signatures of the target
|
|
129880
129878
|
// i.e. declare function f(a: 'A');
|
|
129881
129879
|
// f("/*completion position*/")
|
|
129882
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
129880
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
129883
129881
|
}
|
|
129884
129882
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
129885
129883
|
case 266 /* ImportDeclaration */:
|
|
@@ -129916,15 +129914,22 @@ var ts;
|
|
|
129916
129914
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
129917
129915
|
});
|
|
129918
129916
|
}
|
|
129919
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
129917
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
129920
129918
|
var isNewIdentifier = false;
|
|
129921
129919
|
var uniques = new ts.Map();
|
|
129922
129920
|
var candidates = [];
|
|
129923
|
-
|
|
129921
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
129922
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
129924
129923
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
129925
129924
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
129926
129925
|
return;
|
|
129927
129926
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
129927
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
129928
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
129929
|
+
if (propType) {
|
|
129930
|
+
type = propType;
|
|
129931
|
+
}
|
|
129932
|
+
}
|
|
129928
129933
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
129929
129934
|
return getStringLiteralTypes(type, uniques);
|
|
129930
129935
|
});
|
|
@@ -130467,43 +130472,28 @@ var ts;
|
|
|
130467
130472
|
// Exported only for tests
|
|
130468
130473
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
130469
130474
|
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 = {}));
|
|
130475
|
+
Completions.SortText = {
|
|
130476
|
+
// Presets
|
|
130477
|
+
LocalDeclarationPriority: "10",
|
|
130478
|
+
LocationPriority: "11",
|
|
130479
|
+
OptionalMember: "12",
|
|
130480
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
130481
|
+
SuggestedClassMembers: "14",
|
|
130482
|
+
GlobalsOrKeywords: "15",
|
|
130483
|
+
AutoImportSuggestions: "16",
|
|
130484
|
+
ClassMemberSnippets: "17",
|
|
130485
|
+
JavascriptIdentifiers: "18",
|
|
130486
|
+
// Transformations
|
|
130487
|
+
Deprecated: function (sortText) {
|
|
130488
|
+
return "z" + sortText;
|
|
130489
|
+
},
|
|
130490
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
130491
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
130492
|
+
},
|
|
130493
|
+
SortBelow: function (sortText) {
|
|
130494
|
+
return sortText + "1";
|
|
130495
|
+
},
|
|
130496
|
+
};
|
|
130507
130497
|
/**
|
|
130508
130498
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
130509
130499
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -130523,6 +130513,8 @@ var ts;
|
|
|
130523
130513
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
130524
130514
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
130525
130515
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
130516
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
130517
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
130526
130518
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
130527
130519
|
var SymbolOriginInfoKind;
|
|
130528
130520
|
(function (SymbolOriginInfoKind) {
|
|
@@ -130533,6 +130525,7 @@ var ts;
|
|
|
130533
130525
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
130534
130526
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
130535
130527
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
130528
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
130536
130529
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
130537
130530
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
130538
130531
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -130563,6 +130556,9 @@ var ts;
|
|
|
130563
130556
|
function originIsTypeOnlyAlias(origin) {
|
|
130564
130557
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
130565
130558
|
}
|
|
130559
|
+
function originIsObjectLiteralMethod(origin) {
|
|
130560
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
130561
|
+
}
|
|
130566
130562
|
var KeywordCompletionFilters;
|
|
130567
130563
|
(function (KeywordCompletionFilters) {
|
|
130568
130564
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -130655,7 +130651,7 @@ var ts;
|
|
|
130655
130651
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
130656
130652
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
130657
130653
|
}
|
|
130658
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
130654
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
130659
130655
|
if (!completionData) {
|
|
130660
130656
|
return undefined;
|
|
130661
130657
|
}
|
|
@@ -130753,7 +130749,7 @@ var ts;
|
|
|
130753
130749
|
name: ts.tokenToString(keyword),
|
|
130754
130750
|
kind: "keyword" /* keyword */,
|
|
130755
130751
|
kindModifiers: "" /* none */,
|
|
130756
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
130752
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
130757
130753
|
};
|
|
130758
130754
|
}
|
|
130759
130755
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -130782,7 +130778,7 @@ var ts;
|
|
|
130782
130778
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
130783
130779
|
}
|
|
130784
130780
|
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,
|
|
130781
|
+
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
130782
|
// Verify if the file is JSX language variant
|
|
130787
130783
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
130788
130784
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -130793,7 +130789,7 @@ var ts;
|
|
|
130793
130789
|
var entries = ts.createSortedArray();
|
|
130794
130790
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
130795
130791
|
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,
|
|
130792
|
+
/*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
130793
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
130798
130794
|
}
|
|
130799
130795
|
else {
|
|
@@ -130801,7 +130797,7 @@ var ts;
|
|
|
130801
130797
|
return undefined;
|
|
130802
130798
|
}
|
|
130803
130799
|
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,
|
|
130800
|
+
/*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
130801
|
}
|
|
130806
130802
|
if (keywordFilters !== 0 /* None */) {
|
|
130807
130803
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -130882,7 +130878,7 @@ var ts;
|
|
|
130882
130878
|
name: fullClosingTag,
|
|
130883
130879
|
kind: "class" /* classElement */,
|
|
130884
130880
|
kindModifiers: undefined,
|
|
130885
|
-
sortText: SortText.LocationPriority,
|
|
130881
|
+
sortText: Completions.SortText.LocationPriority,
|
|
130886
130882
|
};
|
|
130887
130883
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
130888
130884
|
}
|
|
@@ -130901,7 +130897,7 @@ var ts;
|
|
|
130901
130897
|
name: realName,
|
|
130902
130898
|
kind: "warning" /* warning */,
|
|
130903
130899
|
kindModifiers: "",
|
|
130904
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
130900
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
130905
130901
|
isFromUncheckedFile: true
|
|
130906
130902
|
}, compareCompletionEntries);
|
|
130907
130903
|
}
|
|
@@ -130912,7 +130908,7 @@ var ts;
|
|
|
130912
130908
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
130913
130909
|
}
|
|
130914
130910
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
130915
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
130911
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
130916
130912
|
}
|
|
130917
130913
|
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
130914
|
var _a, _b;
|
|
@@ -130983,12 +130979,21 @@ var ts;
|
|
|
130983
130979
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
130984
130980
|
var importAdder = void 0;
|
|
130985
130981
|
(_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.
|
|
130982
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
130987
130983
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
130988
130984
|
hasAction = true;
|
|
130989
130985
|
source = CompletionSource.ClassMemberSnippet;
|
|
130990
130986
|
}
|
|
130991
130987
|
}
|
|
130988
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
130989
|
+
var importAdder = void 0;
|
|
130990
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, sourceDisplay = origin.sourceDisplay);
|
|
130991
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
130992
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
130993
|
+
if (importAdder.hasFixes()) {
|
|
130994
|
+
hasAction = true;
|
|
130995
|
+
}
|
|
130996
|
+
}
|
|
130992
130997
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
130993
130998
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
130994
130999
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131147,27 +131152,15 @@ var ts;
|
|
|
131147
131152
|
completionNodes.push(node);
|
|
131148
131153
|
}, body, 2 /* Property */, isAbstract);
|
|
131149
131154
|
if (completionNodes.length) {
|
|
131155
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131150
131156
|
replacementSpan = modifiersSpan;
|
|
131151
131157
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131152
131158
|
// and then format the printed text.
|
|
131153
131159
|
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);
|
|
131160
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131168
131161
|
}
|
|
131169
131162
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131170
|
-
insertText = printer.printSnippetList(
|
|
131163
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131171
131164
|
}
|
|
131172
131165
|
}
|
|
131173
131166
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131217,12 +131210,103 @@ var ts;
|
|
|
131217
131210
|
}
|
|
131218
131211
|
return undefined;
|
|
131219
131212
|
}
|
|
131213
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131214
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131215
|
+
var insertText = name;
|
|
131216
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131217
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131218
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131219
|
+
if (!method) {
|
|
131220
|
+
return undefined;
|
|
131221
|
+
}
|
|
131222
|
+
var printer = createSnippetPrinter({
|
|
131223
|
+
removeComments: true,
|
|
131224
|
+
module: options.module,
|
|
131225
|
+
target: options.target,
|
|
131226
|
+
omitTrailingSemicolon: false,
|
|
131227
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131228
|
+
});
|
|
131229
|
+
if (formatContext) {
|
|
131230
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131231
|
+
}
|
|
131232
|
+
else {
|
|
131233
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131234
|
+
}
|
|
131235
|
+
var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131236
|
+
var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
|
|
131237
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
|
|
131238
|
+
}
|
|
131239
|
+
;
|
|
131240
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131241
|
+
var declarations = symbol.getDeclarations();
|
|
131242
|
+
if (!(declarations && declarations.length)) {
|
|
131243
|
+
return undefined;
|
|
131244
|
+
}
|
|
131245
|
+
var checker = program.getTypeChecker();
|
|
131246
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131247
|
+
var declaration = declarations[0];
|
|
131248
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131249
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131250
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131251
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131252
|
+
switch (declaration.kind) {
|
|
131253
|
+
case 166 /* PropertySignature */:
|
|
131254
|
+
case 167 /* PropertyDeclaration */:
|
|
131255
|
+
case 168 /* MethodSignature */:
|
|
131256
|
+
case 169 /* MethodDeclaration */: {
|
|
131257
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131258
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131259
|
+
: type;
|
|
131260
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131261
|
+
// Only offer the completion if there's a single function type component.
|
|
131262
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131263
|
+
if (functionTypes.length === 1) {
|
|
131264
|
+
effectiveType = functionTypes[0];
|
|
131265
|
+
}
|
|
131266
|
+
else {
|
|
131267
|
+
return undefined;
|
|
131268
|
+
}
|
|
131269
|
+
}
|
|
131270
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131271
|
+
if (signatures.length !== 1) {
|
|
131272
|
+
// We don't support overloads in object literals.
|
|
131273
|
+
return undefined;
|
|
131274
|
+
}
|
|
131275
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131276
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131277
|
+
return undefined;
|
|
131278
|
+
}
|
|
131279
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131280
|
+
if (importableReference) {
|
|
131281
|
+
typeNode = importableReference.typeNode;
|
|
131282
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131283
|
+
}
|
|
131284
|
+
var body = void 0;
|
|
131285
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131286
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131287
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131288
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131289
|
+
}
|
|
131290
|
+
else {
|
|
131291
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131292
|
+
}
|
|
131293
|
+
return ts.factory.createMethodDeclaration(
|
|
131294
|
+
/*decorators*/ undefined,
|
|
131295
|
+
/*modifiers*/ undefined,
|
|
131296
|
+
/*asteriskToken*/ undefined, name,
|
|
131297
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131298
|
+
}
|
|
131299
|
+
default:
|
|
131300
|
+
return undefined;
|
|
131301
|
+
}
|
|
131302
|
+
}
|
|
131220
131303
|
function createSnippetPrinter(printerOptions) {
|
|
131221
131304
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131222
131305
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131223
131306
|
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
131307
|
return {
|
|
131225
131308
|
printSnippetList: printSnippetList,
|
|
131309
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131226
131310
|
};
|
|
131227
131311
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131228
131312
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131230,6 +131314,22 @@ var ts;
|
|
|
131230
131314
|
printer.writeList(format, list, sourceFile, writer);
|
|
131231
131315
|
return writer.getText();
|
|
131232
131316
|
}
|
|
131317
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131318
|
+
var syntheticFile = {
|
|
131319
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131320
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131321
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131322
|
+
},
|
|
131323
|
+
};
|
|
131324
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131325
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131326
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131327
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131328
|
+
/* indentation */ 0,
|
|
131329
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131330
|
+
});
|
|
131331
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131332
|
+
}
|
|
131233
131333
|
}
|
|
131234
131334
|
function originToCompletionEntryData(origin) {
|
|
131235
131335
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131327,7 +131427,7 @@ var ts;
|
|
|
131327
131427
|
return CompletionSource.TypeOnlyAlias;
|
|
131328
131428
|
}
|
|
131329
131429
|
}
|
|
131330
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
131430
|
+
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
131431
|
var _a;
|
|
131332
131432
|
var start = ts.timestamp();
|
|
131333
131433
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131342,12 +131442,12 @@ var ts;
|
|
|
131342
131442
|
var symbol = symbols[i];
|
|
131343
131443
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131344
131444
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131345
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
131445
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131346
131446
|
continue;
|
|
131347
131447
|
}
|
|
131348
131448
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131349
|
-
var
|
|
131350
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131449
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
131450
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131351
131451
|
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
131452
|
if (!entry) {
|
|
131353
131453
|
continue;
|
|
@@ -131365,7 +131465,7 @@ var ts;
|
|
|
131365
131465
|
has: function (name) { return uniques.has(name); },
|
|
131366
131466
|
add: function (name) { return uniques.set(name, true); },
|
|
131367
131467
|
};
|
|
131368
|
-
function shouldIncludeSymbol(symbol,
|
|
131468
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131369
131469
|
var allFlags = symbol.flags;
|
|
131370
131470
|
if (!ts.isSourceFile(location)) {
|
|
131371
131471
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131387,9 +131487,9 @@ var ts;
|
|
|
131387
131487
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131388
131488
|
if (!!sourceFile.externalModuleIndicator
|
|
131389
131489
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
131390
|
-
&&
|
|
131391
|
-
&& (
|
|
131392
|
-
||
|
|
131490
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
131491
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
131492
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
131393
131493
|
return false;
|
|
131394
131494
|
}
|
|
131395
131495
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -131429,7 +131529,7 @@ var ts;
|
|
|
131429
131529
|
name: name,
|
|
131430
131530
|
kindModifiers: "" /* none */,
|
|
131431
131531
|
kind: "label" /* label */,
|
|
131432
|
-
sortText: SortText.LocationPriority
|
|
131532
|
+
sortText: Completions.SortText.LocationPriority
|
|
131433
131533
|
});
|
|
131434
131534
|
}
|
|
131435
131535
|
}
|
|
@@ -131455,7 +131555,7 @@ var ts;
|
|
|
131455
131555
|
}
|
|
131456
131556
|
}
|
|
131457
131557
|
var compilerOptions = program.getCompilerOptions();
|
|
131458
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131558
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
131459
131559
|
if (!completionData) {
|
|
131460
131560
|
return { type: "none" };
|
|
131461
131561
|
}
|
|
@@ -131473,7 +131573,9 @@ var ts;
|
|
|
131473
131573
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
131474
131574
|
var origin = symbolToOriginInfoMap[index];
|
|
131475
131575
|
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 */
|
|
131576
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
131577
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
131578
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
131477
131579
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
131478
131580
|
: undefined;
|
|
131479
131581
|
}) || { type: "none" };
|
|
@@ -131555,6 +131657,20 @@ var ts;
|
|
|
131555
131657
|
};
|
|
131556
131658
|
}
|
|
131557
131659
|
}
|
|
131660
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
131661
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
131662
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
131663
|
+
if (importAdder.hasFixes()) {
|
|
131664
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
131665
|
+
return {
|
|
131666
|
+
sourceDisplay: undefined,
|
|
131667
|
+
codeActions: [{
|
|
131668
|
+
changes: changes,
|
|
131669
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
131670
|
+
}],
|
|
131671
|
+
};
|
|
131672
|
+
}
|
|
131673
|
+
}
|
|
131558
131674
|
if (originIsTypeOnlyAlias(origin)) {
|
|
131559
131675
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
131560
131676
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -131647,8 +131763,9 @@ var ts;
|
|
|
131647
131763
|
var _a;
|
|
131648
131764
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
131649
131765
|
}
|
|
131650
|
-
function getCompletionData(program, log, sourceFile,
|
|
131766
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
131651
131767
|
var typeChecker = program.getTypeChecker();
|
|
131768
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
131652
131769
|
var start = ts.timestamp();
|
|
131653
131770
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
131654
131771
|
// 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 +132008,7 @@ var ts;
|
|
|
131891
132008
|
// This also gets mutated in nested-functions after the return
|
|
131892
132009
|
var symbols = [];
|
|
131893
132010
|
var symbolToOriginInfoMap = [];
|
|
131894
|
-
var
|
|
132011
|
+
var symbolToSortTextMap = [];
|
|
131895
132012
|
var seenPropertySymbols = new ts.Map();
|
|
131896
132013
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
131897
132014
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -131946,7 +132063,7 @@ var ts;
|
|
|
131946
132063
|
contextToken: contextToken,
|
|
131947
132064
|
isJsxInitializer: isJsxInitializer,
|
|
131948
132065
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
131949
|
-
|
|
132066
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
131950
132067
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
131951
132068
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
131952
132069
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132060,7 +132177,7 @@ var ts;
|
|
|
132060
132177
|
isNewIdentifierLocation = true;
|
|
132061
132178
|
}
|
|
132062
132179
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132063
|
-
if (
|
|
132180
|
+
if (inUncheckedFile) {
|
|
132064
132181
|
// In javascript files, for union types, we don't just get the members that
|
|
132065
132182
|
// the individual types have in common, we also include all the members that
|
|
132066
132183
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132145,7 +132262,7 @@ var ts;
|
|
|
132145
132262
|
}
|
|
132146
132263
|
function addSymbolSortInfo(symbol) {
|
|
132147
132264
|
if (isStaticProperty(symbol)) {
|
|
132148
|
-
|
|
132265
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132149
132266
|
}
|
|
132150
132267
|
}
|
|
132151
132268
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132255,7 +132372,7 @@ var ts;
|
|
|
132255
132372
|
var symbol = symbols[i];
|
|
132256
132373
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132257
132374
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132258
|
-
|
|
132375
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132259
132376
|
}
|
|
132260
132377
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132261
132378
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132273,7 +132390,7 @@ var ts;
|
|
|
132273
132390
|
var symbol = _a[_i];
|
|
132274
132391
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132275
132392
|
symbols.push(symbol);
|
|
132276
|
-
|
|
132393
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132277
132394
|
}
|
|
132278
132395
|
}
|
|
132279
132396
|
}
|
|
@@ -132351,7 +132468,7 @@ var ts;
|
|
|
132351
132468
|
}
|
|
132352
132469
|
return false;
|
|
132353
132470
|
}
|
|
132354
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
132471
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132355
132472
|
function collectAutoImports() {
|
|
132356
132473
|
var _a, _b;
|
|
132357
132474
|
if (!shouldOfferImportCompletions())
|
|
@@ -132433,14 +132550,55 @@ var ts;
|
|
|
132433
132550
|
}
|
|
132434
132551
|
function pushAutoImportSymbol(symbol, origin) {
|
|
132435
132552
|
var symbolId = ts.getSymbolId(symbol);
|
|
132436
|
-
if (
|
|
132553
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
132437
132554
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
132438
132555
|
return;
|
|
132439
132556
|
}
|
|
132440
132557
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132441
|
-
|
|
132558
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
132442
132559
|
symbols.push(symbol);
|
|
132443
132560
|
}
|
|
132561
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
132562
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
132563
|
+
// TODO: support JS files.
|
|
132564
|
+
if (ts.isInJSFile(location)) {
|
|
132565
|
+
return;
|
|
132566
|
+
}
|
|
132567
|
+
members.forEach(function (member) {
|
|
132568
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
132569
|
+
return;
|
|
132570
|
+
}
|
|
132571
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
132572
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
132573
|
+
/*jsxIdentifierExpected*/ false);
|
|
132574
|
+
if (!displayName) {
|
|
132575
|
+
return;
|
|
132576
|
+
}
|
|
132577
|
+
var name = displayName.name;
|
|
132578
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
132579
|
+
if (!entryProps) {
|
|
132580
|
+
return;
|
|
132581
|
+
}
|
|
132582
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
132583
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
132584
|
+
symbols.push(member);
|
|
132585
|
+
});
|
|
132586
|
+
}
|
|
132587
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
132588
|
+
/*
|
|
132589
|
+
For an object type
|
|
132590
|
+
`type Foo = {
|
|
132591
|
+
bar(x: number): void;
|
|
132592
|
+
foo: (x: string) => string;
|
|
132593
|
+
}`,
|
|
132594
|
+
`bar` will have symbol flag `Method`,
|
|
132595
|
+
`foo` will have symbol flag `Property`.
|
|
132596
|
+
*/
|
|
132597
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
132598
|
+
return false;
|
|
132599
|
+
}
|
|
132600
|
+
return true;
|
|
132601
|
+
}
|
|
132444
132602
|
/**
|
|
132445
132603
|
* Finds the first node that "embraces" the position, so that one may
|
|
132446
132604
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -132574,6 +132732,7 @@ var ts;
|
|
|
132574
132732
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
132575
132733
|
*/
|
|
132576
132734
|
function tryGetObjectLikeCompletionSymbols() {
|
|
132735
|
+
var symbolsStartIndex = symbols.length;
|
|
132577
132736
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132578
132737
|
if (!objectLikeContainer)
|
|
132579
132738
|
return 0 /* Continue */;
|
|
@@ -132638,9 +132797,16 @@ var ts;
|
|
|
132638
132797
|
}
|
|
132639
132798
|
if (typeMembers && typeMembers.length > 0) {
|
|
132640
132799
|
// Add filtered items to the completion list
|
|
132641
|
-
|
|
132800
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
132801
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
132802
|
+
setSortTextToOptionalMember();
|
|
132803
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
132804
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
132805
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
132806
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
132807
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
132808
|
+
}
|
|
132642
132809
|
}
|
|
132643
|
-
setSortTextToOptionalMember();
|
|
132644
132810
|
return 1 /* Success */;
|
|
132645
132811
|
}
|
|
132646
132812
|
/**
|
|
@@ -132715,7 +132881,7 @@ var ts;
|
|
|
132715
132881
|
var _a, _b;
|
|
132716
132882
|
symbols.push(symbol);
|
|
132717
132883
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
132718
|
-
|
|
132884
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
132719
132885
|
}
|
|
132720
132886
|
});
|
|
132721
132887
|
return 1 /* Success */;
|
|
@@ -132770,29 +132936,6 @@ var ts;
|
|
|
132770
132936
|
}
|
|
132771
132937
|
return 1 /* Success */;
|
|
132772
132938
|
}
|
|
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
132939
|
function isConstructorParameterCompletion(node) {
|
|
132797
132940
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
132798
132941
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133129,7 +133272,7 @@ var ts;
|
|
|
133129
133272
|
var _a;
|
|
133130
133273
|
if (m.flags & 16777216 /* Optional */) {
|
|
133131
133274
|
var symbolId = ts.getSymbolId(m);
|
|
133132
|
-
|
|
133275
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133133
133276
|
}
|
|
133134
133277
|
});
|
|
133135
133278
|
}
|
|
@@ -133141,7 +133284,23 @@ var ts;
|
|
|
133141
133284
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133142
133285
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133143
133286
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133144
|
-
|
|
133287
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133288
|
+
}
|
|
133289
|
+
}
|
|
133290
|
+
}
|
|
133291
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133292
|
+
var _a;
|
|
133293
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133294
|
+
var symbol = symbols[i];
|
|
133295
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133296
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133297
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133298
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133299
|
+
/*jsxIdentifierExpected*/ false);
|
|
133300
|
+
if (displayName) {
|
|
133301
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133302
|
+
var name = displayName.name;
|
|
133303
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133145
133304
|
}
|
|
133146
133305
|
}
|
|
133147
133306
|
}
|
|
@@ -133215,6 +133374,29 @@ var ts;
|
|
|
133215
133374
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133216
133375
|
}
|
|
133217
133376
|
}
|
|
133377
|
+
/**
|
|
133378
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
133379
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
133380
|
+
*/
|
|
133381
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
133382
|
+
if (contextToken) {
|
|
133383
|
+
var parent = contextToken.parent;
|
|
133384
|
+
switch (contextToken.kind) {
|
|
133385
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
133386
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
133387
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
133388
|
+
return parent;
|
|
133389
|
+
}
|
|
133390
|
+
break;
|
|
133391
|
+
case 41 /* AsteriskToken */:
|
|
133392
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
133393
|
+
case 79 /* Identifier */:
|
|
133394
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
133395
|
+
? contextToken.parent.parent : undefined;
|
|
133396
|
+
}
|
|
133397
|
+
}
|
|
133398
|
+
return undefined;
|
|
133399
|
+
}
|
|
133218
133400
|
function getRelevantTokens(position, sourceFile) {
|
|
133219
133401
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133220
133402
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133280,7 +133462,7 @@ var ts;
|
|
|
133280
133462
|
name: ts.tokenToString(i),
|
|
133281
133463
|
kind: "keyword" /* keyword */,
|
|
133282
133464
|
kindModifiers: "" /* none */,
|
|
133283
|
-
sortText: SortText.GlobalsOrKeywords
|
|
133465
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133284
133466
|
});
|
|
133285
133467
|
}
|
|
133286
133468
|
return res;
|
|
@@ -133408,7 +133590,7 @@ var ts;
|
|
|
133408
133590
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
133409
133591
|
kind: "keyword" /* keyword */,
|
|
133410
133592
|
kindModifiers: "" /* none */,
|
|
133411
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
133593
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
133412
133594
|
});
|
|
133413
133595
|
}
|
|
133414
133596
|
}
|
|
@@ -145336,6 +145518,7 @@ var ts;
|
|
|
145336
145518
|
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
145519
|
}
|
|
145338
145520
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
145521
|
+
var _b;
|
|
145339
145522
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145340
145523
|
// formatting context is used by rules provider
|
|
145341
145524
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145367,11 +145550,12 @@ var ts;
|
|
|
145367
145550
|
}
|
|
145368
145551
|
}
|
|
145369
145552
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145370
|
-
var
|
|
145553
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145371
145554
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145372
145555
|
undefined;
|
|
145373
|
-
if (
|
|
145374
|
-
|
|
145556
|
+
if (tokenInfo) {
|
|
145557
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
145558
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145375
145559
|
/*dynamicIndentation*/ undefined);
|
|
145376
145560
|
}
|
|
145377
145561
|
}
|