typescript 5.3.0-dev.20230918 → 5.3.0-dev.20230920

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.3";
21
- var version = `${versionMajorMinor}.0-dev.20230918`;
21
+ var version = `${versionMajorMinor}.0-dev.20230920`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -16423,7 +16423,7 @@ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
16423
16423
  return optionsHaveChanges(oldOptions, newOptions, affectsDeclarationPathOptionDeclarations);
16424
16424
  }
16425
16425
  function getCompilerOptionValue(options, option) {
16426
- return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
16426
+ return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
16427
16427
  }
16428
16428
  function getJSXTransformEnabled(options) {
16429
16429
  const jsx = options.jsx;
@@ -34183,7 +34183,8 @@ var commandOptionsWithoutBuild = [
34183
34183
  {
34184
34184
  name: "allowJs",
34185
34185
  type: "boolean",
34186
- affectsModuleResolution: true,
34186
+ allowJsFlag: true,
34187
+ affectsBuildInfo: true,
34187
34188
  showInSimplifiedHelpView: true,
34188
34189
  category: Diagnostics.JavaScript_Support,
34189
34190
  description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files,
@@ -34193,6 +34194,8 @@ var commandOptionsWithoutBuild = [
34193
34194
  name: "checkJs",
34194
34195
  type: "boolean",
34195
34196
  affectsModuleResolution: true,
34197
+ affectsSemanticDiagnostics: true,
34198
+ affectsBuildInfo: true,
34196
34199
  showInSimplifiedHelpView: true,
34197
34200
  category: Diagnostics.JavaScript_Support,
34198
34201
  description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
@@ -34205,6 +34208,10 @@ var commandOptionsWithoutBuild = [
34205
34208
  affectsEmit: true,
34206
34209
  affectsBuildInfo: true,
34207
34210
  affectsModuleResolution: true,
34211
+ // The checker emits an error when it sees JSX but this option is not set in compilerOptions.
34212
+ // This is effectively a semantic error, so mark this option as affecting semantic diagnostics
34213
+ // so we know to refresh errors when this option is changed.
34214
+ affectsSemanticDiagnostics: true,
34208
34215
  paramType: Diagnostics.KIND,
34209
34216
  showInSimplifiedHelpView: true,
34210
34217
  category: Diagnostics.Language_and_Environment,
@@ -39922,7 +39929,7 @@ function createBinder() {
39922
39929
  case 36 /* ExclamationEqualsToken */:
39923
39930
  case 37 /* EqualsEqualsEqualsToken */:
39924
39931
  case 38 /* ExclamationEqualsEqualsToken */:
39925
- return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
39932
+ return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) || (isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
39926
39933
  case 104 /* InstanceOfKeyword */:
39927
39934
  return isNarrowableOperand(expr.left);
39928
39935
  case 103 /* InKeyword */:
@@ -40242,7 +40249,7 @@ function createBinder() {
40242
40249
  }
40243
40250
  function bindCaseBlock(node) {
40244
40251
  const clauses = node.clauses;
40245
- const isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
40252
+ const isNarrowingSwitch = node.parent.expression.kind === 112 /* TrueKeyword */ || isNarrowingExpression(node.parent.expression);
40246
40253
  let fallthroughFlow = unreachableFlow;
40247
40254
  for (let i = 0; i < clauses.length; i++) {
40248
40255
  const clauseStart = i;
@@ -54201,7 +54208,7 @@ function createTypeChecker(host) {
54201
54208
  }
54202
54209
  function isConstTypeVariable(type, depth = 0) {
54203
54210
  var _a;
54204
- return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
54211
+ return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
54205
54212
  }
54206
54213
  function getConstraintOfIndexedAccess(type) {
54207
54214
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -65549,6 +65556,17 @@ function createTypeChecker(host) {
65549
65556
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65550
65557
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
65551
65558
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
65559
+ } else if (expr.kind === 112 /* TrueKeyword */) {
65560
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
65561
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
65562
+ if (clauseExpression) {
65563
+ type = narrowType(
65564
+ type,
65565
+ clauseExpression,
65566
+ /*assumeTrue*/
65567
+ true
65568
+ );
65569
+ }
65552
65570
  } else {
65553
65571
  if (strictNullChecks) {
65554
65572
  if (optionalChainContainsReference(expr, reference)) {
@@ -65796,6 +65814,10 @@ function createTypeChecker(host) {
65796
65814
  }
65797
65815
  return type;
65798
65816
  }
65817
+ function narrowTypeByBooleanComparison(type, expr, bool, operator, assumeTrue) {
65818
+ assumeTrue = assumeTrue !== (bool.kind === 112 /* TrueKeyword */) !== (operator !== 38 /* ExclamationEqualsEqualsToken */ && operator !== 36 /* ExclamationEqualsToken */);
65819
+ return narrowType(type, expr, assumeTrue);
65820
+ }
65799
65821
  function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
65800
65822
  switch (expr.operatorToken.kind) {
65801
65823
  case 64 /* EqualsToken */:
@@ -65843,6 +65865,12 @@ function createTypeChecker(host) {
65843
65865
  if (isMatchingConstructorReference(right)) {
65844
65866
  return narrowTypeByConstructor(type, operator, left, assumeTrue);
65845
65867
  }
65868
+ if (isBooleanLiteral(right)) {
65869
+ return narrowTypeByBooleanComparison(type, left, right, operator, assumeTrue);
65870
+ }
65871
+ if (isBooleanLiteral(left)) {
65872
+ return narrowTypeByBooleanComparison(type, right, left, operator, assumeTrue);
65873
+ }
65846
65874
  break;
65847
65875
  case 104 /* InstanceOfKeyword */:
65848
65876
  return narrowTypeByInstanceof(type, expr, assumeTrue);
package/lib/tsserver.js CHANGED
@@ -2328,7 +2328,7 @@ module.exports = __toCommonJS(server_exports);
2328
2328
 
2329
2329
  // src/compiler/corePublic.ts
2330
2330
  var versionMajorMinor = "5.3";
2331
- var version = `${versionMajorMinor}.0-dev.20230918`;
2331
+ var version = `${versionMajorMinor}.0-dev.20230920`;
2332
2332
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2333
2333
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2334
2334
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -20572,7 +20572,7 @@ function compilerOptionsAffectDeclarationPath(newOptions, oldOptions) {
20572
20572
  return optionsHaveChanges(oldOptions, newOptions, affectsDeclarationPathOptionDeclarations);
20573
20573
  }
20574
20574
  function getCompilerOptionValue(options, option) {
20575
- return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
20575
+ return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
20576
20576
  }
20577
20577
  function getJSXTransformEnabled(options) {
20578
20578
  const jsx = options.jsx;
@@ -38577,7 +38577,8 @@ var commandOptionsWithoutBuild = [
38577
38577
  {
38578
38578
  name: "allowJs",
38579
38579
  type: "boolean",
38580
- affectsModuleResolution: true,
38580
+ allowJsFlag: true,
38581
+ affectsBuildInfo: true,
38581
38582
  showInSimplifiedHelpView: true,
38582
38583
  category: Diagnostics.JavaScript_Support,
38583
38584
  description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files,
@@ -38587,6 +38588,8 @@ var commandOptionsWithoutBuild = [
38587
38588
  name: "checkJs",
38588
38589
  type: "boolean",
38589
38590
  affectsModuleResolution: true,
38591
+ affectsSemanticDiagnostics: true,
38592
+ affectsBuildInfo: true,
38590
38593
  showInSimplifiedHelpView: true,
38591
38594
  category: Diagnostics.JavaScript_Support,
38592
38595
  description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
@@ -38599,6 +38602,10 @@ var commandOptionsWithoutBuild = [
38599
38602
  affectsEmit: true,
38600
38603
  affectsBuildInfo: true,
38601
38604
  affectsModuleResolution: true,
38605
+ // The checker emits an error when it sees JSX but this option is not set in compilerOptions.
38606
+ // This is effectively a semantic error, so mark this option as affecting semantic diagnostics
38607
+ // so we know to refresh errors when this option is changed.
38608
+ affectsSemanticDiagnostics: true,
38602
38609
  paramType: Diagnostics.KIND,
38603
38610
  showInSimplifiedHelpView: true,
38604
38611
  category: Diagnostics.Language_and_Environment,
@@ -44577,7 +44584,7 @@ function createBinder() {
44577
44584
  case 36 /* ExclamationEqualsToken */:
44578
44585
  case 37 /* EqualsEqualsEqualsToken */:
44579
44586
  case 38 /* ExclamationEqualsEqualsToken */:
44580
- return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
44587
+ return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) || (isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
44581
44588
  case 104 /* InstanceOfKeyword */:
44582
44589
  return isNarrowableOperand(expr.left);
44583
44590
  case 103 /* InKeyword */:
@@ -44897,7 +44904,7 @@ function createBinder() {
44897
44904
  }
44898
44905
  function bindCaseBlock(node) {
44899
44906
  const clauses = node.clauses;
44900
- const isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
44907
+ const isNarrowingSwitch = node.parent.expression.kind === 112 /* TrueKeyword */ || isNarrowingExpression(node.parent.expression);
44901
44908
  let fallthroughFlow = unreachableFlow;
44902
44909
  for (let i = 0; i < clauses.length; i++) {
44903
44910
  const clauseStart = i;
@@ -58901,7 +58908,7 @@ function createTypeChecker(host) {
58901
58908
  }
58902
58909
  function isConstTypeVariable(type, depth = 0) {
58903
58910
  var _a;
58904
- return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
58911
+ return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
58905
58912
  }
58906
58913
  function getConstraintOfIndexedAccess(type) {
58907
58914
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -70249,6 +70256,17 @@ function createTypeChecker(host) {
70249
70256
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70250
70257
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
70251
70258
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
70259
+ } else if (expr.kind === 112 /* TrueKeyword */) {
70260
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
70261
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
70262
+ if (clauseExpression) {
70263
+ type = narrowType(
70264
+ type,
70265
+ clauseExpression,
70266
+ /*assumeTrue*/
70267
+ true
70268
+ );
70269
+ }
70252
70270
  } else {
70253
70271
  if (strictNullChecks) {
70254
70272
  if (optionalChainContainsReference(expr, reference)) {
@@ -70496,6 +70514,10 @@ function createTypeChecker(host) {
70496
70514
  }
70497
70515
  return type;
70498
70516
  }
70517
+ function narrowTypeByBooleanComparison(type, expr, bool, operator, assumeTrue) {
70518
+ assumeTrue = assumeTrue !== (bool.kind === 112 /* TrueKeyword */) !== (operator !== 38 /* ExclamationEqualsEqualsToken */ && operator !== 36 /* ExclamationEqualsToken */);
70519
+ return narrowType(type, expr, assumeTrue);
70520
+ }
70499
70521
  function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
70500
70522
  switch (expr.operatorToken.kind) {
70501
70523
  case 64 /* EqualsToken */:
@@ -70543,6 +70565,12 @@ function createTypeChecker(host) {
70543
70565
  if (isMatchingConstructorReference(right)) {
70544
70566
  return narrowTypeByConstructor(type, operator, left, assumeTrue);
70545
70567
  }
70568
+ if (isBooleanLiteral(right)) {
70569
+ return narrowTypeByBooleanComparison(type, left, right, operator, assumeTrue);
70570
+ }
70571
+ if (isBooleanLiteral(left)) {
70572
+ return narrowTypeByBooleanComparison(type, right, left, operator, assumeTrue);
70573
+ }
70546
70574
  break;
70547
70575
  case 104 /* InstanceOfKeyword */:
70548
70576
  return narrowTypeByInstanceof(type, expr, assumeTrue);
@@ -151098,7 +151126,6 @@ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceF
151098
151126
  if (aliasDeclaration.isTypeOnly) {
151099
151127
  const sortKind = ts_OrganizeImports_exports.detectImportSpecifierSorting(aliasDeclaration.parent.elements, preferences);
151100
151128
  if (aliasDeclaration.parent.elements.length > 1 && sortKind) {
151101
- changes.delete(sourceFile, aliasDeclaration);
151102
151129
  const newSpecifier = factory.updateImportSpecifier(
151103
151130
  aliasDeclaration,
151104
151131
  /*isTypeOnly*/
@@ -151108,10 +151135,13 @@ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceF
151108
151135
  );
151109
151136
  const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
151110
151137
  const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
151111
- changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
151112
- } else {
151113
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
151138
+ if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration) !== insertionIndex) {
151139
+ changes.delete(sourceFile, aliasDeclaration);
151140
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
151141
+ return aliasDeclaration;
151142
+ }
151114
151143
  }
151144
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
151115
151145
  return aliasDeclaration;
151116
151146
  } else {
151117
151147
  Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
@@ -164850,7 +164880,6 @@ __export(ts_InlayHints_exports, {
164850
164880
  });
164851
164881
 
164852
164882
  // src/services/inlayHints.ts
164853
- var maxTypeHintLength = 30;
164854
164883
  var leadingParameterNameCommentRegexFactory = (name) => {
164855
164884
  return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
164856
164885
  };
@@ -164930,9 +164959,10 @@ function provideInlayHints(context) {
164930
164959
  displayParts
164931
164960
  });
164932
164961
  }
164933
- function addTypeHints(text, position) {
164962
+ function addTypeHints(hintText, position) {
164934
164963
  result.push({
164935
- text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
164964
+ text: typeof hintText === "string" ? `: ${hintText}` : "",
164965
+ displayParts: typeof hintText === "string" ? void 0 : [{ text: ": " }, ...hintText],
164936
164966
  position,
164937
164967
  kind: "Type" /* Type */,
164938
164968
  whitespaceBefore: true
@@ -164970,13 +165000,14 @@ function provideInlayHints(context) {
164970
165000
  if (isModuleReferenceType(declarationType)) {
164971
165001
  return;
164972
165002
  }
164973
- const typeDisplayString = printTypeInSingleLine(declarationType);
164974
- if (typeDisplayString) {
164975
- const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
165003
+ const hints = typeToInlayHintParts(declarationType);
165004
+ if (hints) {
165005
+ const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
165006
+ const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
164976
165007
  if (isVariableNameMatchesType) {
164977
165008
  return;
164978
165009
  }
164979
- addTypeHints(typeDisplayString, decl.name.end);
165010
+ addTypeHints(hints, decl.name.end);
164980
165011
  }
164981
165012
  }
164982
165013
  function visitCallOrNewExpression(expr) {
@@ -165084,11 +165115,10 @@ function provideInlayHints(context) {
165084
165115
  if (isModuleReferenceType(returnType)) {
165085
165116
  return;
165086
165117
  }
165087
- const typeDisplayString = printTypeInSingleLine(returnType);
165088
- if (!typeDisplayString) {
165089
- return;
165118
+ const hint = typeToInlayHintParts(returnType);
165119
+ if (hint) {
165120
+ addTypeHints(hint, getTypeAnnotationPosition(decl));
165090
165121
  }
165091
- addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
165092
165122
  }
165093
165123
  function getTypeAnnotationPosition(decl) {
165094
165124
  const closeParenToken = findChildOfKind(decl, 22 /* CloseParenToken */, file);
@@ -165149,6 +165179,303 @@ function provideInlayHints(context) {
165149
165179
  );
165150
165180
  });
165151
165181
  }
165182
+ function typeToInlayHintParts(type) {
165183
+ if (!shouldUseInteractiveInlayHints(preferences)) {
165184
+ return printTypeInSingleLine(type);
165185
+ }
165186
+ const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
165187
+ const typeNode = checker.typeToTypeNode(
165188
+ type,
165189
+ /*enclosingDeclaration*/
165190
+ void 0,
165191
+ flags
165192
+ );
165193
+ Debug.assertIsDefined(typeNode, "should always get typenode");
165194
+ const parts = [];
165195
+ visitForDisplayParts(typeNode);
165196
+ return parts;
165197
+ function visitForDisplayParts(node) {
165198
+ if (!node) {
165199
+ return;
165200
+ }
165201
+ const tokenString = tokenToString(node.kind);
165202
+ if (tokenString) {
165203
+ parts.push({ text: tokenString });
165204
+ return;
165205
+ }
165206
+ switch (node.kind) {
165207
+ case 80 /* Identifier */:
165208
+ const identifier = node;
165209
+ const identifierText = idText(identifier);
165210
+ const name = identifier.symbol && identifier.symbol.declarations && identifier.symbol.declarations.length && getNameOfDeclaration(identifier.symbol.declarations[0]);
165211
+ if (name) {
165212
+ parts.push(getNodeDisplayPart(identifierText, name));
165213
+ } else {
165214
+ parts.push({ text: identifierText });
165215
+ }
165216
+ break;
165217
+ case 9 /* NumericLiteral */:
165218
+ parts.push({ text: node.text });
165219
+ break;
165220
+ case 11 /* StringLiteral */:
165221
+ parts.push({ text: `"${node.text}"` });
165222
+ break;
165223
+ case 166 /* QualifiedName */:
165224
+ const qualifiedName = node;
165225
+ visitForDisplayParts(qualifiedName.left);
165226
+ parts.push({ text: "." });
165227
+ visitForDisplayParts(qualifiedName.right);
165228
+ break;
165229
+ case 182 /* TypePredicate */:
165230
+ const predicate = node;
165231
+ if (predicate.assertsModifier) {
165232
+ parts.push({ text: "asserts " });
165233
+ }
165234
+ visitForDisplayParts(predicate.parameterName);
165235
+ if (predicate.type) {
165236
+ parts.push({ text: " is " });
165237
+ visitForDisplayParts(predicate.type);
165238
+ }
165239
+ break;
165240
+ case 183 /* TypeReference */:
165241
+ const typeReference = node;
165242
+ visitForDisplayParts(typeReference.typeName);
165243
+ if (typeReference.typeArguments) {
165244
+ parts.push({ text: "<" });
165245
+ visitDisplayPartList(typeReference.typeArguments, ", ");
165246
+ parts.push({ text: ">" });
165247
+ }
165248
+ break;
165249
+ case 168 /* TypeParameter */:
165250
+ const typeParameter = node;
165251
+ if (typeParameter.modifiers) {
165252
+ visitDisplayPartList(typeParameter.modifiers, " ");
165253
+ }
165254
+ visitForDisplayParts(typeParameter.name);
165255
+ if (typeParameter.constraint) {
165256
+ parts.push({ text: " extends " });
165257
+ visitForDisplayParts(typeParameter.constraint);
165258
+ }
165259
+ if (typeParameter.default) {
165260
+ parts.push({ text: " = " });
165261
+ visitForDisplayParts(typeParameter.default);
165262
+ }
165263
+ break;
165264
+ case 169 /* Parameter */:
165265
+ const parameter = node;
165266
+ if (parameter.modifiers) {
165267
+ visitDisplayPartList(parameter.modifiers, " ");
165268
+ }
165269
+ if (parameter.dotDotDotToken) {
165270
+ parts.push({ text: "..." });
165271
+ }
165272
+ visitForDisplayParts(parameter.name);
165273
+ if (parameter.questionToken) {
165274
+ parts.push({ text: "?" });
165275
+ }
165276
+ if (parameter.type) {
165277
+ parts.push({ text: ": " });
165278
+ visitForDisplayParts(parameter.type);
165279
+ }
165280
+ break;
165281
+ case 185 /* ConstructorType */:
165282
+ const constructorType = node;
165283
+ parts.push({ text: "new " });
165284
+ if (constructorType.typeParameters) {
165285
+ parts.push({ text: "<" });
165286
+ visitDisplayPartList(constructorType.typeParameters, ", ");
165287
+ parts.push({ text: ">" });
165288
+ }
165289
+ parts.push({ text: "(" });
165290
+ visitDisplayPartList(constructorType.parameters, ", ");
165291
+ parts.push({ text: ")" });
165292
+ parts.push({ text: " => " });
165293
+ visitForDisplayParts(constructorType.type);
165294
+ break;
165295
+ case 186 /* TypeQuery */:
165296
+ const typeQuery = node;
165297
+ parts.push({ text: "typeof " });
165298
+ visitForDisplayParts(typeQuery.exprName);
165299
+ if (typeQuery.typeArguments) {
165300
+ parts.push({ text: "<" });
165301
+ visitDisplayPartList(typeQuery.typeArguments, ", ");
165302
+ parts.push({ text: ">" });
165303
+ }
165304
+ break;
165305
+ case 187 /* TypeLiteral */:
165306
+ const typeLiteral = node;
165307
+ parts.push({ text: "{" });
165308
+ if (typeLiteral.members.length) {
165309
+ parts.push({ text: " " });
165310
+ visitDisplayPartList(typeLiteral.members, "; ");
165311
+ parts.push({ text: " " });
165312
+ }
165313
+ parts.push({ text: "}" });
165314
+ break;
165315
+ case 188 /* ArrayType */:
165316
+ visitForDisplayParts(node.elementType);
165317
+ parts.push({ text: "[]" });
165318
+ break;
165319
+ case 189 /* TupleType */:
165320
+ parts.push({ text: "[" });
165321
+ visitDisplayPartList(node.elements, ", ");
165322
+ parts.push({ text: "]" });
165323
+ break;
165324
+ case 202 /* NamedTupleMember */:
165325
+ const member = node;
165326
+ if (member.dotDotDotToken) {
165327
+ parts.push({ text: "..." });
165328
+ }
165329
+ visitForDisplayParts(member.name);
165330
+ if (member.questionToken) {
165331
+ parts.push({ text: "?" });
165332
+ }
165333
+ parts.push({ text: ": " });
165334
+ visitForDisplayParts(member.type);
165335
+ break;
165336
+ case 190 /* OptionalType */:
165337
+ visitForDisplayParts(node.type);
165338
+ parts.push({ text: "?" });
165339
+ break;
165340
+ case 191 /* RestType */:
165341
+ parts.push({ text: "..." });
165342
+ visitForDisplayParts(node.type);
165343
+ break;
165344
+ case 192 /* UnionType */:
165345
+ visitDisplayPartList(node.types, " | ");
165346
+ break;
165347
+ case 193 /* IntersectionType */:
165348
+ visitDisplayPartList(node.types, " & ");
165349
+ break;
165350
+ case 194 /* ConditionalType */:
165351
+ const conditionalType = node;
165352
+ visitForDisplayParts(conditionalType.checkType);
165353
+ parts.push({ text: " extends " });
165354
+ visitForDisplayParts(conditionalType.extendsType);
165355
+ parts.push({ text: " ? " });
165356
+ visitForDisplayParts(conditionalType.trueType);
165357
+ parts.push({ text: " : " });
165358
+ visitForDisplayParts(conditionalType.falseType);
165359
+ break;
165360
+ case 195 /* InferType */:
165361
+ parts.push({ text: "infer " });
165362
+ visitForDisplayParts(node.typeParameter);
165363
+ break;
165364
+ case 196 /* ParenthesizedType */:
165365
+ parts.push({ text: "(" });
165366
+ visitForDisplayParts(node.type);
165367
+ parts.push({ text: ")" });
165368
+ break;
165369
+ case 198 /* TypeOperator */:
165370
+ const typeOperator = node;
165371
+ parts.push({ text: `${tokenToString(typeOperator.operator)} ` });
165372
+ visitForDisplayParts(typeOperator.type);
165373
+ break;
165374
+ case 199 /* IndexedAccessType */:
165375
+ const indexedAccess = node;
165376
+ visitForDisplayParts(indexedAccess.objectType);
165377
+ parts.push({ text: "[" });
165378
+ visitForDisplayParts(indexedAccess.indexType);
165379
+ parts.push({ text: "]" });
165380
+ break;
165381
+ case 200 /* MappedType */:
165382
+ const mappedType = node;
165383
+ parts.push({ text: "{ " });
165384
+ if (mappedType.readonlyToken) {
165385
+ if (mappedType.readonlyToken.kind === 40 /* PlusToken */) {
165386
+ parts.push({ text: "+" });
165387
+ } else if (mappedType.readonlyToken.kind === 41 /* MinusToken */) {
165388
+ parts.push({ text: "-" });
165389
+ }
165390
+ parts.push({ text: "readonly " });
165391
+ }
165392
+ parts.push({ text: "[" });
165393
+ visitForDisplayParts(mappedType.typeParameter);
165394
+ if (mappedType.nameType) {
165395
+ parts.push({ text: " as " });
165396
+ visitForDisplayParts(mappedType.nameType);
165397
+ }
165398
+ parts.push({ text: "]" });
165399
+ if (mappedType.questionToken) {
165400
+ if (mappedType.questionToken.kind === 40 /* PlusToken */) {
165401
+ parts.push({ text: "+" });
165402
+ } else if (mappedType.questionToken.kind === 41 /* MinusToken */) {
165403
+ parts.push({ text: "-" });
165404
+ }
165405
+ parts.push({ text: "?" });
165406
+ }
165407
+ parts.push({ text: ": " });
165408
+ if (mappedType.type) {
165409
+ visitForDisplayParts(mappedType.type);
165410
+ }
165411
+ parts.push({ text: "; }" });
165412
+ break;
165413
+ case 201 /* LiteralType */:
165414
+ visitForDisplayParts(node.literal);
165415
+ break;
165416
+ case 184 /* FunctionType */:
165417
+ const functionType = node;
165418
+ if (functionType.typeParameters) {
165419
+ parts.push({ text: "<" });
165420
+ visitDisplayPartList(functionType.typeParameters, ", ");
165421
+ parts.push({ text: ">" });
165422
+ }
165423
+ parts.push({ text: "(" });
165424
+ visitDisplayPartList(functionType.parameters, ", ");
165425
+ parts.push({ text: ")" });
165426
+ parts.push({ text: " => " });
165427
+ visitForDisplayParts(functionType.type);
165428
+ break;
165429
+ case 205 /* ImportType */:
165430
+ const importType = node;
165431
+ if (importType.isTypeOf) {
165432
+ parts.push({ text: "typeof " });
165433
+ }
165434
+ parts.push({ text: "import(" });
165435
+ visitForDisplayParts(importType.argument);
165436
+ if (importType.assertions) {
165437
+ parts.push({ text: ", { assert: " });
165438
+ visitDisplayPartList(importType.assertions.assertClause.elements, ", ");
165439
+ parts.push({ text: " }" });
165440
+ }
165441
+ parts.push({ text: ")" });
165442
+ if (importType.qualifier) {
165443
+ parts.push({ text: "." });
165444
+ visitForDisplayParts(importType.qualifier);
165445
+ }
165446
+ if (importType.typeArguments) {
165447
+ parts.push({ text: "<" });
165448
+ visitDisplayPartList(importType.typeArguments, ", ");
165449
+ parts.push({ text: ">" });
165450
+ }
165451
+ break;
165452
+ case 171 /* PropertySignature */:
165453
+ const propertySignature = node;
165454
+ if (propertySignature.modifiers) {
165455
+ visitDisplayPartList(propertySignature.modifiers, " ");
165456
+ }
165457
+ visitForDisplayParts(propertySignature.name);
165458
+ if (propertySignature.questionToken) {
165459
+ parts.push({ text: "?" });
165460
+ }
165461
+ if (propertySignature.type) {
165462
+ parts.push({ text: ": " });
165463
+ visitForDisplayParts(propertySignature.type);
165464
+ }
165465
+ break;
165466
+ default:
165467
+ Debug.failBadSyntaxKind(node);
165468
+ }
165469
+ }
165470
+ function visitDisplayPartList(nodes, separator) {
165471
+ nodes.forEach((node, index) => {
165472
+ if (index > 0) {
165473
+ parts.push({ text: separator });
165474
+ }
165475
+ visitForDisplayParts(node);
165476
+ });
165477
+ }
165478
+ }
165152
165479
  function isUndefined(name) {
165153
165480
  return name === "undefined";
165154
165481
  }
@@ -165314,6 +165641,11 @@ function getJsDocTagsFromDeclarations(declarations, checker) {
165314
165641
  }
165315
165642
  for (const tag of tags) {
165316
165643
  infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
165644
+ if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
165645
+ forEach(tag.typeExpression.type.jsDocPropertyTags, (propTag) => {
165646
+ infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
165647
+ });
165648
+ }
165317
165649
  }
165318
165650
  });
165319
165651
  return infos;
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.3";
38
- version = `${versionMajorMinor}.0-dev.20230918`;
38
+ version = `${versionMajorMinor}.0-dev.20230920`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -17860,7 +17860,7 @@ ${lanes.join("\n")}
17860
17860
  return optionsHaveChanges(oldOptions, newOptions, affectsDeclarationPathOptionDeclarations);
17861
17861
  }
17862
17862
  function getCompilerOptionValue(options, option) {
17863
- return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
17863
+ return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
17864
17864
  }
17865
17865
  function getJSXTransformEnabled(options) {
17866
17866
  const jsx = options.jsx;
@@ -38060,7 +38060,8 @@ ${lanes.join("\n")}
38060
38060
  {
38061
38061
  name: "allowJs",
38062
38062
  type: "boolean",
38063
- affectsModuleResolution: true,
38063
+ allowJsFlag: true,
38064
+ affectsBuildInfo: true,
38064
38065
  showInSimplifiedHelpView: true,
38065
38066
  category: Diagnostics.JavaScript_Support,
38066
38067
  description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files,
@@ -38070,6 +38071,8 @@ ${lanes.join("\n")}
38070
38071
  name: "checkJs",
38071
38072
  type: "boolean",
38072
38073
  affectsModuleResolution: true,
38074
+ affectsSemanticDiagnostics: true,
38075
+ affectsBuildInfo: true,
38073
38076
  showInSimplifiedHelpView: true,
38074
38077
  category: Diagnostics.JavaScript_Support,
38075
38078
  description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
@@ -38082,6 +38085,10 @@ ${lanes.join("\n")}
38082
38085
  affectsEmit: true,
38083
38086
  affectsBuildInfo: true,
38084
38087
  affectsModuleResolution: true,
38088
+ // The checker emits an error when it sees JSX but this option is not set in compilerOptions.
38089
+ // This is effectively a semantic error, so mark this option as affecting semantic diagnostics
38090
+ // so we know to refresh errors when this option is changed.
38091
+ affectsSemanticDiagnostics: true,
38085
38092
  paramType: Diagnostics.KIND,
38086
38093
  showInSimplifiedHelpView: true,
38087
38094
  category: Diagnostics.Language_and_Environment,
@@ -42424,7 +42431,7 @@ ${lanes.join("\n")}
42424
42431
  case 36 /* ExclamationEqualsToken */:
42425
42432
  case 37 /* EqualsEqualsEqualsToken */:
42426
42433
  case 38 /* ExclamationEqualsEqualsToken */:
42427
- return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
42434
+ return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) || (isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
42428
42435
  case 104 /* InstanceOfKeyword */:
42429
42436
  return isNarrowableOperand(expr.left);
42430
42437
  case 103 /* InKeyword */:
@@ -42744,7 +42751,7 @@ ${lanes.join("\n")}
42744
42751
  }
42745
42752
  function bindCaseBlock(node) {
42746
42753
  const clauses = node.clauses;
42747
- const isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
42754
+ const isNarrowingSwitch = node.parent.expression.kind === 112 /* TrueKeyword */ || isNarrowingExpression(node.parent.expression);
42748
42755
  let fallthroughFlow = unreachableFlow;
42749
42756
  for (let i = 0; i < clauses.length; i++) {
42750
42757
  const clauseStart = i;
@@ -56667,7 +56674,7 @@ ${lanes.join("\n")}
56667
56674
  }
56668
56675
  function isConstTypeVariable(type, depth = 0) {
56669
56676
  var _a;
56670
- return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
56677
+ return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
56671
56678
  }
56672
56679
  function getConstraintOfIndexedAccess(type) {
56673
56680
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -68015,6 +68022,17 @@ ${lanes.join("\n")}
68015
68022
  type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68016
68023
  } else if (expr.kind === 221 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
68017
68024
  type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
68025
+ } else if (expr.kind === 112 /* TrueKeyword */) {
68026
+ const clause = flow.switchStatement.caseBlock.clauses.find((_, index) => index === flow.clauseStart);
68027
+ const clauseExpression = clause && clause.kind === 296 /* CaseClause */ ? clause.expression : void 0;
68028
+ if (clauseExpression) {
68029
+ type = narrowType(
68030
+ type,
68031
+ clauseExpression,
68032
+ /*assumeTrue*/
68033
+ true
68034
+ );
68035
+ }
68018
68036
  } else {
68019
68037
  if (strictNullChecks) {
68020
68038
  if (optionalChainContainsReference(expr, reference)) {
@@ -68262,6 +68280,10 @@ ${lanes.join("\n")}
68262
68280
  }
68263
68281
  return type;
68264
68282
  }
68283
+ function narrowTypeByBooleanComparison(type, expr, bool, operator, assumeTrue) {
68284
+ assumeTrue = assumeTrue !== (bool.kind === 112 /* TrueKeyword */) !== (operator !== 38 /* ExclamationEqualsEqualsToken */ && operator !== 36 /* ExclamationEqualsToken */);
68285
+ return narrowType(type, expr, assumeTrue);
68286
+ }
68265
68287
  function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
68266
68288
  switch (expr.operatorToken.kind) {
68267
68289
  case 64 /* EqualsToken */:
@@ -68309,6 +68331,12 @@ ${lanes.join("\n")}
68309
68331
  if (isMatchingConstructorReference(right)) {
68310
68332
  return narrowTypeByConstructor(type, operator, left, assumeTrue);
68311
68333
  }
68334
+ if (isBooleanLiteral(right)) {
68335
+ return narrowTypeByBooleanComparison(type, left, right, operator, assumeTrue);
68336
+ }
68337
+ if (isBooleanLiteral(left)) {
68338
+ return narrowTypeByBooleanComparison(type, right, left, operator, assumeTrue);
68339
+ }
68312
68340
  break;
68313
68341
  case 104 /* InstanceOfKeyword */:
68314
68342
  return narrowTypeByInstanceof(type, expr, assumeTrue);
@@ -149825,7 +149853,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
149825
149853
  if (aliasDeclaration.isTypeOnly) {
149826
149854
  const sortKind = ts_OrganizeImports_exports.detectImportSpecifierSorting(aliasDeclaration.parent.elements, preferences);
149827
149855
  if (aliasDeclaration.parent.elements.length > 1 && sortKind) {
149828
- changes.delete(sourceFile, aliasDeclaration);
149829
149856
  const newSpecifier = factory.updateImportSpecifier(
149830
149857
  aliasDeclaration,
149831
149858
  /*isTypeOnly*/
@@ -149835,10 +149862,13 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
149835
149862
  );
149836
149863
  const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
149837
149864
  const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer);
149838
- changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
149839
- } else {
149840
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
149865
+ if (aliasDeclaration.parent.elements.indexOf(aliasDeclaration) !== insertionIndex) {
149866
+ changes.delete(sourceFile, aliasDeclaration);
149867
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
149868
+ return aliasDeclaration;
149869
+ }
149841
149870
  }
149871
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
149842
149872
  return aliasDeclaration;
149843
149873
  } else {
149844
149874
  Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
@@ -164281,9 +164311,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164281
164311
  displayParts
164282
164312
  });
164283
164313
  }
164284
- function addTypeHints(text, position) {
164314
+ function addTypeHints(hintText, position) {
164285
164315
  result.push({
164286
- text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
164316
+ text: typeof hintText === "string" ? `: ${hintText}` : "",
164317
+ displayParts: typeof hintText === "string" ? void 0 : [{ text: ": " }, ...hintText],
164287
164318
  position,
164288
164319
  kind: "Type" /* Type */,
164289
164320
  whitespaceBefore: true
@@ -164321,13 +164352,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164321
164352
  if (isModuleReferenceType(declarationType)) {
164322
164353
  return;
164323
164354
  }
164324
- const typeDisplayString = printTypeInSingleLine(declarationType);
164325
- if (typeDisplayString) {
164326
- const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
164355
+ const hints = typeToInlayHintParts(declarationType);
164356
+ if (hints) {
164357
+ const hintText = typeof hints === "string" ? hints : hints.map((part) => part.text).join("");
164358
+ const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), hintText);
164327
164359
  if (isVariableNameMatchesType) {
164328
164360
  return;
164329
164361
  }
164330
- addTypeHints(typeDisplayString, decl.name.end);
164362
+ addTypeHints(hints, decl.name.end);
164331
164363
  }
164332
164364
  }
164333
164365
  function visitCallOrNewExpression(expr) {
@@ -164435,11 +164467,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164435
164467
  if (isModuleReferenceType(returnType)) {
164436
164468
  return;
164437
164469
  }
164438
- const typeDisplayString = printTypeInSingleLine(returnType);
164439
- if (!typeDisplayString) {
164440
- return;
164470
+ const hint = typeToInlayHintParts(returnType);
164471
+ if (hint) {
164472
+ addTypeHints(hint, getTypeAnnotationPosition(decl));
164441
164473
  }
164442
- addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
164443
164474
  }
164444
164475
  function getTypeAnnotationPosition(decl) {
164445
164476
  const closeParenToken = findChildOfKind(decl, 22 /* CloseParenToken */, file);
@@ -164500,6 +164531,303 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164500
164531
  );
164501
164532
  });
164502
164533
  }
164534
+ function typeToInlayHintParts(type) {
164535
+ if (!shouldUseInteractiveInlayHints(preferences)) {
164536
+ return printTypeInSingleLine(type);
164537
+ }
164538
+ const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
164539
+ const typeNode = checker.typeToTypeNode(
164540
+ type,
164541
+ /*enclosingDeclaration*/
164542
+ void 0,
164543
+ flags
164544
+ );
164545
+ Debug.assertIsDefined(typeNode, "should always get typenode");
164546
+ const parts = [];
164547
+ visitForDisplayParts(typeNode);
164548
+ return parts;
164549
+ function visitForDisplayParts(node) {
164550
+ if (!node) {
164551
+ return;
164552
+ }
164553
+ const tokenString = tokenToString(node.kind);
164554
+ if (tokenString) {
164555
+ parts.push({ text: tokenString });
164556
+ return;
164557
+ }
164558
+ switch (node.kind) {
164559
+ case 80 /* Identifier */:
164560
+ const identifier = node;
164561
+ const identifierText = idText(identifier);
164562
+ const name = identifier.symbol && identifier.symbol.declarations && identifier.symbol.declarations.length && getNameOfDeclaration(identifier.symbol.declarations[0]);
164563
+ if (name) {
164564
+ parts.push(getNodeDisplayPart(identifierText, name));
164565
+ } else {
164566
+ parts.push({ text: identifierText });
164567
+ }
164568
+ break;
164569
+ case 9 /* NumericLiteral */:
164570
+ parts.push({ text: node.text });
164571
+ break;
164572
+ case 11 /* StringLiteral */:
164573
+ parts.push({ text: `"${node.text}"` });
164574
+ break;
164575
+ case 166 /* QualifiedName */:
164576
+ const qualifiedName = node;
164577
+ visitForDisplayParts(qualifiedName.left);
164578
+ parts.push({ text: "." });
164579
+ visitForDisplayParts(qualifiedName.right);
164580
+ break;
164581
+ case 182 /* TypePredicate */:
164582
+ const predicate = node;
164583
+ if (predicate.assertsModifier) {
164584
+ parts.push({ text: "asserts " });
164585
+ }
164586
+ visitForDisplayParts(predicate.parameterName);
164587
+ if (predicate.type) {
164588
+ parts.push({ text: " is " });
164589
+ visitForDisplayParts(predicate.type);
164590
+ }
164591
+ break;
164592
+ case 183 /* TypeReference */:
164593
+ const typeReference = node;
164594
+ visitForDisplayParts(typeReference.typeName);
164595
+ if (typeReference.typeArguments) {
164596
+ parts.push({ text: "<" });
164597
+ visitDisplayPartList(typeReference.typeArguments, ", ");
164598
+ parts.push({ text: ">" });
164599
+ }
164600
+ break;
164601
+ case 168 /* TypeParameter */:
164602
+ const typeParameter = node;
164603
+ if (typeParameter.modifiers) {
164604
+ visitDisplayPartList(typeParameter.modifiers, " ");
164605
+ }
164606
+ visitForDisplayParts(typeParameter.name);
164607
+ if (typeParameter.constraint) {
164608
+ parts.push({ text: " extends " });
164609
+ visitForDisplayParts(typeParameter.constraint);
164610
+ }
164611
+ if (typeParameter.default) {
164612
+ parts.push({ text: " = " });
164613
+ visitForDisplayParts(typeParameter.default);
164614
+ }
164615
+ break;
164616
+ case 169 /* Parameter */:
164617
+ const parameter = node;
164618
+ if (parameter.modifiers) {
164619
+ visitDisplayPartList(parameter.modifiers, " ");
164620
+ }
164621
+ if (parameter.dotDotDotToken) {
164622
+ parts.push({ text: "..." });
164623
+ }
164624
+ visitForDisplayParts(parameter.name);
164625
+ if (parameter.questionToken) {
164626
+ parts.push({ text: "?" });
164627
+ }
164628
+ if (parameter.type) {
164629
+ parts.push({ text: ": " });
164630
+ visitForDisplayParts(parameter.type);
164631
+ }
164632
+ break;
164633
+ case 185 /* ConstructorType */:
164634
+ const constructorType = node;
164635
+ parts.push({ text: "new " });
164636
+ if (constructorType.typeParameters) {
164637
+ parts.push({ text: "<" });
164638
+ visitDisplayPartList(constructorType.typeParameters, ", ");
164639
+ parts.push({ text: ">" });
164640
+ }
164641
+ parts.push({ text: "(" });
164642
+ visitDisplayPartList(constructorType.parameters, ", ");
164643
+ parts.push({ text: ")" });
164644
+ parts.push({ text: " => " });
164645
+ visitForDisplayParts(constructorType.type);
164646
+ break;
164647
+ case 186 /* TypeQuery */:
164648
+ const typeQuery = node;
164649
+ parts.push({ text: "typeof " });
164650
+ visitForDisplayParts(typeQuery.exprName);
164651
+ if (typeQuery.typeArguments) {
164652
+ parts.push({ text: "<" });
164653
+ visitDisplayPartList(typeQuery.typeArguments, ", ");
164654
+ parts.push({ text: ">" });
164655
+ }
164656
+ break;
164657
+ case 187 /* TypeLiteral */:
164658
+ const typeLiteral = node;
164659
+ parts.push({ text: "{" });
164660
+ if (typeLiteral.members.length) {
164661
+ parts.push({ text: " " });
164662
+ visitDisplayPartList(typeLiteral.members, "; ");
164663
+ parts.push({ text: " " });
164664
+ }
164665
+ parts.push({ text: "}" });
164666
+ break;
164667
+ case 188 /* ArrayType */:
164668
+ visitForDisplayParts(node.elementType);
164669
+ parts.push({ text: "[]" });
164670
+ break;
164671
+ case 189 /* TupleType */:
164672
+ parts.push({ text: "[" });
164673
+ visitDisplayPartList(node.elements, ", ");
164674
+ parts.push({ text: "]" });
164675
+ break;
164676
+ case 202 /* NamedTupleMember */:
164677
+ const member = node;
164678
+ if (member.dotDotDotToken) {
164679
+ parts.push({ text: "..." });
164680
+ }
164681
+ visitForDisplayParts(member.name);
164682
+ if (member.questionToken) {
164683
+ parts.push({ text: "?" });
164684
+ }
164685
+ parts.push({ text: ": " });
164686
+ visitForDisplayParts(member.type);
164687
+ break;
164688
+ case 190 /* OptionalType */:
164689
+ visitForDisplayParts(node.type);
164690
+ parts.push({ text: "?" });
164691
+ break;
164692
+ case 191 /* RestType */:
164693
+ parts.push({ text: "..." });
164694
+ visitForDisplayParts(node.type);
164695
+ break;
164696
+ case 192 /* UnionType */:
164697
+ visitDisplayPartList(node.types, " | ");
164698
+ break;
164699
+ case 193 /* IntersectionType */:
164700
+ visitDisplayPartList(node.types, " & ");
164701
+ break;
164702
+ case 194 /* ConditionalType */:
164703
+ const conditionalType = node;
164704
+ visitForDisplayParts(conditionalType.checkType);
164705
+ parts.push({ text: " extends " });
164706
+ visitForDisplayParts(conditionalType.extendsType);
164707
+ parts.push({ text: " ? " });
164708
+ visitForDisplayParts(conditionalType.trueType);
164709
+ parts.push({ text: " : " });
164710
+ visitForDisplayParts(conditionalType.falseType);
164711
+ break;
164712
+ case 195 /* InferType */:
164713
+ parts.push({ text: "infer " });
164714
+ visitForDisplayParts(node.typeParameter);
164715
+ break;
164716
+ case 196 /* ParenthesizedType */:
164717
+ parts.push({ text: "(" });
164718
+ visitForDisplayParts(node.type);
164719
+ parts.push({ text: ")" });
164720
+ break;
164721
+ case 198 /* TypeOperator */:
164722
+ const typeOperator = node;
164723
+ parts.push({ text: `${tokenToString(typeOperator.operator)} ` });
164724
+ visitForDisplayParts(typeOperator.type);
164725
+ break;
164726
+ case 199 /* IndexedAccessType */:
164727
+ const indexedAccess = node;
164728
+ visitForDisplayParts(indexedAccess.objectType);
164729
+ parts.push({ text: "[" });
164730
+ visitForDisplayParts(indexedAccess.indexType);
164731
+ parts.push({ text: "]" });
164732
+ break;
164733
+ case 200 /* MappedType */:
164734
+ const mappedType = node;
164735
+ parts.push({ text: "{ " });
164736
+ if (mappedType.readonlyToken) {
164737
+ if (mappedType.readonlyToken.kind === 40 /* PlusToken */) {
164738
+ parts.push({ text: "+" });
164739
+ } else if (mappedType.readonlyToken.kind === 41 /* MinusToken */) {
164740
+ parts.push({ text: "-" });
164741
+ }
164742
+ parts.push({ text: "readonly " });
164743
+ }
164744
+ parts.push({ text: "[" });
164745
+ visitForDisplayParts(mappedType.typeParameter);
164746
+ if (mappedType.nameType) {
164747
+ parts.push({ text: " as " });
164748
+ visitForDisplayParts(mappedType.nameType);
164749
+ }
164750
+ parts.push({ text: "]" });
164751
+ if (mappedType.questionToken) {
164752
+ if (mappedType.questionToken.kind === 40 /* PlusToken */) {
164753
+ parts.push({ text: "+" });
164754
+ } else if (mappedType.questionToken.kind === 41 /* MinusToken */) {
164755
+ parts.push({ text: "-" });
164756
+ }
164757
+ parts.push({ text: "?" });
164758
+ }
164759
+ parts.push({ text: ": " });
164760
+ if (mappedType.type) {
164761
+ visitForDisplayParts(mappedType.type);
164762
+ }
164763
+ parts.push({ text: "; }" });
164764
+ break;
164765
+ case 201 /* LiteralType */:
164766
+ visitForDisplayParts(node.literal);
164767
+ break;
164768
+ case 184 /* FunctionType */:
164769
+ const functionType = node;
164770
+ if (functionType.typeParameters) {
164771
+ parts.push({ text: "<" });
164772
+ visitDisplayPartList(functionType.typeParameters, ", ");
164773
+ parts.push({ text: ">" });
164774
+ }
164775
+ parts.push({ text: "(" });
164776
+ visitDisplayPartList(functionType.parameters, ", ");
164777
+ parts.push({ text: ")" });
164778
+ parts.push({ text: " => " });
164779
+ visitForDisplayParts(functionType.type);
164780
+ break;
164781
+ case 205 /* ImportType */:
164782
+ const importType = node;
164783
+ if (importType.isTypeOf) {
164784
+ parts.push({ text: "typeof " });
164785
+ }
164786
+ parts.push({ text: "import(" });
164787
+ visitForDisplayParts(importType.argument);
164788
+ if (importType.assertions) {
164789
+ parts.push({ text: ", { assert: " });
164790
+ visitDisplayPartList(importType.assertions.assertClause.elements, ", ");
164791
+ parts.push({ text: " }" });
164792
+ }
164793
+ parts.push({ text: ")" });
164794
+ if (importType.qualifier) {
164795
+ parts.push({ text: "." });
164796
+ visitForDisplayParts(importType.qualifier);
164797
+ }
164798
+ if (importType.typeArguments) {
164799
+ parts.push({ text: "<" });
164800
+ visitDisplayPartList(importType.typeArguments, ", ");
164801
+ parts.push({ text: ">" });
164802
+ }
164803
+ break;
164804
+ case 171 /* PropertySignature */:
164805
+ const propertySignature = node;
164806
+ if (propertySignature.modifiers) {
164807
+ visitDisplayPartList(propertySignature.modifiers, " ");
164808
+ }
164809
+ visitForDisplayParts(propertySignature.name);
164810
+ if (propertySignature.questionToken) {
164811
+ parts.push({ text: "?" });
164812
+ }
164813
+ if (propertySignature.type) {
164814
+ parts.push({ text: ": " });
164815
+ visitForDisplayParts(propertySignature.type);
164816
+ }
164817
+ break;
164818
+ default:
164819
+ Debug.failBadSyntaxKind(node);
164820
+ }
164821
+ }
164822
+ function visitDisplayPartList(nodes, separator) {
164823
+ nodes.forEach((node, index) => {
164824
+ if (index > 0) {
164825
+ parts.push({ text: separator });
164826
+ }
164827
+ visitForDisplayParts(node);
164828
+ });
164829
+ }
164830
+ }
164503
164831
  function isUndefined(name) {
164504
164832
  return name === "undefined";
164505
164833
  }
@@ -164519,12 +164847,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164519
164847
  };
164520
164848
  }
164521
164849
  }
164522
- var maxTypeHintLength, leadingParameterNameCommentRegexFactory;
164850
+ var leadingParameterNameCommentRegexFactory;
164523
164851
  var init_inlayHints = __esm({
164524
164852
  "src/services/inlayHints.ts"() {
164525
164853
  "use strict";
164526
164854
  init_ts4();
164527
- maxTypeHintLength = 30;
164528
164855
  leadingParameterNameCommentRegexFactory = (name) => {
164529
164856
  return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
164530
164857
  };
@@ -164587,6 +164914,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
164587
164914
  }
164588
164915
  for (const tag of tags) {
164589
164916
  infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
164917
+ if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
164918
+ forEach(tag.typeExpression.type.jsDocPropertyTags, (propTag) => {
164919
+ infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
164920
+ });
164921
+ }
164590
164922
  }
164591
164923
  });
164592
164924
  return infos;
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.3";
57
- var version = `${versionMajorMinor}.0-dev.20230918`;
57
+ var version = `${versionMajorMinor}.0-dev.20230920`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -26005,7 +26005,8 @@ var commandOptionsWithoutBuild = [
26005
26005
  {
26006
26006
  name: "allowJs",
26007
26007
  type: "boolean",
26008
- affectsModuleResolution: true,
26008
+ allowJsFlag: true,
26009
+ affectsBuildInfo: true,
26009
26010
  showInSimplifiedHelpView: true,
26010
26011
  category: Diagnostics.JavaScript_Support,
26011
26012
  description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files,
@@ -26015,6 +26016,8 @@ var commandOptionsWithoutBuild = [
26015
26016
  name: "checkJs",
26016
26017
  type: "boolean",
26017
26018
  affectsModuleResolution: true,
26019
+ affectsSemanticDiagnostics: true,
26020
+ affectsBuildInfo: true,
26018
26021
  showInSimplifiedHelpView: true,
26019
26022
  category: Diagnostics.JavaScript_Support,
26020
26023
  description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files,
@@ -26027,6 +26030,10 @@ var commandOptionsWithoutBuild = [
26027
26030
  affectsEmit: true,
26028
26031
  affectsBuildInfo: true,
26029
26032
  affectsModuleResolution: true,
26033
+ // The checker emits an error when it sees JSX but this option is not set in compilerOptions.
26034
+ // This is effectively a semantic error, so mark this option as affecting semantic diagnostics
26035
+ // so we know to refresh errors when this option is changed.
26036
+ affectsSemanticDiagnostics: true,
26030
26037
  paramType: Diagnostics.KIND,
26031
26038
  showInSimplifiedHelpView: true,
26032
26039
  category: Diagnostics.Language_and_Environment,
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.3.0-dev.20230918",
5
+ "version": "5.3.0-dev.20230920",
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": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "686cb1b63c82e5eee4cd9f8bbdbcf657a4815ff7"
116
+ "gitHead": "2738fbf1e05b9429d03b5956ba0413d92f5b993c"
117
117
  }