typescript 5.3.0-dev.20230919 → 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 +22 -5
- package/lib/tsserver.js +335 -16
- package/lib/typescript.js +336 -17
- package/lib/typingsInstaller.js +9 -2
- package/package.json +2 -2
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.
|
|
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
|
-
|
|
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 */:
|
|
@@ -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 &
|
|
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;
|
|
@@ -65807,6 +65814,10 @@ function createTypeChecker(host) {
|
|
|
65807
65814
|
}
|
|
65808
65815
|
return type;
|
|
65809
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
|
+
}
|
|
65810
65821
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
65811
65822
|
switch (expr.operatorToken.kind) {
|
|
65812
65823
|
case 64 /* EqualsToken */:
|
|
@@ -65854,6 +65865,12 @@ function createTypeChecker(host) {
|
|
|
65854
65865
|
if (isMatchingConstructorReference(right)) {
|
|
65855
65866
|
return narrowTypeByConstructor(type, operator, left, assumeTrue);
|
|
65856
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
|
+
}
|
|
65857
65874
|
break;
|
|
65858
65875
|
case 104 /* InstanceOfKeyword */:
|
|
65859
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.
|
|
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
|
-
|
|
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 */:
|
|
@@ -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 &
|
|
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;
|
|
@@ -70507,6 +70514,10 @@ function createTypeChecker(host) {
|
|
|
70507
70514
|
}
|
|
70508
70515
|
return type;
|
|
70509
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
|
+
}
|
|
70510
70521
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
70511
70522
|
switch (expr.operatorToken.kind) {
|
|
70512
70523
|
case 64 /* EqualsToken */:
|
|
@@ -70554,6 +70565,12 @@ function createTypeChecker(host) {
|
|
|
70554
70565
|
if (isMatchingConstructorReference(right)) {
|
|
70555
70566
|
return narrowTypeByConstructor(type, operator, left, assumeTrue);
|
|
70556
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
|
+
}
|
|
70557
70574
|
break;
|
|
70558
70575
|
case 104 /* InstanceOfKeyword */:
|
|
70559
70576
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
@@ -164863,7 +164880,6 @@ __export(ts_InlayHints_exports, {
|
|
|
164863
164880
|
});
|
|
164864
164881
|
|
|
164865
164882
|
// src/services/inlayHints.ts
|
|
164866
|
-
var maxTypeHintLength = 30;
|
|
164867
164883
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164868
164884
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164869
164885
|
};
|
|
@@ -164943,9 +164959,10 @@ function provideInlayHints(context) {
|
|
|
164943
164959
|
displayParts
|
|
164944
164960
|
});
|
|
164945
164961
|
}
|
|
164946
|
-
function addTypeHints(
|
|
164962
|
+
function addTypeHints(hintText, position) {
|
|
164947
164963
|
result.push({
|
|
164948
|
-
text:
|
|
164964
|
+
text: typeof hintText === "string" ? `: ${hintText}` : "",
|
|
164965
|
+
displayParts: typeof hintText === "string" ? void 0 : [{ text: ": " }, ...hintText],
|
|
164949
164966
|
position,
|
|
164950
164967
|
kind: "Type" /* Type */,
|
|
164951
164968
|
whitespaceBefore: true
|
|
@@ -164983,13 +165000,14 @@ function provideInlayHints(context) {
|
|
|
164983
165000
|
if (isModuleReferenceType(declarationType)) {
|
|
164984
165001
|
return;
|
|
164985
165002
|
}
|
|
164986
|
-
const
|
|
164987
|
-
if (
|
|
164988
|
-
const
|
|
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);
|
|
164989
165007
|
if (isVariableNameMatchesType) {
|
|
164990
165008
|
return;
|
|
164991
165009
|
}
|
|
164992
|
-
addTypeHints(
|
|
165010
|
+
addTypeHints(hints, decl.name.end);
|
|
164993
165011
|
}
|
|
164994
165012
|
}
|
|
164995
165013
|
function visitCallOrNewExpression(expr) {
|
|
@@ -165097,11 +165115,10 @@ function provideInlayHints(context) {
|
|
|
165097
165115
|
if (isModuleReferenceType(returnType)) {
|
|
165098
165116
|
return;
|
|
165099
165117
|
}
|
|
165100
|
-
const
|
|
165101
|
-
if (
|
|
165102
|
-
|
|
165118
|
+
const hint = typeToInlayHintParts(returnType);
|
|
165119
|
+
if (hint) {
|
|
165120
|
+
addTypeHints(hint, getTypeAnnotationPosition(decl));
|
|
165103
165121
|
}
|
|
165104
|
-
addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
|
|
165105
165122
|
}
|
|
165106
165123
|
function getTypeAnnotationPosition(decl) {
|
|
165107
165124
|
const closeParenToken = findChildOfKind(decl, 22 /* CloseParenToken */, file);
|
|
@@ -165162,6 +165179,303 @@ function provideInlayHints(context) {
|
|
|
165162
165179
|
);
|
|
165163
165180
|
});
|
|
165164
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
|
+
}
|
|
165165
165479
|
function isUndefined(name) {
|
|
165166
165480
|
return name === "undefined";
|
|
165167
165481
|
}
|
|
@@ -165327,6 +165641,11 @@ function getJsDocTagsFromDeclarations(declarations, checker) {
|
|
|
165327
165641
|
}
|
|
165328
165642
|
for (const tag of tags) {
|
|
165329
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
|
+
}
|
|
165330
165649
|
}
|
|
165331
165650
|
});
|
|
165332
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.
|
|
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
|
-
|
|
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 */:
|
|
@@ -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 &
|
|
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;
|
|
@@ -68273,6 +68280,10 @@ ${lanes.join("\n")}
|
|
|
68273
68280
|
}
|
|
68274
68281
|
return type;
|
|
68275
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
|
+
}
|
|
68276
68287
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
68277
68288
|
switch (expr.operatorToken.kind) {
|
|
68278
68289
|
case 64 /* EqualsToken */:
|
|
@@ -68320,6 +68331,12 @@ ${lanes.join("\n")}
|
|
|
68320
68331
|
if (isMatchingConstructorReference(right)) {
|
|
68321
68332
|
return narrowTypeByConstructor(type, operator, left, assumeTrue);
|
|
68322
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
|
+
}
|
|
68323
68340
|
break;
|
|
68324
68341
|
case 104 /* InstanceOfKeyword */:
|
|
68325
68342
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
@@ -164294,9 +164311,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164294
164311
|
displayParts
|
|
164295
164312
|
});
|
|
164296
164313
|
}
|
|
164297
|
-
function addTypeHints(
|
|
164314
|
+
function addTypeHints(hintText, position) {
|
|
164298
164315
|
result.push({
|
|
164299
|
-
text:
|
|
164316
|
+
text: typeof hintText === "string" ? `: ${hintText}` : "",
|
|
164317
|
+
displayParts: typeof hintText === "string" ? void 0 : [{ text: ": " }, ...hintText],
|
|
164300
164318
|
position,
|
|
164301
164319
|
kind: "Type" /* Type */,
|
|
164302
164320
|
whitespaceBefore: true
|
|
@@ -164334,13 +164352,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164334
164352
|
if (isModuleReferenceType(declarationType)) {
|
|
164335
164353
|
return;
|
|
164336
164354
|
}
|
|
164337
|
-
const
|
|
164338
|
-
if (
|
|
164339
|
-
const
|
|
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);
|
|
164340
164359
|
if (isVariableNameMatchesType) {
|
|
164341
164360
|
return;
|
|
164342
164361
|
}
|
|
164343
|
-
addTypeHints(
|
|
164362
|
+
addTypeHints(hints, decl.name.end);
|
|
164344
164363
|
}
|
|
164345
164364
|
}
|
|
164346
164365
|
function visitCallOrNewExpression(expr) {
|
|
@@ -164448,11 +164467,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164448
164467
|
if (isModuleReferenceType(returnType)) {
|
|
164449
164468
|
return;
|
|
164450
164469
|
}
|
|
164451
|
-
const
|
|
164452
|
-
if (
|
|
164453
|
-
|
|
164470
|
+
const hint = typeToInlayHintParts(returnType);
|
|
164471
|
+
if (hint) {
|
|
164472
|
+
addTypeHints(hint, getTypeAnnotationPosition(decl));
|
|
164454
164473
|
}
|
|
164455
|
-
addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
|
|
164456
164474
|
}
|
|
164457
164475
|
function getTypeAnnotationPosition(decl) {
|
|
164458
164476
|
const closeParenToken = findChildOfKind(decl, 22 /* CloseParenToken */, file);
|
|
@@ -164513,6 +164531,303 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164513
164531
|
);
|
|
164514
164532
|
});
|
|
164515
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
|
+
}
|
|
164516
164831
|
function isUndefined(name) {
|
|
164517
164832
|
return name === "undefined";
|
|
164518
164833
|
}
|
|
@@ -164532,12 +164847,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164532
164847
|
};
|
|
164533
164848
|
}
|
|
164534
164849
|
}
|
|
164535
|
-
var
|
|
164850
|
+
var leadingParameterNameCommentRegexFactory;
|
|
164536
164851
|
var init_inlayHints = __esm({
|
|
164537
164852
|
"src/services/inlayHints.ts"() {
|
|
164538
164853
|
"use strict";
|
|
164539
164854
|
init_ts4();
|
|
164540
|
-
maxTypeHintLength = 30;
|
|
164541
164855
|
leadingParameterNameCommentRegexFactory = (name) => {
|
|
164542
164856
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164543
164857
|
};
|
|
@@ -164600,6 +164914,11 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
164600
164914
|
}
|
|
164601
164915
|
for (const tag of tags) {
|
|
164602
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
|
+
}
|
|
164603
164922
|
}
|
|
164604
164923
|
});
|
|
164605
164924
|
return infos;
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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.
|
|
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": "
|
|
116
|
+
"gitHead": "2738fbf1e05b9429d03b5956ba0413d92f5b993c"
|
|
117
117
|
}
|