typescript 4.8.0-dev.20220509 → 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/lib.es2021.intl.d.ts +6 -2
- package/lib/lib.esnext.intl.d.ts +5 -1
- 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/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.20220510";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -14267,6 +14267,16 @@ var ts;
|
|
|
14267
14267
|
return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */;
|
|
14268
14268
|
}
|
|
14269
14269
|
ts.isJSDocLinkLike = isJSDocLinkLike;
|
|
14270
|
+
function hasRestParameter(s) {
|
|
14271
|
+
var last = ts.lastOrUndefined(s.parameters);
|
|
14272
|
+
return !!last && isRestParameter(last);
|
|
14273
|
+
}
|
|
14274
|
+
ts.hasRestParameter = hasRestParameter;
|
|
14275
|
+
function isRestParameter(node) {
|
|
14276
|
+
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
14277
|
+
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
14278
|
+
}
|
|
14279
|
+
ts.isRestParameter = isRestParameter;
|
|
14270
14280
|
// #endregion
|
|
14271
14281
|
})(ts || (ts = {}));
|
|
14272
14282
|
/* @internal */
|
|
@@ -17037,16 +17047,6 @@ var ts;
|
|
|
17037
17047
|
return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
|
|
17038
17048
|
}
|
|
17039
17049
|
ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
|
|
17040
|
-
function hasRestParameter(s) {
|
|
17041
|
-
var last = ts.lastOrUndefined(s.parameters);
|
|
17042
|
-
return !!last && isRestParameter(last);
|
|
17043
|
-
}
|
|
17044
|
-
ts.hasRestParameter = hasRestParameter;
|
|
17045
|
-
function isRestParameter(node) {
|
|
17046
|
-
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
17047
|
-
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
17048
|
-
}
|
|
17049
|
-
ts.isRestParameter = isRestParameter;
|
|
17050
17050
|
function hasTypeArguments(node) {
|
|
17051
17051
|
return !!node.typeArguments;
|
|
17052
17052
|
}
|
|
@@ -65659,6 +65659,20 @@ var ts;
|
|
|
65659
65659
|
}
|
|
65660
65660
|
}
|
|
65661
65661
|
}
|
|
65662
|
+
if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
|
|
65663
|
+
// This is a carve-out in comparability to essentially forbid comparing a type parameter
|
|
65664
|
+
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
65665
|
+
var constraint = getConstraintOfTypeParameter(source);
|
|
65666
|
+
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
65667
|
+
while (constraint && constraint.flags & 262144 /* TypeParameter */) {
|
|
65668
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
65669
|
+
return result;
|
|
65670
|
+
}
|
|
65671
|
+
constraint = getConstraintOfTypeParameter(constraint);
|
|
65672
|
+
}
|
|
65673
|
+
}
|
|
65674
|
+
return 0 /* False */;
|
|
65675
|
+
}
|
|
65662
65676
|
}
|
|
65663
65677
|
else if (targetFlags & 4194304 /* Index */) {
|
|
65664
65678
|
var targetType_1 = target.type;
|
|
@@ -65862,8 +65876,8 @@ var ts;
|
|
|
65862
65876
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
65863
65877
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65864
65878
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65865
|
-
var constraint = getConstraintOfType(source);
|
|
65866
|
-
if (!
|
|
65879
|
+
var constraint = getConstraintOfType(source) || unknownType;
|
|
65880
|
+
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65867
65881
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65868
65882
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65869
65883
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -65871,12 +65885,12 @@ var ts;
|
|
|
65871
65885
|
}
|
|
65872
65886
|
}
|
|
65873
65887
|
// 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
|
|
65874
|
-
|
|
65888
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65875
65889
|
resetErrorInfo(saveErrorInfo);
|
|
65876
65890
|
return result;
|
|
65877
65891
|
}
|
|
65878
65892
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
65879
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65893
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65880
65894
|
resetErrorInfo(saveErrorInfo);
|
|
65881
65895
|
return result;
|
|
65882
65896
|
}
|
|
@@ -72713,7 +72727,25 @@ var ts;
|
|
|
72713
72727
|
}
|
|
72714
72728
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
72715
72729
|
return mapType(type, function (t) {
|
|
72716
|
-
|
|
72730
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
72731
|
+
var intersection = t;
|
|
72732
|
+
var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
|
|
72733
|
+
if (newTypes.length > 0) {
|
|
72734
|
+
return getIntersectionType(newTypes);
|
|
72735
|
+
}
|
|
72736
|
+
newTypes = ts.mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
|
|
72737
|
+
if (newTypes.length > 0) {
|
|
72738
|
+
return getIntersectionType(newTypes);
|
|
72739
|
+
}
|
|
72740
|
+
return undefined;
|
|
72741
|
+
}
|
|
72742
|
+
var concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
|
|
72743
|
+
if (concretePropertyType) {
|
|
72744
|
+
return concretePropertyType;
|
|
72745
|
+
}
|
|
72746
|
+
return getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
72747
|
+
}, /*noReductions*/ true);
|
|
72748
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
72717
72749
|
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
72718
72750
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
72719
72751
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
@@ -72721,8 +72753,9 @@ var ts;
|
|
|
72721
72753
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
72722
72754
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
72723
72755
|
}
|
|
72756
|
+
return undefined;
|
|
72724
72757
|
}
|
|
72725
|
-
|
|
72758
|
+
if (t.flags & 3670016 /* StructuredType */) {
|
|
72726
72759
|
var prop = getPropertyOfType(t, name);
|
|
72727
72760
|
if (prop) {
|
|
72728
72761
|
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
|
|
@@ -72733,10 +72766,16 @@ var ts;
|
|
|
72733
72766
|
return restType;
|
|
72734
72767
|
}
|
|
72735
72768
|
}
|
|
72736
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72737
72769
|
}
|
|
72738
72770
|
return undefined;
|
|
72739
|
-
}
|
|
72771
|
+
}
|
|
72772
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
72773
|
+
var _a;
|
|
72774
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
72775
|
+
return undefined;
|
|
72776
|
+
}
|
|
72777
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72778
|
+
}
|
|
72740
72779
|
}
|
|
72741
72780
|
// In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
|
|
72742
72781
|
// the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one
|
|
@@ -81210,7 +81249,7 @@ var ts;
|
|
|
81210
81249
|
* @param type The type of the promise.
|
|
81211
81250
|
* @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
|
|
81212
81251
|
*/
|
|
81213
|
-
function getPromisedTypeOfPromise(type, errorNode) {
|
|
81252
|
+
function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) {
|
|
81214
81253
|
//
|
|
81215
81254
|
// { // type
|
|
81216
81255
|
// then( // thenFunction
|
|
@@ -81245,7 +81284,29 @@ var ts;
|
|
|
81245
81284
|
}
|
|
81246
81285
|
return undefined;
|
|
81247
81286
|
}
|
|
81248
|
-
var
|
|
81287
|
+
var thisTypeForError;
|
|
81288
|
+
var candidates;
|
|
81289
|
+
for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) {
|
|
81290
|
+
var thenSignature = thenSignatures_1[_i];
|
|
81291
|
+
var thisType = getThisTypeOfSignature(thenSignature);
|
|
81292
|
+
if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) {
|
|
81293
|
+
thisTypeForError = thisType;
|
|
81294
|
+
}
|
|
81295
|
+
else {
|
|
81296
|
+
candidates = ts.append(candidates, thenSignature);
|
|
81297
|
+
}
|
|
81298
|
+
}
|
|
81299
|
+
if (!candidates) {
|
|
81300
|
+
ts.Debug.assertIsDefined(thisTypeForError);
|
|
81301
|
+
if (thisTypeForErrorOut) {
|
|
81302
|
+
thisTypeForErrorOut.value = thisTypeForError;
|
|
81303
|
+
}
|
|
81304
|
+
if (errorNode) {
|
|
81305
|
+
error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
|
|
81306
|
+
}
|
|
81307
|
+
return undefined;
|
|
81308
|
+
}
|
|
81309
|
+
var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */);
|
|
81249
81310
|
if (isTypeAny(onfulfilledParameterType)) {
|
|
81250
81311
|
return undefined;
|
|
81251
81312
|
}
|
|
@@ -81369,7 +81430,8 @@ var ts;
|
|
|
81369
81430
|
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
|
|
81370
81431
|
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
81371
81432
|
}
|
|
81372
|
-
var
|
|
81433
|
+
var thisTypeForErrorOut = { value: undefined };
|
|
81434
|
+
var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
|
|
81373
81435
|
if (promisedType) {
|
|
81374
81436
|
if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
|
|
81375
81437
|
// Verify that we don't have a bad actor in the form of a promise whose
|
|
@@ -81438,7 +81500,12 @@ var ts;
|
|
|
81438
81500
|
if (isThenableType(type)) {
|
|
81439
81501
|
if (errorNode) {
|
|
81440
81502
|
ts.Debug.assertIsDefined(diagnosticMessage);
|
|
81441
|
-
|
|
81503
|
+
var chain = void 0;
|
|
81504
|
+
if (thisTypeForErrorOut.value) {
|
|
81505
|
+
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));
|
|
81506
|
+
}
|
|
81507
|
+
chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0);
|
|
81508
|
+
diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain));
|
|
81442
81509
|
}
|
|
81443
81510
|
return undefined;
|
|
81444
81511
|
}
|
|
@@ -122554,6 +122621,8 @@ var ts;
|
|
|
122554
122621
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122555
122622
|
return fileName;
|
|
122556
122623
|
var noExtension = ts.removeFileExtension(fileName);
|
|
122624
|
+
if (fileName === noExtension)
|
|
122625
|
+
return fileName;
|
|
122557
122626
|
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
122558
122627
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122559
122628
|
switch (ending) {
|
|
@@ -127045,6 +127114,8 @@ var ts;
|
|
|
127045
127114
|
case 256 /* FunctionDeclaration */:
|
|
127046
127115
|
case 213 /* FunctionExpression */:
|
|
127047
127116
|
return getAdjustedLocationForFunction(node);
|
|
127117
|
+
case 171 /* Constructor */:
|
|
127118
|
+
return node;
|
|
127048
127119
|
}
|
|
127049
127120
|
}
|
|
127050
127121
|
if (ts.isNamedDeclaration(node)) {
|
|
@@ -140143,11 +140214,12 @@ var ts;
|
|
|
140143
140214
|
ts.forEachUnique(declarations, function (declaration) {
|
|
140144
140215
|
for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) {
|
|
140145
140216
|
var jsdoc = _a[_i];
|
|
140217
|
+
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"); });
|
|
140146
140218
|
// skip comments containing @typedefs since they're not associated with particular declarations
|
|
140147
140219
|
// Exceptions:
|
|
140148
140220
|
// - @typedefs are themselves declarations with associated comments
|
|
140149
140221
|
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
|
|
140150
|
-
if (jsdoc.comment === undefined
|
|
140222
|
+
if (jsdoc.comment === undefined && !inheritDoc
|
|
140151
140223
|
|| ts.isJSDoc(jsdoc)
|
|
140152
140224
|
&& declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */
|
|
140153
140225
|
&& jsdoc.tags
|
|
@@ -140155,7 +140227,10 @@ var ts;
|
|
|
140155
140227
|
&& !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) {
|
|
140156
140228
|
continue;
|
|
140157
140229
|
}
|
|
140158
|
-
var newparts = getDisplayPartsFromComment(jsdoc.comment, checker);
|
|
140230
|
+
var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : [];
|
|
140231
|
+
if (inheritDoc && inheritDoc.comment) {
|
|
140232
|
+
newparts = newparts.concat(getDisplayPartsFromComment(inheritDoc.comment, checker));
|
|
140233
|
+
}
|
|
140159
140234
|
if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) {
|
|
140160
140235
|
parts.push(newparts);
|
|
140161
140236
|
}
|
|
@@ -154911,6 +154986,7 @@ var ts;
|
|
|
154911
154986
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
154912
154987
|
var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
|
|
154913
154988
|
changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
|
|
154989
|
+
importAdder.writeFixes(changes);
|
|
154914
154990
|
}
|
|
154915
154991
|
function addJsxAttributes(changes, context, info) {
|
|
154916
154992
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154919,7 +154995,7 @@ var ts;
|
|
|
154919
154995
|
var jsxAttributesNode = info.parentDeclaration.attributes;
|
|
154920
154996
|
var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
|
|
154921
154997
|
var attrs = ts.map(info.attributes, function (attr) {
|
|
154922
|
-
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
|
|
154998
|
+
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr), info.parentDeclaration);
|
|
154923
154999
|
var name = ts.factory.createIdentifier(attr.name);
|
|
154924
155000
|
var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
|
|
154925
155001
|
// formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
|
|
@@ -154929,6 +155005,7 @@ var ts;
|
|
|
154929
155005
|
var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
|
|
154930
155006
|
var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
|
|
154931
155007
|
changes.replaceNode(context.sourceFile, jsxAttributesNode, jsxAttributes, options);
|
|
155008
|
+
importAdder.writeFixes(changes);
|
|
154932
155009
|
}
|
|
154933
155010
|
function addObjectLiteralProperties(changes, context, info) {
|
|
154934
155011
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154936,7 +155013,7 @@ var ts;
|
|
|
154936
155013
|
var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
|
|
154937
155014
|
var checker = context.program.getTypeChecker();
|
|
154938
155015
|
var props = ts.map(info.properties, function (prop) {
|
|
154939
|
-
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
|
|
155016
|
+
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration);
|
|
154940
155017
|
return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
|
|
154941
155018
|
});
|
|
154942
155019
|
var options = {
|
|
@@ -154945,8 +155022,9 @@ var ts;
|
|
|
154945
155022
|
indentation: info.indentation
|
|
154946
155023
|
};
|
|
154947
155024
|
changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options);
|
|
155025
|
+
importAdder.writeFixes(changes);
|
|
154948
155026
|
}
|
|
154949
|
-
function tryGetValueFromType(context, checker, importAdder, quotePreference, type) {
|
|
155027
|
+
function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) {
|
|
154950
155028
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
154951
155029
|
return createUndefined();
|
|
154952
155030
|
}
|
|
@@ -154983,7 +155061,7 @@ var ts;
|
|
|
154983
155061
|
return ts.factory.createNull();
|
|
154984
155062
|
}
|
|
154985
155063
|
if (type.flags & 1048576 /* Union */) {
|
|
154986
|
-
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); });
|
|
155064
|
+
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); });
|
|
154987
155065
|
return expression !== null && expression !== void 0 ? expression : createUndefined();
|
|
154988
155066
|
}
|
|
154989
155067
|
if (checker.isArrayLikeType(type)) {
|
|
@@ -154991,7 +155069,7 @@ var ts;
|
|
|
154991
155069
|
}
|
|
154992
155070
|
if (isObjectLiteralType(type)) {
|
|
154993
155071
|
var props = ts.map(checker.getPropertiesOfType(type), function (prop) {
|
|
154994
|
-
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined();
|
|
155072
|
+
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration), enclosingDeclaration) : createUndefined();
|
|
154995
155073
|
return ts.factory.createPropertyAssignment(prop.name, initializer);
|
|
154996
155074
|
});
|
|
154997
155075
|
return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true);
|
|
@@ -155003,7 +155081,7 @@ var ts;
|
|
|
155003
155081
|
var signature = checker.getSignaturesOfType(type, 0 /* Call */);
|
|
155004
155082
|
if (signature === undefined)
|
|
155005
155083
|
return createUndefined();
|
|
155006
|
-
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*/
|
|
155084
|
+
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);
|
|
155007
155085
|
return func !== null && func !== void 0 ? func : createUndefined();
|
|
155008
155086
|
}
|
|
155009
155087
|
if (ts.getObjectFlags(type) & 1 /* Class */) {
|
|
@@ -164290,7 +164368,7 @@ var ts;
|
|
|
164290
164368
|
* @returns `true` if `node` has a JSDoc "inheritDoc" tag on it, otherwise `false`.
|
|
164291
164369
|
*/
|
|
164292
164370
|
function hasJSDocInheritDocTag(node) {
|
|
164293
|
-
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
164371
|
+
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc" || tag.tagName.text === "inheritdoc"; });
|
|
164294
164372
|
}
|
|
164295
164373
|
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
164296
164374
|
if (!declarations)
|
|
@@ -164349,13 +164427,15 @@ var ts;
|
|
|
164349
164427
|
}
|
|
164350
164428
|
function findBaseOfDeclaration(checker, declaration, cb) {
|
|
164351
164429
|
var _a;
|
|
164352
|
-
if (ts.hasStaticModifier(declaration))
|
|
164353
|
-
return;
|
|
164354
164430
|
var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent;
|
|
164355
164431
|
if (!classOrInterfaceDeclaration)
|
|
164356
164432
|
return;
|
|
164433
|
+
var isStaticMember = ts.hasStaticModifier(declaration);
|
|
164357
164434
|
return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) {
|
|
164358
|
-
var
|
|
164435
|
+
var baseType = checker.getTypeAtLocation(superTypeNode);
|
|
164436
|
+
var symbol = isStaticMember
|
|
164437
|
+
? ts.find(checker.getExportsOfModule(baseType.symbol), function (s) { return s.escapedName === declaration.symbol.name; })
|
|
164438
|
+
: checker.getPropertyOfType(baseType, declaration.symbol.name);
|
|
164359
164439
|
return symbol ? cb(symbol) : undefined;
|
|
164360
164440
|
});
|
|
164361
164441
|
}
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220510";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -14062,6 +14062,16 @@ var ts;
|
|
|
14062
14062
|
return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */;
|
|
14063
14063
|
}
|
|
14064
14064
|
ts.isJSDocLinkLike = isJSDocLinkLike;
|
|
14065
|
+
function hasRestParameter(s) {
|
|
14066
|
+
var last = ts.lastOrUndefined(s.parameters);
|
|
14067
|
+
return !!last && isRestParameter(last);
|
|
14068
|
+
}
|
|
14069
|
+
ts.hasRestParameter = hasRestParameter;
|
|
14070
|
+
function isRestParameter(node) {
|
|
14071
|
+
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
14072
|
+
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
14073
|
+
}
|
|
14074
|
+
ts.isRestParameter = isRestParameter;
|
|
14065
14075
|
// #endregion
|
|
14066
14076
|
})(ts || (ts = {}));
|
|
14067
14077
|
/* @internal */
|
|
@@ -16832,16 +16842,6 @@ var ts;
|
|
|
16832
16842
|
return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
|
|
16833
16843
|
}
|
|
16834
16844
|
ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
|
|
16835
|
-
function hasRestParameter(s) {
|
|
16836
|
-
var last = ts.lastOrUndefined(s.parameters);
|
|
16837
|
-
return !!last && isRestParameter(last);
|
|
16838
|
-
}
|
|
16839
|
-
ts.hasRestParameter = hasRestParameter;
|
|
16840
|
-
function isRestParameter(node) {
|
|
16841
|
-
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
16842
|
-
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
16843
|
-
}
|
|
16844
|
-
ts.isRestParameter = isRestParameter;
|
|
16845
16845
|
function hasTypeArguments(node) {
|
|
16846
16846
|
return !!node.typeArguments;
|
|
16847
16847
|
}
|
|
@@ -65454,6 +65454,20 @@ var ts;
|
|
|
65454
65454
|
}
|
|
65455
65455
|
}
|
|
65456
65456
|
}
|
|
65457
|
+
if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
|
|
65458
|
+
// This is a carve-out in comparability to essentially forbid comparing a type parameter
|
|
65459
|
+
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
65460
|
+
var constraint = getConstraintOfTypeParameter(source);
|
|
65461
|
+
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
65462
|
+
while (constraint && constraint.flags & 262144 /* TypeParameter */) {
|
|
65463
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
65464
|
+
return result;
|
|
65465
|
+
}
|
|
65466
|
+
constraint = getConstraintOfTypeParameter(constraint);
|
|
65467
|
+
}
|
|
65468
|
+
}
|
|
65469
|
+
return 0 /* False */;
|
|
65470
|
+
}
|
|
65457
65471
|
}
|
|
65458
65472
|
else if (targetFlags & 4194304 /* Index */) {
|
|
65459
65473
|
var targetType_1 = target.type;
|
|
@@ -65657,8 +65671,8 @@ var ts;
|
|
|
65657
65671
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
65658
65672
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65659
65673
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65660
|
-
var constraint = getConstraintOfType(source);
|
|
65661
|
-
if (!
|
|
65674
|
+
var constraint = getConstraintOfType(source) || unknownType;
|
|
65675
|
+
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65662
65676
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65663
65677
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65664
65678
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -65666,12 +65680,12 @@ var ts;
|
|
|
65666
65680
|
}
|
|
65667
65681
|
}
|
|
65668
65682
|
// 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
|
|
65669
|
-
|
|
65683
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65670
65684
|
resetErrorInfo(saveErrorInfo);
|
|
65671
65685
|
return result;
|
|
65672
65686
|
}
|
|
65673
65687
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
65674
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65688
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65675
65689
|
resetErrorInfo(saveErrorInfo);
|
|
65676
65690
|
return result;
|
|
65677
65691
|
}
|
|
@@ -72508,7 +72522,25 @@ var ts;
|
|
|
72508
72522
|
}
|
|
72509
72523
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
72510
72524
|
return mapType(type, function (t) {
|
|
72511
|
-
|
|
72525
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
72526
|
+
var intersection = t;
|
|
72527
|
+
var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
|
|
72528
|
+
if (newTypes.length > 0) {
|
|
72529
|
+
return getIntersectionType(newTypes);
|
|
72530
|
+
}
|
|
72531
|
+
newTypes = ts.mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
|
|
72532
|
+
if (newTypes.length > 0) {
|
|
72533
|
+
return getIntersectionType(newTypes);
|
|
72534
|
+
}
|
|
72535
|
+
return undefined;
|
|
72536
|
+
}
|
|
72537
|
+
var concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
|
|
72538
|
+
if (concretePropertyType) {
|
|
72539
|
+
return concretePropertyType;
|
|
72540
|
+
}
|
|
72541
|
+
return getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
72542
|
+
}, /*noReductions*/ true);
|
|
72543
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
72512
72544
|
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
72513
72545
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
72514
72546
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
@@ -72516,8 +72548,9 @@ var ts;
|
|
|
72516
72548
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
72517
72549
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
72518
72550
|
}
|
|
72551
|
+
return undefined;
|
|
72519
72552
|
}
|
|
72520
|
-
|
|
72553
|
+
if (t.flags & 3670016 /* StructuredType */) {
|
|
72521
72554
|
var prop = getPropertyOfType(t, name);
|
|
72522
72555
|
if (prop) {
|
|
72523
72556
|
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
|
|
@@ -72528,10 +72561,16 @@ var ts;
|
|
|
72528
72561
|
return restType;
|
|
72529
72562
|
}
|
|
72530
72563
|
}
|
|
72531
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72532
72564
|
}
|
|
72533
72565
|
return undefined;
|
|
72534
|
-
}
|
|
72566
|
+
}
|
|
72567
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
72568
|
+
var _a;
|
|
72569
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
72570
|
+
return undefined;
|
|
72571
|
+
}
|
|
72572
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72573
|
+
}
|
|
72535
72574
|
}
|
|
72536
72575
|
// In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
|
|
72537
72576
|
// the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one
|
|
@@ -81005,7 +81044,7 @@ var ts;
|
|
|
81005
81044
|
* @param type The type of the promise.
|
|
81006
81045
|
* @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
|
|
81007
81046
|
*/
|
|
81008
|
-
function getPromisedTypeOfPromise(type, errorNode) {
|
|
81047
|
+
function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) {
|
|
81009
81048
|
//
|
|
81010
81049
|
// { // type
|
|
81011
81050
|
// then( // thenFunction
|
|
@@ -81040,7 +81079,29 @@ var ts;
|
|
|
81040
81079
|
}
|
|
81041
81080
|
return undefined;
|
|
81042
81081
|
}
|
|
81043
|
-
var
|
|
81082
|
+
var thisTypeForError;
|
|
81083
|
+
var candidates;
|
|
81084
|
+
for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) {
|
|
81085
|
+
var thenSignature = thenSignatures_1[_i];
|
|
81086
|
+
var thisType = getThisTypeOfSignature(thenSignature);
|
|
81087
|
+
if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) {
|
|
81088
|
+
thisTypeForError = thisType;
|
|
81089
|
+
}
|
|
81090
|
+
else {
|
|
81091
|
+
candidates = ts.append(candidates, thenSignature);
|
|
81092
|
+
}
|
|
81093
|
+
}
|
|
81094
|
+
if (!candidates) {
|
|
81095
|
+
ts.Debug.assertIsDefined(thisTypeForError);
|
|
81096
|
+
if (thisTypeForErrorOut) {
|
|
81097
|
+
thisTypeForErrorOut.value = thisTypeForError;
|
|
81098
|
+
}
|
|
81099
|
+
if (errorNode) {
|
|
81100
|
+
error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
|
|
81101
|
+
}
|
|
81102
|
+
return undefined;
|
|
81103
|
+
}
|
|
81104
|
+
var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */);
|
|
81044
81105
|
if (isTypeAny(onfulfilledParameterType)) {
|
|
81045
81106
|
return undefined;
|
|
81046
81107
|
}
|
|
@@ -81164,7 +81225,8 @@ var ts;
|
|
|
81164
81225
|
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
|
|
81165
81226
|
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
81166
81227
|
}
|
|
81167
|
-
var
|
|
81228
|
+
var thisTypeForErrorOut = { value: undefined };
|
|
81229
|
+
var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
|
|
81168
81230
|
if (promisedType) {
|
|
81169
81231
|
if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
|
|
81170
81232
|
// Verify that we don't have a bad actor in the form of a promise whose
|
|
@@ -81233,7 +81295,12 @@ var ts;
|
|
|
81233
81295
|
if (isThenableType(type)) {
|
|
81234
81296
|
if (errorNode) {
|
|
81235
81297
|
ts.Debug.assertIsDefined(diagnosticMessage);
|
|
81236
|
-
|
|
81298
|
+
var chain = void 0;
|
|
81299
|
+
if (thisTypeForErrorOut.value) {
|
|
81300
|
+
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));
|
|
81301
|
+
}
|
|
81302
|
+
chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0);
|
|
81303
|
+
diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain));
|
|
81237
81304
|
}
|
|
81238
81305
|
return undefined;
|
|
81239
81306
|
}
|
|
@@ -122349,6 +122416,8 @@ var ts;
|
|
|
122349
122416
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122350
122417
|
return fileName;
|
|
122351
122418
|
var noExtension = ts.removeFileExtension(fileName);
|
|
122419
|
+
if (fileName === noExtension)
|
|
122420
|
+
return fileName;
|
|
122352
122421
|
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
122353
122422
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122354
122423
|
switch (ending) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.8.0-dev.
|
|
5
|
+
"version": "4.8.0-dev.20220510",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|