typescript 4.8.0-dev.20220720 → 4.8.0-dev.20220723
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.dom.d.ts +2 -2
- package/lib/lib.webworker.d.ts +2 -2
- package/lib/tsc.js +16 -9
- package/lib/tsserver.js +93 -41
- package/lib/tsserverlibrary.js +93 -41
- package/lib/typescript.js +93 -41
- package/lib/typescriptServices.js +93 -41
- package/lib/typingsInstaller.js +16 -9
- package/package.json +1 -1
package/lib/lib.dom.d.ts
CHANGED
|
@@ -13848,11 +13848,11 @@ declare var SubmitEvent: {
|
|
|
13848
13848
|
* Available only in secure contexts.
|
|
13849
13849
|
*/
|
|
13850
13850
|
interface SubtleCrypto {
|
|
13851
|
-
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<
|
|
13851
|
+
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
13852
13852
|
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
13853
13853
|
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
13854
13854
|
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
|
13855
|
-
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<
|
|
13855
|
+
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
13856
13856
|
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
13857
13857
|
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
|
13858
13858
|
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
package/lib/lib.webworker.d.ts
CHANGED
|
@@ -3008,11 +3008,11 @@ declare var StorageManager: {
|
|
|
3008
3008
|
* Available only in secure contexts.
|
|
3009
3009
|
*/
|
|
3010
3010
|
interface SubtleCrypto {
|
|
3011
|
-
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<
|
|
3011
|
+
decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
3012
3012
|
deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
3013
3013
|
deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
3014
3014
|
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
|
|
3015
|
-
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<
|
|
3015
|
+
encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
|
|
3016
3016
|
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
3017
3017
|
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
|
|
3018
3018
|
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
|
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.20220723";
|
|
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) {
|
|
@@ -41385,7 +41387,7 @@ var ts;
|
|
|
41385
41387
|
}
|
|
41386
41388
|
}
|
|
41387
41389
|
function checkAndReportErrorForInvalidInitializer() {
|
|
41388
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
41390
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9)) {
|
|
41389
41391
|
error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
|
|
41390
41392
|
? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
|
|
41391
41393
|
: ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
|
|
@@ -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));
|
|
@@ -78644,7 +78650,8 @@ var ts;
|
|
|
78644
78650
|
else {
|
|
78645
78651
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
78646
78652
|
}
|
|
78647
|
-
|
|
78653
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
78654
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
78648
78655
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
78649
78656
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
|
|
78650
78657
|
ts.setTextRange(block, body);
|
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.20220723";
|
|
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) {
|
|
@@ -50437,7 +50439,7 @@ var ts;
|
|
|
50437
50439
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50438
50440
|
// 2. When result is defined
|
|
50439
50441
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50440
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50442
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50441
50443
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50442
50444
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50443
50445
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -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));
|
|
@@ -93512,7 +93518,8 @@ var ts;
|
|
|
93512
93518
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93513
93519
|
}
|
|
93514
93520
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93515
|
-
|
|
93521
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93522
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93516
93523
|
// End the lexical environment.
|
|
93517
93524
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93518
93525
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -141758,8 +141765,12 @@ var ts;
|
|
|
141758
141765
|
return undefined;
|
|
141759
141766
|
}
|
|
141760
141767
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
141761
|
-
var
|
|
141762
|
-
|
|
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) {
|
|
141763
141774
|
return undefined;
|
|
141764
141775
|
}
|
|
141765
141776
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -141776,7 +141787,9 @@ var ts;
|
|
|
141776
141787
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
141777
141788
|
var openComment = "/**";
|
|
141778
141789
|
var closeComment = " */";
|
|
141779
|
-
|
|
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) {
|
|
141780
141793
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
141781
141794
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
141782
141795
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -148838,6 +148851,7 @@ var ts;
|
|
|
148838
148851
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
148839
148852
|
}
|
|
148840
148853
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
148854
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
148841
148855
|
if (ts.nodeIsMissing(child)) {
|
|
148842
148856
|
return inheritedIndentation;
|
|
148843
148857
|
}
|
|
@@ -148904,6 +148918,7 @@ var ts;
|
|
|
148904
148918
|
}
|
|
148905
148919
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
148906
148920
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
148921
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
148907
148922
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
148908
148923
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
148909
148924
|
var startLine = parentStartLine;
|
|
@@ -155363,54 +155378,91 @@ var ts;
|
|
|
155363
155378
|
codefix.registerCodeFix({
|
|
155364
155379
|
errorCodes: errorCodes,
|
|
155365
155380
|
getCodeActions: function (context) {
|
|
155366
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155367
|
-
var
|
|
155368
|
-
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)
|
|
155369
155384
|
return;
|
|
155370
|
-
}
|
|
155371
|
-
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); });
|
|
155372
155386
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155373
155387
|
},
|
|
155374
155388
|
fixIds: [fixId],
|
|
155375
|
-
getAllCodeActions: function (context) {
|
|
155376
|
-
var
|
|
155377
|
-
|
|
155378
|
-
|
|
155379
|
-
|
|
155380
|
-
|
|
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
|
+
}
|
|
155381
155405
|
});
|
|
155382
|
-
function
|
|
155406
|
+
function getInfo(program, sourceFile, span) {
|
|
155383
155407
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155384
|
-
if (
|
|
155408
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155385
155409
|
return;
|
|
155386
155410
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155387
|
-
if (
|
|
155411
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155388
155412
|
return;
|
|
155389
|
-
|
|
155390
|
-
|
|
155391
|
-
function addMissingConstraint(changes, related) {
|
|
155392
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155393
|
-
if (!decl)
|
|
155413
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
155414
|
+
if (declaration === undefined)
|
|
155394
155415
|
return;
|
|
155395
|
-
if (ts.isIdentifier(
|
|
155396
|
-
|
|
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
|
+
}
|
|
155397
155445
|
}
|
|
155398
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155399
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
155400
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155401
|
-
if (!newConstraint)
|
|
155402
|
-
return;
|
|
155403
|
-
var newConstraintText = newConstraint[1];
|
|
155404
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
155405
155446
|
}
|
|
155406
155447
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155407
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155408
155448
|
var end = ts.textSpanEnd(span);
|
|
155449
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155409
155450
|
while (token.end < end) {
|
|
155410
155451
|
token = token.parent;
|
|
155411
155452
|
}
|
|
155412
155453
|
return token;
|
|
155413
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
|
+
}
|
|
155414
155466
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155415
155467
|
})(ts || (ts = {}));
|
|
155416
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.20220723";
|
|
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) {
|
|
@@ -50631,7 +50633,7 @@ var ts;
|
|
|
50631
50633
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50632
50634
|
// 2. When result is defined
|
|
50633
50635
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50634
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50636
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50635
50637
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50636
50638
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50637
50639
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -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));
|
|
@@ -93706,7 +93712,8 @@ var ts;
|
|
|
93706
93712
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93707
93713
|
}
|
|
93708
93714
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93709
|
-
|
|
93715
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93716
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93710
93717
|
// End the lexical environment.
|
|
93711
93718
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93712
93719
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -142371,8 +142378,12 @@ var ts;
|
|
|
142371
142378
|
return undefined;
|
|
142372
142379
|
}
|
|
142373
142380
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142374
|
-
var
|
|
142375
|
-
|
|
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) {
|
|
142376
142387
|
return undefined;
|
|
142377
142388
|
}
|
|
142378
142389
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142389,7 +142400,9 @@ var ts;
|
|
|
142389
142400
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142390
142401
|
var openComment = "/**";
|
|
142391
142402
|
var closeComment = " */";
|
|
142392
|
-
|
|
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) {
|
|
142393
142406
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142394
142407
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142395
142408
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149451,6 +149464,7 @@ var ts;
|
|
|
149451
149464
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149452
149465
|
}
|
|
149453
149466
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149467
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149454
149468
|
if (ts.nodeIsMissing(child)) {
|
|
149455
149469
|
return inheritedIndentation;
|
|
149456
149470
|
}
|
|
@@ -149517,6 +149531,7 @@ var ts;
|
|
|
149517
149531
|
}
|
|
149518
149532
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149519
149533
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149534
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149520
149535
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149521
149536
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149522
149537
|
var startLine = parentStartLine;
|
|
@@ -155976,54 +155991,91 @@ var ts;
|
|
|
155976
155991
|
codefix.registerCodeFix({
|
|
155977
155992
|
errorCodes: errorCodes,
|
|
155978
155993
|
getCodeActions: function (context) {
|
|
155979
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155980
|
-
var
|
|
155981
|
-
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)
|
|
155982
155997
|
return;
|
|
155983
|
-
}
|
|
155984
|
-
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); });
|
|
155985
155999
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155986
156000
|
},
|
|
155987
156001
|
fixIds: [fixId],
|
|
155988
|
-
getAllCodeActions: function (context) {
|
|
155989
|
-
var
|
|
155990
|
-
|
|
155991
|
-
|
|
155992
|
-
|
|
155993
|
-
|
|
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
|
+
}
|
|
155994
156018
|
});
|
|
155995
|
-
function
|
|
156019
|
+
function getInfo(program, sourceFile, span) {
|
|
155996
156020
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155997
|
-
if (
|
|
156021
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155998
156022
|
return;
|
|
155999
156023
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
156000
|
-
if (
|
|
156024
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
156001
156025
|
return;
|
|
156002
|
-
|
|
156003
|
-
|
|
156004
|
-
function addMissingConstraint(changes, related) {
|
|
156005
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
156006
|
-
if (!decl)
|
|
156026
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156027
|
+
if (declaration === undefined)
|
|
156007
156028
|
return;
|
|
156008
|
-
if (ts.isIdentifier(
|
|
156009
|
-
|
|
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
|
+
}
|
|
156010
156058
|
}
|
|
156011
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156012
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156013
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156014
|
-
if (!newConstraint)
|
|
156015
|
-
return;
|
|
156016
|
-
var newConstraintText = newConstraint[1];
|
|
156017
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156018
156059
|
}
|
|
156019
156060
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156020
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156021
156061
|
var end = ts.textSpanEnd(span);
|
|
156062
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156022
156063
|
while (token.end < end) {
|
|
156023
156064
|
token = token.parent;
|
|
156024
156065
|
}
|
|
156025
156066
|
return token;
|
|
156026
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
|
+
}
|
|
156027
156079
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156028
156080
|
})(ts || (ts = {}));
|
|
156029
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.20220723";
|
|
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) {
|
|
@@ -50622,7 +50624,7 @@ var ts;
|
|
|
50622
50624
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50623
50625
|
// 2. When result is defined
|
|
50624
50626
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50625
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50627
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50626
50628
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50627
50629
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50628
50630
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -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));
|
|
@@ -93697,7 +93703,8 @@ var ts;
|
|
|
93697
93703
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93698
93704
|
}
|
|
93699
93705
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93700
|
-
|
|
93706
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93707
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93701
93708
|
// End the lexical environment.
|
|
93702
93709
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93703
93710
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -142362,8 +142369,12 @@ var ts;
|
|
|
142362
142369
|
return undefined;
|
|
142363
142370
|
}
|
|
142364
142371
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142365
|
-
var
|
|
142366
|
-
|
|
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) {
|
|
142367
142378
|
return undefined;
|
|
142368
142379
|
}
|
|
142369
142380
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142380,7 +142391,9 @@ var ts;
|
|
|
142380
142391
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142381
142392
|
var openComment = "/**";
|
|
142382
142393
|
var closeComment = " */";
|
|
142383
|
-
|
|
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) {
|
|
142384
142397
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142385
142398
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142386
142399
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149442,6 +149455,7 @@ var ts;
|
|
|
149442
149455
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149443
149456
|
}
|
|
149444
149457
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149458
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149445
149459
|
if (ts.nodeIsMissing(child)) {
|
|
149446
149460
|
return inheritedIndentation;
|
|
149447
149461
|
}
|
|
@@ -149508,6 +149522,7 @@ var ts;
|
|
|
149508
149522
|
}
|
|
149509
149523
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149510
149524
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149525
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149511
149526
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149512
149527
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149513
149528
|
var startLine = parentStartLine;
|
|
@@ -155967,54 +155982,91 @@ var ts;
|
|
|
155967
155982
|
codefix.registerCodeFix({
|
|
155968
155983
|
errorCodes: errorCodes,
|
|
155969
155984
|
getCodeActions: function (context) {
|
|
155970
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155971
|
-
var
|
|
155972
|
-
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)
|
|
155973
155988
|
return;
|
|
155974
|
-
}
|
|
155975
|
-
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); });
|
|
155976
155990
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155977
155991
|
},
|
|
155978
155992
|
fixIds: [fixId],
|
|
155979
|
-
getAllCodeActions: function (context) {
|
|
155980
|
-
var
|
|
155981
|
-
|
|
155982
|
-
|
|
155983
|
-
|
|
155984
|
-
|
|
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
|
+
}
|
|
155985
156009
|
});
|
|
155986
|
-
function
|
|
156010
|
+
function getInfo(program, sourceFile, span) {
|
|
155987
156011
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155988
|
-
if (
|
|
156012
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155989
156013
|
return;
|
|
155990
156014
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155991
|
-
if (
|
|
156015
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155992
156016
|
return;
|
|
155993
|
-
|
|
155994
|
-
|
|
155995
|
-
function addMissingConstraint(changes, related) {
|
|
155996
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155997
|
-
if (!decl)
|
|
156017
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156018
|
+
if (declaration === undefined)
|
|
155998
156019
|
return;
|
|
155999
|
-
if (ts.isIdentifier(
|
|
156000
|
-
|
|
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
|
+
}
|
|
156001
156049
|
}
|
|
156002
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156003
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156004
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156005
|
-
if (!newConstraint)
|
|
156006
|
-
return;
|
|
156007
|
-
var newConstraintText = newConstraint[1];
|
|
156008
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156009
156050
|
}
|
|
156010
156051
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156011
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156012
156052
|
var end = ts.textSpanEnd(span);
|
|
156053
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156013
156054
|
while (token.end < end) {
|
|
156014
156055
|
token = token.parent;
|
|
156015
156056
|
}
|
|
156016
156057
|
return token;
|
|
156017
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
|
+
}
|
|
156018
156070
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156019
156071
|
})(ts || (ts = {}));
|
|
156020
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.20220723";
|
|
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) {
|
|
@@ -50622,7 +50624,7 @@ var ts;
|
|
|
50622
50624
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50623
50625
|
// 2. When result is defined
|
|
50624
50626
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50625
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50627
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50626
50628
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50627
50629
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50628
50630
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -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));
|
|
@@ -93697,7 +93703,8 @@ var ts;
|
|
|
93697
93703
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93698
93704
|
}
|
|
93699
93705
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93700
|
-
|
|
93706
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93707
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93701
93708
|
// End the lexical environment.
|
|
93702
93709
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93703
93710
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -142362,8 +142369,12 @@ var ts;
|
|
|
142362
142369
|
return undefined;
|
|
142363
142370
|
}
|
|
142364
142371
|
var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn;
|
|
142365
|
-
var
|
|
142366
|
-
|
|
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) {
|
|
142367
142378
|
return undefined;
|
|
142368
142379
|
}
|
|
142369
142380
|
var indentationStr = getIndentationStringAtPosition(sourceFile, position);
|
|
@@ -142380,7 +142391,9 @@ var ts;
|
|
|
142380
142391
|
// * if the caret was directly in front of the object, then we add an extra line and indentation.
|
|
142381
142392
|
var openComment = "/**";
|
|
142382
142393
|
var closeComment = " */";
|
|
142383
|
-
|
|
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) {
|
|
142384
142397
|
var preamble = openComment + newLine + indentationStr + " * ";
|
|
142385
142398
|
var endLine = tokenStart === position ? newLine + indentationStr : "";
|
|
142386
142399
|
var result = preamble + newLine + tags + indentationStr + closeComment + endLine;
|
|
@@ -149442,6 +149455,7 @@ var ts;
|
|
|
149442
149455
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149443
149456
|
}
|
|
149444
149457
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149458
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149445
149459
|
if (ts.nodeIsMissing(child)) {
|
|
149446
149460
|
return inheritedIndentation;
|
|
149447
149461
|
}
|
|
@@ -149508,6 +149522,7 @@ var ts;
|
|
|
149508
149522
|
}
|
|
149509
149523
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149510
149524
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149525
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149511
149526
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149512
149527
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149513
149528
|
var startLine = parentStartLine;
|
|
@@ -155967,54 +155982,91 @@ var ts;
|
|
|
155967
155982
|
codefix.registerCodeFix({
|
|
155968
155983
|
errorCodes: errorCodes,
|
|
155969
155984
|
getCodeActions: function (context) {
|
|
155970
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155971
|
-
var
|
|
155972
|
-
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)
|
|
155973
155988
|
return;
|
|
155974
|
-
}
|
|
155975
|
-
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); });
|
|
155976
155990
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155977
155991
|
},
|
|
155978
155992
|
fixIds: [fixId],
|
|
155979
|
-
getAllCodeActions: function (context) {
|
|
155980
|
-
var
|
|
155981
|
-
|
|
155982
|
-
|
|
155983
|
-
|
|
155984
|
-
|
|
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
|
+
}
|
|
155985
156009
|
});
|
|
155986
|
-
function
|
|
156010
|
+
function getInfo(program, sourceFile, span) {
|
|
155987
156011
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155988
|
-
if (
|
|
156012
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155989
156013
|
return;
|
|
155990
156014
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155991
|
-
if (
|
|
156015
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155992
156016
|
return;
|
|
155993
|
-
|
|
155994
|
-
|
|
155995
|
-
function addMissingConstraint(changes, related) {
|
|
155996
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155997
|
-
if (!decl)
|
|
156017
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156018
|
+
if (declaration === undefined)
|
|
155998
156019
|
return;
|
|
155999
|
-
if (ts.isIdentifier(
|
|
156000
|
-
|
|
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
|
+
}
|
|
156001
156049
|
}
|
|
156002
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156003
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156004
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156005
|
-
if (!newConstraint)
|
|
156006
|
-
return;
|
|
156007
|
-
var newConstraintText = newConstraint[1];
|
|
156008
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156009
156050
|
}
|
|
156010
156051
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156011
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156012
156052
|
var end = ts.textSpanEnd(span);
|
|
156053
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156013
156054
|
while (token.end < end) {
|
|
156014
156055
|
token = token.parent;
|
|
156015
156056
|
}
|
|
156016
156057
|
return token;
|
|
156017
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
|
+
}
|
|
156018
156070
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156019
156071
|
})(ts || (ts = {}));
|
|
156020
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.20220723";
|
|
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) {
|
|
@@ -50417,7 +50419,7 @@ var ts;
|
|
|
50417
50419
|
// 1. When result is undefined, after checking for a missing "this."
|
|
50418
50420
|
// 2. When result is defined
|
|
50419
50421
|
function checkAndReportErrorForInvalidInitializer() {
|
|
50420
|
-
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions)
|
|
50422
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
50421
50423
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
50422
50424
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
50423
50425
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -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));
|
|
@@ -93492,7 +93498,8 @@ var ts;
|
|
|
93492
93498
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true);
|
|
93493
93499
|
}
|
|
93494
93500
|
// Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements
|
|
93495
|
-
|
|
93501
|
+
var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount;
|
|
93502
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start));
|
|
93496
93503
|
// End the lexical environment.
|
|
93497
93504
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93498
93505
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
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.20220723",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|