typescript 5.1.0-dev.20230404 → 5.1.0-dev.20230406
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 +26 -14
- package/lib/tsserver.js +309 -16
- package/lib/tsserverlibrary.js +309 -16
- package/lib/typescript.js +309 -16
- package/lib/typingsInstaller.js +10 -4
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.1";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20230406`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -29277,6 +29277,12 @@ var Parser;
|
|
|
29277
29277
|
if (languageVariant === 1 /* JSX */) {
|
|
29278
29278
|
return parseJsxElementOrSelfClosingElementOrFragment(
|
|
29279
29279
|
/*inExpressionContext*/
|
|
29280
|
+
true,
|
|
29281
|
+
/*topInvalidNodePosition*/
|
|
29282
|
+
void 0,
|
|
29283
|
+
/*openingTag*/
|
|
29284
|
+
void 0,
|
|
29285
|
+
/*mustBeUnary*/
|
|
29280
29286
|
true
|
|
29281
29287
|
);
|
|
29282
29288
|
}
|
|
@@ -29381,7 +29387,7 @@ var Parser;
|
|
|
29381
29387
|
true
|
|
29382
29388
|
)), pos);
|
|
29383
29389
|
}
|
|
29384
|
-
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
|
|
29390
|
+
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
|
|
29385
29391
|
const pos = getNodePos();
|
|
29386
29392
|
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
|
|
29387
29393
|
let result;
|
|
@@ -29419,7 +29425,7 @@ var Parser;
|
|
|
29419
29425
|
Debug.assert(opening.kind === 283 /* JsxSelfClosingElement */);
|
|
29420
29426
|
result = opening;
|
|
29421
29427
|
}
|
|
29422
|
-
if (inExpressionContext && token() === 29 /* LessThanToken */) {
|
|
29428
|
+
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
|
|
29423
29429
|
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
|
|
29424
29430
|
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
|
|
29425
29431
|
/*inExpressionContext*/
|
|
@@ -29452,7 +29458,7 @@ var Parser;
|
|
|
29452
29458
|
parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
|
|
29453
29459
|
} else {
|
|
29454
29460
|
const tag = openingTag.tagName;
|
|
29455
|
-
const start = skipTrivia(sourceText, tag.pos);
|
|
29461
|
+
const start = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
|
|
29456
29462
|
parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
|
|
29457
29463
|
}
|
|
29458
29464
|
return void 0;
|
|
@@ -80351,6 +80357,14 @@ function createTypeChecker(host) {
|
|
|
80351
80357
|
const symbol = getSymbolAtLocation(node);
|
|
80352
80358
|
return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
|
|
80353
80359
|
}
|
|
80360
|
+
if (isBindingElement(node)) {
|
|
80361
|
+
return getTypeForVariableLikeDeclaration(
|
|
80362
|
+
node,
|
|
80363
|
+
/*includeOptionality*/
|
|
80364
|
+
true,
|
|
80365
|
+
0 /* Normal */
|
|
80366
|
+
) || errorType;
|
|
80367
|
+
}
|
|
80354
80368
|
if (isDeclaration(node)) {
|
|
80355
80369
|
const symbol = getSymbolOfDeclaration(node);
|
|
80356
80370
|
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
@@ -89538,11 +89552,12 @@ function transformClassFields(context) {
|
|
|
89538
89552
|
return visitEachChild(node, visitor, context);
|
|
89539
89553
|
}
|
|
89540
89554
|
function visitArrayAssignmentElement(node) {
|
|
89541
|
-
|
|
89542
|
-
|
|
89543
|
-
|
|
89544
|
-
|
|
89545
|
-
|
|
89555
|
+
if (isArrayBindingOrAssignmentElement(node)) {
|
|
89556
|
+
if (isSpreadElement(node))
|
|
89557
|
+
return visitAssignmentRestElement(node);
|
|
89558
|
+
if (!isOmittedExpression(node))
|
|
89559
|
+
return visitAssignmentElement(node);
|
|
89560
|
+
}
|
|
89546
89561
|
return visitEachChild(node, visitor, context);
|
|
89547
89562
|
}
|
|
89548
89563
|
function visitAssignmentProperty(node) {
|
|
@@ -115610,9 +115625,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
115610
115625
|
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
|
|
115611
115626
|
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
|
|
115612
115627
|
}
|
|
115613
|
-
if (options.isolatedModules) {
|
|
115614
|
-
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
|
|
115615
|
-
}
|
|
115616
115628
|
if (options.preserveValueImports) {
|
|
115617
115629
|
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
|
|
115618
115630
|
}
|
|
@@ -118122,7 +118134,7 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
|
|
|
118122
118134
|
return {
|
|
118123
118135
|
dir: rootDir,
|
|
118124
118136
|
dirPath: rootPath,
|
|
118125
|
-
nonRecursive:
|
|
118137
|
+
nonRecursive: true
|
|
118126
118138
|
};
|
|
118127
118139
|
}
|
|
118128
118140
|
}
|
|
@@ -118570,7 +118582,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118570
118582
|
customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
|
|
118571
118583
|
}
|
|
118572
118584
|
if (dirPath === rootPath) {
|
|
118573
|
-
Debug.assert(
|
|
118585
|
+
Debug.assert(nonRecursive);
|
|
118574
118586
|
setAtRoot = true;
|
|
118575
118587
|
} else {
|
|
118576
118588
|
setDirectoryWatcher(dir, dirPath, nonRecursive);
|
package/lib/tsserver.js
CHANGED
|
@@ -2292,7 +2292,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2292
2292
|
|
|
2293
2293
|
// src/compiler/corePublic.ts
|
|
2294
2294
|
var versionMajorMinor = "5.1";
|
|
2295
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2295
|
+
var version = `${versionMajorMinor}.0-dev.20230406`;
|
|
2296
2296
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2297
2297
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2298
2298
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -33659,6 +33659,12 @@ var Parser;
|
|
|
33659
33659
|
if (languageVariant === 1 /* JSX */) {
|
|
33660
33660
|
return parseJsxElementOrSelfClosingElementOrFragment(
|
|
33661
33661
|
/*inExpressionContext*/
|
|
33662
|
+
true,
|
|
33663
|
+
/*topInvalidNodePosition*/
|
|
33664
|
+
void 0,
|
|
33665
|
+
/*openingTag*/
|
|
33666
|
+
void 0,
|
|
33667
|
+
/*mustBeUnary*/
|
|
33662
33668
|
true
|
|
33663
33669
|
);
|
|
33664
33670
|
}
|
|
@@ -33763,7 +33769,7 @@ var Parser;
|
|
|
33763
33769
|
true
|
|
33764
33770
|
)), pos);
|
|
33765
33771
|
}
|
|
33766
|
-
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
|
|
33772
|
+
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
|
|
33767
33773
|
const pos = getNodePos();
|
|
33768
33774
|
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
|
|
33769
33775
|
let result;
|
|
@@ -33801,7 +33807,7 @@ var Parser;
|
|
|
33801
33807
|
Debug.assert(opening.kind === 283 /* JsxSelfClosingElement */);
|
|
33802
33808
|
result = opening;
|
|
33803
33809
|
}
|
|
33804
|
-
if (inExpressionContext && token() === 29 /* LessThanToken */) {
|
|
33810
|
+
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
|
|
33805
33811
|
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
|
|
33806
33812
|
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
|
|
33807
33813
|
/*inExpressionContext*/
|
|
@@ -33834,7 +33840,7 @@ var Parser;
|
|
|
33834
33840
|
parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
|
|
33835
33841
|
} else {
|
|
33836
33842
|
const tag = openingTag.tagName;
|
|
33837
|
-
const start2 = skipTrivia(sourceText, tag.pos);
|
|
33843
|
+
const start2 = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
|
|
33838
33844
|
parseErrorAt(start2, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
|
|
33839
33845
|
}
|
|
33840
33846
|
return void 0;
|
|
@@ -84999,6 +85005,14 @@ function createTypeChecker(host) {
|
|
|
84999
85005
|
const symbol = getSymbolAtLocation(node);
|
|
85000
85006
|
return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
|
|
85001
85007
|
}
|
|
85008
|
+
if (isBindingElement(node)) {
|
|
85009
|
+
return getTypeForVariableLikeDeclaration(
|
|
85010
|
+
node,
|
|
85011
|
+
/*includeOptionality*/
|
|
85012
|
+
true,
|
|
85013
|
+
0 /* Normal */
|
|
85014
|
+
) || errorType;
|
|
85015
|
+
}
|
|
85002
85016
|
if (isDeclaration(node)) {
|
|
85003
85017
|
const symbol = getSymbolOfDeclaration(node);
|
|
85004
85018
|
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
@@ -94357,11 +94371,12 @@ function transformClassFields(context) {
|
|
|
94357
94371
|
return visitEachChild(node, visitor, context);
|
|
94358
94372
|
}
|
|
94359
94373
|
function visitArrayAssignmentElement(node) {
|
|
94360
|
-
|
|
94361
|
-
|
|
94362
|
-
|
|
94363
|
-
|
|
94364
|
-
|
|
94374
|
+
if (isArrayBindingOrAssignmentElement(node)) {
|
|
94375
|
+
if (isSpreadElement(node))
|
|
94376
|
+
return visitAssignmentRestElement(node);
|
|
94377
|
+
if (!isOmittedExpression(node))
|
|
94378
|
+
return visitAssignmentElement(node);
|
|
94379
|
+
}
|
|
94365
94380
|
return visitEachChild(node, visitor, context);
|
|
94366
94381
|
}
|
|
94367
94382
|
function visitAssignmentProperty(node) {
|
|
@@ -120494,9 +120509,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120494
120509
|
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
|
|
120495
120510
|
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
|
|
120496
120511
|
}
|
|
120497
|
-
if (options.isolatedModules) {
|
|
120498
|
-
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
|
|
120499
|
-
}
|
|
120500
120512
|
if (options.preserveValueImports) {
|
|
120501
120513
|
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
|
|
120502
120514
|
}
|
|
@@ -123038,7 +123050,7 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
|
|
|
123038
123050
|
return {
|
|
123039
123051
|
dir: rootDir,
|
|
123040
123052
|
dirPath: rootPath,
|
|
123041
|
-
nonRecursive:
|
|
123053
|
+
nonRecursive: true
|
|
123042
123054
|
};
|
|
123043
123055
|
}
|
|
123044
123056
|
}
|
|
@@ -123486,7 +123498,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123486
123498
|
customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
|
|
123487
123499
|
}
|
|
123488
123500
|
if (dirPath === rootPath) {
|
|
123489
|
-
Debug.assert(
|
|
123501
|
+
Debug.assert(nonRecursive);
|
|
123490
123502
|
setAtRoot = true;
|
|
123491
123503
|
} else {
|
|
123492
123504
|
setDirectoryWatcher(dir, dirPath, nonRecursive);
|
|
@@ -149063,6 +149075,7 @@ function getCompletionsAtPosition(host, program, log, sourceFile, position, pref
|
|
|
149063
149075
|
return void 0;
|
|
149064
149076
|
}
|
|
149065
149077
|
const compilerOptions = program.getCompilerOptions();
|
|
149078
|
+
const checker = program.getTypeChecker();
|
|
149066
149079
|
const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a2 = host.getIncompleteCompletionsCache) == null ? void 0 : _a2.call(host) : void 0;
|
|
149067
149080
|
if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && isIdentifier(previousToken)) {
|
|
149068
149081
|
const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
|
|
@@ -149103,9 +149116,31 @@ function getCompletionsAtPosition(host, program, log, sourceFile, position, pref
|
|
|
149103
149116
|
}
|
|
149104
149117
|
return response;
|
|
149105
149118
|
case 1 /* JsDocTagName */:
|
|
149106
|
-
return jsdocCompletionInfo(
|
|
149119
|
+
return jsdocCompletionInfo([
|
|
149120
|
+
...ts_JsDoc_exports.getJSDocTagNameCompletions(),
|
|
149121
|
+
...getJSDocParameterCompletions(
|
|
149122
|
+
sourceFile,
|
|
149123
|
+
position,
|
|
149124
|
+
checker,
|
|
149125
|
+
compilerOptions,
|
|
149126
|
+
preferences,
|
|
149127
|
+
/*tagNameOnly*/
|
|
149128
|
+
true
|
|
149129
|
+
)
|
|
149130
|
+
]);
|
|
149107
149131
|
case 2 /* JsDocTag */:
|
|
149108
|
-
return jsdocCompletionInfo(
|
|
149132
|
+
return jsdocCompletionInfo([
|
|
149133
|
+
...ts_JsDoc_exports.getJSDocTagCompletions(),
|
|
149134
|
+
...getJSDocParameterCompletions(
|
|
149135
|
+
sourceFile,
|
|
149136
|
+
position,
|
|
149137
|
+
checker,
|
|
149138
|
+
compilerOptions,
|
|
149139
|
+
preferences,
|
|
149140
|
+
/*tagNameOnly*/
|
|
149141
|
+
false
|
|
149142
|
+
)
|
|
149143
|
+
]);
|
|
149109
149144
|
case 3 /* JsDocParameterName */:
|
|
149110
149145
|
return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocParameterNameCompletions(completionData.tag));
|
|
149111
149146
|
case 4 /* Keywords */:
|
|
@@ -149193,6 +149228,264 @@ function continuePreviousIncompleteResponse(cache, file, location, program, host
|
|
|
149193
149228
|
function jsdocCompletionInfo(entries) {
|
|
149194
149229
|
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
|
|
149195
149230
|
}
|
|
149231
|
+
function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
|
|
149232
|
+
const currentToken = getTokenAtPosition(sourceFile, position);
|
|
149233
|
+
if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
|
|
149234
|
+
return [];
|
|
149235
|
+
}
|
|
149236
|
+
const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
|
|
149237
|
+
if (!isJSDoc(jsDoc)) {
|
|
149238
|
+
return [];
|
|
149239
|
+
}
|
|
149240
|
+
const func = jsDoc.parent;
|
|
149241
|
+
if (!isFunctionLike(func)) {
|
|
149242
|
+
return [];
|
|
149243
|
+
}
|
|
149244
|
+
const isJs = isSourceFileJS(sourceFile);
|
|
149245
|
+
const isSnippet = preferences.includeCompletionsWithSnippetText || void 0;
|
|
149246
|
+
const paramTagCount = countWhere(jsDoc.tags, (tag) => isJSDocParameterTag(tag) && tag.getEnd() <= position);
|
|
149247
|
+
return mapDefined(func.parameters, (param) => {
|
|
149248
|
+
if (getJSDocParameterTags(param).length) {
|
|
149249
|
+
return void 0;
|
|
149250
|
+
}
|
|
149251
|
+
if (isIdentifier(param.name)) {
|
|
149252
|
+
const tabstopCounter = { tabstop: 1 };
|
|
149253
|
+
const paramName = param.name.text;
|
|
149254
|
+
let displayText = getJSDocParamAnnotation(
|
|
149255
|
+
paramName,
|
|
149256
|
+
param.initializer,
|
|
149257
|
+
param.dotDotDotToken,
|
|
149258
|
+
isJs,
|
|
149259
|
+
/*isObject*/
|
|
149260
|
+
false,
|
|
149261
|
+
/*isSnippet*/
|
|
149262
|
+
false,
|
|
149263
|
+
checker,
|
|
149264
|
+
options,
|
|
149265
|
+
preferences
|
|
149266
|
+
);
|
|
149267
|
+
let snippetText = isSnippet ? getJSDocParamAnnotation(
|
|
149268
|
+
paramName,
|
|
149269
|
+
param.initializer,
|
|
149270
|
+
param.dotDotDotToken,
|
|
149271
|
+
isJs,
|
|
149272
|
+
/*isObject*/
|
|
149273
|
+
false,
|
|
149274
|
+
/*isSnippet*/
|
|
149275
|
+
true,
|
|
149276
|
+
checker,
|
|
149277
|
+
options,
|
|
149278
|
+
preferences,
|
|
149279
|
+
tabstopCounter
|
|
149280
|
+
) : void 0;
|
|
149281
|
+
if (tagNameOnly) {
|
|
149282
|
+
displayText = displayText.slice(1);
|
|
149283
|
+
if (snippetText)
|
|
149284
|
+
snippetText = snippetText.slice(1);
|
|
149285
|
+
}
|
|
149286
|
+
return {
|
|
149287
|
+
name: displayText,
|
|
149288
|
+
kind: "parameter" /* parameterElement */,
|
|
149289
|
+
sortText: SortText.LocationPriority,
|
|
149290
|
+
insertText: isSnippet ? snippetText : void 0,
|
|
149291
|
+
isSnippet
|
|
149292
|
+
};
|
|
149293
|
+
} else if (param.parent.parameters.indexOf(param) === paramTagCount) {
|
|
149294
|
+
const paramPath = `param${paramTagCount}`;
|
|
149295
|
+
const displayTextResult = generateJSDocParamTagsForDestructuring(
|
|
149296
|
+
paramPath,
|
|
149297
|
+
param.name,
|
|
149298
|
+
param.initializer,
|
|
149299
|
+
param.dotDotDotToken,
|
|
149300
|
+
isJs,
|
|
149301
|
+
/*isSnippet*/
|
|
149302
|
+
false,
|
|
149303
|
+
checker,
|
|
149304
|
+
options,
|
|
149305
|
+
preferences
|
|
149306
|
+
);
|
|
149307
|
+
const snippetTextResult = isSnippet ? generateJSDocParamTagsForDestructuring(
|
|
149308
|
+
paramPath,
|
|
149309
|
+
param.name,
|
|
149310
|
+
param.initializer,
|
|
149311
|
+
param.dotDotDotToken,
|
|
149312
|
+
isJs,
|
|
149313
|
+
/*isSnippet*/
|
|
149314
|
+
true,
|
|
149315
|
+
checker,
|
|
149316
|
+
options,
|
|
149317
|
+
preferences
|
|
149318
|
+
) : void 0;
|
|
149319
|
+
let displayText = displayTextResult.join(getNewLineCharacter(options) + "* ");
|
|
149320
|
+
let snippetText = snippetTextResult == null ? void 0 : snippetTextResult.join(getNewLineCharacter(options) + "* ");
|
|
149321
|
+
if (tagNameOnly) {
|
|
149322
|
+
displayText = displayText.slice(1);
|
|
149323
|
+
if (snippetText)
|
|
149324
|
+
snippetText = snippetText.slice(1);
|
|
149325
|
+
}
|
|
149326
|
+
return {
|
|
149327
|
+
name: displayText,
|
|
149328
|
+
kind: "parameter" /* parameterElement */,
|
|
149329
|
+
sortText: SortText.LocationPriority,
|
|
149330
|
+
insertText: isSnippet ? snippetText : void 0,
|
|
149331
|
+
isSnippet
|
|
149332
|
+
};
|
|
149333
|
+
}
|
|
149334
|
+
});
|
|
149335
|
+
}
|
|
149336
|
+
function generateJSDocParamTagsForDestructuring(path, pattern, initializer, dotDotDotToken, isJs, isSnippet, checker, options, preferences) {
|
|
149337
|
+
if (!isJs) {
|
|
149338
|
+
return [
|
|
149339
|
+
getJSDocParamAnnotation(
|
|
149340
|
+
path,
|
|
149341
|
+
initializer,
|
|
149342
|
+
dotDotDotToken,
|
|
149343
|
+
isJs,
|
|
149344
|
+
/*isObject*/
|
|
149345
|
+
false,
|
|
149346
|
+
isSnippet,
|
|
149347
|
+
checker,
|
|
149348
|
+
options,
|
|
149349
|
+
preferences,
|
|
149350
|
+
{ tabstop: 1 }
|
|
149351
|
+
)
|
|
149352
|
+
];
|
|
149353
|
+
}
|
|
149354
|
+
return patternWorker(path, pattern, initializer, dotDotDotToken, { tabstop: 1 });
|
|
149355
|
+
function patternWorker(path2, pattern2, initializer2, dotDotDotToken2, counter) {
|
|
149356
|
+
if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
|
|
149357
|
+
const oldTabstop = counter.tabstop;
|
|
149358
|
+
const childCounter = { tabstop: oldTabstop };
|
|
149359
|
+
const rootParam = getJSDocParamAnnotation(
|
|
149360
|
+
path2,
|
|
149361
|
+
initializer2,
|
|
149362
|
+
dotDotDotToken2,
|
|
149363
|
+
isJs,
|
|
149364
|
+
/*isObject*/
|
|
149365
|
+
true,
|
|
149366
|
+
isSnippet,
|
|
149367
|
+
checker,
|
|
149368
|
+
options,
|
|
149369
|
+
preferences,
|
|
149370
|
+
childCounter
|
|
149371
|
+
);
|
|
149372
|
+
let childTags = [];
|
|
149373
|
+
for (const element of pattern2.elements) {
|
|
149374
|
+
const elementTags = elementWorker(path2, element, childCounter);
|
|
149375
|
+
if (!elementTags) {
|
|
149376
|
+
childTags = void 0;
|
|
149377
|
+
break;
|
|
149378
|
+
} else {
|
|
149379
|
+
childTags.push(...elementTags);
|
|
149380
|
+
}
|
|
149381
|
+
}
|
|
149382
|
+
if (childTags) {
|
|
149383
|
+
counter.tabstop = childCounter.tabstop;
|
|
149384
|
+
return [rootParam, ...childTags];
|
|
149385
|
+
}
|
|
149386
|
+
}
|
|
149387
|
+
return [
|
|
149388
|
+
getJSDocParamAnnotation(
|
|
149389
|
+
path2,
|
|
149390
|
+
initializer2,
|
|
149391
|
+
dotDotDotToken2,
|
|
149392
|
+
isJs,
|
|
149393
|
+
/*isObject*/
|
|
149394
|
+
false,
|
|
149395
|
+
isSnippet,
|
|
149396
|
+
checker,
|
|
149397
|
+
options,
|
|
149398
|
+
preferences,
|
|
149399
|
+
counter
|
|
149400
|
+
)
|
|
149401
|
+
];
|
|
149402
|
+
}
|
|
149403
|
+
function elementWorker(path2, element, counter) {
|
|
149404
|
+
if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
|
|
149405
|
+
const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
|
|
149406
|
+
if (!propertyName) {
|
|
149407
|
+
return void 0;
|
|
149408
|
+
}
|
|
149409
|
+
const paramName = `${path2}.${propertyName}`;
|
|
149410
|
+
return [
|
|
149411
|
+
getJSDocParamAnnotation(
|
|
149412
|
+
paramName,
|
|
149413
|
+
element.initializer,
|
|
149414
|
+
element.dotDotDotToken,
|
|
149415
|
+
isJs,
|
|
149416
|
+
/*isObject*/
|
|
149417
|
+
false,
|
|
149418
|
+
isSnippet,
|
|
149419
|
+
checker,
|
|
149420
|
+
options,
|
|
149421
|
+
preferences,
|
|
149422
|
+
counter
|
|
149423
|
+
)
|
|
149424
|
+
];
|
|
149425
|
+
} else if (element.propertyName) {
|
|
149426
|
+
const propertyName = tryGetTextOfPropertyName(element.propertyName);
|
|
149427
|
+
return propertyName && patternWorker(`${path2}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
|
|
149428
|
+
}
|
|
149429
|
+
return void 0;
|
|
149430
|
+
}
|
|
149431
|
+
}
|
|
149432
|
+
function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options, preferences, tabstopCounter) {
|
|
149433
|
+
if (isSnippet) {
|
|
149434
|
+
Debug.assertIsDefined(tabstopCounter);
|
|
149435
|
+
}
|
|
149436
|
+
if (initializer) {
|
|
149437
|
+
paramName = getJSDocParamNameWithInitializer(paramName, initializer);
|
|
149438
|
+
}
|
|
149439
|
+
if (isSnippet) {
|
|
149440
|
+
paramName = escapeSnippetText(paramName);
|
|
149441
|
+
}
|
|
149442
|
+
if (isJs) {
|
|
149443
|
+
let type = "*";
|
|
149444
|
+
if (isObject) {
|
|
149445
|
+
Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
|
|
149446
|
+
type = "Object";
|
|
149447
|
+
} else {
|
|
149448
|
+
if (initializer) {
|
|
149449
|
+
const inferredType = checker.getTypeAtLocation(initializer.parent);
|
|
149450
|
+
if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
|
|
149451
|
+
const sourceFile = initializer.getSourceFile();
|
|
149452
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
149453
|
+
const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
|
|
149454
|
+
const typeNode = checker.typeToTypeNode(inferredType, findAncestor(initializer, isFunctionLike), builderFlags);
|
|
149455
|
+
if (typeNode) {
|
|
149456
|
+
const printer = isSnippet ? createSnippetPrinter({
|
|
149457
|
+
removeComments: true,
|
|
149458
|
+
module: options.module,
|
|
149459
|
+
target: options.target
|
|
149460
|
+
}) : createPrinter({
|
|
149461
|
+
removeComments: true,
|
|
149462
|
+
module: options.module,
|
|
149463
|
+
target: options.target
|
|
149464
|
+
});
|
|
149465
|
+
setEmitFlags(typeNode, 1 /* SingleLine */);
|
|
149466
|
+
type = printer.printNode(4 /* Unspecified */, typeNode, sourceFile);
|
|
149467
|
+
}
|
|
149468
|
+
}
|
|
149469
|
+
}
|
|
149470
|
+
if (isSnippet && type === "*") {
|
|
149471
|
+
type = `\${${tabstopCounter.tabstop++}:${type}}`;
|
|
149472
|
+
}
|
|
149473
|
+
}
|
|
149474
|
+
const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
|
|
149475
|
+
const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
|
|
149476
|
+
return `@param {${dotDotDot}${type}} ${paramName} ${description2}`;
|
|
149477
|
+
} else {
|
|
149478
|
+
const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
|
|
149479
|
+
return `@param ${paramName} ${description2}`;
|
|
149480
|
+
}
|
|
149481
|
+
}
|
|
149482
|
+
function getJSDocParamNameWithInitializer(paramName, initializer) {
|
|
149483
|
+
const initializerText = initializer.getText().trim();
|
|
149484
|
+
if (initializerText.includes("\n") || initializerText.length > 80) {
|
|
149485
|
+
return `[${paramName}]`;
|
|
149486
|
+
}
|
|
149487
|
+
return `[${paramName}=${initializerText}]`;
|
|
149488
|
+
}
|
|
149196
149489
|
function keywordToCompletionEntry(keyword) {
|
|
149197
149490
|
return {
|
|
149198
149491
|
name: tokenToString(keyword),
|