typescript 5.4.0-dev.20231204 → 5.4.0-dev.20231206

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.20231204`;
21
+ var version = `${versionMajorMinor}.0-dev.20231206`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -17526,6 +17526,10 @@ function hasResolutionModeOverride(node) {
17526
17526
  }
17527
17527
  return !!getResolutionModeOverride(node.attributes);
17528
17528
  }
17529
+ var stringReplace = String.prototype.replace;
17530
+ function replaceFirstStar(s, replacement) {
17531
+ return stringReplace.call(s, "*", replacement);
17532
+ }
17529
17533
 
17530
17534
  // src/compiler/factory/baseNodeFactory.ts
17531
17535
  function createBaseNodeFactory() {
@@ -39156,7 +39160,7 @@ function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, p
39156
39160
  trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
39157
39161
  }
39158
39162
  const resolved = forEach(paths[matchedPatternText], (subst) => {
39159
- const path = matchedStar ? subst.replace("*", matchedStar) : subst;
39163
+ const path = matchedStar ? replaceFirstStar(subst, matchedStar) : subst;
39160
39164
  const candidate = normalizePath(combinePaths(baseDirectory, path));
39161
39165
  if (state.traceEnabled) {
39162
39166
  trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
@@ -42793,7 +42797,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
42793
42797
  if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
42794
42798
  const matchedStar = value.substring(prefix.length, value.length - suffix.length);
42795
42799
  if (!pathIsRelative(matchedStar)) {
42796
- return key.replace("*", matchedStar);
42800
+ return replaceFirstStar(key, matchedStar);
42797
42801
  }
42798
42802
  }
42799
42803
  }
@@ -42841,11 +42845,11 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
42841
42845
  const trailingSlice = pathOrPattern.slice(starPos + 1);
42842
42846
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
42843
42847
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
42844
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
42848
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
42845
42849
  }
42846
42850
  if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
42847
42851
  const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
42848
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
42852
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
42849
42853
  }
42850
42854
  break;
42851
42855
  }
@@ -73148,9 +73152,16 @@ function createTypeChecker(host) {
73148
73152
  const len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
73149
73153
  for (let i = 0; i < len; i++) {
73150
73154
  const parameter = signature.parameters[i];
73151
- if (!getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
73152
- const contextualParameterType = tryGetTypeAtPosition(context, i);
73153
- assignParameterType(parameter, contextualParameterType);
73155
+ const declaration = parameter.valueDeclaration;
73156
+ if (!getEffectiveTypeAnnotationNode(declaration)) {
73157
+ let type = tryGetTypeAtPosition(context, i);
73158
+ if (type && declaration.initializer) {
73159
+ let initializerType = checkDeclarationInitializer(declaration, 0 /* Normal */);
73160
+ if (!isTypeAssignableTo(initializerType, type) && isTypeAssignableTo(type, initializerType = widenTypeInferredFromInitializer(declaration, initializerType))) {
73161
+ type = initializerType;
73162
+ }
73163
+ }
73164
+ assignParameterType(parameter, type);
73154
73165
  }
73155
73166
  }
73156
73167
  if (signatureHasRestParameter(signature)) {
package/lib/tsserver.js CHANGED
@@ -2052,6 +2052,7 @@ __export(server_exports, {
2052
2052
  removeTrailingDirectorySeparator: () => removeTrailingDirectorySeparator,
2053
2053
  repeatString: () => repeatString,
2054
2054
  replaceElement: () => replaceElement,
2055
+ replaceFirstStar: () => replaceFirstStar,
2055
2056
  resolutionExtensionIsTSOrJson: () => resolutionExtensionIsTSOrJson,
2056
2057
  resolveConfigFileProjectName: () => resolveConfigFileProjectName,
2057
2058
  resolveJSModule: () => resolveJSModule,
@@ -2332,7 +2333,7 @@ module.exports = __toCommonJS(server_exports);
2332
2333
 
2333
2334
  // src/compiler/corePublic.ts
2334
2335
  var versionMajorMinor = "5.4";
2335
- var version = `${versionMajorMinor}.0-dev.20231204`;
2336
+ var version = `${versionMajorMinor}.0-dev.20231206`;
2336
2337
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2337
2338
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2338
2339
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -21746,6 +21747,10 @@ function hasResolutionModeOverride(node) {
21746
21747
  }
21747
21748
  return !!getResolutionModeOverride(node.attributes);
21748
21749
  }
21750
+ var stringReplace = String.prototype.replace;
21751
+ function replaceFirstStar(s, replacement) {
21752
+ return stringReplace.call(s, "*", replacement);
21753
+ }
21749
21754
 
21750
21755
  // src/compiler/factory/baseNodeFactory.ts
21751
21756
  function createBaseNodeFactory() {
@@ -43000,7 +43005,7 @@ function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
43000
43005
  /*excludes*/
43001
43006
  void 0,
43002
43007
  [
43003
- isDeclarationFileName(target) ? target.replace("*", "**/*") : changeAnyExtension(target.replace("*", "**/*"), getDeclarationEmitExtensionForPath(target))
43008
+ isDeclarationFileName(target) ? replaceFirstStar(target, "**/*") : changeAnyExtension(replaceFirstStar(target, "**/*"), getDeclarationEmitExtensionForPath(target))
43004
43009
  ]
43005
43010
  ).forEach((entry) => {
43006
43011
  entrypoints = appendIfUnique(entrypoints, {
@@ -43820,7 +43825,7 @@ function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, p
43820
43825
  trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
43821
43826
  }
43822
43827
  const resolved = forEach(paths[matchedPatternText], (subst) => {
43823
- const path = matchedStar ? subst.replace("*", matchedStar) : subst;
43828
+ const path = matchedStar ? replaceFirstStar(subst, matchedStar) : subst;
43824
43829
  const candidate = normalizePath(combinePaths(baseDirectory, path));
43825
43830
  if (state.traceEnabled) {
43826
43831
  trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
@@ -47520,7 +47525,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, hos
47520
47525
  if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
47521
47526
  const matchedStar = value.substring(prefix.length, value.length - suffix.length);
47522
47527
  if (!pathIsRelative(matchedStar)) {
47523
- return key.replace("*", matchedStar);
47528
+ return replaceFirstStar(key, matchedStar);
47524
47529
  }
47525
47530
  }
47526
47531
  }
@@ -47568,11 +47573,11 @@ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory,
47568
47573
  const trailingSlice = pathOrPattern.slice(starPos + 1);
47569
47574
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
47570
47575
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
47571
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
47576
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
47572
47577
  }
47573
47578
  if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
47574
47579
  const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
47575
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
47580
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
47576
47581
  }
47577
47582
  break;
47578
47583
  }
@@ -77875,9 +77880,16 @@ function createTypeChecker(host) {
77875
77880
  const len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
77876
77881
  for (let i = 0; i < len; i++) {
77877
77882
  const parameter = signature.parameters[i];
77878
- if (!getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
77879
- const contextualParameterType = tryGetTypeAtPosition(context, i);
77880
- assignParameterType(parameter, contextualParameterType);
77883
+ const declaration = parameter.valueDeclaration;
77884
+ if (!getEffectiveTypeAnnotationNode(declaration)) {
77885
+ let type = tryGetTypeAtPosition(context, i);
77886
+ if (type && declaration.initializer) {
77887
+ let initializerType = checkDeclarationInitializer(declaration, 0 /* Normal */);
77888
+ if (!isTypeAssignableTo(initializerType, type) && isTypeAssignableTo(type, initializerType = widenTypeInferredFromInitializer(declaration, initializerType))) {
77889
+ type = initializerType;
77890
+ }
77891
+ }
77892
+ assignParameterType(parameter, type);
77881
77893
  }
77882
77894
  }
77883
77895
  if (signatureHasRestParameter(signature)) {
@@ -133958,7 +133970,7 @@ function getContextualTypeFromParent(node, checker, contextFlags) {
133958
133970
  function quote(sourceFile, preferences, text) {
133959
133971
  const quotePreference = getQuotePreference(sourceFile, preferences);
133960
133972
  const quoted = JSON.stringify(text);
133961
- return quotePreference === 0 /* Single */ ? `'${stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"')}'` : quoted;
133973
+ return quotePreference === 0 /* Single */ ? `'${stripQuotes(quoted).replace(/'/g, () => "\\'").replace(/\\"/g, '"')}'` : quoted;
133962
133974
  }
133963
133975
  function isEqualityOperatorKind(kind) {
133964
133976
  switch (kind) {
@@ -159553,7 +159565,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
159553
159565
  case 19 /* OpenBraceToken */:
159554
159566
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
159555
159567
  default:
159556
- const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile);
159568
+ const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
159557
159569
  return argInfo ? (
159558
159570
  // At `,`, treat this as the next argument after the comma.
159559
159571
  checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
@@ -161680,7 +161692,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
161680
161692
  case 214 /* NewExpression */:
161681
161693
  case 291 /* JsxAttribute */:
161682
161694
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
161683
- const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
161695
+ const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile, typeChecker);
161684
161696
  return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
161685
161697
  }
161686
161698
  case 272 /* ImportDeclaration */:
@@ -164576,7 +164588,7 @@ var Core;
164576
164588
  if (isStringLiteralLike(ref) && ref.text === node.text) {
164577
164589
  if (type) {
164578
164590
  const refType = getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
164579
- if (type !== checker.getStringType() && type === refType) {
164591
+ if (type !== checker.getStringType() && (type === refType || isStringLiteralPropertyReference(ref, checker))) {
164580
164592
  return nodeEntry(ref, 2 /* StringLiteral */);
164581
164593
  }
164582
164594
  } else {
@@ -164590,6 +164602,11 @@ var Core;
164590
164602
  references
164591
164603
  }];
164592
164604
  }
164605
+ function isStringLiteralPropertyReference(node, checker) {
164606
+ if (isPropertySignature(node.parent)) {
164607
+ return checker.getPropertyOfType(checker.getTypeAtLocation(node.parent.parent), node.text);
164608
+ }
164609
+ }
164593
164610
  function populateSearchSymbolSet(symbol, location, checker, isForRename, providePrefixAndSuffixText, implementations) {
164594
164611
  const result = [];
164595
164612
  forEachRelatedSymbol(
@@ -167783,19 +167800,20 @@ function containsPrecedingToken(startingToken, sourceFile, container) {
167783
167800
  }
167784
167801
  return Debug.fail("Could not find preceding token");
167785
167802
  }
167786
- function getArgumentInfoForCompletions(node, position, sourceFile) {
167787
- const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167803
+ function getArgumentInfoForCompletions(node, position, sourceFile, checker) {
167804
+ const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167788
167805
  return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? void 0 : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
167789
167806
  }
167790
- function getArgumentOrParameterListInfo(node, position, sourceFile) {
167791
- const info = getArgumentOrParameterListAndIndex(node, sourceFile);
167807
+ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
167808
+ const info = getArgumentOrParameterListAndIndex(node, sourceFile, checker);
167792
167809
  if (!info)
167793
167810
  return void 0;
167794
167811
  const { list, argumentIndex } = info;
167795
167812
  const argumentCount = getArgumentCount(
167796
167813
  list,
167797
167814
  /*ignoreTrailingComma*/
167798
- isInString(sourceFile, position, node)
167815
+ isInString(sourceFile, position, node),
167816
+ checker
167799
167817
  );
167800
167818
  if (argumentIndex !== 0) {
167801
167819
  Debug.assertLessThan(argumentIndex, argumentCount);
@@ -167803,19 +167821,19 @@ function getArgumentOrParameterListInfo(node, position, sourceFile) {
167803
167821
  const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
167804
167822
  return { list, argumentIndex, argumentCount, argumentsSpan };
167805
167823
  }
167806
- function getArgumentOrParameterListAndIndex(node, sourceFile) {
167824
+ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
167807
167825
  if (node.kind === 30 /* LessThanToken */ || node.kind === 21 /* OpenParenToken */) {
167808
167826
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
167809
167827
  } else {
167810
167828
  const list = findContainingList(node);
167811
- return list && { list, argumentIndex: getArgumentIndex(list, node) };
167829
+ return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
167812
167830
  }
167813
167831
  }
167814
- function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167832
+ function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
167815
167833
  const { parent: parent2 } = node;
167816
167834
  if (isCallOrNewExpression(parent2)) {
167817
167835
  const invocation = parent2;
167818
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167836
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167819
167837
  if (!info)
167820
167838
  return void 0;
167821
167839
  const { list, argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167873,7 +167891,7 @@ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167873
167891
  }
167874
167892
  }
167875
167893
  function getImmediatelyContainingArgumentOrContextualParameterInfo(node, position, sourceFile, checker) {
167876
- return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167894
+ return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167877
167895
  }
167878
167896
  function getHighestBinary(b) {
167879
167897
  return isBinaryExpression(b.parent) ? getHighestBinary(b.parent) : b;
@@ -167915,7 +167933,7 @@ function getContextualSignatureLocationInfo(node, sourceFile, position, checker)
167915
167933
  case 174 /* MethodDeclaration */:
167916
167934
  case 218 /* FunctionExpression */:
167917
167935
  case 219 /* ArrowFunction */:
167918
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167936
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167919
167937
  if (!info)
167920
167938
  return void 0;
167921
167939
  const { argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167938,21 +167956,45 @@ function chooseBetterSymbol(s) {
167938
167956
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
167939
167957
  }) || s : s;
167940
167958
  }
167941
- function getArgumentIndex(argumentsList, node) {
167959
+ function getArgumentIndex(argumentsList, node, checker) {
167960
+ const args = argumentsList.getChildren();
167942
167961
  let argumentIndex = 0;
167943
- for (const child of argumentsList.getChildren()) {
167962
+ for (let pos = 0; pos < length(args); pos++) {
167963
+ const child = args[pos];
167944
167964
  if (child === node) {
167945
167965
  break;
167946
167966
  }
167947
- if (child.kind !== 28 /* CommaToken */) {
167948
- argumentIndex++;
167967
+ if (isSpreadElement(child)) {
167968
+ argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
167969
+ } else {
167970
+ if (child.kind !== 28 /* CommaToken */) {
167971
+ argumentIndex++;
167972
+ }
167949
167973
  }
167950
167974
  }
167951
167975
  return argumentIndex;
167952
167976
  }
167953
- function getArgumentCount(argumentsList, ignoreTrailingComma) {
167977
+ function getSpreadElementCount(node, checker) {
167978
+ const spreadType = checker.getTypeAtLocation(node.expression);
167979
+ if (checker.isTupleType(spreadType)) {
167980
+ const { elementFlags, fixedLength } = spreadType.target;
167981
+ if (fixedLength === 0) {
167982
+ return 0;
167983
+ }
167984
+ const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
167985
+ return firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
167986
+ }
167987
+ return 0;
167988
+ }
167989
+ function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
167954
167990
  const listChildren = argumentsList.getChildren();
167955
- let argumentCount = countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167991
+ let argumentCount = 0;
167992
+ for (const child of listChildren) {
167993
+ if (isSpreadElement(child)) {
167994
+ argumentCount = argumentCount + getSpreadElementCount(child, checker);
167995
+ }
167996
+ }
167997
+ argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167956
167998
  if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
167957
167999
  argumentCount++;
167958
168000
  }
@@ -175139,6 +175181,7 @@ __export(ts_exports2, {
175139
175181
  removeTrailingDirectorySeparator: () => removeTrailingDirectorySeparator,
175140
175182
  repeatString: () => repeatString,
175141
175183
  replaceElement: () => replaceElement,
175184
+ replaceFirstStar: () => replaceFirstStar,
175142
175185
  resolutionExtensionIsTSOrJson: () => resolutionExtensionIsTSOrJson,
175143
175186
  resolveConfigFileProjectName: () => resolveConfigFileProjectName,
175144
175187
  resolveJSModule: () => resolveJSModule,
@@ -189931,6 +189974,7 @@ start(initializeNodeSystem(), require("os").platform());
189931
189974
  removeTrailingDirectorySeparator,
189932
189975
  repeatString,
189933
189976
  replaceElement,
189977
+ replaceFirstStar,
189934
189978
  resolutionExtensionIsTSOrJson,
189935
189979
  resolveConfigFileProjectName,
189936
189980
  resolveJSModule,
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.20231204`;
38
+ version = `${versionMajorMinor}.0-dev.20231206`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -18969,7 +18969,10 @@ ${lanes.join("\n")}
18969
18969
  }
18970
18970
  return !!getResolutionModeOverride(node.attributes);
18971
18971
  }
18972
- var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, getScriptTargetFeatures, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashLibReferenceRegEx, fullTripleSlashAMDReferencePathRegEx, fullTripleSlashAMDModuleRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, objectAllocator, objectAllocatorPatchers, localizedDiagnosticMessages, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsNotSupportingExtensionlessResolution, ModuleSpecifierEnding, extensionsToRemove, emptyFileSystemEntries;
18972
+ function replaceFirstStar(s, replacement) {
18973
+ return stringReplace.call(s, "*", replacement);
18974
+ }
18975
+ var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, getScriptTargetFeatures, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashLibReferenceRegEx, fullTripleSlashAMDReferencePathRegEx, fullTripleSlashAMDModuleRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, objectAllocator, objectAllocatorPatchers, localizedDiagnosticMessages, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsNotSupportingExtensionlessResolution, ModuleSpecifierEnding, extensionsToRemove, emptyFileSystemEntries, stringReplace;
18973
18976
  var init_utilities = __esm({
18974
18977
  "src/compiler/utilities.ts"() {
18975
18978
  "use strict";
@@ -19544,6 +19547,7 @@ ${lanes.join("\n")}
19544
19547
  files: emptyArray,
19545
19548
  directories: emptyArray
19546
19549
  };
19550
+ stringReplace = String.prototype.replace;
19547
19551
  }
19548
19552
  });
19549
19553
 
@@ -40840,7 +40844,7 @@ ${lanes.join("\n")}
40840
40844
  /*excludes*/
40841
40845
  void 0,
40842
40846
  [
40843
- isDeclarationFileName(target) ? target.replace("*", "**/*") : changeAnyExtension(target.replace("*", "**/*"), getDeclarationEmitExtensionForPath(target))
40847
+ isDeclarationFileName(target) ? replaceFirstStar(target, "**/*") : changeAnyExtension(replaceFirstStar(target, "**/*"), getDeclarationEmitExtensionForPath(target))
40844
40848
  ]
40845
40849
  ).forEach((entry) => {
40846
40850
  entrypoints = appendIfUnique(entrypoints, {
@@ -41660,7 +41664,7 @@ ${lanes.join("\n")}
41660
41664
  trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
41661
41665
  }
41662
41666
  const resolved = forEach(paths[matchedPatternText], (subst) => {
41663
- const path = matchedStar ? subst.replace("*", matchedStar) : subst;
41667
+ const path = matchedStar ? replaceFirstStar(subst, matchedStar) : subst;
41664
41668
  const candidate = normalizePath(combinePaths(baseDirectory, path));
41665
41669
  if (state.traceEnabled) {
41666
41670
  trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
@@ -45381,7 +45385,7 @@ ${lanes.join("\n")}
45381
45385
  if (value.length >= prefix.length + suffix.length && startsWith(value, prefix) && endsWith(value, suffix) && validateEnding({ ending, value })) {
45382
45386
  const matchedStar = value.substring(prefix.length, value.length - suffix.length);
45383
45387
  if (!pathIsRelative(matchedStar)) {
45384
- return key.replace("*", matchedStar);
45388
+ return replaceFirstStar(key, matchedStar);
45385
45389
  }
45386
45390
  }
45387
45391
  }
@@ -45429,11 +45433,11 @@ ${lanes.join("\n")}
45429
45433
  const trailingSlice = pathOrPattern.slice(starPos + 1);
45430
45434
  if (startsWith(targetFilePath, leadingSlice) && endsWith(targetFilePath, trailingSlice)) {
45431
45435
  const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
45432
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
45436
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
45433
45437
  }
45434
45438
  if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice) && endsWith(extensionSwappedTarget, trailingSlice)) {
45435
45439
  const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
45436
- return { moduleFileToTry: packageName.replace("*", starReplacement) };
45440
+ return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
45437
45441
  }
45438
45442
  break;
45439
45443
  }
@@ -75638,9 +75642,16 @@ ${lanes.join("\n")}
75638
75642
  const len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75639
75643
  for (let i = 0; i < len; i++) {
75640
75644
  const parameter = signature.parameters[i];
75641
- if (!getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
75642
- const contextualParameterType = tryGetTypeAtPosition(context, i);
75643
- assignParameterType(parameter, contextualParameterType);
75645
+ const declaration = parameter.valueDeclaration;
75646
+ if (!getEffectiveTypeAnnotationNode(declaration)) {
75647
+ let type = tryGetTypeAtPosition(context, i);
75648
+ if (type && declaration.initializer) {
75649
+ let initializerType = checkDeclarationInitializer(declaration, 0 /* Normal */);
75650
+ if (!isTypeAssignableTo(initializerType, type) && isTypeAssignableTo(type, initializerType = widenTypeInferredFromInitializer(declaration, initializerType))) {
75651
+ type = initializerType;
75652
+ }
75653
+ }
75654
+ assignParameterType(parameter, type);
75644
75655
  }
75645
75656
  }
75646
75657
  if (signatureHasRestParameter(signature)) {
@@ -132219,7 +132230,7 @@ ${lanes.join("\n")}
132219
132230
  function quote(sourceFile, preferences, text) {
132220
132231
  const quotePreference = getQuotePreference(sourceFile, preferences);
132221
132232
  const quoted = JSON.stringify(text);
132222
- return quotePreference === 0 /* Single */ ? `'${stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"')}'` : quoted;
132233
+ return quotePreference === 0 /* Single */ ? `'${stripQuotes(quoted).replace(/'/g, () => "\\'").replace(/\\"/g, '"')}'` : quoted;
132223
132234
  }
132224
132235
  function isEqualityOperatorKind(kind) {
132225
132236
  switch (kind) {
@@ -158765,7 +158776,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
158765
158776
  case 19 /* OpenBraceToken */:
158766
158777
  return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
158767
158778
  default:
158768
- const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile);
158779
+ const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
158769
158780
  return argInfo ? (
158770
158781
  // At `,`, treat this as the next argument after the comma.
158771
158782
  checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
@@ -160945,7 +160956,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
160945
160956
  case 214 /* NewExpression */:
160946
160957
  case 291 /* JsxAttribute */:
160947
160958
  if (!isRequireCallArgument(node) && !isImportCall(parent2)) {
160948
- const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile);
160959
+ const argumentInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(parent2.kind === 291 /* JsxAttribute */ ? parent2.parent : node, position, sourceFile, typeChecker);
160949
160960
  return argumentInfo && getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) || fromContextualType(0 /* None */);
160950
160961
  }
160951
160962
  case 272 /* ImportDeclaration */:
@@ -163876,7 +163887,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163876
163887
  if (isStringLiteralLike(ref) && ref.text === node.text) {
163877
163888
  if (type) {
163878
163889
  const refType = getContextualTypeFromParentOrAncestorTypeNode(ref, checker);
163879
- if (type !== checker.getStringType() && type === refType) {
163890
+ if (type !== checker.getStringType() && (type === refType || isStringLiteralPropertyReference(ref, checker))) {
163880
163891
  return nodeEntry(ref, 2 /* StringLiteral */);
163881
163892
  }
163882
163893
  } else {
@@ -163890,6 +163901,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
163890
163901
  references
163891
163902
  }];
163892
163903
  }
163904
+ function isStringLiteralPropertyReference(node, checker) {
163905
+ if (isPropertySignature(node.parent)) {
163906
+ return checker.getPropertyOfType(checker.getTypeAtLocation(node.parent.parent), node.text);
163907
+ }
163908
+ }
163893
163909
  function populateSearchSymbolSet(symbol, location, checker, isForRename, providePrefixAndSuffixText, implementations) {
163894
163910
  const result = [];
163895
163911
  forEachRelatedSymbol(
@@ -167189,19 +167205,20 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167189
167205
  }
167190
167206
  return Debug.fail("Could not find preceding token");
167191
167207
  }
167192
- function getArgumentInfoForCompletions(node, position, sourceFile) {
167193
- const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167208
+ function getArgumentInfoForCompletions(node, position, sourceFile, checker) {
167209
+ const info = getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167194
167210
  return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? void 0 : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
167195
167211
  }
167196
- function getArgumentOrParameterListInfo(node, position, sourceFile) {
167197
- const info = getArgumentOrParameterListAndIndex(node, sourceFile);
167212
+ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
167213
+ const info = getArgumentOrParameterListAndIndex(node, sourceFile, checker);
167198
167214
  if (!info)
167199
167215
  return void 0;
167200
167216
  const { list, argumentIndex } = info;
167201
167217
  const argumentCount = getArgumentCount(
167202
167218
  list,
167203
167219
  /*ignoreTrailingComma*/
167204
- isInString(sourceFile, position, node)
167220
+ isInString(sourceFile, position, node),
167221
+ checker
167205
167222
  );
167206
167223
  if (argumentIndex !== 0) {
167207
167224
  Debug.assertLessThan(argumentIndex, argumentCount);
@@ -167209,19 +167226,19 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167209
167226
  const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
167210
167227
  return { list, argumentIndex, argumentCount, argumentsSpan };
167211
167228
  }
167212
- function getArgumentOrParameterListAndIndex(node, sourceFile) {
167229
+ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
167213
167230
  if (node.kind === 30 /* LessThanToken */ || node.kind === 21 /* OpenParenToken */) {
167214
167231
  return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
167215
167232
  } else {
167216
167233
  const list = findContainingList(node);
167217
- return list && { list, argumentIndex: getArgumentIndex(list, node) };
167234
+ return list && { list, argumentIndex: getArgumentIndex(list, node, checker) };
167218
167235
  }
167219
167236
  }
167220
- function getImmediatelyContainingArgumentInfo(node, position, sourceFile) {
167237
+ function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
167221
167238
  const { parent: parent2 } = node;
167222
167239
  if (isCallOrNewExpression(parent2)) {
167223
167240
  const invocation = parent2;
167224
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167241
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167225
167242
  if (!info)
167226
167243
  return void 0;
167227
167244
  const { list, argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167279,7 +167296,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167279
167296
  }
167280
167297
  }
167281
167298
  function getImmediatelyContainingArgumentOrContextualParameterInfo(node, position, sourceFile, checker) {
167282
- return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile);
167299
+ return tryGetParameterInfo(node, position, sourceFile, checker) || getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker);
167283
167300
  }
167284
167301
  function getHighestBinary(b) {
167285
167302
  return isBinaryExpression(b.parent) ? getHighestBinary(b.parent) : b;
@@ -167321,7 +167338,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167321
167338
  case 174 /* MethodDeclaration */:
167322
167339
  case 218 /* FunctionExpression */:
167323
167340
  case 219 /* ArrowFunction */:
167324
- const info = getArgumentOrParameterListInfo(node, position, sourceFile);
167341
+ const info = getArgumentOrParameterListInfo(node, position, sourceFile, checker);
167325
167342
  if (!info)
167326
167343
  return void 0;
167327
167344
  const { argumentIndex, argumentCount, argumentsSpan } = info;
@@ -167344,21 +167361,45 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
167344
167361
  return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
167345
167362
  }) || s : s;
167346
167363
  }
167347
- function getArgumentIndex(argumentsList, node) {
167364
+ function getArgumentIndex(argumentsList, node, checker) {
167365
+ const args = argumentsList.getChildren();
167348
167366
  let argumentIndex = 0;
167349
- for (const child of argumentsList.getChildren()) {
167367
+ for (let pos = 0; pos < length(args); pos++) {
167368
+ const child = args[pos];
167350
167369
  if (child === node) {
167351
167370
  break;
167352
167371
  }
167353
- if (child.kind !== 28 /* CommaToken */) {
167354
- argumentIndex++;
167372
+ if (isSpreadElement(child)) {
167373
+ argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
167374
+ } else {
167375
+ if (child.kind !== 28 /* CommaToken */) {
167376
+ argumentIndex++;
167377
+ }
167355
167378
  }
167356
167379
  }
167357
167380
  return argumentIndex;
167358
167381
  }
167359
- function getArgumentCount(argumentsList, ignoreTrailingComma) {
167382
+ function getSpreadElementCount(node, checker) {
167383
+ const spreadType = checker.getTypeAtLocation(node.expression);
167384
+ if (checker.isTupleType(spreadType)) {
167385
+ const { elementFlags, fixedLength } = spreadType.target;
167386
+ if (fixedLength === 0) {
167387
+ return 0;
167388
+ }
167389
+ const firstOptionalIndex = findIndex(elementFlags, (f) => !(f & 1 /* Required */));
167390
+ return firstOptionalIndex < 0 ? fixedLength : firstOptionalIndex;
167391
+ }
167392
+ return 0;
167393
+ }
167394
+ function getArgumentCount(argumentsList, ignoreTrailingComma, checker) {
167360
167395
  const listChildren = argumentsList.getChildren();
167361
- let argumentCount = countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167396
+ let argumentCount = 0;
167397
+ for (const child of listChildren) {
167398
+ if (isSpreadElement(child)) {
167399
+ argumentCount = argumentCount + getSpreadElementCount(child, checker);
167400
+ }
167401
+ }
167402
+ argumentCount = argumentCount + countWhere(listChildren, (arg) => arg.kind !== 28 /* CommaToken */);
167362
167403
  if (!ignoreTrailingComma && listChildren.length > 0 && last(listChildren).kind === 28 /* CommaToken */) {
167363
167404
  argumentCount++;
167364
167405
  }
@@ -186697,6 +186738,7 @@ ${e.message}`;
186697
186738
  removeTrailingDirectorySeparator: () => removeTrailingDirectorySeparator,
186698
186739
  repeatString: () => repeatString,
186699
186740
  replaceElement: () => replaceElement,
186741
+ replaceFirstStar: () => replaceFirstStar,
186700
186742
  resolutionExtensionIsTSOrJson: () => resolutionExtensionIsTSOrJson,
186701
186743
  resolveConfigFileProjectName: () => resolveConfigFileProjectName,
186702
186744
  resolveJSModule: () => resolveJSModule,
@@ -189110,6 +189152,7 @@ ${e.message}`;
189110
189152
  removeTrailingDirectorySeparator: () => removeTrailingDirectorySeparator,
189111
189153
  repeatString: () => repeatString,
189112
189154
  replaceElement: () => replaceElement,
189155
+ replaceFirstStar: () => replaceFirstStar,
189113
189156
  resolutionExtensionIsTSOrJson: () => resolutionExtensionIsTSOrJson,
189114
189157
  resolveConfigFileProjectName: () => resolveConfigFileProjectName,
189115
189158
  resolveJSModule: () => resolveJSModule,
@@ -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.20231204`;
57
+ var version = `${versionMajorMinor}.0-dev.20231206`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -11744,6 +11744,10 @@ function getEscapedTextOfJsxNamespacedName(node) {
11744
11744
  function getTextOfJsxNamespacedName(node) {
11745
11745
  return `${idText(node.namespace)}:${idText(node.name)}`;
11746
11746
  }
11747
+ var stringReplace = String.prototype.replace;
11748
+ function replaceFirstStar(s, replacement) {
11749
+ return stringReplace.call(s, "*", replacement);
11750
+ }
11747
11751
 
11748
11752
  // src/compiler/factory/baseNodeFactory.ts
11749
11753
  function createBaseNodeFactory() {
@@ -29000,7 +29004,7 @@ function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, p
29000
29004
  trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
29001
29005
  }
29002
29006
  const resolved = forEach(paths[matchedPatternText], (subst) => {
29003
- const path2 = matchedStar ? subst.replace("*", matchedStar) : subst;
29007
+ const path2 = matchedStar ? replaceFirstStar(subst, matchedStar) : subst;
29004
29008
  const candidate = normalizePath(combinePaths(baseDirectory, path2));
29005
29009
  if (state.traceEnabled) {
29006
29010
  trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path2);
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.20231204",
5
+ "version": "5.4.0-dev.20231206",
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": "ef6ac03df4db7a61034908ffe08ba0ff5a1601ba"
117
+ "gitHead": "1d7c0c977abcb076d6f491ed091834baff6d41f8"
118
118
  }