typescript 5.1.0-dev.20230404 → 5.1.0-dev.20230405

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 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.20230404`;
21
+ var version = `${versionMajorMinor}.0-dev.20230405`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -80351,6 +80351,14 @@ function createTypeChecker(host) {
80351
80351
  const symbol = getSymbolAtLocation(node);
80352
80352
  return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
80353
80353
  }
80354
+ if (isBindingElement(node)) {
80355
+ return getTypeForVariableLikeDeclaration(
80356
+ node,
80357
+ /*includeOptionality*/
80358
+ true,
80359
+ 0 /* Normal */
80360
+ ) || errorType;
80361
+ }
80354
80362
  if (isDeclaration(node)) {
80355
80363
  const symbol = getSymbolOfDeclaration(node);
80356
80364
  return symbol ? getTypeOfSymbol(symbol) : errorType;
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.20230404`;
2295
+ var version = `${versionMajorMinor}.0-dev.20230405`;
2296
2296
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2297
2297
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2298
2298
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -84999,6 +84999,14 @@ function createTypeChecker(host) {
84999
84999
  const symbol = getSymbolAtLocation(node);
85000
85000
  return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
85001
85001
  }
85002
+ if (isBindingElement(node)) {
85003
+ return getTypeForVariableLikeDeclaration(
85004
+ node,
85005
+ /*includeOptionality*/
85006
+ true,
85007
+ 0 /* Normal */
85008
+ ) || errorType;
85009
+ }
85002
85010
  if (isDeclaration(node)) {
85003
85011
  const symbol = getSymbolOfDeclaration(node);
85004
85012
  return symbol ? getTypeOfSymbol(symbol) : errorType;
@@ -149063,6 +149071,7 @@ function getCompletionsAtPosition(host, program, log, sourceFile, position, pref
149063
149071
  return void 0;
149064
149072
  }
149065
149073
  const compilerOptions = program.getCompilerOptions();
149074
+ const checker = program.getTypeChecker();
149066
149075
  const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a2 = host.getIncompleteCompletionsCache) == null ? void 0 : _a2.call(host) : void 0;
149067
149076
  if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && isIdentifier(previousToken)) {
149068
149077
  const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
@@ -149103,9 +149112,31 @@ function getCompletionsAtPosition(host, program, log, sourceFile, position, pref
149103
149112
  }
149104
149113
  return response;
149105
149114
  case 1 /* JsDocTagName */:
149106
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagNameCompletions());
149115
+ return jsdocCompletionInfo([
149116
+ ...ts_JsDoc_exports.getJSDocTagNameCompletions(),
149117
+ ...getJSDocParameterCompletions(
149118
+ sourceFile,
149119
+ position,
149120
+ checker,
149121
+ compilerOptions,
149122
+ preferences,
149123
+ /*tagNameOnly*/
149124
+ true
149125
+ )
149126
+ ]);
149107
149127
  case 2 /* JsDocTag */:
149108
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagCompletions());
149128
+ return jsdocCompletionInfo([
149129
+ ...ts_JsDoc_exports.getJSDocTagCompletions(),
149130
+ ...getJSDocParameterCompletions(
149131
+ sourceFile,
149132
+ position,
149133
+ checker,
149134
+ compilerOptions,
149135
+ preferences,
149136
+ /*tagNameOnly*/
149137
+ false
149138
+ )
149139
+ ]);
149109
149140
  case 3 /* JsDocParameterName */:
149110
149141
  return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocParameterNameCompletions(completionData.tag));
149111
149142
  case 4 /* Keywords */:
@@ -149193,6 +149224,264 @@ function continuePreviousIncompleteResponse(cache, file, location, program, host
149193
149224
  function jsdocCompletionInfo(entries) {
149194
149225
  return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
149195
149226
  }
149227
+ function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
149228
+ const currentToken = getTokenAtPosition(sourceFile, position);
149229
+ if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
149230
+ return [];
149231
+ }
149232
+ const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
149233
+ if (!isJSDoc(jsDoc)) {
149234
+ return [];
149235
+ }
149236
+ const func = jsDoc.parent;
149237
+ if (!isFunctionLike(func)) {
149238
+ return [];
149239
+ }
149240
+ const isJs = isSourceFileJS(sourceFile);
149241
+ const isSnippet = preferences.includeCompletionsWithSnippetText || void 0;
149242
+ const paramTagCount = countWhere(jsDoc.tags, (tag) => isJSDocParameterTag(tag) && tag.getEnd() <= position);
149243
+ return mapDefined(func.parameters, (param) => {
149244
+ if (getJSDocParameterTags(param).length) {
149245
+ return void 0;
149246
+ }
149247
+ if (isIdentifier(param.name)) {
149248
+ const tabstopCounter = { tabstop: 1 };
149249
+ const paramName = param.name.text;
149250
+ let displayText = getJSDocParamAnnotation(
149251
+ paramName,
149252
+ param.initializer,
149253
+ param.dotDotDotToken,
149254
+ isJs,
149255
+ /*isObject*/
149256
+ false,
149257
+ /*isSnippet*/
149258
+ false,
149259
+ checker,
149260
+ options,
149261
+ preferences
149262
+ );
149263
+ let snippetText = isSnippet ? getJSDocParamAnnotation(
149264
+ paramName,
149265
+ param.initializer,
149266
+ param.dotDotDotToken,
149267
+ isJs,
149268
+ /*isObject*/
149269
+ false,
149270
+ /*isSnippet*/
149271
+ true,
149272
+ checker,
149273
+ options,
149274
+ preferences,
149275
+ tabstopCounter
149276
+ ) : void 0;
149277
+ if (tagNameOnly) {
149278
+ displayText = displayText.slice(1);
149279
+ if (snippetText)
149280
+ snippetText = snippetText.slice(1);
149281
+ }
149282
+ return {
149283
+ name: displayText,
149284
+ kind: "parameter" /* parameterElement */,
149285
+ sortText: SortText.LocationPriority,
149286
+ insertText: isSnippet ? snippetText : void 0,
149287
+ isSnippet
149288
+ };
149289
+ } else if (param.parent.parameters.indexOf(param) === paramTagCount) {
149290
+ const paramPath = `param${paramTagCount}`;
149291
+ const displayTextResult = generateJSDocParamTagsForDestructuring(
149292
+ paramPath,
149293
+ param.name,
149294
+ param.initializer,
149295
+ param.dotDotDotToken,
149296
+ isJs,
149297
+ /*isSnippet*/
149298
+ false,
149299
+ checker,
149300
+ options,
149301
+ preferences
149302
+ );
149303
+ const snippetTextResult = isSnippet ? generateJSDocParamTagsForDestructuring(
149304
+ paramPath,
149305
+ param.name,
149306
+ param.initializer,
149307
+ param.dotDotDotToken,
149308
+ isJs,
149309
+ /*isSnippet*/
149310
+ true,
149311
+ checker,
149312
+ options,
149313
+ preferences
149314
+ ) : void 0;
149315
+ let displayText = displayTextResult.join(getNewLineCharacter(options) + "* ");
149316
+ let snippetText = snippetTextResult == null ? void 0 : snippetTextResult.join(getNewLineCharacter(options) + "* ");
149317
+ if (tagNameOnly) {
149318
+ displayText = displayText.slice(1);
149319
+ if (snippetText)
149320
+ snippetText = snippetText.slice(1);
149321
+ }
149322
+ return {
149323
+ name: displayText,
149324
+ kind: "parameter" /* parameterElement */,
149325
+ sortText: SortText.LocationPriority,
149326
+ insertText: isSnippet ? snippetText : void 0,
149327
+ isSnippet
149328
+ };
149329
+ }
149330
+ });
149331
+ }
149332
+ function generateJSDocParamTagsForDestructuring(path, pattern, initializer, dotDotDotToken, isJs, isSnippet, checker, options, preferences) {
149333
+ if (!isJs) {
149334
+ return [
149335
+ getJSDocParamAnnotation(
149336
+ path,
149337
+ initializer,
149338
+ dotDotDotToken,
149339
+ isJs,
149340
+ /*isObject*/
149341
+ false,
149342
+ isSnippet,
149343
+ checker,
149344
+ options,
149345
+ preferences,
149346
+ { tabstop: 1 }
149347
+ )
149348
+ ];
149349
+ }
149350
+ return patternWorker(path, pattern, initializer, dotDotDotToken, { tabstop: 1 });
149351
+ function patternWorker(path2, pattern2, initializer2, dotDotDotToken2, counter) {
149352
+ if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
149353
+ const oldTabstop = counter.tabstop;
149354
+ const childCounter = { tabstop: oldTabstop };
149355
+ const rootParam = getJSDocParamAnnotation(
149356
+ path2,
149357
+ initializer2,
149358
+ dotDotDotToken2,
149359
+ isJs,
149360
+ /*isObject*/
149361
+ true,
149362
+ isSnippet,
149363
+ checker,
149364
+ options,
149365
+ preferences,
149366
+ childCounter
149367
+ );
149368
+ let childTags = [];
149369
+ for (const element of pattern2.elements) {
149370
+ const elementTags = elementWorker(path2, element, childCounter);
149371
+ if (!elementTags) {
149372
+ childTags = void 0;
149373
+ break;
149374
+ } else {
149375
+ childTags.push(...elementTags);
149376
+ }
149377
+ }
149378
+ if (childTags) {
149379
+ counter.tabstop = childCounter.tabstop;
149380
+ return [rootParam, ...childTags];
149381
+ }
149382
+ }
149383
+ return [
149384
+ getJSDocParamAnnotation(
149385
+ path2,
149386
+ initializer2,
149387
+ dotDotDotToken2,
149388
+ isJs,
149389
+ /*isObject*/
149390
+ false,
149391
+ isSnippet,
149392
+ checker,
149393
+ options,
149394
+ preferences,
149395
+ counter
149396
+ )
149397
+ ];
149398
+ }
149399
+ function elementWorker(path2, element, counter) {
149400
+ if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
149401
+ const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
149402
+ if (!propertyName) {
149403
+ return void 0;
149404
+ }
149405
+ const paramName = `${path2}.${propertyName}`;
149406
+ return [
149407
+ getJSDocParamAnnotation(
149408
+ paramName,
149409
+ element.initializer,
149410
+ element.dotDotDotToken,
149411
+ isJs,
149412
+ /*isObject*/
149413
+ false,
149414
+ isSnippet,
149415
+ checker,
149416
+ options,
149417
+ preferences,
149418
+ counter
149419
+ )
149420
+ ];
149421
+ } else if (element.propertyName) {
149422
+ const propertyName = tryGetTextOfPropertyName(element.propertyName);
149423
+ return propertyName && patternWorker(`${path2}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
149424
+ }
149425
+ return void 0;
149426
+ }
149427
+ }
149428
+ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options, preferences, tabstopCounter) {
149429
+ if (isSnippet) {
149430
+ Debug.assertIsDefined(tabstopCounter);
149431
+ }
149432
+ if (initializer) {
149433
+ paramName = getJSDocParamNameWithInitializer(paramName, initializer);
149434
+ }
149435
+ if (isSnippet) {
149436
+ paramName = escapeSnippetText(paramName);
149437
+ }
149438
+ if (isJs) {
149439
+ let type = "*";
149440
+ if (isObject) {
149441
+ Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
149442
+ type = "Object";
149443
+ } else {
149444
+ if (initializer) {
149445
+ const inferredType = checker.getTypeAtLocation(initializer.parent);
149446
+ if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
149447
+ const sourceFile = initializer.getSourceFile();
149448
+ const quotePreference = getQuotePreference(sourceFile, preferences);
149449
+ const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
149450
+ const typeNode = checker.typeToTypeNode(inferredType, findAncestor(initializer, isFunctionLike), builderFlags);
149451
+ if (typeNode) {
149452
+ const printer = isSnippet ? createSnippetPrinter({
149453
+ removeComments: true,
149454
+ module: options.module,
149455
+ target: options.target
149456
+ }) : createPrinter({
149457
+ removeComments: true,
149458
+ module: options.module,
149459
+ target: options.target
149460
+ });
149461
+ setEmitFlags(typeNode, 1 /* SingleLine */);
149462
+ type = printer.printNode(4 /* Unspecified */, typeNode, sourceFile);
149463
+ }
149464
+ }
149465
+ }
149466
+ if (isSnippet && type === "*") {
149467
+ type = `\${${tabstopCounter.tabstop++}:${type}}`;
149468
+ }
149469
+ }
149470
+ const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
149471
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
149472
+ return `@param {${dotDotDot}${type}} ${paramName} ${description2}`;
149473
+ } else {
149474
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
149475
+ return `@param ${paramName} ${description2}`;
149476
+ }
149477
+ }
149478
+ function getJSDocParamNameWithInitializer(paramName, initializer) {
149479
+ const initializerText = initializer.getText().trim();
149480
+ if (initializerText.includes("\n") || initializerText.length > 80) {
149481
+ return `[${paramName}]`;
149482
+ }
149483
+ return `[${paramName}=${initializerText}]`;
149484
+ }
149196
149485
  function keywordToCompletionEntry(keyword) {
149197
149486
  return {
149198
149487
  name: tokenToString(keyword),
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230404`;
38
+ version = `${versionMajorMinor}.0-dev.20230405`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -82801,6 +82801,14 @@ ${lanes.join("\n")}
82801
82801
  const symbol = getSymbolAtLocation(node);
82802
82802
  return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
82803
82803
  }
82804
+ if (isBindingElement(node)) {
82805
+ return getTypeForVariableLikeDeclaration(
82806
+ node,
82807
+ /*includeOptionality*/
82808
+ true,
82809
+ 0 /* Normal */
82810
+ ) || errorType;
82811
+ }
82804
82812
  if (isDeclaration(node)) {
82805
82813
  const symbol = getSymbolOfDeclaration(node);
82806
82814
  return symbol ? getTypeOfSymbol(symbol) : errorType;
@@ -148111,6 +148119,7 @@ ${lanes.join("\n")}
148111
148119
  return void 0;
148112
148120
  }
148113
148121
  const compilerOptions = program.getCompilerOptions();
148122
+ const checker = program.getTypeChecker();
148114
148123
  const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a2 = host.getIncompleteCompletionsCache) == null ? void 0 : _a2.call(host) : void 0;
148115
148124
  if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && isIdentifier(previousToken)) {
148116
148125
  const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
@@ -148151,9 +148160,31 @@ ${lanes.join("\n")}
148151
148160
  }
148152
148161
  return response;
148153
148162
  case 1 /* JsDocTagName */:
148154
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagNameCompletions());
148163
+ return jsdocCompletionInfo([
148164
+ ...ts_JsDoc_exports.getJSDocTagNameCompletions(),
148165
+ ...getJSDocParameterCompletions(
148166
+ sourceFile,
148167
+ position,
148168
+ checker,
148169
+ compilerOptions,
148170
+ preferences,
148171
+ /*tagNameOnly*/
148172
+ true
148173
+ )
148174
+ ]);
148155
148175
  case 2 /* JsDocTag */:
148156
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagCompletions());
148176
+ return jsdocCompletionInfo([
148177
+ ...ts_JsDoc_exports.getJSDocTagCompletions(),
148178
+ ...getJSDocParameterCompletions(
148179
+ sourceFile,
148180
+ position,
148181
+ checker,
148182
+ compilerOptions,
148183
+ preferences,
148184
+ /*tagNameOnly*/
148185
+ false
148186
+ )
148187
+ ]);
148157
148188
  case 3 /* JsDocParameterName */:
148158
148189
  return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocParameterNameCompletions(completionData.tag));
148159
148190
  case 4 /* Keywords */:
@@ -148241,6 +148272,264 @@ ${lanes.join("\n")}
148241
148272
  function jsdocCompletionInfo(entries) {
148242
148273
  return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
148243
148274
  }
148275
+ function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
148276
+ const currentToken = getTokenAtPosition(sourceFile, position);
148277
+ if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
148278
+ return [];
148279
+ }
148280
+ const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
148281
+ if (!isJSDoc(jsDoc)) {
148282
+ return [];
148283
+ }
148284
+ const func = jsDoc.parent;
148285
+ if (!isFunctionLike(func)) {
148286
+ return [];
148287
+ }
148288
+ const isJs = isSourceFileJS(sourceFile);
148289
+ const isSnippet = preferences.includeCompletionsWithSnippetText || void 0;
148290
+ const paramTagCount = countWhere(jsDoc.tags, (tag) => isJSDocParameterTag(tag) && tag.getEnd() <= position);
148291
+ return mapDefined(func.parameters, (param) => {
148292
+ if (getJSDocParameterTags(param).length) {
148293
+ return void 0;
148294
+ }
148295
+ if (isIdentifier(param.name)) {
148296
+ const tabstopCounter = { tabstop: 1 };
148297
+ const paramName = param.name.text;
148298
+ let displayText = getJSDocParamAnnotation(
148299
+ paramName,
148300
+ param.initializer,
148301
+ param.dotDotDotToken,
148302
+ isJs,
148303
+ /*isObject*/
148304
+ false,
148305
+ /*isSnippet*/
148306
+ false,
148307
+ checker,
148308
+ options,
148309
+ preferences
148310
+ );
148311
+ let snippetText = isSnippet ? getJSDocParamAnnotation(
148312
+ paramName,
148313
+ param.initializer,
148314
+ param.dotDotDotToken,
148315
+ isJs,
148316
+ /*isObject*/
148317
+ false,
148318
+ /*isSnippet*/
148319
+ true,
148320
+ checker,
148321
+ options,
148322
+ preferences,
148323
+ tabstopCounter
148324
+ ) : void 0;
148325
+ if (tagNameOnly) {
148326
+ displayText = displayText.slice(1);
148327
+ if (snippetText)
148328
+ snippetText = snippetText.slice(1);
148329
+ }
148330
+ return {
148331
+ name: displayText,
148332
+ kind: "parameter" /* parameterElement */,
148333
+ sortText: SortText.LocationPriority,
148334
+ insertText: isSnippet ? snippetText : void 0,
148335
+ isSnippet
148336
+ };
148337
+ } else if (param.parent.parameters.indexOf(param) === paramTagCount) {
148338
+ const paramPath = `param${paramTagCount}`;
148339
+ const displayTextResult = generateJSDocParamTagsForDestructuring(
148340
+ paramPath,
148341
+ param.name,
148342
+ param.initializer,
148343
+ param.dotDotDotToken,
148344
+ isJs,
148345
+ /*isSnippet*/
148346
+ false,
148347
+ checker,
148348
+ options,
148349
+ preferences
148350
+ );
148351
+ const snippetTextResult = isSnippet ? generateJSDocParamTagsForDestructuring(
148352
+ paramPath,
148353
+ param.name,
148354
+ param.initializer,
148355
+ param.dotDotDotToken,
148356
+ isJs,
148357
+ /*isSnippet*/
148358
+ true,
148359
+ checker,
148360
+ options,
148361
+ preferences
148362
+ ) : void 0;
148363
+ let displayText = displayTextResult.join(getNewLineCharacter(options) + "* ");
148364
+ let snippetText = snippetTextResult == null ? void 0 : snippetTextResult.join(getNewLineCharacter(options) + "* ");
148365
+ if (tagNameOnly) {
148366
+ displayText = displayText.slice(1);
148367
+ if (snippetText)
148368
+ snippetText = snippetText.slice(1);
148369
+ }
148370
+ return {
148371
+ name: displayText,
148372
+ kind: "parameter" /* parameterElement */,
148373
+ sortText: SortText.LocationPriority,
148374
+ insertText: isSnippet ? snippetText : void 0,
148375
+ isSnippet
148376
+ };
148377
+ }
148378
+ });
148379
+ }
148380
+ function generateJSDocParamTagsForDestructuring(path, pattern, initializer, dotDotDotToken, isJs, isSnippet, checker, options, preferences) {
148381
+ if (!isJs) {
148382
+ return [
148383
+ getJSDocParamAnnotation(
148384
+ path,
148385
+ initializer,
148386
+ dotDotDotToken,
148387
+ isJs,
148388
+ /*isObject*/
148389
+ false,
148390
+ isSnippet,
148391
+ checker,
148392
+ options,
148393
+ preferences,
148394
+ { tabstop: 1 }
148395
+ )
148396
+ ];
148397
+ }
148398
+ return patternWorker(path, pattern, initializer, dotDotDotToken, { tabstop: 1 });
148399
+ function patternWorker(path2, pattern2, initializer2, dotDotDotToken2, counter) {
148400
+ if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
148401
+ const oldTabstop = counter.tabstop;
148402
+ const childCounter = { tabstop: oldTabstop };
148403
+ const rootParam = getJSDocParamAnnotation(
148404
+ path2,
148405
+ initializer2,
148406
+ dotDotDotToken2,
148407
+ isJs,
148408
+ /*isObject*/
148409
+ true,
148410
+ isSnippet,
148411
+ checker,
148412
+ options,
148413
+ preferences,
148414
+ childCounter
148415
+ );
148416
+ let childTags = [];
148417
+ for (const element of pattern2.elements) {
148418
+ const elementTags = elementWorker(path2, element, childCounter);
148419
+ if (!elementTags) {
148420
+ childTags = void 0;
148421
+ break;
148422
+ } else {
148423
+ childTags.push(...elementTags);
148424
+ }
148425
+ }
148426
+ if (childTags) {
148427
+ counter.tabstop = childCounter.tabstop;
148428
+ return [rootParam, ...childTags];
148429
+ }
148430
+ }
148431
+ return [
148432
+ getJSDocParamAnnotation(
148433
+ path2,
148434
+ initializer2,
148435
+ dotDotDotToken2,
148436
+ isJs,
148437
+ /*isObject*/
148438
+ false,
148439
+ isSnippet,
148440
+ checker,
148441
+ options,
148442
+ preferences,
148443
+ counter
148444
+ )
148445
+ ];
148446
+ }
148447
+ function elementWorker(path2, element, counter) {
148448
+ if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
148449
+ const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
148450
+ if (!propertyName) {
148451
+ return void 0;
148452
+ }
148453
+ const paramName = `${path2}.${propertyName}`;
148454
+ return [
148455
+ getJSDocParamAnnotation(
148456
+ paramName,
148457
+ element.initializer,
148458
+ element.dotDotDotToken,
148459
+ isJs,
148460
+ /*isObject*/
148461
+ false,
148462
+ isSnippet,
148463
+ checker,
148464
+ options,
148465
+ preferences,
148466
+ counter
148467
+ )
148468
+ ];
148469
+ } else if (element.propertyName) {
148470
+ const propertyName = tryGetTextOfPropertyName(element.propertyName);
148471
+ return propertyName && patternWorker(`${path2}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
148472
+ }
148473
+ return void 0;
148474
+ }
148475
+ }
148476
+ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options, preferences, tabstopCounter) {
148477
+ if (isSnippet) {
148478
+ Debug.assertIsDefined(tabstopCounter);
148479
+ }
148480
+ if (initializer) {
148481
+ paramName = getJSDocParamNameWithInitializer(paramName, initializer);
148482
+ }
148483
+ if (isSnippet) {
148484
+ paramName = escapeSnippetText(paramName);
148485
+ }
148486
+ if (isJs) {
148487
+ let type = "*";
148488
+ if (isObject) {
148489
+ Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
148490
+ type = "Object";
148491
+ } else {
148492
+ if (initializer) {
148493
+ const inferredType = checker.getTypeAtLocation(initializer.parent);
148494
+ if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
148495
+ const sourceFile = initializer.getSourceFile();
148496
+ const quotePreference = getQuotePreference(sourceFile, preferences);
148497
+ const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
148498
+ const typeNode = checker.typeToTypeNode(inferredType, findAncestor(initializer, isFunctionLike), builderFlags);
148499
+ if (typeNode) {
148500
+ const printer = isSnippet ? createSnippetPrinter({
148501
+ removeComments: true,
148502
+ module: options.module,
148503
+ target: options.target
148504
+ }) : createPrinter({
148505
+ removeComments: true,
148506
+ module: options.module,
148507
+ target: options.target
148508
+ });
148509
+ setEmitFlags(typeNode, 1 /* SingleLine */);
148510
+ type = printer.printNode(4 /* Unspecified */, typeNode, sourceFile);
148511
+ }
148512
+ }
148513
+ }
148514
+ if (isSnippet && type === "*") {
148515
+ type = `\${${tabstopCounter.tabstop++}:${type}}`;
148516
+ }
148517
+ }
148518
+ const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
148519
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148520
+ return `@param {${dotDotDot}${type}} ${paramName} ${description2}`;
148521
+ } else {
148522
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148523
+ return `@param ${paramName} ${description2}`;
148524
+ }
148525
+ }
148526
+ function getJSDocParamNameWithInitializer(paramName, initializer) {
148527
+ const initializerText = initializer.getText().trim();
148528
+ if (initializerText.includes("\n") || initializerText.length > 80) {
148529
+ return `[${paramName}]`;
148530
+ }
148531
+ return `[${paramName}=${initializerText}]`;
148532
+ }
148244
148533
  function keywordToCompletionEntry(keyword) {
148245
148534
  return {
148246
148535
  name: tokenToString(keyword),
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230404`;
38
+ version = `${versionMajorMinor}.0-dev.20230405`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -82801,6 +82801,14 @@ ${lanes.join("\n")}
82801
82801
  const symbol = getSymbolAtLocation(node);
82802
82802
  return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
82803
82803
  }
82804
+ if (isBindingElement(node)) {
82805
+ return getTypeForVariableLikeDeclaration(
82806
+ node,
82807
+ /*includeOptionality*/
82808
+ true,
82809
+ 0 /* Normal */
82810
+ ) || errorType;
82811
+ }
82804
82812
  if (isDeclaration(node)) {
82805
82813
  const symbol = getSymbolOfDeclaration(node);
82806
82814
  return symbol ? getTypeOfSymbol(symbol) : errorType;
@@ -148125,6 +148133,7 @@ ${lanes.join("\n")}
148125
148133
  return void 0;
148126
148134
  }
148127
148135
  const compilerOptions = program.getCompilerOptions();
148136
+ const checker = program.getTypeChecker();
148128
148137
  const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a2 = host.getIncompleteCompletionsCache) == null ? void 0 : _a2.call(host) : void 0;
148129
148138
  if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && isIdentifier(previousToken)) {
148130
148139
  const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
@@ -148165,9 +148174,31 @@ ${lanes.join("\n")}
148165
148174
  }
148166
148175
  return response;
148167
148176
  case 1 /* JsDocTagName */:
148168
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagNameCompletions());
148177
+ return jsdocCompletionInfo([
148178
+ ...ts_JsDoc_exports.getJSDocTagNameCompletions(),
148179
+ ...getJSDocParameterCompletions(
148180
+ sourceFile,
148181
+ position,
148182
+ checker,
148183
+ compilerOptions,
148184
+ preferences,
148185
+ /*tagNameOnly*/
148186
+ true
148187
+ )
148188
+ ]);
148169
148189
  case 2 /* JsDocTag */:
148170
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagCompletions());
148190
+ return jsdocCompletionInfo([
148191
+ ...ts_JsDoc_exports.getJSDocTagCompletions(),
148192
+ ...getJSDocParameterCompletions(
148193
+ sourceFile,
148194
+ position,
148195
+ checker,
148196
+ compilerOptions,
148197
+ preferences,
148198
+ /*tagNameOnly*/
148199
+ false
148200
+ )
148201
+ ]);
148171
148202
  case 3 /* JsDocParameterName */:
148172
148203
  return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocParameterNameCompletions(completionData.tag));
148173
148204
  case 4 /* Keywords */:
@@ -148255,6 +148286,264 @@ ${lanes.join("\n")}
148255
148286
  function jsdocCompletionInfo(entries) {
148256
148287
  return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
148257
148288
  }
148289
+ function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
148290
+ const currentToken = getTokenAtPosition(sourceFile, position);
148291
+ if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
148292
+ return [];
148293
+ }
148294
+ const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
148295
+ if (!isJSDoc(jsDoc)) {
148296
+ return [];
148297
+ }
148298
+ const func = jsDoc.parent;
148299
+ if (!isFunctionLike(func)) {
148300
+ return [];
148301
+ }
148302
+ const isJs = isSourceFileJS(sourceFile);
148303
+ const isSnippet = preferences.includeCompletionsWithSnippetText || void 0;
148304
+ const paramTagCount = countWhere(jsDoc.tags, (tag) => isJSDocParameterTag(tag) && tag.getEnd() <= position);
148305
+ return mapDefined(func.parameters, (param) => {
148306
+ if (getJSDocParameterTags(param).length) {
148307
+ return void 0;
148308
+ }
148309
+ if (isIdentifier(param.name)) {
148310
+ const tabstopCounter = { tabstop: 1 };
148311
+ const paramName = param.name.text;
148312
+ let displayText = getJSDocParamAnnotation(
148313
+ paramName,
148314
+ param.initializer,
148315
+ param.dotDotDotToken,
148316
+ isJs,
148317
+ /*isObject*/
148318
+ false,
148319
+ /*isSnippet*/
148320
+ false,
148321
+ checker,
148322
+ options,
148323
+ preferences
148324
+ );
148325
+ let snippetText = isSnippet ? getJSDocParamAnnotation(
148326
+ paramName,
148327
+ param.initializer,
148328
+ param.dotDotDotToken,
148329
+ isJs,
148330
+ /*isObject*/
148331
+ false,
148332
+ /*isSnippet*/
148333
+ true,
148334
+ checker,
148335
+ options,
148336
+ preferences,
148337
+ tabstopCounter
148338
+ ) : void 0;
148339
+ if (tagNameOnly) {
148340
+ displayText = displayText.slice(1);
148341
+ if (snippetText)
148342
+ snippetText = snippetText.slice(1);
148343
+ }
148344
+ return {
148345
+ name: displayText,
148346
+ kind: "parameter" /* parameterElement */,
148347
+ sortText: SortText.LocationPriority,
148348
+ insertText: isSnippet ? snippetText : void 0,
148349
+ isSnippet
148350
+ };
148351
+ } else if (param.parent.parameters.indexOf(param) === paramTagCount) {
148352
+ const paramPath = `param${paramTagCount}`;
148353
+ const displayTextResult = generateJSDocParamTagsForDestructuring(
148354
+ paramPath,
148355
+ param.name,
148356
+ param.initializer,
148357
+ param.dotDotDotToken,
148358
+ isJs,
148359
+ /*isSnippet*/
148360
+ false,
148361
+ checker,
148362
+ options,
148363
+ preferences
148364
+ );
148365
+ const snippetTextResult = isSnippet ? generateJSDocParamTagsForDestructuring(
148366
+ paramPath,
148367
+ param.name,
148368
+ param.initializer,
148369
+ param.dotDotDotToken,
148370
+ isJs,
148371
+ /*isSnippet*/
148372
+ true,
148373
+ checker,
148374
+ options,
148375
+ preferences
148376
+ ) : void 0;
148377
+ let displayText = displayTextResult.join(getNewLineCharacter(options) + "* ");
148378
+ let snippetText = snippetTextResult == null ? void 0 : snippetTextResult.join(getNewLineCharacter(options) + "* ");
148379
+ if (tagNameOnly) {
148380
+ displayText = displayText.slice(1);
148381
+ if (snippetText)
148382
+ snippetText = snippetText.slice(1);
148383
+ }
148384
+ return {
148385
+ name: displayText,
148386
+ kind: "parameter" /* parameterElement */,
148387
+ sortText: SortText.LocationPriority,
148388
+ insertText: isSnippet ? snippetText : void 0,
148389
+ isSnippet
148390
+ };
148391
+ }
148392
+ });
148393
+ }
148394
+ function generateJSDocParamTagsForDestructuring(path, pattern, initializer, dotDotDotToken, isJs, isSnippet, checker, options, preferences) {
148395
+ if (!isJs) {
148396
+ return [
148397
+ getJSDocParamAnnotation(
148398
+ path,
148399
+ initializer,
148400
+ dotDotDotToken,
148401
+ isJs,
148402
+ /*isObject*/
148403
+ false,
148404
+ isSnippet,
148405
+ checker,
148406
+ options,
148407
+ preferences,
148408
+ { tabstop: 1 }
148409
+ )
148410
+ ];
148411
+ }
148412
+ return patternWorker(path, pattern, initializer, dotDotDotToken, { tabstop: 1 });
148413
+ function patternWorker(path2, pattern2, initializer2, dotDotDotToken2, counter) {
148414
+ if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
148415
+ const oldTabstop = counter.tabstop;
148416
+ const childCounter = { tabstop: oldTabstop };
148417
+ const rootParam = getJSDocParamAnnotation(
148418
+ path2,
148419
+ initializer2,
148420
+ dotDotDotToken2,
148421
+ isJs,
148422
+ /*isObject*/
148423
+ true,
148424
+ isSnippet,
148425
+ checker,
148426
+ options,
148427
+ preferences,
148428
+ childCounter
148429
+ );
148430
+ let childTags = [];
148431
+ for (const element of pattern2.elements) {
148432
+ const elementTags = elementWorker(path2, element, childCounter);
148433
+ if (!elementTags) {
148434
+ childTags = void 0;
148435
+ break;
148436
+ } else {
148437
+ childTags.push(...elementTags);
148438
+ }
148439
+ }
148440
+ if (childTags) {
148441
+ counter.tabstop = childCounter.tabstop;
148442
+ return [rootParam, ...childTags];
148443
+ }
148444
+ }
148445
+ return [
148446
+ getJSDocParamAnnotation(
148447
+ path2,
148448
+ initializer2,
148449
+ dotDotDotToken2,
148450
+ isJs,
148451
+ /*isObject*/
148452
+ false,
148453
+ isSnippet,
148454
+ checker,
148455
+ options,
148456
+ preferences,
148457
+ counter
148458
+ )
148459
+ ];
148460
+ }
148461
+ function elementWorker(path2, element, counter) {
148462
+ if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
148463
+ const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
148464
+ if (!propertyName) {
148465
+ return void 0;
148466
+ }
148467
+ const paramName = `${path2}.${propertyName}`;
148468
+ return [
148469
+ getJSDocParamAnnotation(
148470
+ paramName,
148471
+ element.initializer,
148472
+ element.dotDotDotToken,
148473
+ isJs,
148474
+ /*isObject*/
148475
+ false,
148476
+ isSnippet,
148477
+ checker,
148478
+ options,
148479
+ preferences,
148480
+ counter
148481
+ )
148482
+ ];
148483
+ } else if (element.propertyName) {
148484
+ const propertyName = tryGetTextOfPropertyName(element.propertyName);
148485
+ return propertyName && patternWorker(`${path2}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
148486
+ }
148487
+ return void 0;
148488
+ }
148489
+ }
148490
+ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options, preferences, tabstopCounter) {
148491
+ if (isSnippet) {
148492
+ Debug.assertIsDefined(tabstopCounter);
148493
+ }
148494
+ if (initializer) {
148495
+ paramName = getJSDocParamNameWithInitializer(paramName, initializer);
148496
+ }
148497
+ if (isSnippet) {
148498
+ paramName = escapeSnippetText(paramName);
148499
+ }
148500
+ if (isJs) {
148501
+ let type = "*";
148502
+ if (isObject) {
148503
+ Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
148504
+ type = "Object";
148505
+ } else {
148506
+ if (initializer) {
148507
+ const inferredType = checker.getTypeAtLocation(initializer.parent);
148508
+ if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
148509
+ const sourceFile = initializer.getSourceFile();
148510
+ const quotePreference = getQuotePreference(sourceFile, preferences);
148511
+ const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
148512
+ const typeNode = checker.typeToTypeNode(inferredType, findAncestor(initializer, isFunctionLike), builderFlags);
148513
+ if (typeNode) {
148514
+ const printer = isSnippet ? createSnippetPrinter({
148515
+ removeComments: true,
148516
+ module: options.module,
148517
+ target: options.target
148518
+ }) : createPrinter({
148519
+ removeComments: true,
148520
+ module: options.module,
148521
+ target: options.target
148522
+ });
148523
+ setEmitFlags(typeNode, 1 /* SingleLine */);
148524
+ type = printer.printNode(4 /* Unspecified */, typeNode, sourceFile);
148525
+ }
148526
+ }
148527
+ }
148528
+ if (isSnippet && type === "*") {
148529
+ type = `\${${tabstopCounter.tabstop++}:${type}}`;
148530
+ }
148531
+ }
148532
+ const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
148533
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148534
+ return `@param {${dotDotDot}${type}} ${paramName} ${description2}`;
148535
+ } else {
148536
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148537
+ return `@param ${paramName} ${description2}`;
148538
+ }
148539
+ }
148540
+ function getJSDocParamNameWithInitializer(paramName, initializer) {
148541
+ const initializerText = initializer.getText().trim();
148542
+ if (initializerText.includes("\n") || initializerText.length > 80) {
148543
+ return `[${paramName}]`;
148544
+ }
148545
+ return `[${paramName}=${initializerText}]`;
148546
+ }
148258
148547
  function keywordToCompletionEntry(keyword) {
148259
148548
  return {
148260
148549
  name: tokenToString(keyword),
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230404`;
57
+ var version = `${versionMajorMinor}.0-dev.20230405`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
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": "5.1.0-dev.20230404",
5
+ "version": "5.1.0-dev.20230405",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "a280cafbf85df16bcd2f7258f26fdb85615b3c41"
116
+ "gitHead": "e83d61398ea0e4231e882121dd6c6bcfe4fdc9e4"
117
117
  }