typescript 5.4.0-dev.20231203 → 5.4.0-dev.20231205

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.4";
21
- var version = `${versionMajorMinor}.0-dev.20231203`;
21
+ var version = `${versionMajorMinor}.0-dev.20231205`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
package/lib/tsserver.js CHANGED
@@ -2332,7 +2332,7 @@ module.exports = __toCommonJS(server_exports);
2332
2332
 
2333
2333
  // src/compiler/corePublic.ts
2334
2334
  var versionMajorMinor = "5.4";
2335
- var version = `${versionMajorMinor}.0-dev.20231203`;
2335
+ var version = `${versionMajorMinor}.0-dev.20231205`;
2336
2336
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2337
2337
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2338
2338
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -159553,7 +159553,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
159553
159553
  case 19 /* OpenBraceToken */:
159554
159554
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
159555
159555
  default:
159556
- const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile);
159556
+ const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
159557
159557
  return argInfo ? (
159558
159558
  // At `,`, treat this as the next argument after the comma.
159559
159559
  checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
@@ -161680,7 +161680,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
161680
161680
  case 214 /* NewExpression */:
161681
161681
  case 291 /* JsxAttribute */:
161682
161682
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
161683
- const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
161683
+ const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile, typeChecker);
161684
161684
  return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
161685
161685
  }
161686
161686
  case 272 /* ImportDeclaration */:
@@ -164576,7 +164576,7 @@ var Core;
164576
164576
  if (isStringLiteralLike(ref) && ref.text === node.text) {
164577
164577
  if (type) {
164578
164578
  const refType = getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
164579
- if (type !== checker.getStringType() && type === refType) {
164579
+ if (type !== checker.getStringType() && (type === refType || isStringLiteralPropertyReference(ref, checker))) {
164580
164580
  return nodeEntry(ref, 2 /* StringLiteral */);
164581
164581
  }
164582
164582
  } else {
@@ -164590,6 +164590,11 @@ var Core;
164590
164590
  references
164591
164591
  }];
164592
164592
  }
164593
+ function isStringLiteralPropertyReference(node, checker) {
164594
+ if (isPropertySignature(node.parent)) {
164595
+ return checker.getPropertyOfType(checker.getTypeAtLocation(node.parent.parent), node.text);
164596
+ }
164597
+ }
164593
164598
  function populateSearchSymbolSet(symbol, location, checker, isForRename, providePrefixAndSuffixText, implementations) {
164594
164599
  const result = [];
164595
164600
  forEachRelatedSymbol(
@@ -167783,19 +167788,20 @@ function containsPrecedingToken(startingToken, sourceFile, container) {
167783
167788
  }
167784
167789
  return Debug.fail("Could not find preceding token");
167785
167790
  }
167786
- function getArgumentInfoForCompletions(node, position, sourceFile) {
167787
- const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167791
+ function getArgumentInfoForCompletions(node, position, sourceFile, checker) {
167792
+ const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167788
167793
  return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? void 0 : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
167789
167794
  }
167790
- function getArgumentOrParameterListInfo(node, position, sourceFile) {
167791
- const info = getArgumentOrParameterListAndIndex(node, sourceFile);
167795
+ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
167796
+ const info = getArgumentOrParameterListAndIndex(node, sourceFile, checker);
167792
167797
  if (!info)
167793
167798
  return void 0;
167794
167799
  const { list, argumentIndex } = info;
167795
167800
  const argumentCount = getArgumentCount(
167796
167801
  list,
167797
167802
  /*ignoreTrailingComma*/
167798
- isInString(sourceFile, position, node)
167803
+ isInString(sourceFile, position, node),
167804
+ checker
167799
167805
  );
167800
167806
  if (argumentIndex !== 0) {
167801
167807
  Debug.assertLessThan(argumentIndex, argumentCount);
@@ -167803,19 +167809,19 @@ function getArgumentOrParameterListInfo(node, position, sourceFile) {
167803
167809
  const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
167804
167810
  return { list, argumentIndex, argumentCount, argumentsSpan };
167805
167811
  }
167806
- function getArgumentOrParameterListAndIndex(node, sourceFile) {
167812
+ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
167807
167813
  if (node.kind === 30 /* LessThanToken */ || node.kind === 21 /* OpenParenToken */) {
167808
167814
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
167809
167815
  } else {
167810
167816
  const list = findContainingList(node);
167811
- return list && { list, argumentIndex: getArgumentIndex(list, node) };
167817
+ return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
167812
167818
  }
167813
167819
  }
167814
- function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167820
+ function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
167815
167821
  const { parent: parent2 } = node;
167816
167822
  if (isCallOrNewExpression(parent2)) {
167817
167823
  const invocation = parent2;
167818
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167824
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167819
167825
  if (!info)
167820
167826
  return void 0;
167821
167827
  const { list, argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167873,7 +167879,7 @@ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167873
167879
  }
167874
167880
  }
167875
167881
  function getImmediatelyContainingArgumentOrContextualParameterInfo(node, position, sourceFile, checker) {
167876
- return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167882
+ return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167877
167883
  }
167878
167884
  function getHighestBinary(b) {
167879
167885
  return isBinaryExpression(b.parent) ? getHighestBinary(b.parent) : b;
@@ -167915,7 +167921,7 @@ function getContextualSignatureLocationInfo(node, sourceFile, position, checker)
167915
167921
  case 174 /* MethodDeclaration */:
167916
167922
  case 218 /* FunctionExpression */:
167917
167923
  case 219 /* ArrowFunction */:
167918
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167924
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167919
167925
  if (!info)
167920
167926
  return void 0;
167921
167927
  const { argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167938,21 +167944,45 @@ function chooseBetterSymbol(s) {
167938
167944
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
167939
167945
  }) || s : s;
167940
167946
  }
167941
- function getArgumentIndex(argumentsList, node) {
167947
+ function getArgumentIndex(argumentsList, node, checker) {
167948
+ const args = argumentsList.getChildren();
167942
167949
  let argumentIndex = 0;
167943
- for (const child of argumentsList.getChildren()) {
167950
+ for (let pos = 0; pos < length(args); pos++) {
167951
+ const child = args[pos];
167944
167952
  if (child === node) {
167945
167953
  break;
167946
167954
  }
167947
- if (child.kind !== 28 /* CommaToken */) {
167948
- argumentIndex++;
167955
+ if (isSpreadElement(child)) {
167956
+ argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
167957
+ } else {
167958
+ if (child.kind !== 28 /* CommaToken */) {
167959
+ argumentIndex++;
167960
+ }
167949
167961
  }
167950
167962
  }
167951
167963
  return argumentIndex;
167952
167964
  }
167953
- function getArgumentCount(argumentsList, ignoreTrailingComma) {
167965
+ function getSpreadElementCount(node, checker) {
167966
+ const spreadType = checker.getTypeAtLocation(node.expression);
167967
+ if (checker.isTupleType(spreadType)) {
167968
+ const { elementFlags, fixedLength } = spreadType.target;
167969
+ if (fixedLength === 0) {
167970
+ return 0;
167971
+ }
167972
+ const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
167973
+ return firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
167974
+ }
167975
+ return 0;
167976
+ }
167977
+ function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
167954
167978
  const listChildren = argumentsList.getChildren();
167955
- let argumentCount = countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167979
+ let argumentCount = 0;
167980
+ for (const child of listChildren) {
167981
+ if (isSpreadElement(child)) {
167982
+ argumentCount = argumentCount + getSpreadElementCount(child, checker);
167983
+ }
167984
+ }
167985
+ argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167956
167986
  if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
167957
167987
  argumentCount++;
167958
167988
  }
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.4";
38
- version = `${versionMajorMinor}.0-dev.20231203`;
38
+ version = `${versionMajorMinor}.0-dev.20231205`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -158765,7 +158765,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
158765
158765
  case 19 /* OpenBraceToken */:
158766
158766
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
158767
158767
  default:
158768
- const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile);
158768
+ const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
158769
158769
  return argInfo ? (
158770
158770
  // At `,`, treat this as the next argument after the comma.
158771
158771
  checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
@@ -160945,7 +160945,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160945
160945
  case 214 /* NewExpression */:
160946
160946
  case 291 /* JsxAttribute */:
160947
160947
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
160948
- const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
160948
+ const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile, typeChecker);
160949
160949
  return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
160950
160950
  }
160951
160951
  case 272 /* ImportDeclaration */:
@@ -163876,7 +163876,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163876
163876
  if (isStringLiteralLike(ref) && ref.text === node.text) {
163877
163877
  if (type) {
163878
163878
  const refType = getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
163879
- if (type !== checker.getStringType() && type === refType) {
163879
+ if (type !== checker.getStringType() && (type === refType || isStringLiteralPropertyReference(ref, checker))) {
163880
163880
  return nodeEntry(ref, 2 /* StringLiteral */);
163881
163881
  }
163882
163882
  } else {
@@ -163890,6 +163890,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163890
163890
  references
163891
163891
  }];
163892
163892
  }
163893
+ function isStringLiteralPropertyReference(node, checker) {
163894
+ if (isPropertySignature(node.parent)) {
163895
+ return checker.getPropertyOfType(checker.getTypeAtLocation(node.parent.parent), node.text);
163896
+ }
163897
+ }
163893
163898
  function populateSearchSymbolSet(symbol, location, checker, isForRename, providePrefixAndSuffixText, implementations) {
163894
163899
  const result = [];
163895
163900
  forEachRelatedSymbol(
@@ -167189,19 +167194,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167189
167194
  }
167190
167195
  return Debug.fail("Could not find preceding token");
167191
167196
  }
167192
- function getArgumentInfoForCompletions(node, position, sourceFile) {
167193
- const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167197
+ function getArgumentInfoForCompletions(node, position, sourceFile, checker) {
167198
+ const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167194
167199
  return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? void 0 : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
167195
167200
  }
167196
- function getArgumentOrParameterListInfo(node, position, sourceFile) {
167197
- const info = getArgumentOrParameterListAndIndex(node, sourceFile);
167201
+ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
167202
+ const info = getArgumentOrParameterListAndIndex(node, sourceFile, checker);
167198
167203
  if (!info)
167199
167204
  return void 0;
167200
167205
  const { list, argumentIndex } = info;
167201
167206
  const argumentCount = getArgumentCount(
167202
167207
  list,
167203
167208
  /*ignoreTrailingComma*/
167204
- isInString(sourceFile, position, node)
167209
+ isInString(sourceFile, position, node),
167210
+ checker
167205
167211
  );
167206
167212
  if (argumentIndex !== 0) {
167207
167213
  Debug.assertLessThan(argumentIndex, argumentCount);
@@ -167209,19 +167215,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167209
167215
  const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
167210
167216
  return { list, argumentIndex, argumentCount, argumentsSpan };
167211
167217
  }
167212
- function getArgumentOrParameterListAndIndex(node, sourceFile) {
167218
+ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
167213
167219
  if (node.kind === 30 /* LessThanToken */ || node.kind === 21 /* OpenParenToken */) {
167214
167220
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
167215
167221
  } else {
167216
167222
  const list = findContainingList(node);
167217
- return list && { list, argumentIndex: getArgumentIndex(list, node) };
167223
+ return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
167218
167224
  }
167219
167225
  }
167220
- function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167226
+ function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
167221
167227
  const { parent: parent2 } = node;
167222
167228
  if (isCallOrNewExpression(parent2)) {
167223
167229
  const invocation = parent2;
167224
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167230
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167225
167231
  if (!info)
167226
167232
  return void 0;
167227
167233
  const { list, argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167279,7 +167285,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167279
167285
  }
167280
167286
  }
167281
167287
  function getImmediatelyContainingArgumentOrContextualParameterInfo(node, position, sourceFile, checker) {
167282
- return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167288
+ return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167283
167289
  }
167284
167290
  function getHighestBinary(b) {
167285
167291
  return isBinaryExpression(b.parent) ? getHighestBinary(b.parent) : b;
@@ -167321,7 +167327,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167321
167327
  case 174 /* MethodDeclaration */:
167322
167328
  case 218 /* FunctionExpression */:
167323
167329
  case 219 /* ArrowFunction */:
167324
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167330
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167325
167331
  if (!info)
167326
167332
  return void 0;
167327
167333
  const { argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167344,21 +167350,45 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167344
167350
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
167345
167351
  }) || s : s;
167346
167352
  }
167347
- function getArgumentIndex(argumentsList, node) {
167353
+ function getArgumentIndex(argumentsList, node, checker) {
167354
+ const args = argumentsList.getChildren();
167348
167355
  let argumentIndex = 0;
167349
- for (const child of argumentsList.getChildren()) {
167356
+ for (let pos = 0; pos < length(args); pos++) {
167357
+ const child = args[pos];
167350
167358
  if (child === node) {
167351
167359
  break;
167352
167360
  }
167353
- if (child.kind !== 28 /* CommaToken */) {
167354
- argumentIndex++;
167361
+ if (isSpreadElement(child)) {
167362
+ argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
167363
+ } else {
167364
+ if (child.kind !== 28 /* CommaToken */) {
167365
+ argumentIndex++;
167366
+ }
167355
167367
  }
167356
167368
  }
167357
167369
  return argumentIndex;
167358
167370
  }
167359
- function getArgumentCount(argumentsList, ignoreTrailingComma) {
167371
+ function getSpreadElementCount(node, checker) {
167372
+ const spreadType = checker.getTypeAtLocation(node.expression);
167373
+ if (checker.isTupleType(spreadType)) {
167374
+ const { elementFlags, fixedLength } = spreadType.target;
167375
+ if (fixedLength === 0) {
167376
+ return 0;
167377
+ }
167378
+ const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
167379
+ return firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
167380
+ }
167381
+ return 0;
167382
+ }
167383
+ function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
167360
167384
  const listChildren = argumentsList.getChildren();
167361
- let argumentCount = countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167385
+ let argumentCount = 0;
167386
+ for (const child of listChildren) {
167387
+ if (isSpreadElement(child)) {
167388
+ argumentCount = argumentCount + getSpreadElementCount(child, checker);
167389
+ }
167390
+ }
167391
+ argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167362
167392
  if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
167363
167393
  argumentCount++;
167364
167394
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-dev.20231203`;
57
+ var version = `${versionMajorMinor}.0-dev.20231205`;
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.4.0-dev.20231203",
5
+ "version": "5.4.0-dev.20231205",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -114,5 +114,5 @@
114
114
  "node": "20.1.0",
115
115
  "npm": "8.19.4"
116
116
  },
117
- "gitHead": "670815f768afb613ff2651b16dc4258aeb33a036"
117
+ "gitHead": "6c0687e493e23bfd054bf9ae1fc37a7cb75229ad"
118
118
  }