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/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.20230406`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -31763,6 +31763,12 @@ ${lanes.join("\n")}
31763
31763
  if (languageVariant === 1 /* JSX */) {
31764
31764
  return parseJsxElementOrSelfClosingElementOrFragment(
31765
31765
  /*inExpressionContext*/
31766
+ true,
31767
+ /*topInvalidNodePosition*/
31768
+ void 0,
31769
+ /*openingTag*/
31770
+ void 0,
31771
+ /*mustBeUnary*/
31766
31772
  true
31767
31773
  );
31768
31774
  }
@@ -31867,7 +31873,7 @@ ${lanes.join("\n")}
31867
31873
  true
31868
31874
  )), pos);
31869
31875
  }
31870
- function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
31876
+ function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
31871
31877
  const pos = getNodePos();
31872
31878
  const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
31873
31879
  let result;
@@ -31905,7 +31911,7 @@ ${lanes.join("\n")}
31905
31911
  Debug.assert(opening.kind === 283 /* JsxSelfClosingElement */);
31906
31912
  result = opening;
31907
31913
  }
31908
- if (inExpressionContext && token() === 29 /* LessThanToken */) {
31914
+ if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
31909
31915
  const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
31910
31916
  const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
31911
31917
  /*inExpressionContext*/
@@ -31938,7 +31944,7 @@ ${lanes.join("\n")}
31938
31944
  parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
31939
31945
  } else {
31940
31946
  const tag = openingTag.tagName;
31941
- const start = skipTrivia(sourceText, tag.pos);
31947
+ const start = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
31942
31948
  parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
31943
31949
  }
31944
31950
  return void 0;
@@ -82801,6 +82807,14 @@ ${lanes.join("\n")}
82801
82807
  const symbol = getSymbolAtLocation(node);
82802
82808
  return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
82803
82809
  }
82810
+ if (isBindingElement(node)) {
82811
+ return getTypeForVariableLikeDeclaration(
82812
+ node,
82813
+ /*includeOptionality*/
82814
+ true,
82815
+ 0 /* Normal */
82816
+ ) || errorType;
82817
+ }
82804
82818
  if (isDeclaration(node)) {
82805
82819
  const symbol = getSymbolOfDeclaration(node);
82806
82820
  return symbol ? getTypeOfSymbol(symbol) : errorType;
@@ -92334,11 +92348,12 @@ ${lanes.join("\n")}
92334
92348
  return visitEachChild(node, visitor, context);
92335
92349
  }
92336
92350
  function visitArrayAssignmentElement(node) {
92337
- Debug.assertNode(node, isArrayBindingOrAssignmentElement);
92338
- if (isSpreadElement(node))
92339
- return visitAssignmentRestElement(node);
92340
- if (!isOmittedExpression(node))
92341
- return visitAssignmentElement(node);
92351
+ if (isArrayBindingOrAssignmentElement(node)) {
92352
+ if (isSpreadElement(node))
92353
+ return visitAssignmentRestElement(node);
92354
+ if (!isOmittedExpression(node))
92355
+ return visitAssignmentElement(node);
92356
+ }
92342
92357
  return visitEachChild(node, visitor, context);
92343
92358
  }
92344
92359
  function visitAssignmentProperty(node) {
@@ -118504,9 +118519,6 @@ ${lanes.join("\n")}
118504
118519
  if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
118505
118520
  createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
118506
118521
  }
118507
- if (options.isolatedModules) {
118508
- createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
118509
- }
118510
118522
  if (options.preserveValueImports) {
118511
118523
  createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
118512
118524
  }
@@ -121203,7 +121215,7 @@ ${lanes.join("\n")}
121203
121215
  return {
121204
121216
  dir: rootDir,
121205
121217
  dirPath: rootPath,
121206
- nonRecursive: false
121218
+ nonRecursive: true
121207
121219
  };
121208
121220
  }
121209
121221
  }
@@ -121651,7 +121663,7 @@ ${lanes.join("\n")}
121651
121663
  customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
121652
121664
  }
121653
121665
  if (dirPath === rootPath) {
121654
- Debug.assert(!nonRecursive);
121666
+ Debug.assert(nonRecursive);
121655
121667
  setAtRoot = true;
121656
121668
  } else {
121657
121669
  setDirectoryWatcher(dir, dirPath, nonRecursive);
@@ -148125,6 +148137,7 @@ ${lanes.join("\n")}
148125
148137
  return void 0;
148126
148138
  }
148127
148139
  const compilerOptions = program.getCompilerOptions();
148140
+ const checker = program.getTypeChecker();
148128
148141
  const incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a2 = host.getIncompleteCompletionsCache) == null ? void 0 : _a2.call(host) : void 0;
148129
148142
  if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && isIdentifier(previousToken)) {
148130
148143
  const incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken, position);
@@ -148165,9 +148178,31 @@ ${lanes.join("\n")}
148165
148178
  }
148166
148179
  return response;
148167
148180
  case 1 /* JsDocTagName */:
148168
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagNameCompletions());
148181
+ return jsdocCompletionInfo([
148182
+ ...ts_JsDoc_exports.getJSDocTagNameCompletions(),
148183
+ ...getJSDocParameterCompletions(
148184
+ sourceFile,
148185
+ position,
148186
+ checker,
148187
+ compilerOptions,
148188
+ preferences,
148189
+ /*tagNameOnly*/
148190
+ true
148191
+ )
148192
+ ]);
148169
148193
  case 2 /* JsDocTag */:
148170
- return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocTagCompletions());
148194
+ return jsdocCompletionInfo([
148195
+ ...ts_JsDoc_exports.getJSDocTagCompletions(),
148196
+ ...getJSDocParameterCompletions(
148197
+ sourceFile,
148198
+ position,
148199
+ checker,
148200
+ compilerOptions,
148201
+ preferences,
148202
+ /*tagNameOnly*/
148203
+ false
148204
+ )
148205
+ ]);
148171
148206
  case 3 /* JsDocParameterName */:
148172
148207
  return jsdocCompletionInfo(ts_JsDoc_exports.getJSDocParameterNameCompletions(completionData.tag));
148173
148208
  case 4 /* Keywords */:
@@ -148255,6 +148290,264 @@ ${lanes.join("\n")}
148255
148290
  function jsdocCompletionInfo(entries) {
148256
148291
  return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
148257
148292
  }
148293
+ function getJSDocParameterCompletions(sourceFile, position, checker, options, preferences, tagNameOnly) {
148294
+ const currentToken = getTokenAtPosition(sourceFile, position);
148295
+ if (!isJSDocTag(currentToken) && !isJSDoc(currentToken)) {
148296
+ return [];
148297
+ }
148298
+ const jsDoc = isJSDoc(currentToken) ? currentToken : currentToken.parent;
148299
+ if (!isJSDoc(jsDoc)) {
148300
+ return [];
148301
+ }
148302
+ const func = jsDoc.parent;
148303
+ if (!isFunctionLike(func)) {
148304
+ return [];
148305
+ }
148306
+ const isJs = isSourceFileJS(sourceFile);
148307
+ const isSnippet = preferences.includeCompletionsWithSnippetText || void 0;
148308
+ const paramTagCount = countWhere(jsDoc.tags, (tag) => isJSDocParameterTag(tag) && tag.getEnd() <= position);
148309
+ return mapDefined(func.parameters, (param) => {
148310
+ if (getJSDocParameterTags(param).length) {
148311
+ return void 0;
148312
+ }
148313
+ if (isIdentifier(param.name)) {
148314
+ const tabstopCounter = { tabstop: 1 };
148315
+ const paramName = param.name.text;
148316
+ let displayText = getJSDocParamAnnotation(
148317
+ paramName,
148318
+ param.initializer,
148319
+ param.dotDotDotToken,
148320
+ isJs,
148321
+ /*isObject*/
148322
+ false,
148323
+ /*isSnippet*/
148324
+ false,
148325
+ checker,
148326
+ options,
148327
+ preferences
148328
+ );
148329
+ let snippetText = isSnippet ? getJSDocParamAnnotation(
148330
+ paramName,
148331
+ param.initializer,
148332
+ param.dotDotDotToken,
148333
+ isJs,
148334
+ /*isObject*/
148335
+ false,
148336
+ /*isSnippet*/
148337
+ true,
148338
+ checker,
148339
+ options,
148340
+ preferences,
148341
+ tabstopCounter
148342
+ ) : void 0;
148343
+ if (tagNameOnly) {
148344
+ displayText = displayText.slice(1);
148345
+ if (snippetText)
148346
+ snippetText = snippetText.slice(1);
148347
+ }
148348
+ return {
148349
+ name: displayText,
148350
+ kind: "parameter" /* parameterElement */,
148351
+ sortText: SortText.LocationPriority,
148352
+ insertText: isSnippet ? snippetText : void 0,
148353
+ isSnippet
148354
+ };
148355
+ } else if (param.parent.parameters.indexOf(param) === paramTagCount) {
148356
+ const paramPath = `param${paramTagCount}`;
148357
+ const displayTextResult = generateJSDocParamTagsForDestructuring(
148358
+ paramPath,
148359
+ param.name,
148360
+ param.initializer,
148361
+ param.dotDotDotToken,
148362
+ isJs,
148363
+ /*isSnippet*/
148364
+ false,
148365
+ checker,
148366
+ options,
148367
+ preferences
148368
+ );
148369
+ const snippetTextResult = isSnippet ? generateJSDocParamTagsForDestructuring(
148370
+ paramPath,
148371
+ param.name,
148372
+ param.initializer,
148373
+ param.dotDotDotToken,
148374
+ isJs,
148375
+ /*isSnippet*/
148376
+ true,
148377
+ checker,
148378
+ options,
148379
+ preferences
148380
+ ) : void 0;
148381
+ let displayText = displayTextResult.join(getNewLineCharacter(options) + "* ");
148382
+ let snippetText = snippetTextResult == null ? void 0 : snippetTextResult.join(getNewLineCharacter(options) + "* ");
148383
+ if (tagNameOnly) {
148384
+ displayText = displayText.slice(1);
148385
+ if (snippetText)
148386
+ snippetText = snippetText.slice(1);
148387
+ }
148388
+ return {
148389
+ name: displayText,
148390
+ kind: "parameter" /* parameterElement */,
148391
+ sortText: SortText.LocationPriority,
148392
+ insertText: isSnippet ? snippetText : void 0,
148393
+ isSnippet
148394
+ };
148395
+ }
148396
+ });
148397
+ }
148398
+ function generateJSDocParamTagsForDestructuring(path, pattern, initializer, dotDotDotToken, isJs, isSnippet, checker, options, preferences) {
148399
+ if (!isJs) {
148400
+ return [
148401
+ getJSDocParamAnnotation(
148402
+ path,
148403
+ initializer,
148404
+ dotDotDotToken,
148405
+ isJs,
148406
+ /*isObject*/
148407
+ false,
148408
+ isSnippet,
148409
+ checker,
148410
+ options,
148411
+ preferences,
148412
+ { tabstop: 1 }
148413
+ )
148414
+ ];
148415
+ }
148416
+ return patternWorker(path, pattern, initializer, dotDotDotToken, { tabstop: 1 });
148417
+ function patternWorker(path2, pattern2, initializer2, dotDotDotToken2, counter) {
148418
+ if (isObjectBindingPattern(pattern2) && !dotDotDotToken2) {
148419
+ const oldTabstop = counter.tabstop;
148420
+ const childCounter = { tabstop: oldTabstop };
148421
+ const rootParam = getJSDocParamAnnotation(
148422
+ path2,
148423
+ initializer2,
148424
+ dotDotDotToken2,
148425
+ isJs,
148426
+ /*isObject*/
148427
+ true,
148428
+ isSnippet,
148429
+ checker,
148430
+ options,
148431
+ preferences,
148432
+ childCounter
148433
+ );
148434
+ let childTags = [];
148435
+ for (const element of pattern2.elements) {
148436
+ const elementTags = elementWorker(path2, element, childCounter);
148437
+ if (!elementTags) {
148438
+ childTags = void 0;
148439
+ break;
148440
+ } else {
148441
+ childTags.push(...elementTags);
148442
+ }
148443
+ }
148444
+ if (childTags) {
148445
+ counter.tabstop = childCounter.tabstop;
148446
+ return [rootParam, ...childTags];
148447
+ }
148448
+ }
148449
+ return [
148450
+ getJSDocParamAnnotation(
148451
+ path2,
148452
+ initializer2,
148453
+ dotDotDotToken2,
148454
+ isJs,
148455
+ /*isObject*/
148456
+ false,
148457
+ isSnippet,
148458
+ checker,
148459
+ options,
148460
+ preferences,
148461
+ counter
148462
+ )
148463
+ ];
148464
+ }
148465
+ function elementWorker(path2, element, counter) {
148466
+ if (!element.propertyName && isIdentifier(element.name) || isIdentifier(element.name)) {
148467
+ const propertyName = element.propertyName ? tryGetTextOfPropertyName(element.propertyName) : element.name.text;
148468
+ if (!propertyName) {
148469
+ return void 0;
148470
+ }
148471
+ const paramName = `${path2}.${propertyName}`;
148472
+ return [
148473
+ getJSDocParamAnnotation(
148474
+ paramName,
148475
+ element.initializer,
148476
+ element.dotDotDotToken,
148477
+ isJs,
148478
+ /*isObject*/
148479
+ false,
148480
+ isSnippet,
148481
+ checker,
148482
+ options,
148483
+ preferences,
148484
+ counter
148485
+ )
148486
+ ];
148487
+ } else if (element.propertyName) {
148488
+ const propertyName = tryGetTextOfPropertyName(element.propertyName);
148489
+ return propertyName && patternWorker(`${path2}.${propertyName}`, element.name, element.initializer, element.dotDotDotToken, counter);
148490
+ }
148491
+ return void 0;
148492
+ }
148493
+ }
148494
+ function getJSDocParamAnnotation(paramName, initializer, dotDotDotToken, isJs, isObject, isSnippet, checker, options, preferences, tabstopCounter) {
148495
+ if (isSnippet) {
148496
+ Debug.assertIsDefined(tabstopCounter);
148497
+ }
148498
+ if (initializer) {
148499
+ paramName = getJSDocParamNameWithInitializer(paramName, initializer);
148500
+ }
148501
+ if (isSnippet) {
148502
+ paramName = escapeSnippetText(paramName);
148503
+ }
148504
+ if (isJs) {
148505
+ let type = "*";
148506
+ if (isObject) {
148507
+ Debug.assert(!dotDotDotToken, `Cannot annotate a rest parameter with type 'Object'.`);
148508
+ type = "Object";
148509
+ } else {
148510
+ if (initializer) {
148511
+ const inferredType = checker.getTypeAtLocation(initializer.parent);
148512
+ if (!(inferredType.flags & (1 /* Any */ | 16384 /* Void */))) {
148513
+ const sourceFile = initializer.getSourceFile();
148514
+ const quotePreference = getQuotePreference(sourceFile, preferences);
148515
+ const builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */;
148516
+ const typeNode = checker.typeToTypeNode(inferredType, findAncestor(initializer, isFunctionLike), builderFlags);
148517
+ if (typeNode) {
148518
+ const printer = isSnippet ? createSnippetPrinter({
148519
+ removeComments: true,
148520
+ module: options.module,
148521
+ target: options.target
148522
+ }) : createPrinter({
148523
+ removeComments: true,
148524
+ module: options.module,
148525
+ target: options.target
148526
+ });
148527
+ setEmitFlags(typeNode, 1 /* SingleLine */);
148528
+ type = printer.printNode(4 /* Unspecified */, typeNode, sourceFile);
148529
+ }
148530
+ }
148531
+ }
148532
+ if (isSnippet && type === "*") {
148533
+ type = `\${${tabstopCounter.tabstop++}:${type}}`;
148534
+ }
148535
+ }
148536
+ const dotDotDot = !isObject && dotDotDotToken ? "..." : "";
148537
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148538
+ return `@param {${dotDotDot}${type}} ${paramName} ${description2}`;
148539
+ } else {
148540
+ const description2 = isSnippet ? `\${${tabstopCounter.tabstop++}}` : "";
148541
+ return `@param ${paramName} ${description2}`;
148542
+ }
148543
+ }
148544
+ function getJSDocParamNameWithInitializer(paramName, initializer) {
148545
+ const initializerText = initializer.getText().trim();
148546
+ if (initializerText.includes("\n") || initializerText.length > 80) {
148547
+ return `[${paramName}]`;
148548
+ }
148549
+ return `[${paramName}=${initializerText}]`;
148550
+ }
148258
148551
  function keywordToCompletionEntry(keyword) {
148259
148552
  return {
148260
148553
  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.20230406`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -21340,6 +21340,12 @@ var Parser;
21340
21340
  if (languageVariant === 1 /* JSX */) {
21341
21341
  return parseJsxElementOrSelfClosingElementOrFragment(
21342
21342
  /*inExpressionContext*/
21343
+ true,
21344
+ /*topInvalidNodePosition*/
21345
+ void 0,
21346
+ /*openingTag*/
21347
+ void 0,
21348
+ /*mustBeUnary*/
21343
21349
  true
21344
21350
  );
21345
21351
  }
@@ -21444,7 +21450,7 @@ var Parser;
21444
21450
  true
21445
21451
  )), pos);
21446
21452
  }
21447
- function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
21453
+ function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
21448
21454
  const pos = getNodePos();
21449
21455
  const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
21450
21456
  let result;
@@ -21482,7 +21488,7 @@ var Parser;
21482
21488
  Debug.assert(opening.kind === 283 /* JsxSelfClosingElement */);
21483
21489
  result = opening;
21484
21490
  }
21485
- if (inExpressionContext && token() === 29 /* LessThanToken */) {
21491
+ if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
21486
21492
  const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
21487
21493
  const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
21488
21494
  /*inExpressionContext*/
@@ -21515,7 +21521,7 @@ var Parser;
21515
21521
  parseErrorAtRange(openingTag, Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
21516
21522
  } else {
21517
21523
  const tag = openingTag.tagName;
21518
- const start = skipTrivia(sourceText, tag.pos);
21524
+ const start = Math.min(skipTrivia(sourceText, tag.pos), tag.end);
21519
21525
  parseErrorAt(start, tag.end, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
21520
21526
  }
21521
21527
  return void 0;
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.20230406",
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": "68d8be4f1d89d94a543d93fcedad17f3e4ef297b"
117
117
  }