typescript 5.2.0-dev.20230720 → 5.2.0-dev.20230722
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 +52 -41
- package/lib/tsserver.js +208 -104
- package/lib/tsserverlibrary.d.ts +13 -2
- package/lib/tsserverlibrary.js +207 -105
- package/lib/typescript.d.ts +7 -1
- package/lib/typescript.js +189 -101
- package/lib/typingsInstaller.js +11 -4
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -970,6 +970,7 @@ __export(server_exports, {
|
|
|
970
970
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
971
971
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
972
972
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
973
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
973
974
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
974
975
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
975
976
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -1802,6 +1803,7 @@ __export(server_exports, {
|
|
|
1802
1803
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
1803
1804
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
1804
1805
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
1806
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
1805
1807
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
1806
1808
|
isUnaryExpression: () => isUnaryExpression,
|
|
1807
1809
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -2327,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2327
2329
|
|
|
2328
2330
|
// src/compiler/corePublic.ts
|
|
2329
2331
|
var versionMajorMinor = "5.2";
|
|
2330
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2332
|
+
var version = `${versionMajorMinor}.0-dev.20230722`;
|
|
2331
2333
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2334
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2335
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21601,6 +21603,18 @@ function getTextOfJsxNamespacedName(node) {
|
|
|
21601
21603
|
function intrinsicTagNameToString(node) {
|
|
21602
21604
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
21603
21605
|
}
|
|
21606
|
+
function isTypeUsableAsPropertyName(type) {
|
|
21607
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
21608
|
+
}
|
|
21609
|
+
function getPropertyNameFromType(type) {
|
|
21610
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
21611
|
+
return type.escapedName;
|
|
21612
|
+
}
|
|
21613
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
21614
|
+
return escapeLeadingUnderscores("" + type.value);
|
|
21615
|
+
}
|
|
21616
|
+
return Debug.fail();
|
|
21617
|
+
}
|
|
21604
21618
|
|
|
21605
21619
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21606
21620
|
function createBaseNodeFactory() {
|
|
@@ -35109,10 +35123,14 @@ var Parser;
|
|
|
35109
35123
|
case 124 /* ProtectedKeyword */:
|
|
35110
35124
|
case 125 /* PublicKeyword */:
|
|
35111
35125
|
case 148 /* ReadonlyKeyword */:
|
|
35126
|
+
const previousToken = token();
|
|
35112
35127
|
nextToken();
|
|
35113
35128
|
if (scanner2.hasPrecedingLineBreak()) {
|
|
35114
35129
|
return false;
|
|
35115
35130
|
}
|
|
35131
|
+
if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
|
|
35132
|
+
return true;
|
|
35133
|
+
}
|
|
35116
35134
|
continue;
|
|
35117
35135
|
case 162 /* GlobalKeyword */:
|
|
35118
35136
|
nextToken();
|
|
@@ -35477,14 +35495,14 @@ var Parser;
|
|
|
35477
35495
|
function parseObjectBindingPattern() {
|
|
35478
35496
|
const pos = getNodePos();
|
|
35479
35497
|
parseExpected(19 /* OpenBraceToken */);
|
|
35480
|
-
const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
35498
|
+
const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
|
|
35481
35499
|
parseExpected(20 /* CloseBraceToken */);
|
|
35482
35500
|
return finishNode(factory2.createObjectBindingPattern(elements), pos);
|
|
35483
35501
|
}
|
|
35484
35502
|
function parseArrayBindingPattern() {
|
|
35485
35503
|
const pos = getNodePos();
|
|
35486
35504
|
parseExpected(23 /* OpenBracketToken */);
|
|
35487
|
-
const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
35505
|
+
const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
|
|
35488
35506
|
parseExpected(24 /* CloseBracketToken */);
|
|
35489
35507
|
return finishNode(factory2.createArrayBindingPattern(elements), pos);
|
|
35490
35508
|
}
|
|
@@ -36002,6 +36020,9 @@ var Parser;
|
|
|
36002
36020
|
}
|
|
36003
36021
|
function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
|
|
36004
36022
|
parseExpected(156 /* TypeKeyword */);
|
|
36023
|
+
if (scanner2.hasPrecedingLineBreak()) {
|
|
36024
|
+
parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
|
|
36025
|
+
}
|
|
36005
36026
|
const name = parseIdentifier();
|
|
36006
36027
|
const typeParameters = parseTypeParameters();
|
|
36007
36028
|
parseExpected(64 /* EqualsToken */);
|
|
@@ -37903,7 +37924,7 @@ function getNamedArgRegEx(name) {
|
|
|
37903
37924
|
return result;
|
|
37904
37925
|
}
|
|
37905
37926
|
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
|
37906
|
-
var singleLinePragmaRegEx = /^\/\/\/?\s*@(
|
|
37927
|
+
var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
|
|
37907
37928
|
function extractPragmas(pragmas, range, text) {
|
|
37908
37929
|
const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
|
|
37909
37930
|
if (tripleSlash) {
|
|
@@ -47818,7 +47839,7 @@ function createTypeChecker(host) {
|
|
|
47818
47839
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
47819
47840
|
},
|
|
47820
47841
|
getParameterType: getTypeAtPosition,
|
|
47821
|
-
|
|
47842
|
+
getParameterIdentifierInfoAtPosition,
|
|
47822
47843
|
getPromisedTypeOfPromise,
|
|
47823
47844
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
47824
47845
|
getReturnTypeOfSignature,
|
|
@@ -56281,7 +56302,7 @@ function createTypeChecker(host) {
|
|
|
56281
56302
|
false,
|
|
56282
56303
|
definedInMethod && !definedInConstructor
|
|
56283
56304
|
));
|
|
56284
|
-
if (symbol.valueDeclaration && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
56305
|
+
if (symbol.valueDeclaration && isInJSFile(symbol.valueDeclaration) && filterType(widened, (t) => !!(t.flags & ~98304 /* Nullable */)) === neverType) {
|
|
56285
56306
|
reportImplicitAny(symbol.valueDeclaration, anyType);
|
|
56286
56307
|
return anyType;
|
|
56287
56308
|
}
|
|
@@ -57560,9 +57581,6 @@ function createTypeChecker(host) {
|
|
|
57560
57581
|
}
|
|
57561
57582
|
return type;
|
|
57562
57583
|
}
|
|
57563
|
-
function isTypeUsableAsPropertyName(type) {
|
|
57564
|
-
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57565
|
-
}
|
|
57566
57584
|
function isLateBindableName(node) {
|
|
57567
57585
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
57568
57586
|
return false;
|
|
@@ -57583,15 +57601,6 @@ function createTypeChecker(host) {
|
|
|
57583
57601
|
function isNonBindableDynamicName(node) {
|
|
57584
57602
|
return isDynamicName(node) && !isLateBindableName(node);
|
|
57585
57603
|
}
|
|
57586
|
-
function getPropertyNameFromType(type) {
|
|
57587
|
-
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
57588
|
-
return type.escapedName;
|
|
57589
|
-
}
|
|
57590
|
-
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
57591
|
-
return escapeLeadingUnderscores("" + type.value);
|
|
57592
|
-
}
|
|
57593
|
-
return Debug.fail();
|
|
57594
|
-
}
|
|
57595
57604
|
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
|
|
57596
57605
|
Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
|
|
57597
57606
|
symbol.flags |= symbolFlags;
|
|
@@ -58238,20 +58247,17 @@ function createTypeChecker(host) {
|
|
|
58238
58247
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
58239
58248
|
return;
|
|
58240
58249
|
}
|
|
58241
|
-
let members =
|
|
58250
|
+
let members = getExportsOfSymbol(symbol);
|
|
58242
58251
|
let indexInfos;
|
|
58243
|
-
if (symbol
|
|
58244
|
-
|
|
58245
|
-
|
|
58246
|
-
|
|
58247
|
-
|
|
58248
|
-
|
|
58249
|
-
|
|
58250
|
-
|
|
58251
|
-
|
|
58252
|
-
});
|
|
58253
|
-
members = varsOnly;
|
|
58254
|
-
}
|
|
58252
|
+
if (symbol === globalThisSymbol) {
|
|
58253
|
+
const varsOnly = /* @__PURE__ */ new Map();
|
|
58254
|
+
members.forEach((p) => {
|
|
58255
|
+
var _a;
|
|
58256
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
|
|
58257
|
+
varsOnly.set(p.escapedName, p);
|
|
58258
|
+
}
|
|
58259
|
+
});
|
|
58260
|
+
members = varsOnly;
|
|
58255
58261
|
}
|
|
58256
58262
|
let baseConstructorIndexInfo;
|
|
58257
58263
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -76763,7 +76769,7 @@ function createTypeChecker(host) {
|
|
|
76763
76769
|
}
|
|
76764
76770
|
return restParameter.escapedName;
|
|
76765
76771
|
}
|
|
76766
|
-
function
|
|
76772
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
76767
76773
|
var _a;
|
|
76768
76774
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
76769
76775
|
return void 0;
|
|
@@ -76771,10 +76777,16 @@ function createTypeChecker(host) {
|
|
|
76771
76777
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
76772
76778
|
if (pos < paramCount) {
|
|
76773
76779
|
const param = signature.parameters[pos];
|
|
76774
|
-
|
|
76780
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
76781
|
+
return paramIdent ? {
|
|
76782
|
+
parameter: paramIdent,
|
|
76783
|
+
parameterName: param.escapedName,
|
|
76784
|
+
isRestParameter: false
|
|
76785
|
+
} : void 0;
|
|
76775
76786
|
}
|
|
76776
76787
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
76777
|
-
|
|
76788
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
76789
|
+
if (!restIdent) {
|
|
76778
76790
|
return void 0;
|
|
76779
76791
|
}
|
|
76780
76792
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -76783,18 +76795,19 @@ function createTypeChecker(host) {
|
|
|
76783
76795
|
const index = pos - paramCount;
|
|
76784
76796
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
76785
76797
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
76786
|
-
|
|
76787
|
-
|
|
76788
|
-
isRestTupleElement
|
|
76789
|
-
|
|
76798
|
+
if (associatedName) {
|
|
76799
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
76800
|
+
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
76801
|
+
}
|
|
76802
|
+
return void 0;
|
|
76790
76803
|
}
|
|
76791
76804
|
if (pos === paramCount) {
|
|
76792
|
-
return
|
|
76805
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
76793
76806
|
}
|
|
76794
76807
|
return void 0;
|
|
76795
76808
|
}
|
|
76796
|
-
function
|
|
76797
|
-
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
|
|
76809
|
+
function getParameterDeclarationIdentifier(symbol) {
|
|
76810
|
+
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
|
|
76798
76811
|
}
|
|
76799
76812
|
function isValidDeclarationForTupleLabel(d) {
|
|
76800
76813
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -136034,8 +136047,8 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
136034
136047
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
136035
136048
|
}
|
|
136036
136049
|
}
|
|
136037
|
-
const
|
|
136038
|
-
|
|
136050
|
+
const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
|
|
136051
|
+
for (const jsdocTypedefNode of jsdocTypedefNodes) {
|
|
136039
136052
|
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
136040
136053
|
}
|
|
136041
136054
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
@@ -146854,7 +146867,7 @@ __export(ts_codefix_exports, {
|
|
|
146854
146867
|
getFixes: () => getFixes,
|
|
146855
146868
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
146856
146869
|
getImportKind: () => getImportKind,
|
|
146857
|
-
|
|
146870
|
+
getJSDocTypedefNodes: () => getJSDocTypedefNodes,
|
|
146858
146871
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
146859
146872
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
146860
146873
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -149576,13 +149589,14 @@ registerCodeFix({
|
|
|
149576
149589
|
fixIds: [fixId14],
|
|
149577
149590
|
errorCodes: errorCodes15,
|
|
149578
149591
|
getCodeActions(context) {
|
|
149592
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149579
149593
|
const node = getTokenAtPosition(
|
|
149580
149594
|
context.sourceFile,
|
|
149581
149595
|
context.span.start
|
|
149582
149596
|
);
|
|
149583
149597
|
if (!node)
|
|
149584
149598
|
return;
|
|
149585
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
|
|
149599
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
|
|
149586
149600
|
if (changes.length > 0) {
|
|
149587
149601
|
return [
|
|
149588
149602
|
createCodeFixAction(
|
|
@@ -149595,29 +149609,72 @@ registerCodeFix({
|
|
|
149595
149609
|
];
|
|
149596
149610
|
}
|
|
149597
149611
|
},
|
|
149598
|
-
getAllCodeActions: (context) => codeFixAll(
|
|
149599
|
-
|
|
149600
|
-
|
|
149601
|
-
|
|
149602
|
-
|
|
149612
|
+
getAllCodeActions: (context) => codeFixAll(
|
|
149613
|
+
context,
|
|
149614
|
+
errorCodes15,
|
|
149615
|
+
(changes, diag2) => {
|
|
149616
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149617
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
149618
|
+
const fixAll = true;
|
|
149619
|
+
if (node)
|
|
149620
|
+
doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
|
|
149621
|
+
}
|
|
149622
|
+
)
|
|
149603
149623
|
});
|
|
149604
|
-
function doChange12(changes, node, sourceFile) {
|
|
149605
|
-
if (isJSDocTypedefTag(node))
|
|
149606
|
-
fixSingleTypeDef(changes, node, sourceFile);
|
|
149607
|
-
}
|
|
149608
|
-
}
|
|
149609
|
-
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
149610
|
-
if (!typeDefNode)
|
|
149624
|
+
function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
|
|
149625
|
+
if (!isJSDocTypedefTag(node))
|
|
149611
149626
|
return;
|
|
149612
|
-
const declaration = createDeclaration(
|
|
149627
|
+
const declaration = createDeclaration(node);
|
|
149613
149628
|
if (!declaration)
|
|
149614
149629
|
return;
|
|
149615
|
-
const
|
|
149616
|
-
|
|
149617
|
-
|
|
149618
|
-
|
|
149619
|
-
|
|
149630
|
+
const commentNode = node.parent;
|
|
149631
|
+
const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
|
|
149632
|
+
let pos = commentNode.getStart();
|
|
149633
|
+
let prefix = "";
|
|
149634
|
+
if (!leftSibling && commentNode.comment) {
|
|
149635
|
+
pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
|
|
149636
|
+
prefix = `${newLine} */${newLine}`;
|
|
149637
|
+
}
|
|
149638
|
+
if (leftSibling) {
|
|
149639
|
+
if (fixAll && isJSDocTypedefTag(leftSibling)) {
|
|
149640
|
+
pos = node.getStart();
|
|
149641
|
+
prefix = "";
|
|
149642
|
+
} else {
|
|
149643
|
+
pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
|
|
149644
|
+
prefix = `${newLine} */${newLine}`;
|
|
149645
|
+
}
|
|
149646
|
+
}
|
|
149647
|
+
let end = commentNode.getEnd();
|
|
149648
|
+
let suffix = "";
|
|
149649
|
+
if (rightSibling) {
|
|
149650
|
+
if (fixAll && isJSDocTypedefTag(rightSibling)) {
|
|
149651
|
+
end = rightSibling.getStart();
|
|
149652
|
+
suffix = `${newLine}${newLine}`;
|
|
149653
|
+
} else {
|
|
149654
|
+
end = rightSibling.getStart();
|
|
149655
|
+
suffix = `${newLine}/**${newLine} * `;
|
|
149656
|
+
}
|
|
149657
|
+
}
|
|
149658
|
+
changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
|
|
149659
|
+
}
|
|
149660
|
+
function getLeftAndRightSiblings(typedefNode) {
|
|
149661
|
+
const commentNode = typedefNode.parent;
|
|
149662
|
+
const maxChildIndex = commentNode.getChildCount() - 1;
|
|
149663
|
+
const currentNodeIndex = commentNode.getChildren().findIndex(
|
|
149664
|
+
(n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
|
|
149620
149665
|
);
|
|
149666
|
+
const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
|
|
149667
|
+
const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
|
|
149668
|
+
return { leftSibling, rightSibling };
|
|
149669
|
+
}
|
|
149670
|
+
function findEndOfTextBetween(jsDocComment, from, to) {
|
|
149671
|
+
const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
|
|
149672
|
+
for (let i = comment.length; i > 0; i--) {
|
|
149673
|
+
if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
|
|
149674
|
+
return from + i;
|
|
149675
|
+
}
|
|
149676
|
+
}
|
|
149677
|
+
return to;
|
|
149621
149678
|
}
|
|
149622
149679
|
function createDeclaration(tag) {
|
|
149623
149680
|
var _a;
|
|
@@ -149638,7 +149695,7 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149638
149695
|
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
149639
149696
|
if (!some(propertySignatures))
|
|
149640
149697
|
return;
|
|
149641
|
-
|
|
149698
|
+
return factory.createInterfaceDeclaration(
|
|
149642
149699
|
/*modifiers*/
|
|
149643
149700
|
void 0,
|
|
149644
149701
|
typeName,
|
|
@@ -149648,13 +149705,12 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149648
149705
|
void 0,
|
|
149649
149706
|
propertySignatures
|
|
149650
149707
|
);
|
|
149651
|
-
return interfaceDeclaration;
|
|
149652
149708
|
}
|
|
149653
149709
|
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
149654
149710
|
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
149655
149711
|
if (!typeReference)
|
|
149656
149712
|
return;
|
|
149657
|
-
|
|
149713
|
+
return factory.createTypeAliasDeclaration(
|
|
149658
149714
|
/*modifiers*/
|
|
149659
149715
|
void 0,
|
|
149660
149716
|
factory.createIdentifier(typeName),
|
|
@@ -149662,7 +149718,6 @@ function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
|
149662
149718
|
void 0,
|
|
149663
149719
|
typeReference
|
|
149664
149720
|
);
|
|
149665
|
-
return declaration;
|
|
149666
149721
|
}
|
|
149667
149722
|
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
149668
149723
|
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
@@ -149682,30 +149737,28 @@ function createSignatureFromTypeLiteral(typeLiteral) {
|
|
|
149682
149737
|
}
|
|
149683
149738
|
if (typeReference && name) {
|
|
149684
149739
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
149685
|
-
|
|
149740
|
+
return factory.createPropertySignature(
|
|
149686
149741
|
/*modifiers*/
|
|
149687
149742
|
void 0,
|
|
149688
149743
|
name,
|
|
149689
149744
|
questionToken,
|
|
149690
149745
|
typeReference
|
|
149691
149746
|
);
|
|
149692
|
-
return prop;
|
|
149693
149747
|
}
|
|
149694
149748
|
};
|
|
149695
|
-
|
|
149696
|
-
return props;
|
|
149749
|
+
return mapDefined(propertyTags, getSignature);
|
|
149697
149750
|
}
|
|
149698
149751
|
function getPropertyName(tag) {
|
|
149699
149752
|
return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
149700
149753
|
}
|
|
149701
|
-
function
|
|
149754
|
+
function getJSDocTypedefNodes(node) {
|
|
149702
149755
|
if (hasJSDocNodes(node)) {
|
|
149703
|
-
return
|
|
149756
|
+
return flatMap(node.jsDoc, (doc) => {
|
|
149704
149757
|
var _a;
|
|
149705
|
-
return (_a =
|
|
149758
|
+
return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
|
|
149706
149759
|
});
|
|
149707
149760
|
}
|
|
149708
|
-
return
|
|
149761
|
+
return [];
|
|
149709
149762
|
}
|
|
149710
149763
|
|
|
149711
149764
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
@@ -151955,6 +152008,8 @@ function getInfo9(checker, sourceFile, position, errorCode) {
|
|
|
151955
152008
|
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
|
|
151956
152009
|
return void 0;
|
|
151957
152010
|
const pos = declaration.parent.arguments.indexOf(declaration);
|
|
152011
|
+
if (pos === -1)
|
|
152012
|
+
return void 0;
|
|
151958
152013
|
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
|
|
151959
152014
|
if (!type)
|
|
151960
152015
|
return void 0;
|
|
@@ -155122,15 +155177,11 @@ var PreserveOptionalFlags = /* @__PURE__ */ ((PreserveOptionalFlags2) => {
|
|
|
155122
155177
|
})(PreserveOptionalFlags || {});
|
|
155123
155178
|
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
|
|
155124
155179
|
const declarations = symbol.getDeclarations();
|
|
155125
|
-
const declaration = declarations
|
|
155180
|
+
const declaration = firstOrUndefined(declarations);
|
|
155126
155181
|
const checker = context.program.getTypeChecker();
|
|
155127
155182
|
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
|
155128
155183
|
const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
|
|
155129
|
-
const declarationName =
|
|
155130
|
-
getNameOfDeclaration(declaration),
|
|
155131
|
-
/*includeTrivia*/
|
|
155132
|
-
false
|
|
155133
|
-
);
|
|
155184
|
+
const declarationName = createDeclarationName(symbol, declaration);
|
|
155134
155185
|
const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
|
|
155135
155186
|
let modifierFlags = effectiveModifierFlags & 32 /* Static */;
|
|
155136
155187
|
modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
|
|
@@ -155281,6 +155332,19 @@ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, con
|
|
|
155281
155332
|
false
|
|
155282
155333
|
);
|
|
155283
155334
|
}
|
|
155335
|
+
function createDeclarationName(symbol2, declaration2) {
|
|
155336
|
+
if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
|
|
155337
|
+
const nameType = symbol2.links.nameType;
|
|
155338
|
+
if (nameType && isTypeUsableAsPropertyName(nameType)) {
|
|
155339
|
+
return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
|
|
155340
|
+
}
|
|
155341
|
+
}
|
|
155342
|
+
return getSynthesizedDeepClone(
|
|
155343
|
+
getNameOfDeclaration(declaration2),
|
|
155344
|
+
/*includeTrivia*/
|
|
155345
|
+
false
|
|
155346
|
+
);
|
|
155347
|
+
}
|
|
155284
155348
|
}
|
|
155285
155349
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
155286
155350
|
const program = context.program;
|
|
@@ -164498,7 +164562,7 @@ __export(ts_InlayHints_exports, {
|
|
|
164498
164562
|
});
|
|
164499
164563
|
|
|
164500
164564
|
// src/services/inlayHints.ts
|
|
164501
|
-
var
|
|
164565
|
+
var maxTypeHintLength = 30;
|
|
164502
164566
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164503
164567
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164504
164568
|
};
|
|
@@ -164508,6 +164572,9 @@ function shouldShowParameterNameHints(preferences) {
|
|
|
164508
164572
|
function shouldShowLiteralParameterNameHintsOnly(preferences) {
|
|
164509
164573
|
return preferences.includeInlayParameterNameHints === "literals";
|
|
164510
164574
|
}
|
|
164575
|
+
function shouldUseInteractiveInlayHints(preferences) {
|
|
164576
|
+
return preferences.interactiveInlayHints === true;
|
|
164577
|
+
}
|
|
164511
164578
|
function provideInlayHints(context) {
|
|
164512
164579
|
const { file, program, span, cancellationToken, preferences } = context;
|
|
164513
164580
|
const sourceFileText = file.text;
|
|
@@ -164558,9 +164625,15 @@ function provideInlayHints(context) {
|
|
|
164558
164625
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
164559
164626
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
164560
164627
|
}
|
|
164561
|
-
function addParameterHints(text, position, isFirstVariadicArgument) {
|
|
164628
|
+
function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
|
|
164629
|
+
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
|
164630
|
+
if (shouldUseInteractiveInlayHints(preferences)) {
|
|
164631
|
+
hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
|
|
164632
|
+
} else {
|
|
164633
|
+
hintText += ":";
|
|
164634
|
+
}
|
|
164562
164635
|
result.push({
|
|
164563
|
-
text:
|
|
164636
|
+
text: hintText,
|
|
164564
164637
|
position,
|
|
164565
164638
|
kind: "Parameter" /* Parameter */,
|
|
164566
164639
|
whitespaceAfter: true
|
|
@@ -164568,7 +164641,7 @@ function provideInlayHints(context) {
|
|
|
164568
164641
|
}
|
|
164569
164642
|
function addTypeHints(text, position) {
|
|
164570
164643
|
result.push({
|
|
164571
|
-
text: `: ${
|
|
164644
|
+
text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
|
|
164572
164645
|
position,
|
|
164573
164646
|
kind: "Type" /* Type */,
|
|
164574
164647
|
whitespaceBefore: true
|
|
@@ -164576,7 +164649,7 @@ function provideInlayHints(context) {
|
|
|
164576
164649
|
}
|
|
164577
164650
|
function addEnumMemberValueHints(text, position) {
|
|
164578
164651
|
result.push({
|
|
164579
|
-
text: `= ${
|
|
164652
|
+
text: `= ${text}`,
|
|
164580
164653
|
position,
|
|
164581
164654
|
kind: "Enum" /* Enum */,
|
|
164582
164655
|
whitespaceBefore: true
|
|
@@ -164626,6 +164699,7 @@ function provideInlayHints(context) {
|
|
|
164626
164699
|
return;
|
|
164627
164700
|
}
|
|
164628
164701
|
let signatureParamPos = 0;
|
|
164702
|
+
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
164629
164703
|
for (const originalArg of args) {
|
|
164630
164704
|
const arg = skipParentheses(originalArg);
|
|
164631
164705
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
@@ -164646,10 +164720,10 @@ function provideInlayHints(context) {
|
|
|
164646
164720
|
}
|
|
164647
164721
|
}
|
|
164648
164722
|
}
|
|
164649
|
-
const
|
|
164723
|
+
const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
|
|
164650
164724
|
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
164651
|
-
if (
|
|
164652
|
-
const
|
|
164725
|
+
if (identifierInfo) {
|
|
164726
|
+
const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
|
|
164653
164727
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
164654
164728
|
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
|
|
164655
164729
|
continue;
|
|
@@ -164658,7 +164732,7 @@ function provideInlayHints(context) {
|
|
|
164658
164732
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164659
164733
|
continue;
|
|
164660
164734
|
}
|
|
164661
|
-
addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
|
|
164735
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
|
164662
164736
|
}
|
|
164663
164737
|
}
|
|
164664
164738
|
}
|
|
@@ -164764,12 +164838,6 @@ function provideInlayHints(context) {
|
|
|
164764
164838
|
}
|
|
164765
164839
|
return printTypeInSingleLine(signatureParamType);
|
|
164766
164840
|
}
|
|
164767
|
-
function truncation(text, maxLength2) {
|
|
164768
|
-
if (text.length > maxLength2) {
|
|
164769
|
-
return text.substr(0, maxLength2 - "...".length) + "...";
|
|
164770
|
-
}
|
|
164771
|
-
return text;
|
|
164772
|
-
}
|
|
164773
164841
|
function printTypeInSingleLine(type) {
|
|
164774
164842
|
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
164775
164843
|
const printer = createPrinterWithRemoveComments();
|
|
@@ -164800,6 +164868,13 @@ function provideInlayHints(context) {
|
|
|
164800
164868
|
}
|
|
164801
164869
|
return true;
|
|
164802
164870
|
}
|
|
164871
|
+
function getNodeDisplayPart(text, node, sourceFile) {
|
|
164872
|
+
return {
|
|
164873
|
+
text,
|
|
164874
|
+
span: createTextSpanFromNode(node, sourceFile),
|
|
164875
|
+
file: sourceFile.fileName
|
|
164876
|
+
};
|
|
164877
|
+
}
|
|
164803
164878
|
}
|
|
164804
164879
|
|
|
164805
164880
|
// src/services/_namespaces/ts.JsDoc.ts
|
|
@@ -167219,7 +167294,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
167219
167294
|
}
|
|
167220
167295
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
167221
167296
|
}
|
|
167222
|
-
function
|
|
167297
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
167223
167298
|
var _a;
|
|
167224
167299
|
const displayParts = [];
|
|
167225
167300
|
let documentation = [];
|
|
@@ -167228,7 +167303,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167228
167303
|
let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
167229
167304
|
let hasAddedSymbolInfo = false;
|
|
167230
167305
|
const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
|
|
167231
|
-
let type;
|
|
167232
167306
|
let documentationFromAlias;
|
|
167233
167307
|
let tagsFromAlias;
|
|
167234
167308
|
let hasMultipleSignatures = false;
|
|
@@ -167257,7 +167331,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167257
167331
|
}
|
|
167258
167332
|
}
|
|
167259
167333
|
let signature;
|
|
167260
|
-
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167334
|
+
type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
|
|
167261
167335
|
if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
|
|
167262
167336
|
const right = location.parent.name;
|
|
167263
167337
|
if (right === location || right && right.getFullWidth() === 0) {
|
|
@@ -167472,12 +167546,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167472
167546
|
if (declarationName && !hasAddedSymbolInfo) {
|
|
167473
167547
|
const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
|
|
167474
167548
|
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
|
167475
|
-
const resolvedInfo =
|
|
167549
|
+
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167476
167550
|
typeChecker,
|
|
167477
167551
|
resolvedSymbol,
|
|
167478
167552
|
getSourceFileOfNode(resolvedNode),
|
|
167479
167553
|
resolvedNode,
|
|
167480
167554
|
declarationName,
|
|
167555
|
+
type,
|
|
167481
167556
|
semanticMeaning,
|
|
167482
167557
|
shouldUseAliasName ? symbol : resolvedSymbol
|
|
167483
167558
|
);
|
|
@@ -167732,6 +167807,19 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167732
167807
|
addRange(displayParts, typeParameterParts);
|
|
167733
167808
|
}
|
|
167734
167809
|
}
|
|
167810
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
167811
|
+
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167812
|
+
typeChecker,
|
|
167813
|
+
symbol,
|
|
167814
|
+
sourceFile,
|
|
167815
|
+
enclosingDeclaration,
|
|
167816
|
+
location,
|
|
167817
|
+
/*type*/
|
|
167818
|
+
void 0,
|
|
167819
|
+
semanticMeaning,
|
|
167820
|
+
alias
|
|
167821
|
+
);
|
|
167822
|
+
}
|
|
167735
167823
|
function isLocalVariableOrFunction(symbol) {
|
|
167736
167824
|
if (symbol.parent) {
|
|
167737
167825
|
return false;
|
|
@@ -172741,6 +172829,7 @@ __export(ts_exports2, {
|
|
|
172741
172829
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
172742
172830
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
172743
172831
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
172832
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
172744
172833
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
172745
172834
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
172746
172835
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -173573,6 +173662,7 @@ __export(ts_exports2, {
|
|
|
173573
173662
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
173574
173663
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
173575
173664
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
173665
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
173576
173666
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
173577
173667
|
isUnaryExpression: () => isUnaryExpression,
|
|
173578
173668
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -183431,10 +183521,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
183431
183521
|
const { file, project } = this.getFileAndProject(args);
|
|
183432
183522
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
183433
183523
|
const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
|
|
183434
|
-
return hints.map((hint) =>
|
|
183435
|
-
|
|
183436
|
-
|
|
183437
|
-
|
|
183524
|
+
return hints.map((hint) => {
|
|
183525
|
+
const { text, position } = hint;
|
|
183526
|
+
const hintText = typeof text === "string" ? text : text.map(({ text: text2, span, file: file2 }) => ({
|
|
183527
|
+
text: text2,
|
|
183528
|
+
span: span && {
|
|
183529
|
+
start: scriptInfo.positionToLineOffset(span.start),
|
|
183530
|
+
end: scriptInfo.positionToLineOffset(span.start + span.length),
|
|
183531
|
+
file: file2
|
|
183532
|
+
}
|
|
183533
|
+
}));
|
|
183534
|
+
return {
|
|
183535
|
+
...hint,
|
|
183536
|
+
position: scriptInfo.positionToLineOffset(position),
|
|
183537
|
+
text: hintText
|
|
183538
|
+
};
|
|
183539
|
+
});
|
|
183438
183540
|
}
|
|
183439
183541
|
setCompilerOptionsForInferredProjects(args) {
|
|
183440
183542
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
@@ -187255,6 +187357,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
187255
187357
|
getPropertyAssignmentAliasLikeExpression,
|
|
187256
187358
|
getPropertyNameForPropertyNameNode,
|
|
187257
187359
|
getPropertyNameForUniqueESSymbol,
|
|
187360
|
+
getPropertyNameFromType,
|
|
187258
187361
|
getPropertyNameOfBindingOrAssignmentElement,
|
|
187259
187362
|
getPropertySymbolFromBindingElement,
|
|
187260
187363
|
getPropertySymbolsFromContextualType,
|
|
@@ -188087,6 +188190,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188087
188190
|
isTypeQueryNode,
|
|
188088
188191
|
isTypeReferenceNode,
|
|
188089
188192
|
isTypeReferenceType,
|
|
188193
|
+
isTypeUsableAsPropertyName,
|
|
188090
188194
|
isUMDExportSymbol,
|
|
188091
188195
|
isUnaryExpression,
|
|
188092
188196
|
isUnaryExpressionWithWrite,
|