typescript 4.8.0-dev.20220507 → 4.8.0-dev.20220510
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +12 -11
- package/lib/de/diagnosticMessages.generated.json +12 -11
- package/lib/es/diagnosticMessages.generated.json +12 -11
- package/lib/fr/diagnosticMessages.generated.json +12 -11
- package/lib/it/diagnosticMessages.generated.json +12 -11
- package/lib/ja/diagnosticMessages.generated.json +12 -11
- package/lib/ko/diagnosticMessages.generated.json +12 -11
- package/lib/lib.es2021.intl.d.ts +6 -2
- package/lib/lib.esnext.intl.d.ts +5 -1
- package/lib/pl/diagnosticMessages.generated.json +12 -11
- package/lib/pt-br/diagnosticMessages.generated.json +12 -11
- package/lib/ru/diagnosticMessages.generated.json +12 -11
- package/lib/tr/diagnosticMessages.generated.json +12 -11
- package/lib/tsc.js +90 -23
- package/lib/tsserver.js +115 -35
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +115 -35
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +115 -35
- package/lib/typescriptServices.d.ts +2 -0
- package/lib/typescriptServices.js +115 -35
- package/lib/typingsInstaller.js +92 -23
- package/lib/zh-cn/diagnosticMessages.generated.json +12 -11
- package/lib/zh-tw/diagnosticMessages.generated.json +12 -11
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220510";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -14073,6 +14073,16 @@ var ts;
|
|
|
14073
14073
|
return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */;
|
|
14074
14074
|
}
|
|
14075
14075
|
ts.isJSDocLinkLike = isJSDocLinkLike;
|
|
14076
|
+
function hasRestParameter(s) {
|
|
14077
|
+
var last = ts.lastOrUndefined(s.parameters);
|
|
14078
|
+
return !!last && isRestParameter(last);
|
|
14079
|
+
}
|
|
14080
|
+
ts.hasRestParameter = hasRestParameter;
|
|
14081
|
+
function isRestParameter(node) {
|
|
14082
|
+
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
14083
|
+
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
14084
|
+
}
|
|
14085
|
+
ts.isRestParameter = isRestParameter;
|
|
14076
14086
|
// #endregion
|
|
14077
14087
|
})(ts || (ts = {}));
|
|
14078
14088
|
/* @internal */
|
|
@@ -16843,16 +16853,6 @@ var ts;
|
|
|
16843
16853
|
return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
|
|
16844
16854
|
}
|
|
16845
16855
|
ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
|
|
16846
|
-
function hasRestParameter(s) {
|
|
16847
|
-
var last = ts.lastOrUndefined(s.parameters);
|
|
16848
|
-
return !!last && isRestParameter(last);
|
|
16849
|
-
}
|
|
16850
|
-
ts.hasRestParameter = hasRestParameter;
|
|
16851
|
-
function isRestParameter(node) {
|
|
16852
|
-
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
16853
|
-
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
16854
|
-
}
|
|
16855
|
-
ts.isRestParameter = isRestParameter;
|
|
16856
16856
|
function hasTypeArguments(node) {
|
|
16857
16857
|
return !!node.typeArguments;
|
|
16858
16858
|
}
|
|
@@ -65465,6 +65465,20 @@ var ts;
|
|
|
65465
65465
|
}
|
|
65466
65466
|
}
|
|
65467
65467
|
}
|
|
65468
|
+
if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
|
|
65469
|
+
// This is a carve-out in comparability to essentially forbid comparing a type parameter
|
|
65470
|
+
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
65471
|
+
var constraint = getConstraintOfTypeParameter(source);
|
|
65472
|
+
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
65473
|
+
while (constraint && constraint.flags & 262144 /* TypeParameter */) {
|
|
65474
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
65475
|
+
return result;
|
|
65476
|
+
}
|
|
65477
|
+
constraint = getConstraintOfTypeParameter(constraint);
|
|
65478
|
+
}
|
|
65479
|
+
}
|
|
65480
|
+
return 0 /* False */;
|
|
65481
|
+
}
|
|
65468
65482
|
}
|
|
65469
65483
|
else if (targetFlags & 4194304 /* Index */) {
|
|
65470
65484
|
var targetType_1 = target.type;
|
|
@@ -65668,8 +65682,8 @@ var ts;
|
|
|
65668
65682
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
65669
65683
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65670
65684
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65671
|
-
var constraint = getConstraintOfType(source);
|
|
65672
|
-
if (!
|
|
65685
|
+
var constraint = getConstraintOfType(source) || unknownType;
|
|
65686
|
+
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65673
65687
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65674
65688
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65675
65689
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -65677,12 +65691,12 @@ var ts;
|
|
|
65677
65691
|
}
|
|
65678
65692
|
}
|
|
65679
65693
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
65680
|
-
|
|
65694
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65681
65695
|
resetErrorInfo(saveErrorInfo);
|
|
65682
65696
|
return result;
|
|
65683
65697
|
}
|
|
65684
65698
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
65685
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65699
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65686
65700
|
resetErrorInfo(saveErrorInfo);
|
|
65687
65701
|
return result;
|
|
65688
65702
|
}
|
|
@@ -72519,7 +72533,25 @@ var ts;
|
|
|
72519
72533
|
}
|
|
72520
72534
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
72521
72535
|
return mapType(type, function (t) {
|
|
72522
|
-
|
|
72536
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
72537
|
+
var intersection = t;
|
|
72538
|
+
var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
|
|
72539
|
+
if (newTypes.length > 0) {
|
|
72540
|
+
return getIntersectionType(newTypes);
|
|
72541
|
+
}
|
|
72542
|
+
newTypes = ts.mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
|
|
72543
|
+
if (newTypes.length > 0) {
|
|
72544
|
+
return getIntersectionType(newTypes);
|
|
72545
|
+
}
|
|
72546
|
+
return undefined;
|
|
72547
|
+
}
|
|
72548
|
+
var concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
|
|
72549
|
+
if (concretePropertyType) {
|
|
72550
|
+
return concretePropertyType;
|
|
72551
|
+
}
|
|
72552
|
+
return getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
72553
|
+
}, /*noReductions*/ true);
|
|
72554
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
72523
72555
|
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
72524
72556
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
72525
72557
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
@@ -72527,8 +72559,9 @@ var ts;
|
|
|
72527
72559
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
72528
72560
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
72529
72561
|
}
|
|
72562
|
+
return undefined;
|
|
72530
72563
|
}
|
|
72531
|
-
|
|
72564
|
+
if (t.flags & 3670016 /* StructuredType */) {
|
|
72532
72565
|
var prop = getPropertyOfType(t, name);
|
|
72533
72566
|
if (prop) {
|
|
72534
72567
|
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
|
|
@@ -72539,10 +72572,16 @@ var ts;
|
|
|
72539
72572
|
return restType;
|
|
72540
72573
|
}
|
|
72541
72574
|
}
|
|
72542
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72543
72575
|
}
|
|
72544
72576
|
return undefined;
|
|
72545
|
-
}
|
|
72577
|
+
}
|
|
72578
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
72579
|
+
var _a;
|
|
72580
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
72581
|
+
return undefined;
|
|
72582
|
+
}
|
|
72583
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72584
|
+
}
|
|
72546
72585
|
}
|
|
72547
72586
|
// In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
|
|
72548
72587
|
// the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one
|
|
@@ -81016,7 +81055,7 @@ var ts;
|
|
|
81016
81055
|
* @param type The type of the promise.
|
|
81017
81056
|
* @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
|
|
81018
81057
|
*/
|
|
81019
|
-
function getPromisedTypeOfPromise(type, errorNode) {
|
|
81058
|
+
function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) {
|
|
81020
81059
|
//
|
|
81021
81060
|
// { // type
|
|
81022
81061
|
// then( // thenFunction
|
|
@@ -81051,7 +81090,29 @@ var ts;
|
|
|
81051
81090
|
}
|
|
81052
81091
|
return undefined;
|
|
81053
81092
|
}
|
|
81054
|
-
var
|
|
81093
|
+
var thisTypeForError;
|
|
81094
|
+
var candidates;
|
|
81095
|
+
for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) {
|
|
81096
|
+
var thenSignature = thenSignatures_1[_i];
|
|
81097
|
+
var thisType = getThisTypeOfSignature(thenSignature);
|
|
81098
|
+
if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) {
|
|
81099
|
+
thisTypeForError = thisType;
|
|
81100
|
+
}
|
|
81101
|
+
else {
|
|
81102
|
+
candidates = ts.append(candidates, thenSignature);
|
|
81103
|
+
}
|
|
81104
|
+
}
|
|
81105
|
+
if (!candidates) {
|
|
81106
|
+
ts.Debug.assertIsDefined(thisTypeForError);
|
|
81107
|
+
if (thisTypeForErrorOut) {
|
|
81108
|
+
thisTypeForErrorOut.value = thisTypeForError;
|
|
81109
|
+
}
|
|
81110
|
+
if (errorNode) {
|
|
81111
|
+
error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
|
|
81112
|
+
}
|
|
81113
|
+
return undefined;
|
|
81114
|
+
}
|
|
81115
|
+
var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */);
|
|
81055
81116
|
if (isTypeAny(onfulfilledParameterType)) {
|
|
81056
81117
|
return undefined;
|
|
81057
81118
|
}
|
|
@@ -81175,7 +81236,8 @@ var ts;
|
|
|
81175
81236
|
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
|
|
81176
81237
|
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
81177
81238
|
}
|
|
81178
|
-
var
|
|
81239
|
+
var thisTypeForErrorOut = { value: undefined };
|
|
81240
|
+
var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
|
|
81179
81241
|
if (promisedType) {
|
|
81180
81242
|
if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
|
|
81181
81243
|
// Verify that we don't have a bad actor in the form of a promise whose
|
|
@@ -81244,7 +81306,12 @@ var ts;
|
|
|
81244
81306
|
if (isThenableType(type)) {
|
|
81245
81307
|
if (errorNode) {
|
|
81246
81308
|
ts.Debug.assertIsDefined(diagnosticMessage);
|
|
81247
|
-
|
|
81309
|
+
var chain = void 0;
|
|
81310
|
+
if (thisTypeForErrorOut.value) {
|
|
81311
|
+
chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForErrorOut.value));
|
|
81312
|
+
}
|
|
81313
|
+
chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0);
|
|
81314
|
+
diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain));
|
|
81248
81315
|
}
|
|
81249
81316
|
return undefined;
|
|
81250
81317
|
}
|
|
@@ -122360,6 +122427,8 @@ var ts;
|
|
|
122360
122427
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122361
122428
|
return fileName;
|
|
122362
122429
|
var noExtension = ts.removeFileExtension(fileName);
|
|
122430
|
+
if (fileName === noExtension)
|
|
122431
|
+
return fileName;
|
|
122363
122432
|
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
122364
122433
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122365
122434
|
switch (ending) {
|
|
@@ -126434,6 +126503,8 @@ var ts;
|
|
|
126434
126503
|
case 256 /* FunctionDeclaration */:
|
|
126435
126504
|
case 213 /* FunctionExpression */:
|
|
126436
126505
|
return getAdjustedLocationForFunction(node);
|
|
126506
|
+
case 171 /* Constructor */:
|
|
126507
|
+
return node;
|
|
126437
126508
|
}
|
|
126438
126509
|
}
|
|
126439
126510
|
if (ts.isNamedDeclaration(node)) {
|
|
@@ -139532,11 +139603,12 @@ var ts;
|
|
|
139532
139603
|
ts.forEachUnique(declarations, function (declaration) {
|
|
139533
139604
|
for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) {
|
|
139534
139605
|
var jsdoc = _a[_i];
|
|
139606
|
+
var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); });
|
|
139535
139607
|
// skip comments containing @typedefs since they're not associated with particular declarations
|
|
139536
139608
|
// Exceptions:
|
|
139537
139609
|
// - @typedefs are themselves declarations with associated comments
|
|
139538
139610
|
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
|
|
139539
|
-
if (jsdoc.comment === undefined
|
|
139611
|
+
if (jsdoc.comment === undefined && !inheritDoc
|
|
139540
139612
|
|| ts.isJSDoc(jsdoc)
|
|
139541
139613
|
&& declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */
|
|
139542
139614
|
&& jsdoc.tags
|
|
@@ -139544,7 +139616,10 @@ var ts;
|
|
|
139544
139616
|
&& !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) {
|
|
139545
139617
|
continue;
|
|
139546
139618
|
}
|
|
139547
|
-
var newparts = getDisplayPartsFromComment(jsdoc.comment, checker);
|
|
139619
|
+
var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : [];
|
|
139620
|
+
if (inheritDoc && inheritDoc.comment) {
|
|
139621
|
+
newparts = newparts.concat(getDisplayPartsFromComment(inheritDoc.comment, checker));
|
|
139622
|
+
}
|
|
139548
139623
|
if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) {
|
|
139549
139624
|
parts.push(newparts);
|
|
139550
139625
|
}
|
|
@@ -154300,6 +154375,7 @@ var ts;
|
|
|
154300
154375
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
154301
154376
|
var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
|
|
154302
154377
|
changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
|
|
154378
|
+
importAdder.writeFixes(changes);
|
|
154303
154379
|
}
|
|
154304
154380
|
function addJsxAttributes(changes, context, info) {
|
|
154305
154381
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154308,7 +154384,7 @@ var ts;
|
|
|
154308
154384
|
var jsxAttributesNode = info.parentDeclaration.attributes;
|
|
154309
154385
|
var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
|
|
154310
154386
|
var attrs = ts.map(info.attributes, function (attr) {
|
|
154311
|
-
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
|
|
154387
|
+
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr), info.parentDeclaration);
|
|
154312
154388
|
var name = ts.factory.createIdentifier(attr.name);
|
|
154313
154389
|
var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
|
|
154314
154390
|
// formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
|
|
@@ -154318,6 +154394,7 @@ var ts;
|
|
|
154318
154394
|
var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
|
|
154319
154395
|
var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
|
|
154320
154396
|
changes.replaceNode(context.sourceFile, jsxAttributesNode, jsxAttributes, options);
|
|
154397
|
+
importAdder.writeFixes(changes);
|
|
154321
154398
|
}
|
|
154322
154399
|
function addObjectLiteralProperties(changes, context, info) {
|
|
154323
154400
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154325,7 +154402,7 @@ var ts;
|
|
|
154325
154402
|
var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
|
|
154326
154403
|
var checker = context.program.getTypeChecker();
|
|
154327
154404
|
var props = ts.map(info.properties, function (prop) {
|
|
154328
|
-
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
|
|
154405
|
+
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration);
|
|
154329
154406
|
return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
|
|
154330
154407
|
});
|
|
154331
154408
|
var options = {
|
|
@@ -154334,8 +154411,9 @@ var ts;
|
|
|
154334
154411
|
indentation: info.indentation
|
|
154335
154412
|
};
|
|
154336
154413
|
changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options);
|
|
154414
|
+
importAdder.writeFixes(changes);
|
|
154337
154415
|
}
|
|
154338
|
-
function tryGetValueFromType(context, checker, importAdder, quotePreference, type) {
|
|
154416
|
+
function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) {
|
|
154339
154417
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
154340
154418
|
return createUndefined();
|
|
154341
154419
|
}
|
|
@@ -154372,7 +154450,7 @@ var ts;
|
|
|
154372
154450
|
return ts.factory.createNull();
|
|
154373
154451
|
}
|
|
154374
154452
|
if (type.flags & 1048576 /* Union */) {
|
|
154375
|
-
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); });
|
|
154453
|
+
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); });
|
|
154376
154454
|
return expression !== null && expression !== void 0 ? expression : createUndefined();
|
|
154377
154455
|
}
|
|
154378
154456
|
if (checker.isArrayLikeType(type)) {
|
|
@@ -154380,7 +154458,7 @@ var ts;
|
|
|
154380
154458
|
}
|
|
154381
154459
|
if (isObjectLiteralType(type)) {
|
|
154382
154460
|
var props = ts.map(checker.getPropertiesOfType(type), function (prop) {
|
|
154383
|
-
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined();
|
|
154461
|
+
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration), enclosingDeclaration) : createUndefined();
|
|
154384
154462
|
return ts.factory.createPropertyAssignment(prop.name, initializer);
|
|
154385
154463
|
});
|
|
154386
154464
|
return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true);
|
|
@@ -154392,7 +154470,7 @@ var ts;
|
|
|
154392
154470
|
var signature = checker.getSignaturesOfType(type, 0 /* Call */);
|
|
154393
154471
|
if (signature === undefined)
|
|
154394
154472
|
return createUndefined();
|
|
154395
|
-
var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/
|
|
154473
|
+
var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder);
|
|
154396
154474
|
return func !== null && func !== void 0 ? func : createUndefined();
|
|
154397
154475
|
}
|
|
154398
154476
|
if (ts.getObjectFlags(type) & 1 /* Class */) {
|
|
@@ -163679,7 +163757,7 @@ var ts;
|
|
|
163679
163757
|
* @returns `true` if `node` has a JSDoc "inheritDoc" tag on it, otherwise `false`.
|
|
163680
163758
|
*/
|
|
163681
163759
|
function hasJSDocInheritDocTag(node) {
|
|
163682
|
-
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
163760
|
+
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc" || tag.tagName.text === "inheritdoc"; });
|
|
163683
163761
|
}
|
|
163684
163762
|
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
163685
163763
|
if (!declarations)
|
|
@@ -163738,13 +163816,15 @@ var ts;
|
|
|
163738
163816
|
}
|
|
163739
163817
|
function findBaseOfDeclaration(checker, declaration, cb) {
|
|
163740
163818
|
var _a;
|
|
163741
|
-
if (ts.hasStaticModifier(declaration))
|
|
163742
|
-
return;
|
|
163743
163819
|
var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent;
|
|
163744
163820
|
if (!classOrInterfaceDeclaration)
|
|
163745
163821
|
return;
|
|
163822
|
+
var isStaticMember = ts.hasStaticModifier(declaration);
|
|
163746
163823
|
return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) {
|
|
163747
|
-
var
|
|
163824
|
+
var baseType = checker.getTypeAtLocation(superTypeNode);
|
|
163825
|
+
var symbol = isStaticMember
|
|
163826
|
+
? ts.find(checker.getExportsOfModule(baseType.symbol), function (s) { return s.escapedName === declaration.symbol.name; })
|
|
163827
|
+
: checker.getPropertyOfType(baseType, declaration.symbol.name);
|
|
163748
163828
|
return symbol ? cb(symbol) : undefined;
|
|
163749
163829
|
});
|
|
163750
163830
|
}
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -4510,6 +4510,8 @@ declare namespace ts {
|
|
|
4510
4510
|
function isObjectLiteralElement(node: Node): node is ObjectLiteralElement;
|
|
4511
4511
|
function isStringLiteralLike(node: Node): node is StringLiteralLike;
|
|
4512
4512
|
function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain;
|
|
4513
|
+
function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean;
|
|
4514
|
+
function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean;
|
|
4513
4515
|
}
|
|
4514
4516
|
declare namespace ts {
|
|
4515
4517
|
const factory: NodeFactory;
|