typescript 5.1.0-dev.20230403 → 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/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.20230403`;
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),
@@ -153401,7 +153690,7 @@ ${lanes.join("\n")}
153401
153690
  ((Core2) => {
153402
153691
  function getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options = {}, sourceFilesSet = new Set(sourceFiles.map((f) => f.fileName))) {
153403
153692
  var _a2, _b, _c;
153404
- node = getAdjustedNode(node, options);
153693
+ node = getAdjustedNode2(node, options);
153405
153694
  if (isSourceFile(node)) {
153406
153695
  const resolvedRef = ts_GoToDefinition_exports.getReferenceAtPosition(node, position, program);
153407
153696
  if (!(resolvedRef == null ? void 0 : resolvedRef.file)) {
@@ -153469,7 +153758,7 @@ ${lanes.join("\n")}
153469
153758
  return mergeReferences(program, moduleReferences, references, moduleReferencesOfExportTarget);
153470
153759
  }
153471
153760
  Core2.getReferencedSymbolsForNode = getReferencedSymbolsForNode;
153472
- function getAdjustedNode(node, options) {
153761
+ function getAdjustedNode2(node, options) {
153473
153762
  if (options.use === 1 /* References */) {
153474
153763
  node = getAdjustedReferenceLocation(node);
153475
153764
  } else if (options.use === 2 /* Rename */) {
@@ -153477,7 +153766,7 @@ ${lanes.join("\n")}
153477
153766
  }
153478
153767
  return node;
153479
153768
  }
153480
- Core2.getAdjustedNode = getAdjustedNode;
153769
+ Core2.getAdjustedNode = getAdjustedNode2;
153481
153770
  function getReferencesForFileName(fileName, program, sourceFiles, sourceFilesSet = new Set(sourceFiles.map((f) => f.fileName))) {
153482
153771
  var _a2, _b;
153483
153772
  const moduleSymbol = (_a2 = program.getSourceFile(fileName)) == null ? void 0 : _a2.symbol;
@@ -162580,8 +162869,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162580
162869
  return isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
162581
162870
  }
162582
162871
  function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
162583
- const info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
162584
- if (!info)
162872
+ const node = getAdjustedNode(startingToken);
162873
+ if (node === void 0)
162874
+ return void 0;
162875
+ const info = getContextualSignatureLocationInfo(node, sourceFile, position, checker);
162876
+ if (info === void 0)
162585
162877
  return void 0;
162586
162878
  const { contextualType, argumentIndex, argumentCount, argumentsSpan } = info;
162587
162879
  const nonNullableContextualType = contextualType.getNonNullableType();
@@ -162594,16 +162886,23 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162594
162886
  const invocation = { kind: 2 /* Contextual */, signature, node: startingToken, symbol: chooseBetterSymbol(symbol) };
162595
162887
  return { isTypeParameterList: false, invocation, argumentsSpan, argumentIndex, argumentCount };
162596
162888
  }
162597
- function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
162598
- if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
162599
- return void 0;
162600
- const { parent: parent2 } = startingToken;
162889
+ function getAdjustedNode(node) {
162890
+ switch (node.kind) {
162891
+ case 20 /* OpenParenToken */:
162892
+ case 27 /* CommaToken */:
162893
+ return node;
162894
+ default:
162895
+ return findAncestor(node.parent, (n) => isParameter(n) ? true : isBindingElement(n) || isObjectBindingPattern(n) || isArrayBindingPattern(n) ? false : "quit");
162896
+ }
162897
+ }
162898
+ function getContextualSignatureLocationInfo(node, sourceFile, position, checker) {
162899
+ const { parent: parent2 } = node;
162601
162900
  switch (parent2.kind) {
162602
162901
  case 215 /* ParenthesizedExpression */:
162603
162902
  case 172 /* MethodDeclaration */:
162604
162903
  case 216 /* FunctionExpression */:
162605
162904
  case 217 /* ArrowFunction */:
162606
- const info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
162905
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile);
162607
162906
  if (!info)
162608
162907
  return void 0;
162609
162908
  const { argumentIndex, argumentCount, argumentsSpan } = info;
@@ -162612,7 +162911,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
162612
162911
  case 224 /* BinaryExpression */: {
162613
162912
  const highestBinary = getHighestBinary(parent2);
162614
162913
  const contextualType2 = checker.getContextualType(highestBinary);
162615
- const argumentIndex2 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent2) - 1;
162914
+ const argumentIndex2 = node.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent2) - 1;
162616
162915
  const argumentCount2 = countBinaryExpressionParameters(highestBinary);
162617
162916
  return contextualType2 && { contextualType: contextualType2, argumentIndex: argumentIndex2, argumentCount: argumentCount2, argumentsSpan: createTextSpanFromNode(parent2) };
162618
162917
  }
@@ -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.20230403`;
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.20230403",
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": "21db2ae9a2cb8ba88f9b10ac11d3bbd928bde3b1"
116
+ "gitHead": "e83d61398ea0e4231e882121dd6c6bcfe4fdc9e4"
117
117
  }