typescript 4.7.0-dev.20220328 → 4.7.0-dev.20220331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/protocol.d.ts +30 -0
- package/lib/tsc.js +163 -139
- package/lib/tsserver.js +618 -351
- package/lib/tsserverlibrary.d.ts +38 -0
- package/lib/tsserverlibrary.js +618 -351
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +600 -349
- package/lib/typescriptServices.d.ts +8 -0
- package/lib/typescriptServices.js +600 -349
- package/lib/typingsInstaller.js +181 -153
- package/package.json +1 -1
|
@@ -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.20220331";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -9689,6 +9689,7 @@ var ts;
|
|
|
9689
9689
|
An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
|
|
9690
9690
|
Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
|
|
9691
9691
|
true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
|
|
9692
|
+
List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
|
|
9692
9693
|
Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
|
|
9693
9694
|
Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
|
|
9694
9695
|
Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
|
|
@@ -13606,7 +13607,9 @@ var ts;
|
|
|
13606
13607
|
|| kind === 174 /* CallSignature */
|
|
13607
13608
|
|| kind === 166 /* PropertySignature */
|
|
13608
13609
|
|| kind === 168 /* MethodSignature */
|
|
13609
|
-
|| kind === 176 /* IndexSignature
|
|
13610
|
+
|| kind === 176 /* IndexSignature */
|
|
13611
|
+
|| kind === 172 /* GetAccessor */
|
|
13612
|
+
|| kind === 173 /* SetAccessor */;
|
|
13610
13613
|
}
|
|
13611
13614
|
ts.isTypeElement = isTypeElement;
|
|
13612
13615
|
function isClassOrTypeElement(node) {
|
|
@@ -39681,6 +39684,18 @@ var ts;
|
|
|
39681
39684
|
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
|
|
39682
39685
|
defaultValueDescription: false,
|
|
39683
39686
|
},
|
|
39687
|
+
{
|
|
39688
|
+
name: "moduleSuffixes",
|
|
39689
|
+
type: "list",
|
|
39690
|
+
element: {
|
|
39691
|
+
name: "suffix",
|
|
39692
|
+
type: "string",
|
|
39693
|
+
},
|
|
39694
|
+
listPreserveFalsyValues: true,
|
|
39695
|
+
affectsModuleResolution: true,
|
|
39696
|
+
category: ts.Diagnostics.Modules,
|
|
39697
|
+
description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
|
|
39698
|
+
},
|
|
39684
39699
|
// Source Maps
|
|
39685
39700
|
{
|
|
39686
39701
|
name: "sourceRoot",
|
|
@@ -41607,7 +41622,7 @@ var ts;
|
|
|
41607
41622
|
if (option.type === "list") {
|
|
41608
41623
|
var listOption_1 = option;
|
|
41609
41624
|
if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
|
|
41610
|
-
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
|
|
41625
|
+
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
|
|
41611
41626
|
}
|
|
41612
41627
|
return value;
|
|
41613
41628
|
}
|
|
@@ -41648,7 +41663,7 @@ var ts;
|
|
|
41648
41663
|
}
|
|
41649
41664
|
}
|
|
41650
41665
|
function convertJsonOptionOfListType(option, values, basePath, errors) {
|
|
41651
|
-
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
|
|
41666
|
+
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
|
|
41652
41667
|
}
|
|
41653
41668
|
/**
|
|
41654
41669
|
* Tests for a path that ends in a recursive directory wildcard.
|
|
@@ -43274,6 +43289,15 @@ var ts;
|
|
|
43274
43289
|
}
|
|
43275
43290
|
/** Return the file if it exists. */
|
|
43276
43291
|
function tryFile(fileName, onlyRecordFailures, state) {
|
|
43292
|
+
var _a, _b;
|
|
43293
|
+
if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
43294
|
+
return tryFileLookup(fileName, onlyRecordFailures, state);
|
|
43295
|
+
}
|
|
43296
|
+
var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
|
|
43297
|
+
var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
|
|
43298
|
+
return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
|
|
43299
|
+
}
|
|
43300
|
+
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
43277
43301
|
if (!onlyRecordFailures) {
|
|
43278
43302
|
if (state.host.fileExists(fileName)) {
|
|
43279
43303
|
if (state.traceEnabled) {
|
|
@@ -47588,6 +47612,7 @@ var ts;
|
|
|
47588
47612
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47589
47613
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47590
47614
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47615
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47591
47616
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47592
47617
|
var CheckMode;
|
|
47593
47618
|
(function (CheckMode) {
|
|
@@ -47597,7 +47622,8 @@ var ts;
|
|
|
47597
47622
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47598
47623
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47599
47624
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47600
|
-
CheckMode[CheckMode["
|
|
47625
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47626
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47601
47627
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47602
47628
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47603
47629
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47935,26 +47961,10 @@ var ts;
|
|
|
47935
47961
|
if (!node) {
|
|
47936
47962
|
return undefined;
|
|
47937
47963
|
}
|
|
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;
|
|
47964
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47965
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47956
47966
|
}
|
|
47957
|
-
return
|
|
47967
|
+
return getContextualType(node, contextFlags);
|
|
47958
47968
|
},
|
|
47959
47969
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47960
47970
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47974,6 +47984,9 @@ var ts;
|
|
|
47974
47984
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47975
47985
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47976
47986
|
},
|
|
47987
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47988
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47989
|
+
},
|
|
47977
47990
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47978
47991
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47979
47992
|
},
|
|
@@ -48126,10 +48139,34 @@ var ts;
|
|
|
48126
48139
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
48127
48140
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
48128
48141
|
};
|
|
48129
|
-
function
|
|
48142
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
48143
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
48144
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
48145
|
+
if (containingCall) {
|
|
48146
|
+
var toMarkSkip = node;
|
|
48147
|
+
do {
|
|
48148
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
48149
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48150
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48151
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
48152
|
+
}
|
|
48153
|
+
var result = fn();
|
|
48154
|
+
if (containingCall) {
|
|
48155
|
+
var toMarkSkip = node;
|
|
48156
|
+
do {
|
|
48157
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
48158
|
+
toMarkSkip = toMarkSkip.parent;
|
|
48159
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
48160
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
48161
|
+
}
|
|
48162
|
+
return result;
|
|
48163
|
+
}
|
|
48164
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
48130
48165
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
48131
48166
|
apparentArgumentCount = argumentCount;
|
|
48132
|
-
var res = node ?
|
|
48167
|
+
var res = !node ? undefined :
|
|
48168
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
48169
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
48133
48170
|
apparentArgumentCount = undefined;
|
|
48134
48171
|
return res;
|
|
48135
48172
|
}
|
|
@@ -49102,6 +49139,10 @@ var ts;
|
|
|
49102
49139
|
}
|
|
49103
49140
|
}
|
|
49104
49141
|
}
|
|
49142
|
+
function isConstAssertion(location) {
|
|
49143
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
49144
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
49145
|
+
}
|
|
49105
49146
|
/**
|
|
49106
49147
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
49107
49148
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -49127,6 +49168,11 @@ var ts;
|
|
|
49127
49168
|
var grandparent;
|
|
49128
49169
|
var isInExternalModule = false;
|
|
49129
49170
|
loop: while (location) {
|
|
49171
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
49172
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
49173
|
+
// (it refers to the constant type of the expression instead)
|
|
49174
|
+
return undefined;
|
|
49175
|
+
}
|
|
49130
49176
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
49131
49177
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
49132
49178
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -52247,7 +52293,15 @@ var ts;
|
|
|
52247
52293
|
if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
|
|
52248
52294
|
return node;
|
|
52249
52295
|
}
|
|
52250
|
-
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
|
|
52296
|
+
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
|
|
52297
|
+
}
|
|
52298
|
+
function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
|
|
52299
|
+
if (nodes && nodes.length === 0) {
|
|
52300
|
+
// Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
|
|
52301
|
+
// which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
|
|
52302
|
+
return ts.setTextRange(ts.factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
|
|
52303
|
+
}
|
|
52304
|
+
return ts.visitNodes(nodes, visitor, test, start, count);
|
|
52251
52305
|
}
|
|
52252
52306
|
}
|
|
52253
52307
|
function createTypeNodeFromObjectType(type) {
|
|
@@ -55075,6 +55129,8 @@ var ts;
|
|
|
55075
55129
|
return !!target.resolvedTypeArguments;
|
|
55076
55130
|
case 7 /* ResolvedBaseTypes */:
|
|
55077
55131
|
return !!target.baseTypesResolved;
|
|
55132
|
+
case 8 /* WriteType */:
|
|
55133
|
+
return !!getSymbolLinks(target).writeType;
|
|
55078
55134
|
}
|
|
55079
55135
|
return ts.Debug.assertNever(propertyName);
|
|
55080
55136
|
}
|
|
@@ -55252,7 +55308,7 @@ var ts;
|
|
|
55252
55308
|
}
|
|
55253
55309
|
/** Return the inferred type for a binding element */
|
|
55254
55310
|
function getTypeForBindingElement(declaration) {
|
|
55255
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55311
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55256
55312
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55257
55313
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55258
55314
|
}
|
|
@@ -55992,6 +56048,11 @@ var ts;
|
|
|
55992
56048
|
}
|
|
55993
56049
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55994
56050
|
}
|
|
56051
|
+
if (ts.isAccessor(declaration)) {
|
|
56052
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
56053
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
56054
|
+
return getTypeOfAccessors(symbol);
|
|
56055
|
+
}
|
|
55995
56056
|
// Handle variable, parameter or property
|
|
55996
56057
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55997
56058
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -56055,9 +56116,6 @@ var ts;
|
|
|
56055
56116
|
else if (ts.isEnumMember(declaration)) {
|
|
56056
56117
|
type = getTypeOfEnumMember(symbol);
|
|
56057
56118
|
}
|
|
56058
|
-
else if (ts.isAccessor(declaration)) {
|
|
56059
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
56060
|
-
}
|
|
56061
56119
|
else {
|
|
56062
56120
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
56063
56121
|
}
|
|
@@ -56096,87 +56154,61 @@ var ts;
|
|
|
56096
56154
|
}
|
|
56097
56155
|
function getTypeOfAccessors(symbol) {
|
|
56098
56156
|
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()) {
|
|
56157
|
+
if (!links.type) {
|
|
56158
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
56159
|
+
return errorType;
|
|
56160
|
+
}
|
|
56112
56161
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56162
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56163
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
56164
|
+
// body return type inference, in that order.
|
|
56165
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
56166
|
+
getAnnotatedAccessorType(getter) ||
|
|
56167
|
+
getAnnotatedAccessorType(setter) ||
|
|
56168
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
56169
|
+
if (!type) {
|
|
56170
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
56171
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
56172
|
+
}
|
|
56173
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
56174
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56175
|
+
}
|
|
56176
|
+
type = anyType;
|
|
56177
|
+
}
|
|
56178
|
+
if (!popTypeResolution()) {
|
|
56179
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
56180
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56181
|
+
}
|
|
56182
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56183
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56116
56184
|
}
|
|
56117
|
-
else if (noImplicitAny) {
|
|
56185
|
+
else if (getter && noImplicitAny) {
|
|
56118
56186
|
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
56187
|
}
|
|
56188
|
+
type = anyType;
|
|
56120
56189
|
}
|
|
56121
|
-
type =
|
|
56190
|
+
links.type = type;
|
|
56122
56191
|
}
|
|
56123
|
-
return type;
|
|
56192
|
+
return links.type;
|
|
56124
56193
|
}
|
|
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));
|
|
56194
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
56195
|
+
var links = getSymbolLinks(symbol);
|
|
56196
|
+
if (!links.writeType) {
|
|
56197
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
56198
|
+
return errorType;
|
|
56169
56199
|
}
|
|
56170
|
-
|
|
56171
|
-
|
|
56172
|
-
|
|
56173
|
-
|
|
56174
|
-
|
|
56175
|
-
|
|
56176
|
-
|
|
56200
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56201
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
56202
|
+
if (!popTypeResolution()) {
|
|
56203
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56204
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56205
|
+
}
|
|
56206
|
+
writeType = anyType;
|
|
56177
56207
|
}
|
|
56178
|
-
|
|
56208
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
56209
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
56179
56210
|
}
|
|
56211
|
+
return links.writeType;
|
|
56180
56212
|
}
|
|
56181
56213
|
function getBaseTypeVariableOfClass(symbol) {
|
|
56182
56214
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56258,17 +56290,11 @@ var ts;
|
|
|
56258
56290
|
}
|
|
56259
56291
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56260
56292
|
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;
|
|
56293
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56294
|
+
}
|
|
56295
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56296
|
+
var links = getSymbolLinks(symbol);
|
|
56297
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56272
56298
|
}
|
|
56273
56299
|
function reportCircularityError(symbol) {
|
|
56274
56300
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56305,35 +56331,23 @@ var ts;
|
|
|
56305
56331
|
return links.writeType;
|
|
56306
56332
|
}
|
|
56307
56333
|
/**
|
|
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.
|
|
56334
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56335
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56336
|
+
* intersection of the writeTypes of their constituents.
|
|
56314
56337
|
*/
|
|
56315
56338
|
function getWriteTypeOfSymbol(symbol) {
|
|
56316
56339
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56317
|
-
if (
|
|
56318
|
-
|
|
56319
|
-
|
|
56320
|
-
|
|
56321
|
-
|
|
56340
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56341
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56342
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56343
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56344
|
+
symbol.writeType || symbol.type :
|
|
56345
|
+
getTypeOfSymbol(symbol);
|
|
56322
56346
|
}
|
|
56323
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56324
|
-
var writeType = symbol.writeType;
|
|
56325
|
-
if (writeType) {
|
|
56326
|
-
return writeType;
|
|
56327
|
-
}
|
|
56328
|
-
}
|
|
56329
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56330
|
-
}
|
|
56331
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56332
56347
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56333
|
-
|
|
56334
|
-
|
|
56335
|
-
|
|
56336
|
-
}
|
|
56348
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56349
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56350
|
+
getWriteTypeOfAccessors(symbol);
|
|
56337
56351
|
}
|
|
56338
56352
|
return getTypeOfSymbol(symbol);
|
|
56339
56353
|
}
|
|
@@ -68422,7 +68436,7 @@ var ts;
|
|
|
68422
68436
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68423
68437
|
var targetProp = properties_3[_i];
|
|
68424
68438
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68425
|
-
if (sourceProp) {
|
|
68439
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68426
68440
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68427
68441
|
}
|
|
68428
68442
|
}
|
|
@@ -70804,7 +70818,7 @@ var ts;
|
|
|
70804
70818
|
}
|
|
70805
70819
|
}
|
|
70806
70820
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70807
|
-
return
|
|
70821
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70808
70822
|
}
|
|
70809
70823
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70810
70824
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -70896,7 +70910,7 @@ var ts;
|
|
|
70896
70910
|
// as we want the type of a rest element to be generic when possible.
|
|
70897
70911
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70898
70912
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70899
|
-
(checkMode && checkMode &
|
|
70913
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70900
70914
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70901
70915
|
: getContextualType(node));
|
|
70902
70916
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -71017,7 +71031,7 @@ var ts;
|
|
|
71017
71031
|
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
|
|
71018
71032
|
var contextualSignature = getContextualSignature(func);
|
|
71019
71033
|
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
|
|
71020
|
-
var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
|
|
71034
|
+
var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
|
|
71021
71035
|
if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
|
|
71022
71036
|
var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
|
|
71023
71037
|
var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
|
|
@@ -71835,7 +71849,7 @@ var ts;
|
|
|
71835
71849
|
var parent = declaration.parent.parent;
|
|
71836
71850
|
var name = declaration.propertyName || declaration.name;
|
|
71837
71851
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71838
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71852
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71839
71853
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71840
71854
|
return undefined;
|
|
71841
71855
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -72322,9 +72336,14 @@ var ts;
|
|
|
72322
72336
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72323
72337
|
}
|
|
72324
72338
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72325
|
-
// incorporate inferences made from the return type in a function call.
|
|
72339
|
+
// incorporate inferences made from the return type in a function call. We remove
|
|
72340
|
+
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72341
|
+
// literals actually end up widening to 'boolean' (see #48363).
|
|
72326
72342
|
if (inferenceContext.returnMapper) {
|
|
72327
|
-
|
|
72343
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72344
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72345
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72346
|
+
type;
|
|
72328
72347
|
}
|
|
72329
72348
|
}
|
|
72330
72349
|
}
|
|
@@ -74889,7 +74908,7 @@ var ts;
|
|
|
74889
74908
|
}
|
|
74890
74909
|
for (var i = 0; i < argCount; i++) {
|
|
74891
74910
|
var arg = args[i];
|
|
74892
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74911
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74893
74912
|
var paramType = getTypeAtPosition(signature, i);
|
|
74894
74913
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74895
74914
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75574,7 +75593,7 @@ var ts;
|
|
|
75574
75593
|
}
|
|
75575
75594
|
}
|
|
75576
75595
|
}
|
|
75577
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75596
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75578
75597
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75579
75598
|
var _a, _b;
|
|
75580
75599
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75675,14 +75694,14 @@ var ts;
|
|
|
75675
75694
|
}
|
|
75676
75695
|
}
|
|
75677
75696
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75678
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75697
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75679
75698
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75680
75699
|
checkNodeDeferred(node);
|
|
75681
75700
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75682
75701
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75683
75702
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75684
75703
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75685
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75704
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75686
75705
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75687
75706
|
}
|
|
75688
75707
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75730,7 +75749,7 @@ var ts;
|
|
|
75730
75749
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75731
75750
|
return createSymbolWithType(ts.first(sources), type);
|
|
75732
75751
|
}
|
|
75733
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75752
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75734
75753
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75735
75754
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75736
75755
|
// f({ |
|
|
@@ -75746,7 +75765,7 @@ var ts;
|
|
|
75746
75765
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75747
75766
|
var instantiated = typeArgumentNodes
|
|
75748
75767
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75749
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75768
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75750
75769
|
candidates[bestIndex] = instantiated;
|
|
75751
75770
|
return instantiated;
|
|
75752
75771
|
}
|
|
@@ -75760,9 +75779,9 @@ var ts;
|
|
|
75760
75779
|
}
|
|
75761
75780
|
return typeArguments;
|
|
75762
75781
|
}
|
|
75763
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75782
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75764
75783
|
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);
|
|
75784
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75766
75785
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75767
75786
|
}
|
|
75768
75787
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81828,7 +81847,7 @@ var ts;
|
|
|
81828
81847
|
}
|
|
81829
81848
|
// check private/protected variable access
|
|
81830
81849
|
var parent = node.parent.parent;
|
|
81831
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81850
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81832
81851
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81833
81852
|
var name = node.propertyName || node.name;
|
|
81834
81853
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -82007,6 +82026,8 @@ var ts;
|
|
|
82007
82026
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
82008
82027
|
? condExpr.right
|
|
82009
82028
|
: condExpr;
|
|
82029
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
82030
|
+
return;
|
|
82010
82031
|
var type = checkTruthinessExpression(location);
|
|
82011
82032
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82012
82033
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -116924,6 +116945,13 @@ var ts;
|
|
|
116924
116945
|
return "skip";
|
|
116925
116946
|
}
|
|
116926
116947
|
break;
|
|
116948
|
+
case 270 /* ImportSpecifier */:
|
|
116949
|
+
case 275 /* ExportSpecifier */:
|
|
116950
|
+
if (node.isTypeOnly) {
|
|
116951
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116952
|
+
return "skip";
|
|
116953
|
+
}
|
|
116954
|
+
break;
|
|
116927
116955
|
case 265 /* ImportEqualsDeclaration */:
|
|
116928
116956
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116929
116957
|
return "skip";
|
|
@@ -126684,12 +126712,8 @@ var ts;
|
|
|
126684
126712
|
}
|
|
126685
126713
|
}
|
|
126686
126714
|
ts.findNextToken = findNextToken;
|
|
126687
|
-
/**
|
|
126688
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126689
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126690
|
-
*/
|
|
126691
126715
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126692
|
-
var result = find(startNode || sourceFile);
|
|
126716
|
+
var result = find((startNode || sourceFile));
|
|
126693
126717
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126694
126718
|
return result;
|
|
126695
126719
|
function find(n) {
|
|
@@ -127789,6 +127813,14 @@ var ts;
|
|
|
127789
127813
|
});
|
|
127790
127814
|
}
|
|
127791
127815
|
ts.signatureToDisplayParts = signatureToDisplayParts;
|
|
127816
|
+
function nodeToDisplayParts(node, enclosingDeclaration) {
|
|
127817
|
+
var file = enclosingDeclaration.getSourceFile();
|
|
127818
|
+
return mapToDisplayParts(function (writer) {
|
|
127819
|
+
var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
127820
|
+
printer.writeNode(4 /* Unspecified */, node, file, writer);
|
|
127821
|
+
});
|
|
127822
|
+
}
|
|
127823
|
+
ts.nodeToDisplayParts = nodeToDisplayParts;
|
|
127792
127824
|
function isImportOrExportSpecifierName(location) {
|
|
127793
127825
|
return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
|
127794
127826
|
}
|
|
@@ -130485,12 +130517,13 @@ var ts;
|
|
|
130485
130517
|
}
|
|
130486
130518
|
case 208 /* CallExpression */:
|
|
130487
130519
|
case 209 /* NewExpression */:
|
|
130520
|
+
case 285 /* JsxAttribute */:
|
|
130488
130521
|
if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) {
|
|
130489
|
-
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile);
|
|
130522
|
+
var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile);
|
|
130490
130523
|
// Get string literal completions from specialized signatures of the target
|
|
130491
130524
|
// i.e. declare function f(a: 'A');
|
|
130492
130525
|
// f("/*completion position*/")
|
|
130493
|
-
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType();
|
|
130526
|
+
return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType();
|
|
130494
130527
|
}
|
|
130495
130528
|
// falls through (is `require("")` or `require(""` or `import("")`)
|
|
130496
130529
|
case 266 /* ImportDeclaration */:
|
|
@@ -130527,15 +130560,22 @@ var ts;
|
|
|
130527
130560
|
return type !== current && ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal) ? type.literal.text : undefined;
|
|
130528
130561
|
});
|
|
130529
130562
|
}
|
|
130530
|
-
function getStringLiteralCompletionsFromSignature(argumentInfo, checker) {
|
|
130563
|
+
function getStringLiteralCompletionsFromSignature(call, arg, argumentInfo, checker) {
|
|
130531
130564
|
var isNewIdentifier = false;
|
|
130532
130565
|
var uniques = new ts.Map();
|
|
130533
130566
|
var candidates = [];
|
|
130534
|
-
|
|
130567
|
+
var editingArgument = ts.isJsxOpeningLikeElement(call) ? ts.Debug.checkDefined(ts.findAncestor(arg.parent, ts.isJsxAttribute)) : arg;
|
|
130568
|
+
checker.getResolvedSignatureForStringLiteralCompletions(call, editingArgument, candidates);
|
|
130535
130569
|
var types = ts.flatMap(candidates, function (candidate) {
|
|
130536
130570
|
if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length)
|
|
130537
130571
|
return;
|
|
130538
130572
|
var type = candidate.getTypeParameterAtPosition(argumentInfo.argumentIndex);
|
|
130573
|
+
if (ts.isJsxOpeningLikeElement(call)) {
|
|
130574
|
+
var propType = checker.getTypeOfPropertyOfType(type, editingArgument.name.text);
|
|
130575
|
+
if (propType) {
|
|
130576
|
+
type = propType;
|
|
130577
|
+
}
|
|
130578
|
+
}
|
|
130539
130579
|
isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */);
|
|
130540
130580
|
return getStringLiteralTypes(type, uniques);
|
|
130541
130581
|
});
|
|
@@ -131078,43 +131118,28 @@ var ts;
|
|
|
131078
131118
|
// Exported only for tests
|
|
131079
131119
|
Completions.moduleSpecifierResolutionLimit = 100;
|
|
131080
131120
|
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 = {}));
|
|
131121
|
+
Completions.SortText = {
|
|
131122
|
+
// Presets
|
|
131123
|
+
LocalDeclarationPriority: "10",
|
|
131124
|
+
LocationPriority: "11",
|
|
131125
|
+
OptionalMember: "12",
|
|
131126
|
+
MemberDeclaredBySpreadAssignment: "13",
|
|
131127
|
+
SuggestedClassMembers: "14",
|
|
131128
|
+
GlobalsOrKeywords: "15",
|
|
131129
|
+
AutoImportSuggestions: "16",
|
|
131130
|
+
ClassMemberSnippets: "17",
|
|
131131
|
+
JavascriptIdentifiers: "18",
|
|
131132
|
+
// Transformations
|
|
131133
|
+
Deprecated: function (sortText) {
|
|
131134
|
+
return "z" + sortText;
|
|
131135
|
+
},
|
|
131136
|
+
ObjectLiteralProperty: function (presetSortText, symbolDisplayName) {
|
|
131137
|
+
return presetSortText + "\0" + symbolDisplayName + "\0";
|
|
131138
|
+
},
|
|
131139
|
+
SortBelow: function (sortText) {
|
|
131140
|
+
return sortText + "1";
|
|
131141
|
+
},
|
|
131142
|
+
};
|
|
131118
131143
|
/**
|
|
131119
131144
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
131120
131145
|
* completion items with the same `name`. (Each completion item must
|
|
@@ -131134,6 +131159,8 @@ var ts;
|
|
|
131134
131159
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
131135
131160
|
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
131136
131161
|
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
131162
|
+
/** Auto-import that comes attached to an object literal method snippet */
|
|
131163
|
+
CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
131137
131164
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
131138
131165
|
var SymbolOriginInfoKind;
|
|
131139
131166
|
(function (SymbolOriginInfoKind) {
|
|
@@ -131144,6 +131171,7 @@ var ts;
|
|
|
131144
131171
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
131145
131172
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
131146
131173
|
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
131174
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
|
|
131147
131175
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
131148
131176
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
131149
131177
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -131174,6 +131202,9 @@ var ts;
|
|
|
131174
131202
|
function originIsTypeOnlyAlias(origin) {
|
|
131175
131203
|
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
131176
131204
|
}
|
|
131205
|
+
function originIsObjectLiteralMethod(origin) {
|
|
131206
|
+
return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
|
|
131207
|
+
}
|
|
131177
131208
|
var KeywordCompletionFilters;
|
|
131178
131209
|
(function (KeywordCompletionFilters) {
|
|
131179
131210
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -131266,7 +131297,7 @@ var ts;
|
|
|
131266
131297
|
&& (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) {
|
|
131267
131298
|
return getLabelCompletionAtPosition(previousToken.parent);
|
|
131268
131299
|
}
|
|
131269
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
131300
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken);
|
|
131270
131301
|
if (!completionData) {
|
|
131271
131302
|
return undefined;
|
|
131272
131303
|
}
|
|
@@ -131364,7 +131395,7 @@ var ts;
|
|
|
131364
131395
|
name: ts.tokenToString(keyword),
|
|
131365
131396
|
kind: "keyword" /* keyword */,
|
|
131366
131397
|
kindModifiers: "" /* none */,
|
|
131367
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
131398
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
131368
131399
|
};
|
|
131369
131400
|
}
|
|
131370
131401
|
function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) {
|
|
@@ -131393,7 +131424,7 @@ var ts;
|
|
|
131393
131424
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
131394
131425
|
}
|
|
131395
131426
|
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,
|
|
131427
|
+
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
131428
|
// Verify if the file is JSX language variant
|
|
131398
131429
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
131399
131430
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -131404,7 +131435,7 @@ var ts;
|
|
|
131404
131435
|
var entries = ts.createSortedArray();
|
|
131405
131436
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
131406
131437
|
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,
|
|
131438
|
+
/*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
131439
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
131409
131440
|
}
|
|
131410
131441
|
else {
|
|
@@ -131412,7 +131443,7 @@ var ts;
|
|
|
131412
131443
|
return undefined;
|
|
131413
131444
|
}
|
|
131414
131445
|
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,
|
|
131446
|
+
/*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
131447
|
}
|
|
131417
131448
|
if (keywordFilters !== 0 /* None */) {
|
|
131418
131449
|
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -131493,7 +131524,7 @@ var ts;
|
|
|
131493
131524
|
name: fullClosingTag,
|
|
131494
131525
|
kind: "class" /* classElement */,
|
|
131495
131526
|
kindModifiers: undefined,
|
|
131496
|
-
sortText: SortText.LocationPriority,
|
|
131527
|
+
sortText: Completions.SortText.LocationPriority,
|
|
131497
131528
|
};
|
|
131498
131529
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] };
|
|
131499
131530
|
}
|
|
@@ -131512,7 +131543,7 @@ var ts;
|
|
|
131512
131543
|
name: realName,
|
|
131513
131544
|
kind: "warning" /* warning */,
|
|
131514
131545
|
kindModifiers: "",
|
|
131515
|
-
sortText: SortText.JavascriptIdentifiers,
|
|
131546
|
+
sortText: Completions.SortText.JavascriptIdentifiers,
|
|
131516
131547
|
isFromUncheckedFile: true
|
|
131517
131548
|
}, compareCompletionEntries);
|
|
131518
131549
|
}
|
|
@@ -131523,7 +131554,7 @@ var ts;
|
|
|
131523
131554
|
ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal);
|
|
131524
131555
|
}
|
|
131525
131556
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
131526
|
-
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
131557
|
+
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority };
|
|
131527
131558
|
}
|
|
131528
131559
|
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
131560
|
var _a, _b;
|
|
@@ -131534,6 +131565,7 @@ var ts;
|
|
|
131534
131565
|
var source = getSourceFromOrigin(origin);
|
|
131535
131566
|
var sourceDisplay;
|
|
131536
131567
|
var hasAction;
|
|
131568
|
+
var labelDetails;
|
|
131537
131569
|
var typeChecker = program.getTypeChecker();
|
|
131538
131570
|
var insertQuestionDot = origin && originIsNullableMember(origin);
|
|
131539
131571
|
var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
|
|
@@ -131594,12 +131626,25 @@ var ts;
|
|
|
131594
131626
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131595
131627
|
var importAdder = void 0;
|
|
131596
131628
|
(_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.
|
|
131629
|
+
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131598
131630
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131599
131631
|
hasAction = true;
|
|
131600
131632
|
source = CompletionSource.ClassMemberSnippet;
|
|
131601
131633
|
}
|
|
131602
131634
|
}
|
|
131635
|
+
if (origin && originIsObjectLiteralMethod(origin)) {
|
|
131636
|
+
var importAdder = void 0;
|
|
131637
|
+
(insertText = origin.insertText, isSnippet = origin.isSnippet, importAdder = origin.importAdder, labelDetails = origin.labelDetails);
|
|
131638
|
+
if (!preferences.useLabelDetailsInCompletionEntries) {
|
|
131639
|
+
name = name + labelDetails.detail;
|
|
131640
|
+
labelDetails = undefined;
|
|
131641
|
+
}
|
|
131642
|
+
source = CompletionSource.ObjectLiteralMethodSnippet;
|
|
131643
|
+
sortText = Completions.SortText.SortBelow(sortText);
|
|
131644
|
+
if (importAdder.hasFixes()) {
|
|
131645
|
+
hasAction = true;
|
|
131646
|
+
}
|
|
131647
|
+
}
|
|
131603
131648
|
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
131604
131649
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
131605
131650
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -131647,6 +131692,7 @@ var ts;
|
|
|
131647
131692
|
insertText: insertText,
|
|
131648
131693
|
replacementSpan: replacementSpan,
|
|
131649
131694
|
sourceDisplay: sourceDisplay,
|
|
131695
|
+
labelDetails: labelDetails,
|
|
131650
131696
|
isSnippet: isSnippet,
|
|
131651
131697
|
isPackageJsonImport: originIsPackageJsonImport(origin) || undefined,
|
|
131652
131698
|
isImportStatementCompletion: !!importCompletionNode || undefined,
|
|
@@ -131758,27 +131804,15 @@ var ts;
|
|
|
131758
131804
|
completionNodes.push(node);
|
|
131759
131805
|
}, body, 2 /* Property */, isAbstract);
|
|
131760
131806
|
if (completionNodes.length) {
|
|
131807
|
+
var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
|
|
131761
131808
|
replacementSpan = modifiersSpan;
|
|
131762
131809
|
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
131763
131810
|
// and then format the printed text.
|
|
131764
131811
|
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);
|
|
131812
|
+
insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
|
|
131779
131813
|
}
|
|
131780
131814
|
else { // Otherwise, just use emitter to print the new nodes.
|
|
131781
|
-
insertText = printer.printSnippetList(
|
|
131815
|
+
insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
131782
131816
|
}
|
|
131783
131817
|
}
|
|
131784
131818
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
|
|
@@ -131828,12 +131862,113 @@ var ts;
|
|
|
131828
131862
|
}
|
|
131829
131863
|
return undefined;
|
|
131830
131864
|
}
|
|
131865
|
+
function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
|
|
131866
|
+
var isSnippet = preferences.includeCompletionsWithSnippetText || undefined;
|
|
131867
|
+
var insertText = name;
|
|
131868
|
+
var sourceFile = enclosingDeclaration.getSourceFile();
|
|
131869
|
+
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
131870
|
+
var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder);
|
|
131871
|
+
if (!method) {
|
|
131872
|
+
return undefined;
|
|
131873
|
+
}
|
|
131874
|
+
var printer = createSnippetPrinter({
|
|
131875
|
+
removeComments: true,
|
|
131876
|
+
module: options.module,
|
|
131877
|
+
target: options.target,
|
|
131878
|
+
omitTrailingSemicolon: false,
|
|
131879
|
+
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
131880
|
+
});
|
|
131881
|
+
if (formatContext) {
|
|
131882
|
+
insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
|
|
131883
|
+
}
|
|
131884
|
+
else {
|
|
131885
|
+
insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
|
|
131886
|
+
}
|
|
131887
|
+
var signaturePrinter = ts.createPrinter({
|
|
131888
|
+
removeComments: true,
|
|
131889
|
+
module: options.module,
|
|
131890
|
+
target: options.target,
|
|
131891
|
+
omitTrailingSemicolon: true,
|
|
131892
|
+
});
|
|
131893
|
+
// The `labelDetails.detail` will be displayed right beside the method name,
|
|
131894
|
+
// so we drop the name (and modifiers) from the signature.
|
|
131895
|
+
var methodSignature = ts.factory.createMethodSignature(
|
|
131896
|
+
/*modifiers*/ undefined,
|
|
131897
|
+
/*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type);
|
|
131898
|
+
var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) };
|
|
131899
|
+
return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, labelDetails: labelDetails };
|
|
131900
|
+
}
|
|
131901
|
+
;
|
|
131902
|
+
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder) {
|
|
131903
|
+
var declarations = symbol.getDeclarations();
|
|
131904
|
+
if (!(declarations && declarations.length)) {
|
|
131905
|
+
return undefined;
|
|
131906
|
+
}
|
|
131907
|
+
var checker = program.getTypeChecker();
|
|
131908
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
131909
|
+
var declaration = declarations[0];
|
|
131910
|
+
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
131911
|
+
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
131912
|
+
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
131913
|
+
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
|
|
131914
|
+
switch (declaration.kind) {
|
|
131915
|
+
case 166 /* PropertySignature */:
|
|
131916
|
+
case 167 /* PropertyDeclaration */:
|
|
131917
|
+
case 168 /* MethodSignature */:
|
|
131918
|
+
case 169 /* MethodDeclaration */: {
|
|
131919
|
+
var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10
|
|
131920
|
+
? checker.getUnionType(type.types, 2 /* Subtype */)
|
|
131921
|
+
: type;
|
|
131922
|
+
if (effectiveType.flags & 1048576 /* Union */) {
|
|
131923
|
+
// Only offer the completion if there's a single function type component.
|
|
131924
|
+
var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; });
|
|
131925
|
+
if (functionTypes.length === 1) {
|
|
131926
|
+
effectiveType = functionTypes[0];
|
|
131927
|
+
}
|
|
131928
|
+
else {
|
|
131929
|
+
return undefined;
|
|
131930
|
+
}
|
|
131931
|
+
}
|
|
131932
|
+
var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */);
|
|
131933
|
+
if (signatures.length !== 1) {
|
|
131934
|
+
// We don't support overloads in object literals.
|
|
131935
|
+
return undefined;
|
|
131936
|
+
}
|
|
131937
|
+
var typeNode = checker.typeToTypeNode(effectiveType, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
|
|
131938
|
+
if (!typeNode || !ts.isFunctionTypeNode(typeNode)) {
|
|
131939
|
+
return undefined;
|
|
131940
|
+
}
|
|
131941
|
+
var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
131942
|
+
if (importableReference) {
|
|
131943
|
+
typeNode = importableReference.typeNode;
|
|
131944
|
+
ts.codefix.importSymbols(importAdder, importableReference.symbols);
|
|
131945
|
+
}
|
|
131946
|
+
var body = void 0;
|
|
131947
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
131948
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
131949
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
131950
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
131951
|
+
}
|
|
131952
|
+
else {
|
|
131953
|
+
body = ts.factory.createBlock([], /* multiline */ true);
|
|
131954
|
+
}
|
|
131955
|
+
return ts.factory.createMethodDeclaration(
|
|
131956
|
+
/*decorators*/ undefined,
|
|
131957
|
+
/*modifiers*/ undefined,
|
|
131958
|
+
/*asteriskToken*/ undefined, name,
|
|
131959
|
+
/*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
|
|
131960
|
+
}
|
|
131961
|
+
default:
|
|
131962
|
+
return undefined;
|
|
131963
|
+
}
|
|
131964
|
+
}
|
|
131831
131965
|
function createSnippetPrinter(printerOptions) {
|
|
131832
131966
|
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
131833
131967
|
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
131834
131968
|
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
131969
|
return {
|
|
131836
131970
|
printSnippetList: printSnippetList,
|
|
131971
|
+
printAndFormatSnippetList: printAndFormatSnippetList,
|
|
131837
131972
|
};
|
|
131838
131973
|
/* Snippet-escaping version of `printer.printList`. */
|
|
131839
131974
|
function printSnippetList(format, list, sourceFile) {
|
|
@@ -131841,6 +131976,22 @@ var ts;
|
|
|
131841
131976
|
printer.writeList(format, list, sourceFile, writer);
|
|
131842
131977
|
return writer.getText();
|
|
131843
131978
|
}
|
|
131979
|
+
function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
|
|
131980
|
+
var syntheticFile = {
|
|
131981
|
+
text: printSnippetList(format, list, sourceFile),
|
|
131982
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
131983
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
131984
|
+
},
|
|
131985
|
+
};
|
|
131986
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
131987
|
+
var changes = ts.flatMap(list, function (node) {
|
|
131988
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
131989
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
|
|
131990
|
+
/* indentation */ 0,
|
|
131991
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
|
|
131992
|
+
});
|
|
131993
|
+
return ts.textChanges.applyChanges(syntheticFile.text, changes);
|
|
131994
|
+
}
|
|
131844
131995
|
}
|
|
131845
131996
|
function originToCompletionEntryData(origin) {
|
|
131846
131997
|
var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
|
|
@@ -131938,7 +132089,7 @@ var ts;
|
|
|
131938
132089
|
return CompletionSource.TypeOnlyAlias;
|
|
131939
132090
|
}
|
|
131940
132091
|
}
|
|
131941
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap,
|
|
132092
|
+
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
132093
|
var _a;
|
|
131943
132094
|
var start = ts.timestamp();
|
|
131944
132095
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -131953,12 +132104,12 @@ var ts;
|
|
|
131953
132104
|
var symbol = symbols[i];
|
|
131954
132105
|
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
131955
132106
|
var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
|
131956
|
-
if (!info || uniques.get(info.name) || kind === 1 /* Global */ &&
|
|
132107
|
+
if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) {
|
|
131957
132108
|
continue;
|
|
131958
132109
|
}
|
|
131959
132110
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131960
|
-
var
|
|
131961
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
132111
|
+
var originalSortText = (_a = symbolToSortTextMap === null || symbolToSortTextMap === void 0 ? void 0 : symbolToSortTextMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
132112
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? Completions.SortText.Deprecated(originalSortText) : originalSortText);
|
|
131962
132113
|
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
132114
|
if (!entry) {
|
|
131964
132115
|
continue;
|
|
@@ -131976,7 +132127,7 @@ var ts;
|
|
|
131976
132127
|
has: function (name) { return uniques.has(name); },
|
|
131977
132128
|
add: function (name) { return uniques.set(name, true); },
|
|
131978
132129
|
};
|
|
131979
|
-
function shouldIncludeSymbol(symbol,
|
|
132130
|
+
function shouldIncludeSymbol(symbol, symbolToSortTextMap) {
|
|
131980
132131
|
var allFlags = symbol.flags;
|
|
131981
132132
|
if (!ts.isSourceFile(location)) {
|
|
131982
132133
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
@@ -131998,9 +132149,9 @@ var ts;
|
|
|
131998
132149
|
// Auto Imports are not available for scripts so this conditional is always false
|
|
131999
132150
|
if (!!sourceFile.externalModuleIndicator
|
|
132000
132151
|
&& !compilerOptions.allowUmdGlobalAccess
|
|
132001
|
-
&&
|
|
132002
|
-
&& (
|
|
132003
|
-
||
|
|
132152
|
+
&& symbolToSortTextMap[ts.getSymbolId(symbol)] === Completions.SortText.GlobalsOrKeywords
|
|
132153
|
+
&& (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.AutoImportSuggestions
|
|
132154
|
+
|| symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === Completions.SortText.LocationPriority)) {
|
|
132004
132155
|
return false;
|
|
132005
132156
|
}
|
|
132006
132157
|
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
@@ -132040,7 +132191,7 @@ var ts;
|
|
|
132040
132191
|
name: name,
|
|
132041
132192
|
kindModifiers: "" /* none */,
|
|
132042
132193
|
kind: "label" /* label */,
|
|
132043
|
-
sortText: SortText.LocationPriority
|
|
132194
|
+
sortText: Completions.SortText.LocationPriority
|
|
132044
132195
|
});
|
|
132045
132196
|
}
|
|
132046
132197
|
}
|
|
@@ -132066,7 +132217,7 @@ var ts;
|
|
|
132066
132217
|
}
|
|
132067
132218
|
}
|
|
132068
132219
|
var compilerOptions = program.getCompilerOptions();
|
|
132069
|
-
var completionData = getCompletionData(program, log, sourceFile,
|
|
132220
|
+
var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host, /*formatContext*/ undefined);
|
|
132070
132221
|
if (!completionData) {
|
|
132071
132222
|
return { type: "none" };
|
|
132072
132223
|
}
|
|
@@ -132084,7 +132235,9 @@ var ts;
|
|
|
132084
132235
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
132085
132236
|
var origin = symbolToOriginInfoMap[index];
|
|
132086
132237
|
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 */
|
|
132238
|
+
return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
|
|
132239
|
+
|| entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
|
|
132240
|
+
|| getSourceFromOrigin(origin) === entryId.source)
|
|
132088
132241
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
132089
132242
|
: undefined;
|
|
132090
132243
|
}) || { type: "none" };
|
|
@@ -132166,6 +132319,20 @@ var ts;
|
|
|
132166
132319
|
};
|
|
132167
132320
|
}
|
|
132168
132321
|
}
|
|
132322
|
+
if (source === CompletionSource.ObjectLiteralMethodSnippet) {
|
|
132323
|
+
var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
|
|
132324
|
+
var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
|
|
132325
|
+
if (importAdder.hasFixes()) {
|
|
132326
|
+
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
132327
|
+
return {
|
|
132328
|
+
sourceDisplay: undefined,
|
|
132329
|
+
codeActions: [{
|
|
132330
|
+
changes: changes,
|
|
132331
|
+
description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
|
|
132332
|
+
}],
|
|
132333
|
+
};
|
|
132334
|
+
}
|
|
132335
|
+
}
|
|
132169
132336
|
if (originIsTypeOnlyAlias(origin)) {
|
|
132170
132337
|
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
132171
132338
|
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
@@ -132258,8 +132425,9 @@ var ts;
|
|
|
132258
132425
|
var _a;
|
|
132259
132426
|
return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; }));
|
|
132260
132427
|
}
|
|
132261
|
-
function getCompletionData(program, log, sourceFile,
|
|
132428
|
+
function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
|
|
132262
132429
|
var typeChecker = program.getTypeChecker();
|
|
132430
|
+
var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
|
|
132263
132431
|
var start = ts.timestamp();
|
|
132264
132432
|
var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
|
|
132265
132433
|
// 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 +132670,7 @@ var ts;
|
|
|
132502
132670
|
// This also gets mutated in nested-functions after the return
|
|
132503
132671
|
var symbols = [];
|
|
132504
132672
|
var symbolToOriginInfoMap = [];
|
|
132505
|
-
var
|
|
132673
|
+
var symbolToSortTextMap = [];
|
|
132506
132674
|
var seenPropertySymbols = new ts.Map();
|
|
132507
132675
|
var isTypeOnlyLocation = isTypeOnlyCompletion();
|
|
132508
132676
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -132557,7 +132725,7 @@ var ts;
|
|
|
132557
132725
|
contextToken: contextToken,
|
|
132558
132726
|
isJsxInitializer: isJsxInitializer,
|
|
132559
132727
|
insideJsDocTagTypeExpression: insideJsDocTagTypeExpression,
|
|
132560
|
-
|
|
132728
|
+
symbolToSortTextMap: symbolToSortTextMap,
|
|
132561
132729
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
132562
132730
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
132563
132731
|
isRightOfOpenTag: isRightOfOpenTag,
|
|
@@ -132671,7 +132839,7 @@ var ts;
|
|
|
132671
132839
|
isNewIdentifierLocation = true;
|
|
132672
132840
|
}
|
|
132673
132841
|
var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
|
|
132674
|
-
if (
|
|
132842
|
+
if (inUncheckedFile) {
|
|
132675
132843
|
// In javascript files, for union types, we don't just get the members that
|
|
132676
132844
|
// the individual types have in common, we also include all the members that
|
|
132677
132845
|
// each individual type has. This is because we're going to add all identifiers
|
|
@@ -132756,7 +132924,7 @@ var ts;
|
|
|
132756
132924
|
}
|
|
132757
132925
|
function addSymbolSortInfo(symbol) {
|
|
132758
132926
|
if (isStaticProperty(symbol)) {
|
|
132759
|
-
|
|
132927
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.LocalDeclarationPriority;
|
|
132760
132928
|
}
|
|
132761
132929
|
}
|
|
132762
132930
|
function addSymbolOriginInfo(symbol) {
|
|
@@ -132866,7 +133034,7 @@ var ts;
|
|
|
132866
133034
|
var symbol = symbols[i];
|
|
132867
133035
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
132868
133036
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
132869
|
-
|
|
133037
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords;
|
|
132870
133038
|
}
|
|
132871
133039
|
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
132872
133040
|
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
@@ -132884,7 +133052,7 @@ var ts;
|
|
|
132884
133052
|
var symbol = _a[_i];
|
|
132885
133053
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
132886
133054
|
symbols.push(symbol);
|
|
132887
|
-
|
|
133055
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers;
|
|
132888
133056
|
}
|
|
132889
133057
|
}
|
|
132890
133058
|
}
|
|
@@ -132962,7 +133130,7 @@ var ts;
|
|
|
132962
133130
|
}
|
|
132963
133131
|
return false;
|
|
132964
133132
|
}
|
|
132965
|
-
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `
|
|
133133
|
+
/** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */
|
|
132966
133134
|
function collectAutoImports() {
|
|
132967
133135
|
var _a, _b;
|
|
132968
133136
|
if (!shouldOfferImportCompletions())
|
|
@@ -133044,14 +133212,55 @@ var ts;
|
|
|
133044
133212
|
}
|
|
133045
133213
|
function pushAutoImportSymbol(symbol, origin) {
|
|
133046
133214
|
var symbolId = ts.getSymbolId(symbol);
|
|
133047
|
-
if (
|
|
133215
|
+
if (symbolToSortTextMap[symbolId] === Completions.SortText.GlobalsOrKeywords) {
|
|
133048
133216
|
// If an auto-importable symbol is available as a global, don't add the auto import
|
|
133049
133217
|
return;
|
|
133050
133218
|
}
|
|
133051
133219
|
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133052
|
-
|
|
133220
|
+
symbolToSortTextMap[symbolId] = importCompletionNode ? Completions.SortText.LocationPriority : Completions.SortText.AutoImportSuggestions;
|
|
133053
133221
|
symbols.push(symbol);
|
|
133054
133222
|
}
|
|
133223
|
+
/* Mutates `symbols` and `symbolToOriginInfoMap`. */
|
|
133224
|
+
function collectObjectLiteralMethodSymbols(members, enclosingDeclaration) {
|
|
133225
|
+
// TODO: support JS files.
|
|
133226
|
+
if (ts.isInJSFile(location)) {
|
|
133227
|
+
return;
|
|
133228
|
+
}
|
|
133229
|
+
members.forEach(function (member) {
|
|
133230
|
+
if (!isObjectLiteralMethodSymbol(member)) {
|
|
133231
|
+
return;
|
|
133232
|
+
}
|
|
133233
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions),
|
|
133234
|
+
/*origin*/ undefined, 0 /* ObjectPropertyDeclaration */,
|
|
133235
|
+
/*jsxIdentifierExpected*/ false);
|
|
133236
|
+
if (!displayName) {
|
|
133237
|
+
return;
|
|
133238
|
+
}
|
|
133239
|
+
var name = displayName.name;
|
|
133240
|
+
var entryProps = getEntryForObjectLiteralMethodCompletion(member, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext);
|
|
133241
|
+
if (!entryProps) {
|
|
133242
|
+
return;
|
|
133243
|
+
}
|
|
133244
|
+
var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps);
|
|
133245
|
+
symbolToOriginInfoMap[symbols.length] = origin;
|
|
133246
|
+
symbols.push(member);
|
|
133247
|
+
});
|
|
133248
|
+
}
|
|
133249
|
+
function isObjectLiteralMethodSymbol(symbol) {
|
|
133250
|
+
/*
|
|
133251
|
+
For an object type
|
|
133252
|
+
`type Foo = {
|
|
133253
|
+
bar(x: number): void;
|
|
133254
|
+
foo: (x: string) => string;
|
|
133255
|
+
}`,
|
|
133256
|
+
`bar` will have symbol flag `Method`,
|
|
133257
|
+
`foo` will have symbol flag `Property`.
|
|
133258
|
+
*/
|
|
133259
|
+
if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
|
|
133260
|
+
return false;
|
|
133261
|
+
}
|
|
133262
|
+
return true;
|
|
133263
|
+
}
|
|
133055
133264
|
/**
|
|
133056
133265
|
* Finds the first node that "embraces" the position, so that one may
|
|
133057
133266
|
* accurately aggregate locals from the closest containing scope.
|
|
@@ -133185,6 +133394,7 @@ var ts;
|
|
|
133185
133394
|
* @returns true if 'symbols' was successfully populated; false otherwise.
|
|
133186
133395
|
*/
|
|
133187
133396
|
function tryGetObjectLikeCompletionSymbols() {
|
|
133397
|
+
var symbolsStartIndex = symbols.length;
|
|
133188
133398
|
var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
|
|
133189
133399
|
if (!objectLikeContainer)
|
|
133190
133400
|
return 0 /* Continue */;
|
|
@@ -133249,9 +133459,16 @@ var ts;
|
|
|
133249
133459
|
}
|
|
133250
133460
|
if (typeMembers && typeMembers.length > 0) {
|
|
133251
133461
|
// Add filtered items to the completion list
|
|
133252
|
-
|
|
133462
|
+
var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
|
|
133463
|
+
symbols = ts.concatenate(symbols, filteredMembers);
|
|
133464
|
+
setSortTextToOptionalMember();
|
|
133465
|
+
if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */
|
|
133466
|
+
&& preferences.includeCompletionsWithObjectLiteralMethodSnippets
|
|
133467
|
+
&& preferences.includeCompletionsWithInsertText) {
|
|
133468
|
+
transformObjectLiteralMembersSortText(symbolsStartIndex);
|
|
133469
|
+
collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer);
|
|
133470
|
+
}
|
|
133253
133471
|
}
|
|
133254
|
-
setSortTextToOptionalMember();
|
|
133255
133472
|
return 1 /* Success */;
|
|
133256
133473
|
}
|
|
133257
133474
|
/**
|
|
@@ -133326,7 +133543,7 @@ var ts;
|
|
|
133326
133543
|
var _a, _b;
|
|
133327
133544
|
symbols.push(symbol);
|
|
133328
133545
|
if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) {
|
|
133329
|
-
|
|
133546
|
+
symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember;
|
|
133330
133547
|
}
|
|
133331
133548
|
});
|
|
133332
133549
|
return 1 /* Success */;
|
|
@@ -133381,29 +133598,6 @@ var ts;
|
|
|
133381
133598
|
}
|
|
133382
133599
|
return 1 /* Success */;
|
|
133383
133600
|
}
|
|
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
133601
|
function isConstructorParameterCompletion(node) {
|
|
133408
133602
|
return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
|
|
133409
133603
|
&& (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
|
|
@@ -133740,7 +133934,7 @@ var ts;
|
|
|
133740
133934
|
var _a;
|
|
133741
133935
|
if (m.flags & 16777216 /* Optional */) {
|
|
133742
133936
|
var symbolId = ts.getSymbolId(m);
|
|
133743
|
-
|
|
133937
|
+
symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember;
|
|
133744
133938
|
}
|
|
133745
133939
|
});
|
|
133746
133940
|
}
|
|
@@ -133752,7 +133946,23 @@ var ts;
|
|
|
133752
133946
|
for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) {
|
|
133753
133947
|
var contextualMemberSymbol = contextualMemberSymbols_1[_i];
|
|
133754
133948
|
if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) {
|
|
133755
|
-
|
|
133949
|
+
symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = Completions.SortText.MemberDeclaredBySpreadAssignment;
|
|
133950
|
+
}
|
|
133951
|
+
}
|
|
133952
|
+
}
|
|
133953
|
+
function transformObjectLiteralMembersSortText(start) {
|
|
133954
|
+
var _a;
|
|
133955
|
+
for (var i = start; i < symbols.length; i++) {
|
|
133956
|
+
var symbol = symbols[i];
|
|
133957
|
+
var symbolId = ts.getSymbolId(symbol);
|
|
133958
|
+
var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
|
|
133959
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
133960
|
+
var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */,
|
|
133961
|
+
/*jsxIdentifierExpected*/ false);
|
|
133962
|
+
if (displayName) {
|
|
133963
|
+
var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority;
|
|
133964
|
+
var name = displayName.name;
|
|
133965
|
+
symbolToSortTextMap[symbolId] = Completions.SortText.ObjectLiteralProperty(originalSortText, name);
|
|
133756
133966
|
}
|
|
133757
133967
|
}
|
|
133758
133968
|
}
|
|
@@ -133826,6 +134036,29 @@ var ts;
|
|
|
133826
134036
|
return node.getStart(sourceFile) <= position && position <= node.getEnd();
|
|
133827
134037
|
}
|
|
133828
134038
|
}
|
|
134039
|
+
/**
|
|
134040
|
+
* Returns the immediate owning object literal or binding pattern of a context token,
|
|
134041
|
+
* on the condition that one exists and that the context implies completion should be given.
|
|
134042
|
+
*/
|
|
134043
|
+
function tryGetObjectLikeCompletionContainer(contextToken) {
|
|
134044
|
+
if (contextToken) {
|
|
134045
|
+
var parent = contextToken.parent;
|
|
134046
|
+
switch (contextToken.kind) {
|
|
134047
|
+
case 18 /* OpenBraceToken */: // const x = { |
|
|
134048
|
+
case 27 /* CommaToken */: // const x = { a: 0, |
|
|
134049
|
+
if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
|
|
134050
|
+
return parent;
|
|
134051
|
+
}
|
|
134052
|
+
break;
|
|
134053
|
+
case 41 /* AsteriskToken */:
|
|
134054
|
+
return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
|
|
134055
|
+
case 79 /* Identifier */:
|
|
134056
|
+
return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
|
|
134057
|
+
? contextToken.parent.parent : undefined;
|
|
134058
|
+
}
|
|
134059
|
+
}
|
|
134060
|
+
return undefined;
|
|
134061
|
+
}
|
|
133829
134062
|
function getRelevantTokens(position, sourceFile) {
|
|
133830
134063
|
var previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
133831
134064
|
if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
|
|
@@ -133891,7 +134124,7 @@ var ts;
|
|
|
133891
134124
|
name: ts.tokenToString(i),
|
|
133892
134125
|
kind: "keyword" /* keyword */,
|
|
133893
134126
|
kindModifiers: "" /* none */,
|
|
133894
|
-
sortText: SortText.GlobalsOrKeywords
|
|
134127
|
+
sortText: Completions.SortText.GlobalsOrKeywords
|
|
133895
134128
|
});
|
|
133896
134129
|
}
|
|
133897
134130
|
return res;
|
|
@@ -134019,7 +134252,7 @@ var ts;
|
|
|
134019
134252
|
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
134020
134253
|
kind: "keyword" /* keyword */,
|
|
134021
134254
|
kindModifiers: "" /* none */,
|
|
134022
|
-
sortText: SortText.GlobalsOrKeywords,
|
|
134255
|
+
sortText: Completions.SortText.GlobalsOrKeywords,
|
|
134023
134256
|
});
|
|
134024
134257
|
}
|
|
134025
134258
|
}
|
|
@@ -139212,7 +139445,8 @@ var ts;
|
|
|
139212
139445
|
return undefined;
|
|
139213
139446
|
}
|
|
139214
139447
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
139215
|
-
|
|
139448
|
+
var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined;
|
|
139449
|
+
if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) {
|
|
139216
139450
|
return undefined;
|
|
139217
139451
|
}
|
|
139218
139452
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -145947,6 +146181,7 @@ var ts;
|
|
|
145947
146181
|
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
146182
|
}
|
|
145949
146183
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
146184
|
+
var _b;
|
|
145950
146185
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145951
146186
|
// formatting context is used by rules provider
|
|
145952
146187
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145978,11 +146213,12 @@ var ts;
|
|
|
145978
146213
|
}
|
|
145979
146214
|
}
|
|
145980
146215
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145981
|
-
var
|
|
146216
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145982
146217
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145983
146218
|
undefined;
|
|
145984
|
-
if (
|
|
145985
|
-
|
|
146219
|
+
if (tokenInfo) {
|
|
146220
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
146221
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145986
146222
|
/*dynamicIndentation*/ undefined);
|
|
145987
146223
|
}
|
|
145988
146224
|
}
|
|
@@ -147904,25 +148140,25 @@ var ts;
|
|
|
147904
148140
|
suffix: this.newLineCharacter
|
|
147905
148141
|
});
|
|
147906
148142
|
};
|
|
147907
|
-
ChangeTracker.prototype.
|
|
147908
|
-
this.insertNodeAtStartWorker(sourceFile,
|
|
148143
|
+
ChangeTracker.prototype.insertMemberAtStart = function (sourceFile, node, newElement) {
|
|
148144
|
+
this.insertNodeAtStartWorker(sourceFile, node, newElement);
|
|
147909
148145
|
};
|
|
147910
148146
|
ChangeTracker.prototype.insertNodeAtObjectStart = function (sourceFile, obj, newElement) {
|
|
147911
148147
|
this.insertNodeAtStartWorker(sourceFile, obj, newElement);
|
|
147912
148148
|
};
|
|
147913
|
-
ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile,
|
|
148149
|
+
ChangeTracker.prototype.insertNodeAtStartWorker = function (sourceFile, node, newElement) {
|
|
147914
148150
|
var _a;
|
|
147915
|
-
var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile,
|
|
147916
|
-
this.insertNodeAt(sourceFile, getMembersOrProperties(
|
|
148151
|
+
var indentation = (_a = this.guessIndentationFromExistingMembers(sourceFile, node)) !== null && _a !== void 0 ? _a : this.computeIndentationForNewMember(sourceFile, node);
|
|
148152
|
+
this.insertNodeAt(sourceFile, getMembersOrProperties(node).pos, newElement, this.getInsertNodeAtStartInsertOptions(sourceFile, node, indentation));
|
|
147917
148153
|
};
|
|
147918
148154
|
/**
|
|
147919
148155
|
* Tries to guess the indentation from the existing members of a class/interface/object. All members must be on
|
|
147920
148156
|
* new lines and must share the same indentation.
|
|
147921
148157
|
*/
|
|
147922
|
-
ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile,
|
|
148158
|
+
ChangeTracker.prototype.guessIndentationFromExistingMembers = function (sourceFile, node) {
|
|
147923
148159
|
var indentation;
|
|
147924
|
-
var lastRange =
|
|
147925
|
-
for (var _i = 0, _a = getMembersOrProperties(
|
|
148160
|
+
var lastRange = node;
|
|
148161
|
+
for (var _i = 0, _a = getMembersOrProperties(node); _i < _a.length; _i++) {
|
|
147926
148162
|
var member = _a[_i];
|
|
147927
148163
|
if (ts.rangeStartPositionsAreOnSameLine(lastRange, member, sourceFile)) {
|
|
147928
148164
|
// each indented member must be on a new line
|
|
@@ -147941,13 +148177,13 @@ var ts;
|
|
|
147941
148177
|
}
|
|
147942
148178
|
return indentation;
|
|
147943
148179
|
};
|
|
147944
|
-
ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile,
|
|
148180
|
+
ChangeTracker.prototype.computeIndentationForNewMember = function (sourceFile, node) {
|
|
147945
148181
|
var _a;
|
|
147946
|
-
var
|
|
147947
|
-
return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(
|
|
148182
|
+
var nodeStart = node.getStart(sourceFile);
|
|
148183
|
+
return ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(ts.getLineStartPositionForPosition(nodeStart, sourceFile), nodeStart, sourceFile, this.formatContext.options)
|
|
147948
148184
|
+ ((_a = this.formatContext.options.indentSize) !== null && _a !== void 0 ? _a : 4);
|
|
147949
148185
|
};
|
|
147950
|
-
ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile,
|
|
148186
|
+
ChangeTracker.prototype.getInsertNodeAtStartInsertOptions = function (sourceFile, node, indentation) {
|
|
147951
148187
|
// Rules:
|
|
147952
148188
|
// - Always insert leading newline.
|
|
147953
148189
|
// - For object literals:
|
|
@@ -147957,11 +148193,11 @@ var ts;
|
|
|
147957
148193
|
// and the node is empty (because we didn't add a trailing comma per the previous rule).
|
|
147958
148194
|
// - Only insert a trailing newline if body is single-line and there are no other insertions for the node.
|
|
147959
148195
|
// NOTE: This is handled in `finishClassesWithNodesInsertedAtStart`.
|
|
147960
|
-
var members = getMembersOrProperties(
|
|
148196
|
+
var members = getMembersOrProperties(node);
|
|
147961
148197
|
var isEmpty = members.length === 0;
|
|
147962
|
-
var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(
|
|
147963
|
-
var insertTrailingComma = ts.isObjectLiteralExpression(
|
|
147964
|
-
var insertLeadingComma = ts.isObjectLiteralExpression(
|
|
148198
|
+
var isFirstInsertion = ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(node), { node: node, sourceFile: sourceFile });
|
|
148199
|
+
var insertTrailingComma = ts.isObjectLiteralExpression(node) && (!ts.isJsonSourceFile(sourceFile) || !isEmpty);
|
|
148200
|
+
var insertLeadingComma = ts.isObjectLiteralExpression(node) && ts.isJsonSourceFile(sourceFile) && isEmpty && !isFirstInsertion;
|
|
147965
148201
|
return {
|
|
147966
148202
|
indentation: indentation,
|
|
147967
148203
|
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
|
|
@@ -148255,8 +148491,8 @@ var ts;
|
|
|
148255
148491
|
var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile);
|
|
148256
148492
|
return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end];
|
|
148257
148493
|
}
|
|
148258
|
-
function getMembersOrProperties(
|
|
148259
|
-
return ts.isObjectLiteralExpression(
|
|
148494
|
+
function getMembersOrProperties(node) {
|
|
148495
|
+
return ts.isObjectLiteralExpression(node) ? node.properties : node.members;
|
|
148260
148496
|
}
|
|
148261
148497
|
function getNewFileText(statements, scriptKind, newLineCharacter, formatContext) {
|
|
148262
148498
|
return changesToText.newFileChangesWorker(/*oldFile*/ undefined, scriptKind, statements, newLineCharacter, formatContext);
|
|
@@ -151539,7 +151775,7 @@ var ts;
|
|
|
151539
151775
|
changeTracker.insertNodeAfter(sourceFile, constructor, newElement);
|
|
151540
151776
|
}
|
|
151541
151777
|
else {
|
|
151542
|
-
changeTracker.
|
|
151778
|
+
changeTracker.insertMemberAtStart(sourceFile, cls, newElement);
|
|
151543
151779
|
}
|
|
151544
151780
|
}
|
|
151545
151781
|
}
|
|
@@ -153323,7 +153559,7 @@ var ts;
|
|
|
153323
153559
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); });
|
|
153324
153560
|
return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)];
|
|
153325
153561
|
}
|
|
153326
|
-
if (info.kind ===
|
|
153562
|
+
if (info.kind === 1 /* Enum */) {
|
|
153327
153563
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); });
|
|
153328
153564
|
return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)];
|
|
153329
153565
|
}
|
|
@@ -153351,10 +153587,10 @@ var ts;
|
|
|
153351
153587
|
addJsxAttributes(changes, context, info);
|
|
153352
153588
|
}
|
|
153353
153589
|
else {
|
|
153354
|
-
if (info.kind ===
|
|
153590
|
+
if (info.kind === 1 /* Enum */) {
|
|
153355
153591
|
addEnumMemberDeclaration(changes, checker, info);
|
|
153356
153592
|
}
|
|
153357
|
-
if (info.kind ===
|
|
153593
|
+
if (info.kind === 0 /* TypeLikeDeclaration */) {
|
|
153358
153594
|
var parentDeclaration = info.parentDeclaration, token_1 = info.token;
|
|
153359
153595
|
var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; });
|
|
153360
153596
|
if (!infos.some(function (i) { return i.token.text === token_1.text; })) {
|
|
@@ -153363,11 +153599,11 @@ var ts;
|
|
|
153363
153599
|
}
|
|
153364
153600
|
}
|
|
153365
153601
|
});
|
|
153366
|
-
typeDeclToMembers.forEach(function (infos,
|
|
153367
|
-
var supers = codefix.getAllSupers(
|
|
153602
|
+
typeDeclToMembers.forEach(function (infos, declaration) {
|
|
153603
|
+
var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker);
|
|
153368
153604
|
var _loop_15 = function (info) {
|
|
153369
153605
|
// If some superclass added this property, don't add it again.
|
|
153370
|
-
if (supers.some(function (superClassOrInterface) {
|
|
153606
|
+
if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) {
|
|
153371
153607
|
var superInfos = typeDeclToMembers.get(superClassOrInterface);
|
|
153372
153608
|
return !!superInfos && superInfos.some(function (_a) {
|
|
153373
153609
|
var token = _a.token;
|
|
@@ -153381,11 +153617,11 @@ var ts;
|
|
|
153381
153617
|
addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile);
|
|
153382
153618
|
}
|
|
153383
153619
|
else {
|
|
153384
|
-
if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration)) {
|
|
153620
|
+
if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) {
|
|
153385
153621
|
addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */));
|
|
153386
153622
|
}
|
|
153387
153623
|
else {
|
|
153388
|
-
var typeNode = getTypeNode(
|
|
153624
|
+
var typeNode = getTypeNode(checker, parentDeclaration, token);
|
|
153389
153625
|
addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */);
|
|
153390
153626
|
}
|
|
153391
153627
|
}
|
|
@@ -153400,8 +153636,8 @@ var ts;
|
|
|
153400
153636
|
});
|
|
153401
153637
|
var InfoKind;
|
|
153402
153638
|
(function (InfoKind) {
|
|
153403
|
-
InfoKind[InfoKind["
|
|
153404
|
-
InfoKind[InfoKind["
|
|
153639
|
+
InfoKind[InfoKind["TypeLikeDeclaration"] = 0] = "TypeLikeDeclaration";
|
|
153640
|
+
InfoKind[InfoKind["Enum"] = 1] = "Enum";
|
|
153405
153641
|
InfoKind[InfoKind["Function"] = 2] = "Function";
|
|
153406
153642
|
InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral";
|
|
153407
153643
|
InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes";
|
|
@@ -153471,20 +153707,21 @@ var ts;
|
|
|
153471
153707
|
if (!classDeclaration && ts.isPrivateIdentifier(token))
|
|
153472
153708
|
return undefined;
|
|
153473
153709
|
// Prefer to change the class instead of the interface if they are merged
|
|
153474
|
-
var
|
|
153475
|
-
if (
|
|
153476
|
-
var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
153477
|
-
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(
|
|
153710
|
+
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
153711
|
+
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
153712
|
+
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
153713
|
+
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
153478
153714
|
return undefined;
|
|
153479
|
-
var declSourceFile =
|
|
153480
|
-
var modifierFlags =
|
|
153715
|
+
var declSourceFile = declaration.getSourceFile();
|
|
153716
|
+
var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ :
|
|
153717
|
+
(makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */);
|
|
153481
153718
|
var isJSFile = ts.isSourceFileJS(declSourceFile);
|
|
153482
153719
|
var call = ts.tryCast(parent.parent, ts.isCallExpression);
|
|
153483
|
-
return { kind:
|
|
153720
|
+
return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
153484
153721
|
}
|
|
153485
153722
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
153486
153723
|
if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
153487
|
-
return { kind:
|
|
153724
|
+
return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration };
|
|
153488
153725
|
}
|
|
153489
153726
|
return undefined;
|
|
153490
153727
|
}
|
|
@@ -153497,7 +153734,7 @@ var ts;
|
|
|
153497
153734
|
}
|
|
153498
153735
|
function createActionForAddMissingMemberInJavascriptFile(context, _a) {
|
|
153499
153736
|
var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token;
|
|
153500
|
-
if (ts.isInterfaceDeclaration(parentDeclaration)) {
|
|
153737
|
+
if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) {
|
|
153501
153738
|
return undefined;
|
|
153502
153739
|
}
|
|
153503
153740
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); });
|
|
@@ -153508,7 +153745,7 @@ var ts;
|
|
|
153508
153745
|
ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor;
|
|
153509
153746
|
return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members);
|
|
153510
153747
|
}
|
|
153511
|
-
function addMissingMemberInJs(changeTracker,
|
|
153748
|
+
function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) {
|
|
153512
153749
|
var tokenName = token.text;
|
|
153513
153750
|
if (makeStatic) {
|
|
153514
153751
|
if (classDeclaration.kind === 226 /* ClassExpression */) {
|
|
@@ -153516,7 +153753,7 @@ var ts;
|
|
|
153516
153753
|
}
|
|
153517
153754
|
var className = classDeclaration.name.getText();
|
|
153518
153755
|
var staticInitialization = initializePropertyToUndefined(ts.factory.createIdentifier(className), tokenName);
|
|
153519
|
-
changeTracker.insertNodeAfter(
|
|
153756
|
+
changeTracker.insertNodeAfter(sourceFile, classDeclaration, staticInitialization);
|
|
153520
153757
|
}
|
|
153521
153758
|
else if (ts.isPrivateIdentifier(token)) {
|
|
153522
153759
|
var property = ts.factory.createPropertyDeclaration(
|
|
@@ -153527,10 +153764,10 @@ var ts;
|
|
|
153527
153764
|
/*initializer*/ undefined);
|
|
153528
153765
|
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
|
|
153529
153766
|
if (lastProp) {
|
|
153530
|
-
changeTracker.insertNodeAfter(
|
|
153767
|
+
changeTracker.insertNodeAfter(sourceFile, lastProp, property);
|
|
153531
153768
|
}
|
|
153532
153769
|
else {
|
|
153533
|
-
changeTracker.
|
|
153770
|
+
changeTracker.insertMemberAtStart(sourceFile, classDeclaration, property);
|
|
153534
153771
|
}
|
|
153535
153772
|
}
|
|
153536
153773
|
else {
|
|
@@ -153539,7 +153776,7 @@ var ts;
|
|
|
153539
153776
|
return;
|
|
153540
153777
|
}
|
|
153541
153778
|
var propertyInitialization = initializePropertyToUndefined(ts.factory.createThis(), tokenName);
|
|
153542
|
-
changeTracker.insertNodeAtConstructorEnd(
|
|
153779
|
+
changeTracker.insertNodeAtConstructorEnd(sourceFile, classConstructor, propertyInitialization);
|
|
153543
153780
|
}
|
|
153544
153781
|
}
|
|
153545
153782
|
function initializePropertyToUndefined(obj, propertyName) {
|
|
@@ -153561,13 +153798,13 @@ var ts;
|
|
|
153561
153798
|
actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode));
|
|
153562
153799
|
return actions;
|
|
153563
153800
|
}
|
|
153564
|
-
function getTypeNode(checker,
|
|
153801
|
+
function getTypeNode(checker, node, token) {
|
|
153565
153802
|
var typeNode;
|
|
153566
153803
|
if (token.parent.parent.kind === 221 /* BinaryExpression */) {
|
|
153567
153804
|
var binaryExpression = token.parent.parent;
|
|
153568
153805
|
var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
|
|
153569
153806
|
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
|
|
153570
|
-
typeNode = checker.typeToTypeNode(widenedType,
|
|
153807
|
+
typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */);
|
|
153571
153808
|
}
|
|
153572
153809
|
else {
|
|
153573
153810
|
var contextualType = checker.getContextualType(token.parent);
|
|
@@ -153575,24 +153812,23 @@ var ts;
|
|
|
153575
153812
|
}
|
|
153576
153813
|
return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */);
|
|
153577
153814
|
}
|
|
153578
|
-
function addPropertyDeclaration(changeTracker,
|
|
153579
|
-
var
|
|
153580
|
-
|
|
153581
|
-
|
|
153582
|
-
|
|
153583
|
-
|
|
153584
|
-
var lastProp = getNodeToInsertPropertyAfter(classDeclaration);
|
|
153815
|
+
function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) {
|
|
153816
|
+
var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined;
|
|
153817
|
+
var property = ts.isClassLike(node)
|
|
153818
|
+
? ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined)
|
|
153819
|
+
: ts.factory.createPropertySignature(/*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, typeNode);
|
|
153820
|
+
var lastProp = getNodeToInsertPropertyAfter(node);
|
|
153585
153821
|
if (lastProp) {
|
|
153586
|
-
changeTracker.insertNodeAfter(
|
|
153822
|
+
changeTracker.insertNodeAfter(sourceFile, lastProp, property);
|
|
153587
153823
|
}
|
|
153588
153824
|
else {
|
|
153589
|
-
changeTracker.
|
|
153825
|
+
changeTracker.insertMemberAtStart(sourceFile, node, property);
|
|
153590
153826
|
}
|
|
153591
153827
|
}
|
|
153592
153828
|
// Gets the last of the first run of PropertyDeclarations, or undefined if the class does not start with a PropertyDeclaration.
|
|
153593
|
-
function getNodeToInsertPropertyAfter(
|
|
153829
|
+
function getNodeToInsertPropertyAfter(node) {
|
|
153594
153830
|
var res;
|
|
153595
|
-
for (var _i = 0, _a =
|
|
153831
|
+
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
153596
153832
|
var member = _a[_i];
|
|
153597
153833
|
if (!ts.isPropertyDeclaration(member))
|
|
153598
153834
|
break;
|
|
@@ -153600,7 +153836,7 @@ var ts;
|
|
|
153600
153836
|
}
|
|
153601
153837
|
return res;
|
|
153602
153838
|
}
|
|
153603
|
-
function createAddIndexSignatureAction(context,
|
|
153839
|
+
function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) {
|
|
153604
153840
|
// Index signatures cannot have the static modifier.
|
|
153605
153841
|
var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */);
|
|
153606
153842
|
var indexingParameter = ts.factory.createParameterDeclaration(
|
|
@@ -153612,7 +153848,7 @@ var ts;
|
|
|
153612
153848
|
var indexSignature = ts.factory.createIndexSignature(
|
|
153613
153849
|
/*decorators*/ undefined,
|
|
153614
153850
|
/*modifiers*/ undefined, [indexingParameter], typeNode);
|
|
153615
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.
|
|
153851
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.insertMemberAtStart(sourceFile, node, indexSignature); });
|
|
153616
153852
|
// No fixId here because code-fix-all currently only works on adding individual named properties.
|
|
153617
153853
|
return codefix.createCodeFixActionWithoutFixAll(fixMissingMember, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]);
|
|
153618
153854
|
}
|
|
@@ -153635,13 +153871,14 @@ var ts;
|
|
|
153635
153871
|
}
|
|
153636
153872
|
function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) {
|
|
153637
153873
|
var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host);
|
|
153638
|
-
var
|
|
153639
|
-
var
|
|
153640
|
-
|
|
153641
|
-
|
|
153874
|
+
var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */;
|
|
153875
|
+
var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration);
|
|
153876
|
+
var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression);
|
|
153877
|
+
if (containingMethodDeclaration) {
|
|
153878
|
+
changes.insertNodeAfter(sourceFile, containingMethodDeclaration, signatureDeclaration);
|
|
153642
153879
|
}
|
|
153643
153880
|
else {
|
|
153644
|
-
changes.
|
|
153881
|
+
changes.insertMemberAtStart(sourceFile, parentDeclaration, signatureDeclaration);
|
|
153645
153882
|
}
|
|
153646
153883
|
importAdder.writeFixes(changes);
|
|
153647
153884
|
}
|
|
@@ -153804,6 +154041,13 @@ var ts;
|
|
|
153804
154041
|
return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
153805
154042
|
});
|
|
153806
154043
|
}
|
|
154044
|
+
function tryGetContainingMethodDeclaration(node, callExpression) {
|
|
154045
|
+
if (ts.isTypeLiteralNode(node)) {
|
|
154046
|
+
return undefined;
|
|
154047
|
+
}
|
|
154048
|
+
var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); });
|
|
154049
|
+
return declaration && declaration.parent === node ? declaration : undefined;
|
|
154050
|
+
}
|
|
153807
154051
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
153808
154052
|
})(ts || (ts = {}));
|
|
153809
154053
|
/* @internal */
|
|
@@ -153947,7 +154191,7 @@ var ts;
|
|
|
153947
154191
|
// so duplicates cannot occur.
|
|
153948
154192
|
var abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember);
|
|
153949
154193
|
var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host);
|
|
153950
|
-
codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.
|
|
154194
|
+
codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, function (member) { return changeTracker.insertMemberAtStart(sourceFile, classDeclaration, member); });
|
|
153951
154195
|
importAdder.writeFixes(changeTracker);
|
|
153952
154196
|
}
|
|
153953
154197
|
function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
@@ -156520,13 +156764,20 @@ var ts;
|
|
|
156520
156764
|
var type = isJs || contextualType === undefined
|
|
156521
156765
|
? undefined
|
|
156522
156766
|
: checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
|
|
156523
|
-
|
|
156524
|
-
|
|
156525
|
-
|
|
156526
|
-
|
|
156767
|
+
switch (kind) {
|
|
156768
|
+
case 169 /* MethodDeclaration */:
|
|
156769
|
+
return ts.factory.createMethodDeclaration(
|
|
156770
|
+
/*decorators*/ undefined, modifiers, asteriskToken, name,
|
|
156771
|
+
/*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
|
|
156772
|
+
case 168 /* MethodSignature */:
|
|
156773
|
+
return ts.factory.createMethodSignature(modifiers, name,
|
|
156774
|
+
/*questionToken*/ undefined, typeParameters, parameters, type);
|
|
156775
|
+
case 256 /* FunctionDeclaration */:
|
|
156776
|
+
return ts.factory.createFunctionDeclaration(
|
|
156777
|
+
/*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
|
|
156778
|
+
default:
|
|
156779
|
+
ts.Debug.fail("Unexpected kind");
|
|
156527
156780
|
}
|
|
156528
|
-
return ts.factory.createFunctionDeclaration(
|
|
156529
|
-
/*decorators*/ undefined, modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
|
|
156530
156781
|
}
|
|
156531
156782
|
codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression;
|
|
156532
156783
|
function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) {
|
|
@@ -156852,7 +157103,7 @@ var ts;
|
|
|
156852
157103
|
}
|
|
156853
157104
|
}
|
|
156854
157105
|
function insertAccessor(changeTracker, file, accessor, declaration, container) {
|
|
156855
|
-
ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.
|
|
157106
|
+
ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertMemberAtStart(file, container, accessor) :
|
|
156856
157107
|
ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) :
|
|
156857
157108
|
changeTracker.insertNodeAfter(file, declaration, accessor);
|
|
156858
157109
|
}
|