typescript 4.8.0-dev.20220721 → 4.8.0-dev.20220724
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/tsc.js +13 -7
- package/lib/tsserver.js +90 -39
- package/lib/tsserverlibrary.js +90 -39
- package/lib/typescript.js +90 -39
- package/lib/typescriptServices.js +90 -39
- package/lib/typingsInstaller.js +13 -7
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.8";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220724";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -4317,8 +4317,10 @@ var ts;
|
|
|
4317
4317
|
watchPresentFileSystemEntry();
|
|
4318
4318
|
return {
|
|
4319
4319
|
close: function () {
|
|
4320
|
-
watcher
|
|
4321
|
-
|
|
4320
|
+
if (watcher) {
|
|
4321
|
+
watcher.close();
|
|
4322
|
+
watcher = undefined;
|
|
4323
|
+
}
|
|
4322
4324
|
}
|
|
4323
4325
|
};
|
|
4324
4326
|
function updateWatcher(createWatcher) {
|
|
@@ -66741,7 +66743,11 @@ var ts;
|
|
|
66741
66743
|
var operator = operatorToken.kind;
|
|
66742
66744
|
if (operator === 55 || operator === 56 || operator === 60) {
|
|
66743
66745
|
if (operator === 55) {
|
|
66744
|
-
var parent =
|
|
66746
|
+
var parent = node.parent;
|
|
66747
|
+
while (parent.kind === 212
|
|
66748
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 || parent.operatorToken.kind === 56)) {
|
|
66749
|
+
parent = parent.parent;
|
|
66750
|
+
}
|
|
66745
66751
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
66746
66752
|
}
|
|
66747
66753
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -76304,13 +76310,13 @@ var ts;
|
|
|
76304
76310
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
76305
76311
|
case 200:
|
|
76306
76312
|
ts.Debug.type(node);
|
|
76307
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
76313
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
76308
76314
|
case 295:
|
|
76309
76315
|
ts.Debug.type(node);
|
|
76310
76316
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
76311
76317
|
case 197:
|
|
76312
76318
|
ts.Debug.type(node);
|
|
76313
|
-
return factory.updateNamedTupleMember(node,
|
|
76319
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
76314
76320
|
case 191:
|
|
76315
76321
|
ts.Debug.type(node);
|
|
76316
76322
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -76373,7 +76379,7 @@ var ts;
|
|
|
76373
76379
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
76374
76380
|
case 210:
|
|
76375
76381
|
ts.Debug.type(node);
|
|
76376
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
76382
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
76377
76383
|
case 211:
|
|
76378
76384
|
ts.Debug.type(node);
|
|
76379
76385
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
package/lib/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220724";
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -6857,8 +6857,10 @@ var ts;
|
|
|
6857
6857
|
return {
|
|
6858
6858
|
close: function () {
|
|
6859
6859
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
6860
|
-
watcher
|
|
6861
|
-
|
|
6860
|
+
if (watcher) {
|
|
6861
|
+
watcher.close();
|
|
6862
|
+
watcher = undefined;
|
|
6863
|
+
}
|
|
6862
6864
|
}
|
|
6863
6865
|
};
|
|
6864
6866
|
function updateWatcher(createWatcher) {
|
|
@@ -79638,7 +79640,11 @@ var ts;
|
|
|
79638
79640
|
var operator = operatorToken.kind;
|
|
79639
79641
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79640
79642
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79641
|
-
var parent =
|
|
79643
|
+
var parent = node.parent;
|
|
79644
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79645
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79646
|
+
parent = parent.parent;
|
|
79647
|
+
}
|
|
79642
79648
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79643
79649
|
}
|
|
79644
79650
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90560,13 +90566,13 @@ var ts;
|
|
|
90560
90566
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90561
90567
|
case 200 /* ImportType */:
|
|
90562
90568
|
ts.Debug.type(node);
|
|
90563
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90569
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90564
90570
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90565
90571
|
ts.Debug.type(node);
|
|
90566
90572
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90567
90573
|
case 197 /* NamedTupleMember */:
|
|
90568
90574
|
ts.Debug.type(node);
|
|
90569
|
-
return factory.updateNamedTupleMember(node,
|
|
90575
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90570
90576
|
case 191 /* ParenthesizedType */:
|
|
90571
90577
|
ts.Debug.type(node);
|
|
90572
90578
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90631,7 +90637,7 @@ var ts;
|
|
|
90631
90637
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90632
90638
|
case 210 /* TaggedTemplateExpression */:
|
|
90633
90639
|
ts.Debug.type(node);
|
|
90634
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90640
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90635
90641
|
case 211 /* TypeAssertionExpression */:
|
|
90636
90642
|
ts.Debug.type(node);
|
|
90637
90643
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -141759,8 +141765,12 @@ var ts;
|
|
|
141759
141765
|
return undefined;
|
|
141760
141766
|
}
|
|
141761
141767
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
141762
|
-
var
|
|
141763
|
-
|
|
141768
|
+
var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined;
|
|
141769
|
+
var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc);
|
|
141770
|
+
if (commentOwner.getStart(sourceFile) < position
|
|
141771
|
+
|| lastJsDoc
|
|
141772
|
+
&& existingDocComment
|
|
141773
|
+
&& lastJsDoc !== existingDocComment) {
|
|
141764
141774
|
return undefined;
|
|
141765
141775
|
}
|
|
141766
141776
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -141777,7 +141787,9 @@ var ts;
|
|
|
141777
141787
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
141778
141788
|
var openComment = "/**";
|
|
141779
141789
|
var closeComment = " */";
|
|
141780
|
-
|
|
141790
|
+
// If any of the existing jsDoc has tags, ignore adding new ones.
|
|
141791
|
+
var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; });
|
|
141792
|
+
if (tags && !hasTag) {
|
|
141781
141793
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
141782
141794
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
141783
141795
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -148839,6 +148851,7 @@ var ts;
|
|
|
148839
148851
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
148840
148852
|
}
|
|
148841
148853
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
148854
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
148842
148855
|
if (ts.nodeIsMissing(child)) {
|
|
148843
148856
|
return inheritedIndentation;
|
|
148844
148857
|
}
|
|
@@ -148905,6 +148918,7 @@ var ts;
|
|
|
148905
148918
|
}
|
|
148906
148919
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
148907
148920
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
148921
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
148908
148922
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
148909
148923
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
148910
148924
|
var startLine = parentStartLine;
|
|
@@ -155364,54 +155378,91 @@ var ts;
|
|
|
155364
155378
|
codefix.registerCodeFix({
|
|
155365
155379
|
errorCodes: errorCodes,
|
|
155366
155380
|
getCodeActions: function (context) {
|
|
155367
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155368
|
-
var
|
|
155369
|
-
if (
|
|
155381
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host;
|
|
155382
|
+
var info = getInfo(program, sourceFile, span);
|
|
155383
|
+
if (info === undefined)
|
|
155370
155384
|
return;
|
|
155371
|
-
}
|
|
155372
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155385
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); });
|
|
155373
155386
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155374
155387
|
},
|
|
155375
155388
|
fixIds: [fixId],
|
|
155376
|
-
getAllCodeActions: function (context) {
|
|
155377
|
-
var
|
|
155378
|
-
|
|
155379
|
-
|
|
155380
|
-
|
|
155381
|
-
|
|
155389
|
+
getAllCodeActions: function (context) {
|
|
155390
|
+
var program = context.program, preferences = context.preferences, host = context.host;
|
|
155391
|
+
var seen = new ts.Map();
|
|
155392
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
155393
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155394
|
+
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155395
|
+
if (info) {
|
|
155396
|
+
var id = ts.getNodeId(info.declaration) + "#" + info.token.getText();
|
|
155397
|
+
if (ts.addToSeen(seen, id)) {
|
|
155398
|
+
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
155399
|
+
}
|
|
155400
|
+
}
|
|
155401
|
+
return undefined;
|
|
155402
|
+
});
|
|
155403
|
+
}));
|
|
155404
|
+
}
|
|
155382
155405
|
});
|
|
155383
|
-
function
|
|
155406
|
+
function getInfo(program, sourceFile, span) {
|
|
155384
155407
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155385
|
-
if (
|
|
155408
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155386
155409
|
return;
|
|
155387
155410
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155388
|
-
if (
|
|
155411
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155389
155412
|
return;
|
|
155390
|
-
|
|
155391
|
-
|
|
155392
|
-
function addMissingConstraint(changes, related) {
|
|
155393
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155394
|
-
if (!decl)
|
|
155413
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
155414
|
+
if (declaration === undefined)
|
|
155395
155415
|
return;
|
|
155396
|
-
if (ts.isIdentifier(
|
|
155397
|
-
|
|
155416
|
+
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
155417
|
+
declaration = declaration.parent;
|
|
155418
|
+
}
|
|
155419
|
+
if (ts.isTypeParameterDeclaration(declaration)) {
|
|
155420
|
+
// should only issue fix on type parameters written using `extends`
|
|
155421
|
+
if (ts.isMappedTypeNode(declaration.parent))
|
|
155422
|
+
return;
|
|
155423
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155424
|
+
var checker = program.getTypeChecker();
|
|
155425
|
+
var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
|
155426
|
+
return { constraint: constraint, declaration: declaration, token: token };
|
|
155427
|
+
}
|
|
155428
|
+
return undefined;
|
|
155429
|
+
}
|
|
155430
|
+
function addMissingConstraint(changes, program, preferences, host, sourceFile, info) {
|
|
155431
|
+
var declaration = info.declaration, constraint = info.constraint;
|
|
155432
|
+
var checker = program.getTypeChecker();
|
|
155433
|
+
if (ts.isString(constraint)) {
|
|
155434
|
+
changes.insertText(sourceFile, declaration.name.end, " extends " + constraint);
|
|
155435
|
+
}
|
|
155436
|
+
else {
|
|
155437
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
155438
|
+
var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host });
|
|
155439
|
+
var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
155440
|
+
var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
|
155441
|
+
if (typeNode) {
|
|
155442
|
+
changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
|
155443
|
+
importAdder.writeFixes(changes);
|
|
155444
|
+
}
|
|
155398
155445
|
}
|
|
155399
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155400
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
155401
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155402
|
-
if (!newConstraint)
|
|
155403
|
-
return;
|
|
155404
|
-
var newConstraintText = newConstraint[1];
|
|
155405
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
155406
155446
|
}
|
|
155407
155447
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155408
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155409
155448
|
var end = ts.textSpanEnd(span);
|
|
155449
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155410
155450
|
while (token.end < end) {
|
|
155411
155451
|
token = token.parent;
|
|
155412
155452
|
}
|
|
155413
155453
|
return token;
|
|
155414
155454
|
}
|
|
155455
|
+
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
155456
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
155457
|
+
return constraint;
|
|
155458
|
+
}
|
|
155459
|
+
function tryGetConstraintType(checker, node) {
|
|
155460
|
+
if (ts.isTypeNode(node.parent)) {
|
|
155461
|
+
return checker.getTypeArgumentConstraint(node.parent);
|
|
155462
|
+
}
|
|
155463
|
+
var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined;
|
|
155464
|
+
return contextualType || checker.getTypeAtLocation(node);
|
|
155465
|
+
}
|
|
155415
155466
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155416
155467
|
})(ts || (ts = {}));
|
|
155417
155468
|
/* @internal */
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220724";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -7051,8 +7051,10 @@ var ts;
|
|
|
7051
7051
|
return {
|
|
7052
7052
|
close: function () {
|
|
7053
7053
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
7054
|
-
watcher
|
|
7055
|
-
|
|
7054
|
+
if (watcher) {
|
|
7055
|
+
watcher.close();
|
|
7056
|
+
watcher = undefined;
|
|
7057
|
+
}
|
|
7056
7058
|
}
|
|
7057
7059
|
};
|
|
7058
7060
|
function updateWatcher(createWatcher) {
|
|
@@ -79832,7 +79834,11 @@ var ts;
|
|
|
79832
79834
|
var operator = operatorToken.kind;
|
|
79833
79835
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79834
79836
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79835
|
-
var parent =
|
|
79837
|
+
var parent = node.parent;
|
|
79838
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79839
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79840
|
+
parent = parent.parent;
|
|
79841
|
+
}
|
|
79836
79842
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79837
79843
|
}
|
|
79838
79844
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90754,13 +90760,13 @@ var ts;
|
|
|
90754
90760
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90755
90761
|
case 200 /* ImportType */:
|
|
90756
90762
|
ts.Debug.type(node);
|
|
90757
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90763
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90758
90764
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90759
90765
|
ts.Debug.type(node);
|
|
90760
90766
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90761
90767
|
case 197 /* NamedTupleMember */:
|
|
90762
90768
|
ts.Debug.type(node);
|
|
90763
|
-
return factory.updateNamedTupleMember(node,
|
|
90769
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90764
90770
|
case 191 /* ParenthesizedType */:
|
|
90765
90771
|
ts.Debug.type(node);
|
|
90766
90772
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90825,7 +90831,7 @@ var ts;
|
|
|
90825
90831
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90826
90832
|
case 210 /* TaggedTemplateExpression */:
|
|
90827
90833
|
ts.Debug.type(node);
|
|
90828
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90834
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90829
90835
|
case 211 /* TypeAssertionExpression */:
|
|
90830
90836
|
ts.Debug.type(node);
|
|
90831
90837
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -142372,8 +142378,12 @@ var ts;
|
|
|
142372
142378
|
return undefined;
|
|
142373
142379
|
}
|
|
142374
142380
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142375
|
-
var
|
|
142376
|
-
|
|
142381
|
+
var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined;
|
|
142382
|
+
var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc);
|
|
142383
|
+
if (commentOwner.getStart(sourceFile) < position
|
|
142384
|
+
|| lastJsDoc
|
|
142385
|
+
&& existingDocComment
|
|
142386
|
+
&& lastJsDoc !== existingDocComment) {
|
|
142377
142387
|
return undefined;
|
|
142378
142388
|
}
|
|
142379
142389
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142390,7 +142400,9 @@ var ts;
|
|
|
142390
142400
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142391
142401
|
var openComment = "/**";
|
|
142392
142402
|
var closeComment = " */";
|
|
142393
|
-
|
|
142403
|
+
// If any of the existing jsDoc has tags, ignore adding new ones.
|
|
142404
|
+
var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; });
|
|
142405
|
+
if (tags && !hasTag) {
|
|
142394
142406
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142395
142407
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142396
142408
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149452,6 +149464,7 @@ var ts;
|
|
|
149452
149464
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149453
149465
|
}
|
|
149454
149466
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149467
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149455
149468
|
if (ts.nodeIsMissing(child)) {
|
|
149456
149469
|
return inheritedIndentation;
|
|
149457
149470
|
}
|
|
@@ -149518,6 +149531,7 @@ var ts;
|
|
|
149518
149531
|
}
|
|
149519
149532
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149520
149533
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149534
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149521
149535
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149522
149536
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149523
149537
|
var startLine = parentStartLine;
|
|
@@ -155977,54 +155991,91 @@ var ts;
|
|
|
155977
155991
|
codefix.registerCodeFix({
|
|
155978
155992
|
errorCodes: errorCodes,
|
|
155979
155993
|
getCodeActions: function (context) {
|
|
155980
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155981
|
-
var
|
|
155982
|
-
if (
|
|
155994
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host;
|
|
155995
|
+
var info = getInfo(program, sourceFile, span);
|
|
155996
|
+
if (info === undefined)
|
|
155983
155997
|
return;
|
|
155984
|
-
}
|
|
155985
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155998
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); });
|
|
155986
155999
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155987
156000
|
},
|
|
155988
156001
|
fixIds: [fixId],
|
|
155989
|
-
getAllCodeActions: function (context) {
|
|
155990
|
-
var
|
|
155991
|
-
|
|
155992
|
-
|
|
155993
|
-
|
|
155994
|
-
|
|
156002
|
+
getAllCodeActions: function (context) {
|
|
156003
|
+
var program = context.program, preferences = context.preferences, host = context.host;
|
|
156004
|
+
var seen = new ts.Map();
|
|
156005
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
156006
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
156007
|
+
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
156008
|
+
if (info) {
|
|
156009
|
+
var id = ts.getNodeId(info.declaration) + "#" + info.token.getText();
|
|
156010
|
+
if (ts.addToSeen(seen, id)) {
|
|
156011
|
+
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156012
|
+
}
|
|
156013
|
+
}
|
|
156014
|
+
return undefined;
|
|
156015
|
+
});
|
|
156016
|
+
}));
|
|
156017
|
+
}
|
|
155995
156018
|
});
|
|
155996
|
-
function
|
|
156019
|
+
function getInfo(program, sourceFile, span) {
|
|
155997
156020
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155998
|
-
if (
|
|
156021
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155999
156022
|
return;
|
|
156000
156023
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
156001
|
-
if (
|
|
156024
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
156002
156025
|
return;
|
|
156003
|
-
|
|
156004
|
-
|
|
156005
|
-
function addMissingConstraint(changes, related) {
|
|
156006
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
156007
|
-
if (!decl)
|
|
156026
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156027
|
+
if (declaration === undefined)
|
|
156008
156028
|
return;
|
|
156009
|
-
if (ts.isIdentifier(
|
|
156010
|
-
|
|
156029
|
+
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
156030
|
+
declaration = declaration.parent;
|
|
156031
|
+
}
|
|
156032
|
+
if (ts.isTypeParameterDeclaration(declaration)) {
|
|
156033
|
+
// should only issue fix on type parameters written using `extends`
|
|
156034
|
+
if (ts.isMappedTypeNode(declaration.parent))
|
|
156035
|
+
return;
|
|
156036
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156037
|
+
var checker = program.getTypeChecker();
|
|
156038
|
+
var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
|
156039
|
+
return { constraint: constraint, declaration: declaration, token: token };
|
|
156040
|
+
}
|
|
156041
|
+
return undefined;
|
|
156042
|
+
}
|
|
156043
|
+
function addMissingConstraint(changes, program, preferences, host, sourceFile, info) {
|
|
156044
|
+
var declaration = info.declaration, constraint = info.constraint;
|
|
156045
|
+
var checker = program.getTypeChecker();
|
|
156046
|
+
if (ts.isString(constraint)) {
|
|
156047
|
+
changes.insertText(sourceFile, declaration.name.end, " extends " + constraint);
|
|
156048
|
+
}
|
|
156049
|
+
else {
|
|
156050
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156051
|
+
var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host });
|
|
156052
|
+
var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
156053
|
+
var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
|
156054
|
+
if (typeNode) {
|
|
156055
|
+
changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
|
156056
|
+
importAdder.writeFixes(changes);
|
|
156057
|
+
}
|
|
156011
156058
|
}
|
|
156012
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156013
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156014
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156015
|
-
if (!newConstraint)
|
|
156016
|
-
return;
|
|
156017
|
-
var newConstraintText = newConstraint[1];
|
|
156018
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156019
156059
|
}
|
|
156020
156060
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156021
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156022
156061
|
var end = ts.textSpanEnd(span);
|
|
156062
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156023
156063
|
while (token.end < end) {
|
|
156024
156064
|
token = token.parent;
|
|
156025
156065
|
}
|
|
156026
156066
|
return token;
|
|
156027
156067
|
}
|
|
156068
|
+
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
156069
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
156070
|
+
return constraint;
|
|
156071
|
+
}
|
|
156072
|
+
function tryGetConstraintType(checker, node) {
|
|
156073
|
+
if (ts.isTypeNode(node.parent)) {
|
|
156074
|
+
return checker.getTypeArgumentConstraint(node.parent);
|
|
156075
|
+
}
|
|
156076
|
+
var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined;
|
|
156077
|
+
return contextualType || checker.getTypeAtLocation(node);
|
|
156078
|
+
}
|
|
156028
156079
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156029
156080
|
})(ts || (ts = {}));
|
|
156030
156081
|
/* @internal */
|
package/lib/typescript.js
CHANGED
|
@@ -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.20220724";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -7042,8 +7042,10 @@ var ts;
|
|
|
7042
7042
|
return {
|
|
7043
7043
|
close: function () {
|
|
7044
7044
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
7045
|
-
watcher
|
|
7046
|
-
|
|
7045
|
+
if (watcher) {
|
|
7046
|
+
watcher.close();
|
|
7047
|
+
watcher = undefined;
|
|
7048
|
+
}
|
|
7047
7049
|
}
|
|
7048
7050
|
};
|
|
7049
7051
|
function updateWatcher(createWatcher) {
|
|
@@ -79823,7 +79825,11 @@ var ts;
|
|
|
79823
79825
|
var operator = operatorToken.kind;
|
|
79824
79826
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79825
79827
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79826
|
-
var parent =
|
|
79828
|
+
var parent = node.parent;
|
|
79829
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79830
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79831
|
+
parent = parent.parent;
|
|
79832
|
+
}
|
|
79827
79833
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79828
79834
|
}
|
|
79829
79835
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90745,13 +90751,13 @@ var ts;
|
|
|
90745
90751
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90746
90752
|
case 200 /* ImportType */:
|
|
90747
90753
|
ts.Debug.type(node);
|
|
90748
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90754
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90749
90755
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90750
90756
|
ts.Debug.type(node);
|
|
90751
90757
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90752
90758
|
case 197 /* NamedTupleMember */:
|
|
90753
90759
|
ts.Debug.type(node);
|
|
90754
|
-
return factory.updateNamedTupleMember(node,
|
|
90760
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90755
90761
|
case 191 /* ParenthesizedType */:
|
|
90756
90762
|
ts.Debug.type(node);
|
|
90757
90763
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90816,7 +90822,7 @@ var ts;
|
|
|
90816
90822
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90817
90823
|
case 210 /* TaggedTemplateExpression */:
|
|
90818
90824
|
ts.Debug.type(node);
|
|
90819
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90825
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90820
90826
|
case 211 /* TypeAssertionExpression */:
|
|
90821
90827
|
ts.Debug.type(node);
|
|
90822
90828
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -142363,8 +142369,12 @@ var ts;
|
|
|
142363
142369
|
return undefined;
|
|
142364
142370
|
}
|
|
142365
142371
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142366
|
-
var
|
|
142367
|
-
|
|
142372
|
+
var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined;
|
|
142373
|
+
var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc);
|
|
142374
|
+
if (commentOwner.getStart(sourceFile) < position
|
|
142375
|
+
|| lastJsDoc
|
|
142376
|
+
&& existingDocComment
|
|
142377
|
+
&& lastJsDoc !== existingDocComment) {
|
|
142368
142378
|
return undefined;
|
|
142369
142379
|
}
|
|
142370
142380
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142381,7 +142391,9 @@ var ts;
|
|
|
142381
142391
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142382
142392
|
var openComment = "/**";
|
|
142383
142393
|
var closeComment = " */";
|
|
142384
|
-
|
|
142394
|
+
// If any of the existing jsDoc has tags, ignore adding new ones.
|
|
142395
|
+
var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; });
|
|
142396
|
+
if (tags && !hasTag) {
|
|
142385
142397
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142386
142398
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142387
142399
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149443,6 +149455,7 @@ var ts;
|
|
|
149443
149455
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149444
149456
|
}
|
|
149445
149457
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149458
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149446
149459
|
if (ts.nodeIsMissing(child)) {
|
|
149447
149460
|
return inheritedIndentation;
|
|
149448
149461
|
}
|
|
@@ -149509,6 +149522,7 @@ var ts;
|
|
|
149509
149522
|
}
|
|
149510
149523
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149511
149524
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149525
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149512
149526
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149513
149527
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149514
149528
|
var startLine = parentStartLine;
|
|
@@ -155968,54 +155982,91 @@ var ts;
|
|
|
155968
155982
|
codefix.registerCodeFix({
|
|
155969
155983
|
errorCodes: errorCodes,
|
|
155970
155984
|
getCodeActions: function (context) {
|
|
155971
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155972
|
-
var
|
|
155973
|
-
if (
|
|
155985
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host;
|
|
155986
|
+
var info = getInfo(program, sourceFile, span);
|
|
155987
|
+
if (info === undefined)
|
|
155974
155988
|
return;
|
|
155975
|
-
}
|
|
155976
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155989
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); });
|
|
155977
155990
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155978
155991
|
},
|
|
155979
155992
|
fixIds: [fixId],
|
|
155980
|
-
getAllCodeActions: function (context) {
|
|
155981
|
-
var
|
|
155982
|
-
|
|
155983
|
-
|
|
155984
|
-
|
|
155985
|
-
|
|
155993
|
+
getAllCodeActions: function (context) {
|
|
155994
|
+
var program = context.program, preferences = context.preferences, host = context.host;
|
|
155995
|
+
var seen = new ts.Map();
|
|
155996
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
155997
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155998
|
+
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155999
|
+
if (info) {
|
|
156000
|
+
var id = ts.getNodeId(info.declaration) + "#" + info.token.getText();
|
|
156001
|
+
if (ts.addToSeen(seen, id)) {
|
|
156002
|
+
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156003
|
+
}
|
|
156004
|
+
}
|
|
156005
|
+
return undefined;
|
|
156006
|
+
});
|
|
156007
|
+
}));
|
|
156008
|
+
}
|
|
155986
156009
|
});
|
|
155987
|
-
function
|
|
156010
|
+
function getInfo(program, sourceFile, span) {
|
|
155988
156011
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155989
|
-
if (
|
|
156012
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155990
156013
|
return;
|
|
155991
156014
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155992
|
-
if (
|
|
156015
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155993
156016
|
return;
|
|
155994
|
-
|
|
155995
|
-
|
|
155996
|
-
function addMissingConstraint(changes, related) {
|
|
155997
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155998
|
-
if (!decl)
|
|
156017
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156018
|
+
if (declaration === undefined)
|
|
155999
156019
|
return;
|
|
156000
|
-
if (ts.isIdentifier(
|
|
156001
|
-
|
|
156020
|
+
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
156021
|
+
declaration = declaration.parent;
|
|
156022
|
+
}
|
|
156023
|
+
if (ts.isTypeParameterDeclaration(declaration)) {
|
|
156024
|
+
// should only issue fix on type parameters written using `extends`
|
|
156025
|
+
if (ts.isMappedTypeNode(declaration.parent))
|
|
156026
|
+
return;
|
|
156027
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156028
|
+
var checker = program.getTypeChecker();
|
|
156029
|
+
var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
|
156030
|
+
return { constraint: constraint, declaration: declaration, token: token };
|
|
156031
|
+
}
|
|
156032
|
+
return undefined;
|
|
156033
|
+
}
|
|
156034
|
+
function addMissingConstraint(changes, program, preferences, host, sourceFile, info) {
|
|
156035
|
+
var declaration = info.declaration, constraint = info.constraint;
|
|
156036
|
+
var checker = program.getTypeChecker();
|
|
156037
|
+
if (ts.isString(constraint)) {
|
|
156038
|
+
changes.insertText(sourceFile, declaration.name.end, " extends " + constraint);
|
|
156039
|
+
}
|
|
156040
|
+
else {
|
|
156041
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156042
|
+
var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host });
|
|
156043
|
+
var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
156044
|
+
var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
|
156045
|
+
if (typeNode) {
|
|
156046
|
+
changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
|
156047
|
+
importAdder.writeFixes(changes);
|
|
156048
|
+
}
|
|
156002
156049
|
}
|
|
156003
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156004
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156005
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156006
|
-
if (!newConstraint)
|
|
156007
|
-
return;
|
|
156008
|
-
var newConstraintText = newConstraint[1];
|
|
156009
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156010
156050
|
}
|
|
156011
156051
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156012
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156013
156052
|
var end = ts.textSpanEnd(span);
|
|
156053
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156014
156054
|
while (token.end < end) {
|
|
156015
156055
|
token = token.parent;
|
|
156016
156056
|
}
|
|
156017
156057
|
return token;
|
|
156018
156058
|
}
|
|
156059
|
+
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
156060
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
156061
|
+
return constraint;
|
|
156062
|
+
}
|
|
156063
|
+
function tryGetConstraintType(checker, node) {
|
|
156064
|
+
if (ts.isTypeNode(node.parent)) {
|
|
156065
|
+
return checker.getTypeArgumentConstraint(node.parent);
|
|
156066
|
+
}
|
|
156067
|
+
var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined;
|
|
156068
|
+
return contextualType || checker.getTypeAtLocation(node);
|
|
156069
|
+
}
|
|
156019
156070
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156020
156071
|
})(ts || (ts = {}));
|
|
156021
156072
|
/* @internal */
|
|
@@ -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.20220724";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -7042,8 +7042,10 @@ var ts;
|
|
|
7042
7042
|
return {
|
|
7043
7043
|
close: function () {
|
|
7044
7044
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
7045
|
-
watcher
|
|
7046
|
-
|
|
7045
|
+
if (watcher) {
|
|
7046
|
+
watcher.close();
|
|
7047
|
+
watcher = undefined;
|
|
7048
|
+
}
|
|
7047
7049
|
}
|
|
7048
7050
|
};
|
|
7049
7051
|
function updateWatcher(createWatcher) {
|
|
@@ -79823,7 +79825,11 @@ var ts;
|
|
|
79823
79825
|
var operator = operatorToken.kind;
|
|
79824
79826
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79825
79827
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79826
|
-
var parent =
|
|
79828
|
+
var parent = node.parent;
|
|
79829
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79830
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79831
|
+
parent = parent.parent;
|
|
79832
|
+
}
|
|
79827
79833
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79828
79834
|
}
|
|
79829
79835
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90745,13 +90751,13 @@ var ts;
|
|
|
90745
90751
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90746
90752
|
case 200 /* ImportType */:
|
|
90747
90753
|
ts.Debug.type(node);
|
|
90748
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90754
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90749
90755
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90750
90756
|
ts.Debug.type(node);
|
|
90751
90757
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90752
90758
|
case 197 /* NamedTupleMember */:
|
|
90753
90759
|
ts.Debug.type(node);
|
|
90754
|
-
return factory.updateNamedTupleMember(node,
|
|
90760
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90755
90761
|
case 191 /* ParenthesizedType */:
|
|
90756
90762
|
ts.Debug.type(node);
|
|
90757
90763
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90816,7 +90822,7 @@ var ts;
|
|
|
90816
90822
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90817
90823
|
case 210 /* TaggedTemplateExpression */:
|
|
90818
90824
|
ts.Debug.type(node);
|
|
90819
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90825
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90820
90826
|
case 211 /* TypeAssertionExpression */:
|
|
90821
90827
|
ts.Debug.type(node);
|
|
90822
90828
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -142363,8 +142369,12 @@ var ts;
|
|
|
142363
142369
|
return undefined;
|
|
142364
142370
|
}
|
|
142365
142371
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142366
|
-
var
|
|
142367
|
-
|
|
142372
|
+
var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined;
|
|
142373
|
+
var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc);
|
|
142374
|
+
if (commentOwner.getStart(sourceFile) < position
|
|
142375
|
+
|| lastJsDoc
|
|
142376
|
+
&& existingDocComment
|
|
142377
|
+
&& lastJsDoc !== existingDocComment) {
|
|
142368
142378
|
return undefined;
|
|
142369
142379
|
}
|
|
142370
142380
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142381,7 +142391,9 @@ var ts;
|
|
|
142381
142391
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142382
142392
|
var openComment = "/**";
|
|
142383
142393
|
var closeComment = " */";
|
|
142384
|
-
|
|
142394
|
+
// If any of the existing jsDoc has tags, ignore adding new ones.
|
|
142395
|
+
var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; });
|
|
142396
|
+
if (tags && !hasTag) {
|
|
142385
142397
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142386
142398
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142387
142399
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149443,6 +149455,7 @@ var ts;
|
|
|
149443
149455
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149444
149456
|
}
|
|
149445
149457
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149458
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149446
149459
|
if (ts.nodeIsMissing(child)) {
|
|
149447
149460
|
return inheritedIndentation;
|
|
149448
149461
|
}
|
|
@@ -149509,6 +149522,7 @@ var ts;
|
|
|
149509
149522
|
}
|
|
149510
149523
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149511
149524
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149525
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149512
149526
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149513
149527
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149514
149528
|
var startLine = parentStartLine;
|
|
@@ -155968,54 +155982,91 @@ var ts;
|
|
|
155968
155982
|
codefix.registerCodeFix({
|
|
155969
155983
|
errorCodes: errorCodes,
|
|
155970
155984
|
getCodeActions: function (context) {
|
|
155971
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155972
|
-
var
|
|
155973
|
-
if (
|
|
155985
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host;
|
|
155986
|
+
var info = getInfo(program, sourceFile, span);
|
|
155987
|
+
if (info === undefined)
|
|
155974
155988
|
return;
|
|
155975
|
-
}
|
|
155976
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155989
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); });
|
|
155977
155990
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155978
155991
|
},
|
|
155979
155992
|
fixIds: [fixId],
|
|
155980
|
-
getAllCodeActions: function (context) {
|
|
155981
|
-
var
|
|
155982
|
-
|
|
155983
|
-
|
|
155984
|
-
|
|
155985
|
-
|
|
155993
|
+
getAllCodeActions: function (context) {
|
|
155994
|
+
var program = context.program, preferences = context.preferences, host = context.host;
|
|
155995
|
+
var seen = new ts.Map();
|
|
155996
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
155997
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155998
|
+
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155999
|
+
if (info) {
|
|
156000
|
+
var id = ts.getNodeId(info.declaration) + "#" + info.token.getText();
|
|
156001
|
+
if (ts.addToSeen(seen, id)) {
|
|
156002
|
+
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
156003
|
+
}
|
|
156004
|
+
}
|
|
156005
|
+
return undefined;
|
|
156006
|
+
});
|
|
156007
|
+
}));
|
|
156008
|
+
}
|
|
155986
156009
|
});
|
|
155987
|
-
function
|
|
156010
|
+
function getInfo(program, sourceFile, span) {
|
|
155988
156011
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155989
|
-
if (
|
|
156012
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155990
156013
|
return;
|
|
155991
156014
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155992
|
-
if (
|
|
156015
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155993
156016
|
return;
|
|
155994
|
-
|
|
155995
|
-
|
|
155996
|
-
function addMissingConstraint(changes, related) {
|
|
155997
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155998
|
-
if (!decl)
|
|
156017
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156018
|
+
if (declaration === undefined)
|
|
155999
156019
|
return;
|
|
156000
|
-
if (ts.isIdentifier(
|
|
156001
|
-
|
|
156020
|
+
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
156021
|
+
declaration = declaration.parent;
|
|
156022
|
+
}
|
|
156023
|
+
if (ts.isTypeParameterDeclaration(declaration)) {
|
|
156024
|
+
// should only issue fix on type parameters written using `extends`
|
|
156025
|
+
if (ts.isMappedTypeNode(declaration.parent))
|
|
156026
|
+
return;
|
|
156027
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156028
|
+
var checker = program.getTypeChecker();
|
|
156029
|
+
var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
|
156030
|
+
return { constraint: constraint, declaration: declaration, token: token };
|
|
156031
|
+
}
|
|
156032
|
+
return undefined;
|
|
156033
|
+
}
|
|
156034
|
+
function addMissingConstraint(changes, program, preferences, host, sourceFile, info) {
|
|
156035
|
+
var declaration = info.declaration, constraint = info.constraint;
|
|
156036
|
+
var checker = program.getTypeChecker();
|
|
156037
|
+
if (ts.isString(constraint)) {
|
|
156038
|
+
changes.insertText(sourceFile, declaration.name.end, " extends " + constraint);
|
|
156039
|
+
}
|
|
156040
|
+
else {
|
|
156041
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156042
|
+
var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host });
|
|
156043
|
+
var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
156044
|
+
var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
|
156045
|
+
if (typeNode) {
|
|
156046
|
+
changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
|
156047
|
+
importAdder.writeFixes(changes);
|
|
156048
|
+
}
|
|
156002
156049
|
}
|
|
156003
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156004
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156005
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156006
|
-
if (!newConstraint)
|
|
156007
|
-
return;
|
|
156008
|
-
var newConstraintText = newConstraint[1];
|
|
156009
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156010
156050
|
}
|
|
156011
156051
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156012
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156013
156052
|
var end = ts.textSpanEnd(span);
|
|
156053
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156014
156054
|
while (token.end < end) {
|
|
156015
156055
|
token = token.parent;
|
|
156016
156056
|
}
|
|
156017
156057
|
return token;
|
|
156018
156058
|
}
|
|
156059
|
+
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
156060
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
156061
|
+
return constraint;
|
|
156062
|
+
}
|
|
156063
|
+
function tryGetConstraintType(checker, node) {
|
|
156064
|
+
if (ts.isTypeNode(node.parent)) {
|
|
156065
|
+
return checker.getTypeArgumentConstraint(node.parent);
|
|
156066
|
+
}
|
|
156067
|
+
var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined;
|
|
156068
|
+
return contextualType || checker.getTypeAtLocation(node);
|
|
156069
|
+
}
|
|
156019
156070
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156020
156071
|
})(ts || (ts = {}));
|
|
156021
156072
|
/* @internal */
|
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.20220724";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -6837,8 +6837,10 @@ var ts;
|
|
|
6837
6837
|
return {
|
|
6838
6838
|
close: function () {
|
|
6839
6839
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
6840
|
-
watcher
|
|
6841
|
-
|
|
6840
|
+
if (watcher) {
|
|
6841
|
+
watcher.close();
|
|
6842
|
+
watcher = undefined;
|
|
6843
|
+
}
|
|
6842
6844
|
}
|
|
6843
6845
|
};
|
|
6844
6846
|
function updateWatcher(createWatcher) {
|
|
@@ -79618,7 +79620,11 @@ var ts;
|
|
|
79618
79620
|
var operator = operatorToken.kind;
|
|
79619
79621
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79620
79622
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79621
|
-
var parent =
|
|
79623
|
+
var parent = node.parent;
|
|
79624
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79625
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79626
|
+
parent = parent.parent;
|
|
79627
|
+
}
|
|
79622
79628
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79623
79629
|
}
|
|
79624
79630
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90540,13 +90546,13 @@ var ts;
|
|
|
90540
90546
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90541
90547
|
case 200 /* ImportType */:
|
|
90542
90548
|
ts.Debug.type(node);
|
|
90543
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90549
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90544
90550
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90545
90551
|
ts.Debug.type(node);
|
|
90546
90552
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90547
90553
|
case 197 /* NamedTupleMember */:
|
|
90548
90554
|
ts.Debug.type(node);
|
|
90549
|
-
return factory.updateNamedTupleMember(node,
|
|
90555
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90550
90556
|
case 191 /* ParenthesizedType */:
|
|
90551
90557
|
ts.Debug.type(node);
|
|
90552
90558
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90611,7 +90617,7 @@ var ts;
|
|
|
90611
90617
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90612
90618
|
case 210 /* TaggedTemplateExpression */:
|
|
90613
90619
|
ts.Debug.type(node);
|
|
90614
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90620
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90615
90621
|
case 211 /* TypeAssertionExpression */:
|
|
90616
90622
|
ts.Debug.type(node);
|
|
90617
90623
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
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.20220724",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|