@typescript-deploys/pr-build 5.7.0-pr-57718-9 → 5.8.0-pr-57838-3
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 +580 -128
- package/lib/_tsserver.js +43 -7
- package/lib/lib.decorators.d.ts +13 -15
- package/lib/lib.es2020.bigint.d.ts +2 -0
- package/lib/lib.es5.d.ts +1 -1
- package/lib/lib.esnext.d.ts +1 -0
- package/lib/lib.esnext.promise.d.ts +34 -0
- package/lib/typescript.d.ts +13 -14
- package/lib/typescript.js +783 -217
- package/package.json +1 -1
- package/lib/cancellationToken.js +0 -90
package/lib/typescript.js
CHANGED
|
@@ -2277,8 +2277,8 @@ __export(typescript_exports, {
|
|
|
2277
2277
|
module.exports = __toCommonJS(typescript_exports);
|
|
2278
2278
|
|
|
2279
2279
|
// src/compiler/corePublic.ts
|
|
2280
|
-
var versionMajorMinor = "5.
|
|
2281
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2280
|
+
var versionMajorMinor = "5.8";
|
|
2281
|
+
var version = `${versionMajorMinor}.0-insiders.20241130`;
|
|
2282
2282
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2283
2283
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2284
2284
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6531,6 +6531,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6531
6531
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
|
6532
6532
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
|
6533
6533
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
|
6534
|
+
ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
|
|
6534
6535
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
6535
6536
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
6536
6537
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -7141,8 +7142,9 @@ var OuterExpressionKinds = /* @__PURE__ */ ((OuterExpressionKinds2) => {
|
|
|
7141
7142
|
OuterExpressionKinds2[OuterExpressionKinds2["NonNullAssertions"] = 4] = "NonNullAssertions";
|
|
7142
7143
|
OuterExpressionKinds2[OuterExpressionKinds2["PartiallyEmittedExpressions"] = 8] = "PartiallyEmittedExpressions";
|
|
7143
7144
|
OuterExpressionKinds2[OuterExpressionKinds2["ExpressionsWithTypeArguments"] = 16] = "ExpressionsWithTypeArguments";
|
|
7144
|
-
OuterExpressionKinds2[OuterExpressionKinds2["
|
|
7145
|
-
OuterExpressionKinds2[OuterExpressionKinds2["
|
|
7145
|
+
OuterExpressionKinds2[OuterExpressionKinds2["Satisfies"] = 32] = "Satisfies";
|
|
7146
|
+
OuterExpressionKinds2[OuterExpressionKinds2["Assertions"] = 38] = "Assertions";
|
|
7147
|
+
OuterExpressionKinds2[OuterExpressionKinds2["All"] = 63] = "All";
|
|
7146
7148
|
OuterExpressionKinds2[OuterExpressionKinds2["ExcludeJSDocTypeAssertion"] = -2147483648] = "ExcludeJSDocTypeAssertion";
|
|
7147
7149
|
return OuterExpressionKinds2;
|
|
7148
7150
|
})(OuterExpressionKinds || {});
|
|
@@ -18774,7 +18776,7 @@ function tryGetImportFromModuleSpecifier(node) {
|
|
|
18774
18776
|
}
|
|
18775
18777
|
}
|
|
18776
18778
|
function shouldRewriteModuleSpecifier(specifier, compilerOptions) {
|
|
18777
|
-
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier);
|
|
18779
|
+
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier) && hasTSFileExtension(specifier);
|
|
18778
18780
|
}
|
|
18779
18781
|
function getExternalModuleName(node) {
|
|
18780
18782
|
switch (node.kind) {
|
|
@@ -26552,6 +26554,8 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
26552
26554
|
node.colonToken = colonToken ?? createToken(59 /* ColonToken */);
|
|
26553
26555
|
node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
|
|
26554
26556
|
node.transformFlags |= propagateChildFlags(node.condition) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.whenTrue) | propagateChildFlags(node.colonToken) | propagateChildFlags(node.whenFalse);
|
|
26557
|
+
node.flowNodeWhenFalse = void 0;
|
|
26558
|
+
node.flowNodeWhenTrue = void 0;
|
|
26555
26559
|
return node;
|
|
26556
26560
|
}
|
|
26557
26561
|
function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
|
|
@@ -28355,7 +28359,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
28355
28359
|
function isIgnorableParen(node) {
|
|
28356
28360
|
return isParenthesizedExpression(node) && nodeIsSynthesized(node) && nodeIsSynthesized(getSourceMapRange(node)) && nodeIsSynthesized(getCommentRange(node)) && !some(getSyntheticLeadingComments(node)) && !some(getSyntheticTrailingComments(node));
|
|
28357
28361
|
}
|
|
28358
|
-
function restoreOuterExpressions(outerExpression, innerExpression, kinds =
|
|
28362
|
+
function restoreOuterExpressions(outerExpression, innerExpression, kinds = 63 /* All */) {
|
|
28359
28363
|
if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
|
|
28360
28364
|
return updateOuterExpression(
|
|
28361
28365
|
outerExpression,
|
|
@@ -28401,7 +28405,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
28401
28405
|
}
|
|
28402
28406
|
}
|
|
28403
28407
|
function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers = false) {
|
|
28404
|
-
const callee = skipOuterExpressions(expression,
|
|
28408
|
+
const callee = skipOuterExpressions(expression, 63 /* All */);
|
|
28405
28409
|
let thisArg;
|
|
28406
28410
|
let target;
|
|
28407
28411
|
if (isSuperProperty(callee)) {
|
|
@@ -31404,7 +31408,7 @@ function getJSDocTypeAssertionType(node) {
|
|
|
31404
31408
|
Debug.assertIsDefined(type);
|
|
31405
31409
|
return type;
|
|
31406
31410
|
}
|
|
31407
|
-
function isOuterExpression(node, kinds =
|
|
31411
|
+
function isOuterExpression(node, kinds = 63 /* All */) {
|
|
31408
31412
|
switch (node.kind) {
|
|
31409
31413
|
case 217 /* ParenthesizedExpression */:
|
|
31410
31414
|
if (kinds & -2147483648 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
|
|
@@ -31413,8 +31417,9 @@ function isOuterExpression(node, kinds = 31 /* All */) {
|
|
|
31413
31417
|
return (kinds & 1 /* Parentheses */) !== 0;
|
|
31414
31418
|
case 216 /* TypeAssertionExpression */:
|
|
31415
31419
|
case 234 /* AsExpression */:
|
|
31416
|
-
case 238 /* SatisfiesExpression */:
|
|
31417
31420
|
return (kinds & 2 /* TypeAssertions */) !== 0;
|
|
31421
|
+
case 238 /* SatisfiesExpression */:
|
|
31422
|
+
return (kinds & (2 /* TypeAssertions */ | 32 /* Satisfies */)) !== 0;
|
|
31418
31423
|
case 233 /* ExpressionWithTypeArguments */:
|
|
31419
31424
|
return (kinds & 16 /* ExpressionsWithTypeArguments */) !== 0;
|
|
31420
31425
|
case 235 /* NonNullExpression */:
|
|
@@ -31424,13 +31429,13 @@ function isOuterExpression(node, kinds = 31 /* All */) {
|
|
|
31424
31429
|
}
|
|
31425
31430
|
return false;
|
|
31426
31431
|
}
|
|
31427
|
-
function skipOuterExpressions(node, kinds =
|
|
31432
|
+
function skipOuterExpressions(node, kinds = 63 /* All */) {
|
|
31428
31433
|
while (isOuterExpression(node, kinds)) {
|
|
31429
31434
|
node = node.expression;
|
|
31430
31435
|
}
|
|
31431
31436
|
return node;
|
|
31432
31437
|
}
|
|
31433
|
-
function walkUpOuterExpressions(node, kinds =
|
|
31438
|
+
function walkUpOuterExpressions(node, kinds = 63 /* All */) {
|
|
31434
31439
|
let parent2 = node.parent;
|
|
31435
31440
|
while (isOuterExpression(parent2, kinds)) {
|
|
31436
31441
|
parent2 = parent2.parent;
|
|
@@ -40351,6 +40356,7 @@ var libEntries = [
|
|
|
40351
40356
|
["esnext.regexp", "lib.es2024.regexp.d.ts"],
|
|
40352
40357
|
["esnext.string", "lib.es2024.string.d.ts"],
|
|
40353
40358
|
["esnext.iterator", "lib.esnext.iterator.d.ts"],
|
|
40359
|
+
["esnext.promise", "lib.esnext.promise.d.ts"],
|
|
40354
40360
|
["decorators", "lib.decorators.d.ts"],
|
|
40355
40361
|
["decorators.legacy", "lib.decorators.legacy.d.ts"]
|
|
40356
40362
|
];
|
|
@@ -46411,6 +46417,7 @@ function createBinder() {
|
|
|
46411
46417
|
var preSwitchCaseFlow;
|
|
46412
46418
|
var activeLabelList;
|
|
46413
46419
|
var hasExplicitReturn;
|
|
46420
|
+
var inReturnPosition;
|
|
46414
46421
|
var hasFlowEffects;
|
|
46415
46422
|
var emitFlags;
|
|
46416
46423
|
var inStrictMode;
|
|
@@ -46483,6 +46490,7 @@ function createBinder() {
|
|
|
46483
46490
|
currentExceptionTarget = void 0;
|
|
46484
46491
|
activeLabelList = void 0;
|
|
46485
46492
|
hasExplicitReturn = false;
|
|
46493
|
+
inReturnPosition = false;
|
|
46486
46494
|
hasFlowEffects = false;
|
|
46487
46495
|
inAssignmentPattern = false;
|
|
46488
46496
|
emitFlags = 0 /* None */;
|
|
@@ -46719,6 +46727,8 @@ function createBinder() {
|
|
|
46719
46727
|
const saveContainer = container;
|
|
46720
46728
|
const saveThisParentContainer = thisParentContainer;
|
|
46721
46729
|
const savedBlockScopeContainer = blockScopeContainer;
|
|
46730
|
+
const savedInReturnPosition = inReturnPosition;
|
|
46731
|
+
if (node.kind === 219 /* ArrowFunction */ && node.body.kind !== 241 /* Block */) inReturnPosition = true;
|
|
46722
46732
|
if (containerFlags & 1 /* IsContainer */) {
|
|
46723
46733
|
if (node.kind !== 219 /* ArrowFunction */) {
|
|
46724
46734
|
thisParentContainer = container;
|
|
@@ -46796,6 +46806,7 @@ function createBinder() {
|
|
|
46796
46806
|
} else {
|
|
46797
46807
|
bindChildren(node);
|
|
46798
46808
|
}
|
|
46809
|
+
inReturnPosition = savedInReturnPosition;
|
|
46799
46810
|
container = saveContainer;
|
|
46800
46811
|
thisParentContainer = saveThisParentContainer;
|
|
46801
46812
|
blockScopeContainer = savedBlockScopeContainer;
|
|
@@ -47247,7 +47258,10 @@ function createBinder() {
|
|
|
47247
47258
|
currentFlow = finishFlowLabel(postIfLabel);
|
|
47248
47259
|
}
|
|
47249
47260
|
function bindReturnOrThrow(node) {
|
|
47261
|
+
const savedInReturnPosition = inReturnPosition;
|
|
47262
|
+
inReturnPosition = true;
|
|
47250
47263
|
bind(node.expression);
|
|
47264
|
+
inReturnPosition = savedInReturnPosition;
|
|
47251
47265
|
if (node.kind === 253 /* ReturnStatement */) {
|
|
47252
47266
|
hasExplicitReturn = true;
|
|
47253
47267
|
if (currentReturnTarget) {
|
|
@@ -47608,10 +47622,16 @@ function createBinder() {
|
|
|
47608
47622
|
hasFlowEffects = false;
|
|
47609
47623
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
47610
47624
|
currentFlow = finishFlowLabel(trueLabel);
|
|
47625
|
+
if (inReturnPosition) {
|
|
47626
|
+
node.flowNodeWhenTrue = currentFlow;
|
|
47627
|
+
}
|
|
47611
47628
|
bind(node.questionToken);
|
|
47612
47629
|
bind(node.whenTrue);
|
|
47613
47630
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
47614
47631
|
currentFlow = finishFlowLabel(falseLabel);
|
|
47632
|
+
if (inReturnPosition) {
|
|
47633
|
+
node.flowNodeWhenFalse = currentFlow;
|
|
47634
|
+
}
|
|
47615
47635
|
bind(node.colonToken);
|
|
47616
47636
|
bind(node.whenFalse);
|
|
47617
47637
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
@@ -50768,8 +50788,8 @@ function createTypeChecker(host) {
|
|
|
50768
50788
|
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
|
|
50769
50789
|
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
|
|
50770
50790
|
},
|
|
50771
|
-
writeType: (type, enclosingDeclaration, flags, writer) => {
|
|
50772
|
-
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
|
|
50791
|
+
writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
|
|
50792
|
+
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
|
|
50773
50793
|
},
|
|
50774
50794
|
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
|
|
50775
50795
|
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
|
|
@@ -51555,6 +51575,7 @@ function createTypeChecker(host) {
|
|
|
51555
51575
|
[".jsx", ".jsx"],
|
|
51556
51576
|
[".json", ".json"]
|
|
51557
51577
|
];
|
|
51578
|
+
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
|
51558
51579
|
initializeTypeChecker();
|
|
51559
51580
|
return checker;
|
|
51560
51581
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
|
@@ -52418,9 +52439,9 @@ function createTypeChecker(host) {
|
|
|
52418
52439
|
const containerKind = grandparent.parent.kind;
|
|
52419
52440
|
if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) {
|
|
52420
52441
|
error2(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name));
|
|
52421
|
-
} else if (
|
|
52442
|
+
} else if (isClassLike(grandparent.parent) && heritageKind === 96 /* ExtendsKeyword */) {
|
|
52422
52443
|
error2(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name));
|
|
52423
|
-
} else if (
|
|
52444
|
+
} else if (isClassLike(grandparent.parent) && heritageKind === 119 /* ImplementsKeyword */) {
|
|
52424
52445
|
error2(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name));
|
|
52425
52446
|
}
|
|
52426
52447
|
} else {
|
|
@@ -54293,7 +54314,7 @@ function createTypeChecker(host) {
|
|
|
54293
54314
|
const links = getSymbolLinks(symbol);
|
|
54294
54315
|
const cache = links.accessibleChainCache || (links.accessibleChainCache = /* @__PURE__ */ new Map());
|
|
54295
54316
|
const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, ___, node) => node);
|
|
54296
|
-
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation
|
|
54317
|
+
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation ? getNodeId(firstRelevantLocation) : 0}|${meaning}`;
|
|
54297
54318
|
if (cache.has(key)) {
|
|
54298
54319
|
return cache.get(key);
|
|
54299
54320
|
}
|
|
@@ -54690,14 +54711,18 @@ function createTypeChecker(host) {
|
|
|
54690
54711
|
return writer2;
|
|
54691
54712
|
}
|
|
54692
54713
|
}
|
|
54693
|
-
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
|
|
54694
|
-
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation
|
|
54714
|
+
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
|
|
54715
|
+
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */ || verbosityLevel !== void 0;
|
|
54695
54716
|
const typeNode = nodeBuilder.typeToTypeNode(
|
|
54696
54717
|
type,
|
|
54697
54718
|
enclosingDeclaration,
|
|
54698
|
-
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0
|
|
54719
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
|
|
54699
54720
|
/*internalFlags*/
|
|
54700
|
-
void 0
|
|
54721
|
+
void 0,
|
|
54722
|
+
/*tracker*/
|
|
54723
|
+
void 0,
|
|
54724
|
+
verbosityLevel,
|
|
54725
|
+
out
|
|
54701
54726
|
);
|
|
54702
54727
|
if (typeNode === void 0) return Debug.fail("should always get typenode");
|
|
54703
54728
|
const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
|
|
@@ -54837,12 +54862,7 @@ function createTypeChecker(host) {
|
|
|
54837
54862
|
enterNewScope(context, node) {
|
|
54838
54863
|
if (isFunctionLike(node) || isJSDocSignature(node)) {
|
|
54839
54864
|
const signature = getSignatureFromDeclaration(node);
|
|
54840
|
-
|
|
54841
|
-
signature,
|
|
54842
|
-
/*skipUnionExpanding*/
|
|
54843
|
-
true
|
|
54844
|
-
)[0];
|
|
54845
|
-
return enterNewScope(context, node, expandedParams, signature.typeParameters);
|
|
54865
|
+
return enterNewScope(context, node, signature.parameters, signature.typeParameters);
|
|
54846
54866
|
} else {
|
|
54847
54867
|
const typeParameters = isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
|
|
54848
54868
|
return enterNewScope(
|
|
@@ -54929,31 +54949,127 @@ function createTypeChecker(host) {
|
|
|
54929
54949
|
};
|
|
54930
54950
|
return {
|
|
54931
54951
|
syntacticBuilderResolver,
|
|
54932
|
-
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
54933
|
-
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54934
|
-
|
|
54935
|
-
|
|
54936
|
-
|
|
54937
|
-
|
|
54938
|
-
|
|
54939
|
-
|
|
54940
|
-
|
|
54941
|
-
|
|
54942
|
-
)
|
|
54943
|
-
|
|
54944
|
-
|
|
54945
|
-
|
|
54946
|
-
|
|
54947
|
-
|
|
54948
|
-
|
|
54949
|
-
|
|
54950
|
-
)
|
|
54951
|
-
|
|
54952
|
-
|
|
54953
|
-
|
|
54954
|
-
|
|
54955
|
-
|
|
54956
|
-
|
|
54952
|
+
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
|
|
54953
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54954
|
+
enclosingDeclaration,
|
|
54955
|
+
flags,
|
|
54956
|
+
internalFlags,
|
|
54957
|
+
tracker,
|
|
54958
|
+
/*verbosityLevel*/
|
|
54959
|
+
void 0,
|
|
54960
|
+
(context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
|
|
54961
|
+
),
|
|
54962
|
+
serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54963
|
+
enclosingDeclaration,
|
|
54964
|
+
flags,
|
|
54965
|
+
internalFlags,
|
|
54966
|
+
tracker,
|
|
54967
|
+
/*verbosityLevel*/
|
|
54968
|
+
void 0,
|
|
54969
|
+
(context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
|
|
54970
|
+
),
|
|
54971
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54972
|
+
enclosingDeclaration,
|
|
54973
|
+
flags,
|
|
54974
|
+
internalFlags,
|
|
54975
|
+
tracker,
|
|
54976
|
+
/*verbosityLevel*/
|
|
54977
|
+
void 0,
|
|
54978
|
+
(context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
|
|
54979
|
+
),
|
|
54980
|
+
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54981
|
+
enclosingDeclaration,
|
|
54982
|
+
flags,
|
|
54983
|
+
internalFlags,
|
|
54984
|
+
tracker,
|
|
54985
|
+
/*verbosityLevel*/
|
|
54986
|
+
void 0,
|
|
54987
|
+
(context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
|
|
54988
|
+
),
|
|
54989
|
+
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
54990
|
+
enclosingDeclaration,
|
|
54991
|
+
flags,
|
|
54992
|
+
internalFlags,
|
|
54993
|
+
tracker,
|
|
54994
|
+
/*verbosityLevel*/
|
|
54995
|
+
void 0,
|
|
54996
|
+
(context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
54997
|
+
indexInfo,
|
|
54998
|
+
context,
|
|
54999
|
+
/*typeNode*/
|
|
55000
|
+
void 0
|
|
55001
|
+
)
|
|
55002
|
+
),
|
|
55003
|
+
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55004
|
+
enclosingDeclaration,
|
|
55005
|
+
flags,
|
|
55006
|
+
internalFlags,
|
|
55007
|
+
tracker,
|
|
55008
|
+
/*verbosityLevel*/
|
|
55009
|
+
void 0,
|
|
55010
|
+
(context) => signatureToSignatureDeclarationHelper(signature, kind, context)
|
|
55011
|
+
),
|
|
55012
|
+
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55013
|
+
enclosingDeclaration,
|
|
55014
|
+
flags,
|
|
55015
|
+
internalFlags,
|
|
55016
|
+
tracker,
|
|
55017
|
+
/*verbosityLevel*/
|
|
55018
|
+
void 0,
|
|
55019
|
+
(context) => symbolToName(
|
|
55020
|
+
symbol,
|
|
55021
|
+
context,
|
|
55022
|
+
meaning,
|
|
55023
|
+
/*expectsIdentifier*/
|
|
55024
|
+
false
|
|
55025
|
+
)
|
|
55026
|
+
),
|
|
55027
|
+
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55028
|
+
enclosingDeclaration,
|
|
55029
|
+
flags,
|
|
55030
|
+
internalFlags,
|
|
55031
|
+
tracker,
|
|
55032
|
+
/*verbosityLevel*/
|
|
55033
|
+
void 0,
|
|
55034
|
+
(context) => symbolToExpression(symbol, context, meaning)
|
|
55035
|
+
),
|
|
55036
|
+
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55037
|
+
enclosingDeclaration,
|
|
55038
|
+
flags,
|
|
55039
|
+
internalFlags,
|
|
55040
|
+
tracker,
|
|
55041
|
+
/*verbosityLevel*/
|
|
55042
|
+
void 0,
|
|
55043
|
+
(context) => typeParametersToTypeParameterDeclarations(symbol, context)
|
|
55044
|
+
),
|
|
55045
|
+
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55046
|
+
enclosingDeclaration,
|
|
55047
|
+
flags,
|
|
55048
|
+
internalFlags,
|
|
55049
|
+
tracker,
|
|
55050
|
+
/*verbosityLevel*/
|
|
55051
|
+
void 0,
|
|
55052
|
+
(context) => symbolToParameterDeclaration(symbol, context)
|
|
55053
|
+
),
|
|
55054
|
+
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel) => withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context)),
|
|
55055
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55056
|
+
enclosingDeclaration,
|
|
55057
|
+
flags,
|
|
55058
|
+
internalFlags,
|
|
55059
|
+
tracker,
|
|
55060
|
+
/*verbosityLevel*/
|
|
55061
|
+
void 0,
|
|
55062
|
+
(context) => symbolTableToDeclarationStatements(symbolTable, context)
|
|
55063
|
+
),
|
|
55064
|
+
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext2(
|
|
55065
|
+
enclosingDeclaration,
|
|
55066
|
+
flags,
|
|
55067
|
+
internalFlags,
|
|
55068
|
+
tracker,
|
|
55069
|
+
/*verbosityLevel*/
|
|
55070
|
+
void 0,
|
|
55071
|
+
(context) => symbolToNode(symbol, context, meaning)
|
|
55072
|
+
)
|
|
54957
55073
|
};
|
|
54958
55074
|
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
|
54959
55075
|
const type = getTypeFromTypeNodeWithoutContext(node);
|
|
@@ -54995,7 +55111,7 @@ function createTypeChecker(host) {
|
|
|
54995
55111
|
}
|
|
54996
55112
|
return symbolToExpression(symbol, context, meaning);
|
|
54997
55113
|
}
|
|
54998
|
-
function withContext2(enclosingDeclaration, flags, internalFlags, tracker, cb) {
|
|
55114
|
+
function withContext2(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
|
|
54999
55115
|
const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
|
|
55000
55116
|
const context = {
|
|
55001
55117
|
enclosingDeclaration,
|
|
@@ -55003,6 +55119,7 @@ function createTypeChecker(host) {
|
|
|
55003
55119
|
flags: flags || 0 /* None */,
|
|
55004
55120
|
internalFlags: internalFlags || 0 /* None */,
|
|
55005
55121
|
tracker: void 0,
|
|
55122
|
+
unfoldDepth: verbosityLevel ?? -1,
|
|
55006
55123
|
encounteredError: false,
|
|
55007
55124
|
suppressReportInferenceFallback: false,
|
|
55008
55125
|
reportedDiagnostic: false,
|
|
@@ -55024,13 +55141,18 @@ function createTypeChecker(host) {
|
|
|
55024
55141
|
typeParameterNamesByText: void 0,
|
|
55025
55142
|
typeParameterNamesByTextNextNameCount: void 0,
|
|
55026
55143
|
enclosingSymbolTypes: /* @__PURE__ */ new Map(),
|
|
55027
|
-
mapper: void 0
|
|
55144
|
+
mapper: void 0,
|
|
55145
|
+
depth: 0,
|
|
55146
|
+
couldUnfoldMore: false
|
|
55028
55147
|
};
|
|
55029
55148
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
|
55030
55149
|
const resultingNode = cb(context);
|
|
55031
55150
|
if (context.truncating && context.flags & 1 /* NoTruncation */) {
|
|
55032
55151
|
context.tracker.reportTruncationError();
|
|
55033
55152
|
}
|
|
55153
|
+
if (out) {
|
|
55154
|
+
out.couldUnfoldMore = context.couldUnfoldMore;
|
|
55155
|
+
}
|
|
55034
55156
|
return context.encounteredError ? void 0 : resultingNode;
|
|
55035
55157
|
}
|
|
55036
55158
|
function addSymbolTypeToContext(context, symbol, type) {
|
|
@@ -55049,16 +55171,36 @@ function createTypeChecker(host) {
|
|
|
55049
55171
|
function saveRestoreFlags(context) {
|
|
55050
55172
|
const flags = context.flags;
|
|
55051
55173
|
const internalFlags = context.internalFlags;
|
|
55174
|
+
const depth = context.depth;
|
|
55052
55175
|
return restore;
|
|
55053
55176
|
function restore() {
|
|
55054
55177
|
context.flags = flags;
|
|
55055
55178
|
context.internalFlags = internalFlags;
|
|
55179
|
+
context.depth = depth;
|
|
55056
55180
|
}
|
|
55057
55181
|
}
|
|
55058
55182
|
function checkTruncationLength(context) {
|
|
55059
55183
|
if (context.truncating) return context.truncating;
|
|
55060
55184
|
return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
|
|
55061
55185
|
}
|
|
55186
|
+
function couldUnfoldType(type, context) {
|
|
55187
|
+
var _a;
|
|
55188
|
+
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
|
55189
|
+
return false;
|
|
55190
|
+
}
|
|
55191
|
+
return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
|
|
55192
|
+
}
|
|
55193
|
+
function canUnfoldType(type, context) {
|
|
55194
|
+
var _a;
|
|
55195
|
+
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
|
55196
|
+
return false;
|
|
55197
|
+
}
|
|
55198
|
+
const result = context.depth < context.unfoldDepth;
|
|
55199
|
+
if (!result) {
|
|
55200
|
+
context.couldUnfoldMore = true;
|
|
55201
|
+
}
|
|
55202
|
+
return result;
|
|
55203
|
+
}
|
|
55062
55204
|
function typeToTypeNodeHelper(type, context) {
|
|
55063
55205
|
const restoreFlags = saveRestoreFlags(context);
|
|
55064
55206
|
const typeNode = typeToTypeNodeWorker(type, context);
|
|
@@ -55206,16 +55348,27 @@ function createTypeChecker(host) {
|
|
|
55206
55348
|
return factory.createThisTypeNode();
|
|
55207
55349
|
}
|
|
55208
55350
|
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
|
|
55209
|
-
|
|
55210
|
-
|
|
55211
|
-
|
|
55212
|
-
|
|
55351
|
+
if (!canUnfoldType(type, context)) {
|
|
55352
|
+
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
|
|
55353
|
+
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
|
|
55354
|
+
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
|
|
55355
|
+
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
|
55356
|
+
}
|
|
55357
|
+
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
|
55213
55358
|
}
|
|
55214
|
-
|
|
55359
|
+
context.depth += 1;
|
|
55215
55360
|
}
|
|
55216
55361
|
const objectFlags = getObjectFlags(type);
|
|
55217
55362
|
if (objectFlags & 4 /* Reference */) {
|
|
55218
55363
|
Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
55364
|
+
if (canUnfoldType(type, context)) {
|
|
55365
|
+
context.depth += 1;
|
|
55366
|
+
return createAnonymousTypeNode(
|
|
55367
|
+
type,
|
|
55368
|
+
/*forceClassExpansion*/
|
|
55369
|
+
true
|
|
55370
|
+
);
|
|
55371
|
+
}
|
|
55219
55372
|
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
|
|
55220
55373
|
}
|
|
55221
55374
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
@@ -55245,6 +55398,14 @@ function createTypeChecker(host) {
|
|
|
55245
55398
|
void 0
|
|
55246
55399
|
);
|
|
55247
55400
|
}
|
|
55401
|
+
if (objectFlags & 3 /* ClassOrInterface */ && canUnfoldType(type, context)) {
|
|
55402
|
+
context.depth += 1;
|
|
55403
|
+
return createAnonymousTypeNode(
|
|
55404
|
+
type,
|
|
55405
|
+
/*forceClassExpansion*/
|
|
55406
|
+
true
|
|
55407
|
+
);
|
|
55408
|
+
}
|
|
55248
55409
|
if (type.symbol) {
|
|
55249
55410
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
55250
55411
|
}
|
|
@@ -55448,7 +55609,7 @@ function createTypeChecker(host) {
|
|
|
55448
55609
|
}
|
|
55449
55610
|
return result;
|
|
55450
55611
|
}
|
|
55451
|
-
function createAnonymousTypeNode(type2) {
|
|
55612
|
+
function createAnonymousTypeNode(type2, forceClassExpansion = false) {
|
|
55452
55613
|
var _a2, _b2;
|
|
55453
55614
|
const typeId = type2.id;
|
|
55454
55615
|
const symbol = type2.symbol;
|
|
@@ -55471,7 +55632,7 @@ function createTypeChecker(host) {
|
|
|
55471
55632
|
const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
|
|
55472
55633
|
if (isJSConstructor(symbol.valueDeclaration)) {
|
|
55473
55634
|
return symbolToTypeNode(symbol, context, isInstanceType);
|
|
55474
|
-
} else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
55635
|
+
} else if (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
55475
55636
|
symbol,
|
|
55476
55637
|
context.enclosingDeclaration,
|
|
55477
55638
|
isInstanceType,
|
|
@@ -55515,7 +55676,7 @@ function createTypeChecker(host) {
|
|
|
55515
55676
|
if (id && !context.symbolDepth) {
|
|
55516
55677
|
context.symbolDepth = /* @__PURE__ */ new Map();
|
|
55517
55678
|
}
|
|
55518
|
-
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
55679
|
+
const links = context.unfoldDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
55519
55680
|
const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
|
|
55520
55681
|
if (links) {
|
|
55521
55682
|
links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
|
|
@@ -56430,7 +56591,7 @@ function createTypeChecker(host) {
|
|
|
56430
56591
|
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
|
56431
56592
|
}
|
|
56432
56593
|
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
|
|
56433
|
-
return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
56594
|
+
return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
56434
56595
|
}
|
|
56435
56596
|
function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
|
|
56436
56597
|
const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
|
|
@@ -57064,7 +57225,7 @@ function createTypeChecker(host) {
|
|
|
57064
57225
|
let result;
|
|
57065
57226
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
|
57066
57227
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
57067
|
-
if (decl) {
|
|
57228
|
+
if (!couldUnfoldType(type, context) && decl) {
|
|
57068
57229
|
if (isAccessor(decl)) {
|
|
57069
57230
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
|
57070
57231
|
} else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
|
|
@@ -59859,7 +60020,6 @@ function createTypeChecker(host) {
|
|
|
59859
60020
|
const flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0);
|
|
59860
60021
|
const symbol = createSymbol(flags, text);
|
|
59861
60022
|
symbol.links.type = getTypeFromBindingElement(e, includePatternInType, reportErrors2);
|
|
59862
|
-
symbol.links.bindingElement = e;
|
|
59863
60023
|
members.set(symbol.escapedName, symbol);
|
|
59864
60024
|
});
|
|
59865
60025
|
const result = createAnonymousType(
|
|
@@ -63787,11 +63947,14 @@ function createTypeChecker(host) {
|
|
|
63787
63947
|
function isNoInferType(type) {
|
|
63788
63948
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
63789
63949
|
}
|
|
63790
|
-
function
|
|
63791
|
-
return
|
|
63950
|
+
function isNarrowingSubstitutionType(type) {
|
|
63951
|
+
return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /* IsNarrowingType */);
|
|
63792
63952
|
}
|
|
63793
|
-
function
|
|
63794
|
-
|
|
63953
|
+
function getSubstitutionType(baseType, constraint, isNarrowed) {
|
|
63954
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
|
|
63955
|
+
}
|
|
63956
|
+
function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
|
|
63957
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
|
|
63795
63958
|
const cached = substitutionTypes.get(id);
|
|
63796
63959
|
if (cached) {
|
|
63797
63960
|
return cached;
|
|
@@ -63799,6 +63962,9 @@ function createTypeChecker(host) {
|
|
|
63799
63962
|
const result = createType(33554432 /* Substitution */);
|
|
63800
63963
|
result.baseType = baseType;
|
|
63801
63964
|
result.constraint = constraint;
|
|
63965
|
+
if (isNarrowed) {
|
|
63966
|
+
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
|
63967
|
+
}
|
|
63802
63968
|
substitutionTypes.set(id, result);
|
|
63803
63969
|
return result;
|
|
63804
63970
|
}
|
|
@@ -66001,7 +66167,7 @@ function createTypeChecker(host) {
|
|
|
66001
66167
|
function isDeferredType(type, checkTuples) {
|
|
66002
66168
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
66003
66169
|
}
|
|
66004
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
66170
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing) {
|
|
66005
66171
|
let result;
|
|
66006
66172
|
let extraTypes;
|
|
66007
66173
|
let tailCount = 0;
|
|
@@ -66018,10 +66184,11 @@ function createTypeChecker(host) {
|
|
|
66018
66184
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
66019
66185
|
return wildcardType;
|
|
66020
66186
|
}
|
|
66187
|
+
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
|
66021
66188
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
|
66022
66189
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
|
66023
66190
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
|
66024
|
-
const checkTypeDeferred = isDeferredType(
|
|
66191
|
+
const checkTypeDeferred = isDeferredType(effectiveCheckType, checkTuples);
|
|
66025
66192
|
let combinedMapper;
|
|
66026
66193
|
if (root.inferTypeParameters) {
|
|
66027
66194
|
const context = createInferenceContext(
|
|
@@ -66040,8 +66207,8 @@ function createTypeChecker(host) {
|
|
|
66040
66207
|
}
|
|
66041
66208
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
66042
66209
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
66043
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
|
66044
|
-
if (
|
|
66210
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (effectiveCheckType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(effectiveCheckType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
66211
|
+
if (effectiveCheckType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(effectiveCheckType)))) {
|
|
66045
66212
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
66046
66213
|
}
|
|
66047
66214
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -66058,7 +66225,7 @@ function createTypeChecker(host) {
|
|
|
66058
66225
|
result = instantiateType(falseType2, mapper);
|
|
66059
66226
|
break;
|
|
66060
66227
|
}
|
|
66061
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
|
66228
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(effectiveCheckType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
66062
66229
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
66063
66230
|
const trueMapper = combinedMapper || mapper;
|
|
66064
66231
|
if (canTailRecurse(trueType2, trueMapper)) {
|
|
@@ -67024,8 +67191,39 @@ function createTypeChecker(host) {
|
|
|
67024
67191
|
if (!result) {
|
|
67025
67192
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
67026
67193
|
const checkType = root.checkType;
|
|
67027
|
-
|
|
67028
|
-
|
|
67194
|
+
let distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
|
67195
|
+
let narrowingBaseType;
|
|
67196
|
+
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
|
|
67197
|
+
if (forNarrowing) {
|
|
67198
|
+
narrowingBaseType = distributionType.baseType;
|
|
67199
|
+
distributionType = getReducedType(distributionType.constraint);
|
|
67200
|
+
}
|
|
67201
|
+
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
67202
|
+
if (narrowingBaseType) {
|
|
67203
|
+
result = mapTypeToIntersection(
|
|
67204
|
+
distributionType,
|
|
67205
|
+
(t) => getConditionalType(
|
|
67206
|
+
root,
|
|
67207
|
+
prependTypeMapping(checkType, getSubstitutionType(
|
|
67208
|
+
narrowingBaseType,
|
|
67209
|
+
t,
|
|
67210
|
+
/*isNarrowed*/
|
|
67211
|
+
true
|
|
67212
|
+
), newMapper),
|
|
67213
|
+
forConstraint,
|
|
67214
|
+
/*aliasSymbol*/
|
|
67215
|
+
void 0,
|
|
67216
|
+
/*aliasTypeArguments*/
|
|
67217
|
+
void 0,
|
|
67218
|
+
forNarrowing
|
|
67219
|
+
)
|
|
67220
|
+
);
|
|
67221
|
+
} else {
|
|
67222
|
+
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
|
67223
|
+
}
|
|
67224
|
+
} else {
|
|
67225
|
+
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
67226
|
+
}
|
|
67029
67227
|
root.instantiations.set(id, result);
|
|
67030
67228
|
}
|
|
67031
67229
|
return result;
|
|
@@ -68168,10 +68366,12 @@ function createTypeChecker(host) {
|
|
|
68168
68366
|
function shouldNormalizeIntersection(type) {
|
|
68169
68367
|
let hasInstantiable = false;
|
|
68170
68368
|
let hasNullableOrEmpty = false;
|
|
68369
|
+
let hasSubstitution = false;
|
|
68171
68370
|
for (const t of type.types) {
|
|
68172
68371
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
68173
68372
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
68174
|
-
|
|
68373
|
+
hasSubstitution || (hasSubstitution = isNarrowingSubstitutionType(t));
|
|
68374
|
+
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
|
68175
68375
|
}
|
|
68176
68376
|
return false;
|
|
68177
68377
|
}
|
|
@@ -69263,15 +69463,15 @@ function createTypeChecker(host) {
|
|
|
69263
69463
|
}
|
|
69264
69464
|
return result2;
|
|
69265
69465
|
}
|
|
69266
|
-
function getApparentMappedTypeKeys(nameType,
|
|
69267
|
-
const modifiersType = getApparentType(getModifiersTypeFromMappedType(
|
|
69466
|
+
function getApparentMappedTypeKeys(nameType, mappedType) {
|
|
69467
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(mappedType));
|
|
69268
69468
|
const mappedKeys = [];
|
|
69269
69469
|
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
69270
69470
|
modifiersType,
|
|
69271
69471
|
8576 /* StringOrNumberLiteralOrUnique */,
|
|
69272
69472
|
/*stringsOnly*/
|
|
69273
69473
|
false,
|
|
69274
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(
|
|
69474
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), t)))
|
|
69275
69475
|
);
|
|
69276
69476
|
return getUnionType(mappedKeys);
|
|
69277
69477
|
}
|
|
@@ -69636,7 +69836,15 @@ function createTypeChecker(host) {
|
|
|
69636
69836
|
if (isDeferredMappedIndex) {
|
|
69637
69837
|
const mappedType = source2.type;
|
|
69638
69838
|
const nameType = getNameTypeFromMappedType(mappedType);
|
|
69639
|
-
|
|
69839
|
+
let sourceMappedKeys;
|
|
69840
|
+
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType)) {
|
|
69841
|
+
sourceMappedKeys = getApparentMappedTypeKeys(nameType, mappedType);
|
|
69842
|
+
if (sourceMappedKeys.flags & 131072 /* Never */) {
|
|
69843
|
+
sourceMappedKeys = stringNumberSymbolType;
|
|
69844
|
+
}
|
|
69845
|
+
} else {
|
|
69846
|
+
sourceMappedKeys = nameType || getConstraintTypeFromMappedType(mappedType);
|
|
69847
|
+
}
|
|
69640
69848
|
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
69641
69849
|
return result2;
|
|
69642
69850
|
}
|
|
@@ -73330,6 +73538,18 @@ function createTypeChecker(host) {
|
|
|
73330
73538
|
}
|
|
73331
73539
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
73332
73540
|
}
|
|
73541
|
+
function mapTypeToIntersection(type, mapper) {
|
|
73542
|
+
if (type.flags & 131072 /* Never */) {
|
|
73543
|
+
return type;
|
|
73544
|
+
}
|
|
73545
|
+
if (!(type.flags & 1048576 /* Union */)) {
|
|
73546
|
+
return mapper(type);
|
|
73547
|
+
}
|
|
73548
|
+
const origin = type.origin;
|
|
73549
|
+
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
|
73550
|
+
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
|
73551
|
+
return getIntersectionType(mappedTypes);
|
|
73552
|
+
}
|
|
73333
73553
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
73334
73554
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
73335
73555
|
}
|
|
@@ -74912,11 +75132,11 @@ function createTypeChecker(host) {
|
|
|
74912
75132
|
));
|
|
74913
75133
|
return contextualType && !isGenericType(contextualType);
|
|
74914
75134
|
}
|
|
74915
|
-
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
75135
|
+
function getNarrowableTypeForReference(type, reference, checkMode, forReturnTypeNarrowing) {
|
|
74916
75136
|
if (isNoInferType(type)) {
|
|
74917
75137
|
type = type.baseType;
|
|
74918
75138
|
}
|
|
74919
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
75139
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (forReturnTypeNarrowing || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
74920
75140
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
74921
75141
|
}
|
|
74922
75142
|
function isExportOrExportExpression(location) {
|
|
@@ -75069,7 +75289,7 @@ function createTypeChecker(host) {
|
|
|
75069
75289
|
jsxFactorySym = resolveName(
|
|
75070
75290
|
jsxFactoryLocation,
|
|
75071
75291
|
jsxFactoryNamespace,
|
|
75072
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
75292
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
75073
75293
|
jsxFactoryRefErr,
|
|
75074
75294
|
/*isUse*/
|
|
75075
75295
|
true
|
|
@@ -75088,7 +75308,7 @@ function createTypeChecker(host) {
|
|
|
75088
75308
|
resolveName(
|
|
75089
75309
|
jsxFactoryLocation,
|
|
75090
75310
|
localJsxNamespace,
|
|
75091
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
75311
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
75092
75312
|
jsxFactoryRefErr,
|
|
75093
75313
|
/*isUse*/
|
|
75094
75314
|
true
|
|
@@ -76041,9 +76261,16 @@ function createTypeChecker(host) {
|
|
|
76041
76261
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
76042
76262
|
const func = getContainingFunction(node);
|
|
76043
76263
|
if (func) {
|
|
76264
|
+
const functionFlags = getFunctionFlags(func);
|
|
76265
|
+
const links = getNodeLinks(node);
|
|
76266
|
+
if (links.contextualReturnType) {
|
|
76267
|
+
if (functionFlags & 2 /* Async */) {
|
|
76268
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76269
|
+
}
|
|
76270
|
+
return links.contextualReturnType;
|
|
76271
|
+
}
|
|
76044
76272
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
76045
76273
|
if (contextualReturnType) {
|
|
76046
|
-
const functionFlags = getFunctionFlags(func);
|
|
76047
76274
|
if (functionFlags & 1 /* Generator */) {
|
|
76048
76275
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
76049
76276
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -76741,6 +76968,13 @@ function createTypeChecker(host) {
|
|
|
76741
76968
|
if (index >= 0) {
|
|
76742
76969
|
return contextualTypes[index];
|
|
76743
76970
|
}
|
|
76971
|
+
const links = getNodeLinks(node);
|
|
76972
|
+
if (links.contextualReturnType) {
|
|
76973
|
+
if (node.flags & 65536 /* AwaitContext */) {
|
|
76974
|
+
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
76975
|
+
}
|
|
76976
|
+
return links.contextualReturnType;
|
|
76977
|
+
}
|
|
76744
76978
|
const { parent: parent2 } = node;
|
|
76745
76979
|
switch (parent2.kind) {
|
|
76746
76980
|
case 260 /* VariableDeclaration */:
|
|
@@ -79417,8 +79651,8 @@ function createTypeChecker(host) {
|
|
|
79417
79651
|
}
|
|
79418
79652
|
}
|
|
79419
79653
|
function getEffectiveCheckNode(argument) {
|
|
79420
|
-
|
|
79421
|
-
return
|
|
79654
|
+
const flags = isInJSFile(argument) ? 1 /* Parentheses */ | 32 /* Satisfies */ | -2147483648 /* ExcludeJSDocTypeAssertion */ : 1 /* Parentheses */ | 32 /* Satisfies */;
|
|
79655
|
+
return skipOuterExpressions(argument, flags);
|
|
79422
79656
|
}
|
|
79423
79657
|
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
|
|
79424
79658
|
const errorOutputContainer = { errors: void 0, skipLogging: true };
|
|
@@ -79843,11 +80077,16 @@ function createTypeChecker(host) {
|
|
|
79843
80077
|
if (!result) {
|
|
79844
80078
|
result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
79845
80079
|
}
|
|
80080
|
+
const links = getNodeLinks(node);
|
|
80081
|
+
if (links.resolvedSignature !== resolvingSignature && !candidatesOutArray) {
|
|
80082
|
+
Debug.assert(links.resolvedSignature);
|
|
80083
|
+
return links.resolvedSignature;
|
|
80084
|
+
}
|
|
79846
80085
|
if (result) {
|
|
79847
80086
|
return result;
|
|
79848
80087
|
}
|
|
79849
80088
|
result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
79850
|
-
|
|
80089
|
+
links.resolvedSignature = result;
|
|
79851
80090
|
if (reportErrors2) {
|
|
79852
80091
|
if (!headMessage && isInstanceof) {
|
|
79853
80092
|
headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
|
|
@@ -80612,7 +80851,7 @@ function createTypeChecker(host) {
|
|
|
80612
80851
|
const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName(
|
|
80613
80852
|
node,
|
|
80614
80853
|
jsxFragmentFactoryName,
|
|
80615
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
80854
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
80616
80855
|
/*nameNotFoundMessage*/
|
|
80617
80856
|
jsxFactoryRefErr,
|
|
80618
80857
|
/*isUse*/
|
|
@@ -80731,12 +80970,9 @@ function createTypeChecker(host) {
|
|
|
80731
80970
|
resolutionStart = resolutionTargets.length;
|
|
80732
80971
|
}
|
|
80733
80972
|
links.resolvedSignature = resolvingSignature;
|
|
80734
|
-
|
|
80973
|
+
const result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
|
|
80735
80974
|
resolutionStart = saveResolutionStart;
|
|
80736
80975
|
if (result !== resolvingSignature) {
|
|
80737
|
-
if (links.resolvedSignature !== resolvingSignature) {
|
|
80738
|
-
result = links.resolvedSignature;
|
|
80739
|
-
}
|
|
80740
80976
|
links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
|
|
80741
80977
|
}
|
|
80742
80978
|
return result;
|
|
@@ -82264,7 +82500,7 @@ function createTypeChecker(host) {
|
|
|
82264
82500
|
});
|
|
82265
82501
|
}
|
|
82266
82502
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
82267
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
82503
|
+
const antecedent = canHaveFlowNode(expr) && expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
82268
82504
|
2 /* Start */,
|
|
82269
82505
|
/*node*/
|
|
82270
82506
|
void 0,
|
|
@@ -82412,19 +82648,7 @@ function createTypeChecker(host) {
|
|
|
82412
82648
|
const exprType = checkExpression(node.body);
|
|
82413
82649
|
const returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
|
|
82414
82650
|
if (returnOrPromisedType) {
|
|
82415
|
-
|
|
82416
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
82417
|
-
const awaitedType = checkAwaitedType(
|
|
82418
|
-
exprType,
|
|
82419
|
-
/*withAlias*/
|
|
82420
|
-
false,
|
|
82421
|
-
effectiveCheckNode,
|
|
82422
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
82423
|
-
);
|
|
82424
|
-
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
82425
|
-
} else {
|
|
82426
|
-
checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
82427
|
-
}
|
|
82651
|
+
checkReturnExpression(node, returnOrPromisedType, node.body, node.body, exprType);
|
|
82428
82652
|
}
|
|
82429
82653
|
}
|
|
82430
82654
|
}
|
|
@@ -82507,7 +82731,7 @@ function createTypeChecker(host) {
|
|
|
82507
82731
|
return false;
|
|
82508
82732
|
}
|
|
82509
82733
|
function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
|
|
82510
|
-
const node = skipOuterExpressions(expr,
|
|
82734
|
+
const node = skipOuterExpressions(expr, 38 /* Assertions */ | 1 /* Parentheses */);
|
|
82511
82735
|
if (node.kind !== 80 /* Identifier */ && !isAccessExpression(node)) {
|
|
82512
82736
|
error2(expr, invalidReferenceMessage);
|
|
82513
82737
|
return false;
|
|
@@ -83158,7 +83382,7 @@ function createTypeChecker(host) {
|
|
|
83158
83382
|
if (isBinaryExpression(right) && (right.operatorToken.kind === 57 /* BarBarToken */ || right.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
|
|
83159
83383
|
grammarErrorOnNode(right, Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, tokenToString(right.operatorToken.kind), tokenToString(operatorToken.kind));
|
|
83160
83384
|
}
|
|
83161
|
-
const leftTarget = skipOuterExpressions(left,
|
|
83385
|
+
const leftTarget = skipOuterExpressions(left, 63 /* All */);
|
|
83162
83386
|
const nullishSemantics = getSyntacticNullishnessSemantics(leftTarget);
|
|
83163
83387
|
if (nullishSemantics !== 3 /* Sometimes */) {
|
|
83164
83388
|
if (node.parent.kind === 226 /* BinaryExpression */) {
|
|
@@ -83178,7 +83402,9 @@ function createTypeChecker(host) {
|
|
|
83178
83402
|
switch (node.kind) {
|
|
83179
83403
|
case 223 /* AwaitExpression */:
|
|
83180
83404
|
case 213 /* CallExpression */:
|
|
83405
|
+
case 215 /* TaggedTemplateExpression */:
|
|
83181
83406
|
case 212 /* ElementAccessExpression */:
|
|
83407
|
+
case 236 /* MetaProperty */:
|
|
83182
83408
|
case 214 /* NewExpression */:
|
|
83183
83409
|
case 211 /* PropertyAccessExpression */:
|
|
83184
83410
|
case 229 /* YieldExpression */:
|
|
@@ -83194,6 +83420,8 @@ function createTypeChecker(host) {
|
|
|
83194
83420
|
case 56 /* AmpersandAmpersandToken */:
|
|
83195
83421
|
case 77 /* AmpersandAmpersandEqualsToken */:
|
|
83196
83422
|
return 3 /* Sometimes */;
|
|
83423
|
+
case 28 /* CommaToken */:
|
|
83424
|
+
return getSyntacticNullishnessSemantics(node.right);
|
|
83197
83425
|
}
|
|
83198
83426
|
return 2 /* Never */;
|
|
83199
83427
|
case 227 /* ConditionalExpression */:
|
|
@@ -87646,7 +87874,6 @@ function createTypeChecker(host) {
|
|
|
87646
87874
|
}
|
|
87647
87875
|
const signature = getSignatureFromDeclaration(container);
|
|
87648
87876
|
const returnType = getReturnTypeOfSignature(signature);
|
|
87649
|
-
const functionFlags = getFunctionFlags(container);
|
|
87650
87877
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
87651
87878
|
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
87652
87879
|
if (container.kind === 178 /* SetAccessor */) {
|
|
@@ -87654,26 +87881,249 @@ function createTypeChecker(host) {
|
|
|
87654
87881
|
error2(node, Diagnostics.Setters_cannot_return_a_value);
|
|
87655
87882
|
}
|
|
87656
87883
|
} else if (container.kind === 176 /* Constructor */) {
|
|
87657
|
-
|
|
87884
|
+
const exprType2 = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
87885
|
+
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType2, returnType, node, node.expression)) {
|
|
87658
87886
|
error2(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
87659
87887
|
}
|
|
87660
87888
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
87661
|
-
const unwrappedReturnType = unwrapReturnType(returnType,
|
|
87662
|
-
|
|
87663
|
-
exprType,
|
|
87664
|
-
/*withAlias*/
|
|
87665
|
-
false,
|
|
87666
|
-
node,
|
|
87667
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
87668
|
-
) : exprType;
|
|
87669
|
-
if (unwrappedReturnType) {
|
|
87670
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
|
|
87671
|
-
}
|
|
87889
|
+
const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(container)) ?? returnType;
|
|
87890
|
+
checkReturnExpression(container, unwrappedReturnType, node, node.expression, exprType);
|
|
87672
87891
|
}
|
|
87673
87892
|
} else if (container.kind !== 176 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
87674
87893
|
error2(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
87675
87894
|
}
|
|
87676
87895
|
}
|
|
87896
|
+
function checkReturnExpression(container, unwrappedReturnType, node, expr, exprType, inConditionalExpression = false) {
|
|
87897
|
+
const excludeJSDocTypeAssertions = isInJSFile(node);
|
|
87898
|
+
const functionFlags = getFunctionFlags(container);
|
|
87899
|
+
if (expr) {
|
|
87900
|
+
const unwrappedExpr = skipParentheses(expr, excludeJSDocTypeAssertions);
|
|
87901
|
+
if (isConditionalExpression(unwrappedExpr)) {
|
|
87902
|
+
checkReturnExpression(
|
|
87903
|
+
container,
|
|
87904
|
+
unwrappedReturnType,
|
|
87905
|
+
node,
|
|
87906
|
+
unwrappedExpr.whenTrue,
|
|
87907
|
+
checkExpression(unwrappedExpr.whenTrue),
|
|
87908
|
+
/*inConditionalExpression*/
|
|
87909
|
+
true
|
|
87910
|
+
);
|
|
87911
|
+
checkReturnExpression(
|
|
87912
|
+
container,
|
|
87913
|
+
unwrappedReturnType,
|
|
87914
|
+
node,
|
|
87915
|
+
unwrappedExpr.whenFalse,
|
|
87916
|
+
checkExpression(unwrappedExpr.whenFalse),
|
|
87917
|
+
/*inConditionalExpression*/
|
|
87918
|
+
true
|
|
87919
|
+
);
|
|
87920
|
+
return;
|
|
87921
|
+
}
|
|
87922
|
+
}
|
|
87923
|
+
const inReturnStatement = node.kind === 253 /* ReturnStatement */;
|
|
87924
|
+
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
87925
|
+
exprType,
|
|
87926
|
+
/*withAlias*/
|
|
87927
|
+
false,
|
|
87928
|
+
node,
|
|
87929
|
+
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
87930
|
+
) : exprType;
|
|
87931
|
+
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
|
87932
|
+
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
|
87933
|
+
if (!(unwrappedReturnType.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */)) || !couldContainTypeVariables(unwrappedReturnType)) {
|
|
87934
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
87935
|
+
return;
|
|
87936
|
+
}
|
|
87937
|
+
if (checkTypeAssignableTo(
|
|
87938
|
+
unwrappedExprType,
|
|
87939
|
+
unwrappedReturnType,
|
|
87940
|
+
/*errorNode*/
|
|
87941
|
+
void 0
|
|
87942
|
+
)) {
|
|
87943
|
+
return;
|
|
87944
|
+
}
|
|
87945
|
+
let narrowPosition = node;
|
|
87946
|
+
let narrowFlowNode = inReturnStatement && node.flowNode;
|
|
87947
|
+
if (expr && isConditionalExpression(expr.parent)) {
|
|
87948
|
+
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
87949
|
+
narrowPosition = expr;
|
|
87950
|
+
}
|
|
87951
|
+
if (!narrowFlowNode) {
|
|
87952
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
87953
|
+
return;
|
|
87954
|
+
}
|
|
87955
|
+
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
87956
|
+
container,
|
|
87957
|
+
/*includeThisTypes*/
|
|
87958
|
+
false
|
|
87959
|
+
), getEffectiveTypeParameterDeclarations(container));
|
|
87960
|
+
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
87961
|
+
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
87962
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
87963
|
+
return;
|
|
87964
|
+
}
|
|
87965
|
+
const narrowedTypeParameters = [];
|
|
87966
|
+
const narrowedTypes = [];
|
|
87967
|
+
for (const [typeParam, symbol, reference] of narrowableTypeParameters) {
|
|
87968
|
+
const narrowReference = factory.cloneNode(reference);
|
|
87969
|
+
narrowReference.id = void 0;
|
|
87970
|
+
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
|
87971
|
+
setParent(narrowReference, narrowPosition.parent);
|
|
87972
|
+
narrowReference.flowNode = narrowFlowNode;
|
|
87973
|
+
const initialType = getNarrowableTypeForReference(
|
|
87974
|
+
typeParam,
|
|
87975
|
+
narrowReference,
|
|
87976
|
+
/*checkMode*/
|
|
87977
|
+
void 0,
|
|
87978
|
+
/*forReturnTypeNarrowing*/
|
|
87979
|
+
true
|
|
87980
|
+
);
|
|
87981
|
+
if (initialType === typeParam) {
|
|
87982
|
+
continue;
|
|
87983
|
+
}
|
|
87984
|
+
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
87985
|
+
const exprType2 = getTypeFromFlowType(flowType);
|
|
87986
|
+
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
87987
|
+
continue;
|
|
87988
|
+
}
|
|
87989
|
+
const narrowedType = getSubstitutionType(
|
|
87990
|
+
typeParam,
|
|
87991
|
+
exprType2,
|
|
87992
|
+
/*isNarrowed*/
|
|
87993
|
+
true
|
|
87994
|
+
);
|
|
87995
|
+
narrowedTypeParameters.push(typeParam);
|
|
87996
|
+
narrowedTypes.push(narrowedType);
|
|
87997
|
+
}
|
|
87998
|
+
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
|
87999
|
+
const narrowedReturnType = instantiateType(
|
|
88000
|
+
unwrappedReturnType,
|
|
88001
|
+
narrowMapper
|
|
88002
|
+
);
|
|
88003
|
+
if (expr) {
|
|
88004
|
+
const links = getNodeLinks(expr);
|
|
88005
|
+
if (!links.contextualReturnType) {
|
|
88006
|
+
links.contextualReturnType = narrowedReturnType;
|
|
88007
|
+
}
|
|
88008
|
+
}
|
|
88009
|
+
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
|
88010
|
+
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
88011
|
+
narrowedExprType,
|
|
88012
|
+
/*withAlias*/
|
|
88013
|
+
false,
|
|
88014
|
+
node,
|
|
88015
|
+
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
88016
|
+
) : narrowedExprType;
|
|
88017
|
+
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
|
88018
|
+
}
|
|
88019
|
+
function getNarrowableTypeParameters(candidates) {
|
|
88020
|
+
const narrowableParams = [];
|
|
88021
|
+
for (const typeParam of candidates) {
|
|
88022
|
+
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
88023
|
+
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
88024
|
+
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
88025
|
+
const declaration = typeParam.symbol.declarations[0];
|
|
88026
|
+
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
|
88027
|
+
if (!isFunctionLike(container)) continue;
|
|
88028
|
+
let reference;
|
|
88029
|
+
let hasInvalidReference = false;
|
|
88030
|
+
for (const paramDecl of container.parameters) {
|
|
88031
|
+
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
|
88032
|
+
if (!typeNode) continue;
|
|
88033
|
+
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
|
88034
|
+
let candidateReference;
|
|
88035
|
+
if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
|
|
88036
|
+
if (reference) {
|
|
88037
|
+
hasInvalidReference = true;
|
|
88038
|
+
break;
|
|
88039
|
+
}
|
|
88040
|
+
reference = candidateReference;
|
|
88041
|
+
} else {
|
|
88042
|
+
hasInvalidReference = true;
|
|
88043
|
+
break;
|
|
88044
|
+
}
|
|
88045
|
+
}
|
|
88046
|
+
}
|
|
88047
|
+
if (!hasInvalidReference && reference) {
|
|
88048
|
+
const symbol = getResolvedSymbol(reference);
|
|
88049
|
+
if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
|
|
88050
|
+
}
|
|
88051
|
+
}
|
|
88052
|
+
}
|
|
88053
|
+
return narrowableParams;
|
|
88054
|
+
function getValidParameterReference(paramDecl, constraint) {
|
|
88055
|
+
if (!isIdentifier(paramDecl.name)) return;
|
|
88056
|
+
const isOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
|
88057
|
+
if (isOptional && !containsUndefinedType(constraint)) return;
|
|
88058
|
+
return paramDecl.name;
|
|
88059
|
+
}
|
|
88060
|
+
function isReferenceToTypeParameter(typeParam, node) {
|
|
88061
|
+
return getTypeFromTypeReference(node) === typeParam;
|
|
88062
|
+
}
|
|
88063
|
+
function isTypeParameterReferenced(typeParam, node) {
|
|
88064
|
+
return isReferenced(node);
|
|
88065
|
+
function isReferenced(node2) {
|
|
88066
|
+
if (isTypeReferenceNode(node2)) {
|
|
88067
|
+
return isReferenceToTypeParameter(typeParam, node2);
|
|
88068
|
+
}
|
|
88069
|
+
if (isTypeQueryNode(node2)) {
|
|
88070
|
+
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
|
88071
|
+
}
|
|
88072
|
+
return !!forEachChild(node2, isReferenced);
|
|
88073
|
+
}
|
|
88074
|
+
}
|
|
88075
|
+
}
|
|
88076
|
+
function isNarrowableReturnType(returnType) {
|
|
88077
|
+
return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
|
88078
|
+
}
|
|
88079
|
+
function isNarrowableConditionalType(type, mapper) {
|
|
88080
|
+
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
|
88081
|
+
const mapped = getMappedType(t, mapper);
|
|
88082
|
+
if (isNarrowingSubstitutionType(mapped)) {
|
|
88083
|
+
return mapped.baseType;
|
|
88084
|
+
}
|
|
88085
|
+
return mapped;
|
|
88086
|
+
});
|
|
88087
|
+
const id = `${type.id}:${getTypeListId(typeArguments)}`;
|
|
88088
|
+
let result = narrowableReturnTypeCache.get(id);
|
|
88089
|
+
if (result === void 0) {
|
|
88090
|
+
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
|
88091
|
+
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
|
88092
|
+
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
|
|
88093
|
+
narrowableReturnTypeCache.set(id, result);
|
|
88094
|
+
}
|
|
88095
|
+
return result;
|
|
88096
|
+
}
|
|
88097
|
+
function isNarrowableConditionalTypeWorker(type) {
|
|
88098
|
+
if (!type.root.isDistributive) {
|
|
88099
|
+
return false;
|
|
88100
|
+
}
|
|
88101
|
+
if (type.root.inferTypeParameters) {
|
|
88102
|
+
return false;
|
|
88103
|
+
}
|
|
88104
|
+
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
88105
|
+
return false;
|
|
88106
|
+
}
|
|
88107
|
+
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
|
88108
|
+
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
|
88109
|
+
return false;
|
|
88110
|
+
}
|
|
88111
|
+
if (!everyType(type.extendsType, (extendsType) => some(
|
|
88112
|
+
constraintType.types,
|
|
88113
|
+
(constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
|
|
88114
|
+
))) {
|
|
88115
|
+
return false;
|
|
88116
|
+
}
|
|
88117
|
+
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
88118
|
+
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
|
88119
|
+
if (!isValidTrueType) return false;
|
|
88120
|
+
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
88121
|
+
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
|
88122
|
+
return isValidFalseType;
|
|
88123
|
+
}
|
|
88124
|
+
function isConditionalType(type) {
|
|
88125
|
+
return !!(type.flags & 16777216 /* Conditional */);
|
|
88126
|
+
}
|
|
87677
88127
|
function checkWithStatement(node) {
|
|
87678
88128
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
87679
88129
|
if (node.flags & 65536 /* AwaitContext */) {
|
|
@@ -97829,7 +98279,7 @@ function transformTypeScript(context) {
|
|
|
97829
98279
|
return updated;
|
|
97830
98280
|
}
|
|
97831
98281
|
function visitParenthesizedExpression(node) {
|
|
97832
|
-
const innerExpression = skipOuterExpressions(node.expression, ~(
|
|
98282
|
+
const innerExpression = skipOuterExpressions(node.expression, ~(38 /* Assertions */ | 16 /* ExpressionsWithTypeArguments */));
|
|
97833
98283
|
if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
|
|
97834
98284
|
const expression = visitNode(node.expression, visitor, isExpression);
|
|
97835
98285
|
Debug.assert(expression);
|
|
@@ -136959,18 +137409,21 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
136959
137409
|
return failed;
|
|
136960
137410
|
}
|
|
136961
137411
|
function typeFromFunctionLikeExpression(fnNode, context) {
|
|
136962
|
-
const
|
|
136963
|
-
context.noInferenceFallback = true;
|
|
136964
|
-
createReturnFromSignature(
|
|
137412
|
+
const returnType = createReturnFromSignature(
|
|
136965
137413
|
fnNode,
|
|
136966
137414
|
/*symbol*/
|
|
136967
137415
|
void 0,
|
|
136968
137416
|
context
|
|
136969
137417
|
);
|
|
136970
|
-
reuseTypeParameters(fnNode.typeParameters, context);
|
|
136971
|
-
fnNode.parameters.map((p) => ensureParameter(p, context));
|
|
136972
|
-
|
|
136973
|
-
|
|
137418
|
+
const typeParameters = reuseTypeParameters(fnNode.typeParameters, context);
|
|
137419
|
+
const parameters = fnNode.parameters.map((p) => ensureParameter(p, context));
|
|
137420
|
+
return syntacticResult(
|
|
137421
|
+
factory.createFunctionTypeNode(
|
|
137422
|
+
typeParameters,
|
|
137423
|
+
parameters,
|
|
137424
|
+
returnType
|
|
137425
|
+
)
|
|
137426
|
+
);
|
|
136974
137427
|
}
|
|
136975
137428
|
function canGetTypeFromArrayLiteral(arrayLiteral, context, isConstContext) {
|
|
136976
137429
|
if (!isConstContext) {
|
|
@@ -139817,9 +140270,9 @@ function mapToDisplayParts(writeDisplayParts) {
|
|
|
139817
140270
|
displayPartWriter.clear();
|
|
139818
140271
|
}
|
|
139819
140272
|
}
|
|
139820
|
-
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None
|
|
140273
|
+
function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags = 0 /* None */, verbosityLevel, out) {
|
|
139821
140274
|
return mapToDisplayParts((writer) => {
|
|
139822
|
-
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer);
|
|
140275
|
+
typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer, verbosityLevel, out);
|
|
139823
140276
|
});
|
|
139824
140277
|
}
|
|
139825
140278
|
function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags = 0 /* None */) {
|
|
@@ -140526,7 +140979,7 @@ function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
|
|
|
140526
140979
|
return moduleSpecifierToValidIdentifier(removeFileExtension(stripQuotes(moduleSymbol.name)), target, forceCapitalize);
|
|
140527
140980
|
}
|
|
140528
140981
|
function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
|
|
140529
|
-
const baseName = getBaseFileName(removeSuffix(moduleSpecifier, "/index"));
|
|
140982
|
+
const baseName = getBaseFileName(removeSuffix(removeFileExtension(moduleSpecifier), "/index"));
|
|
140530
140983
|
let res = "";
|
|
140531
140984
|
let lastCharWasValid = true;
|
|
140532
140985
|
const firstCharCode = baseName.charCodeAt(0);
|
|
@@ -140738,6 +141191,7 @@ var ExportKind = /* @__PURE__ */ ((ExportKind3) => {
|
|
|
140738
141191
|
ExportKind3[ExportKind3["Default"] = 1] = "Default";
|
|
140739
141192
|
ExportKind3[ExportKind3["ExportEquals"] = 2] = "ExportEquals";
|
|
140740
141193
|
ExportKind3[ExportKind3["UMD"] = 3] = "UMD";
|
|
141194
|
+
ExportKind3[ExportKind3["Module"] = 4] = "Module";
|
|
140741
141195
|
return ExportKind3;
|
|
140742
141196
|
})(ExportKind || {});
|
|
140743
141197
|
function createCacheableExportInfoMap(host) {
|
|
@@ -146430,23 +146884,22 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
146430
146884
|
const unusedImportsFromOldFile = /* @__PURE__ */ new Set();
|
|
146431
146885
|
for (const statement of toMove) {
|
|
146432
146886
|
forEachReference(statement, checker, enclosingRange, (symbol, isValidTypeOnlyUseSite) => {
|
|
146433
|
-
if (!symbol.declarations
|
|
146887
|
+
if (!symbol.declarations) {
|
|
146434
146888
|
return;
|
|
146435
146889
|
}
|
|
146436
146890
|
if (existingTargetLocals.has(skipAlias(symbol, checker))) {
|
|
146437
146891
|
unusedImportsFromOldFile.add(symbol);
|
|
146438
146892
|
return;
|
|
146439
146893
|
}
|
|
146440
|
-
|
|
146441
|
-
|
|
146442
|
-
|
|
146443
|
-
|
|
146444
|
-
|
|
146445
|
-
|
|
146446
|
-
|
|
146447
|
-
|
|
146448
|
-
|
|
146449
|
-
}
|
|
146894
|
+
const importedDeclaration = find(symbol.declarations, isInImport);
|
|
146895
|
+
if (importedDeclaration) {
|
|
146896
|
+
const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol);
|
|
146897
|
+
oldImportsNeededByTargetFile.set(symbol, [
|
|
146898
|
+
prevIsTypeOnly === void 0 ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite,
|
|
146899
|
+
tryCast(importedDeclaration, (d) => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d))
|
|
146900
|
+
]);
|
|
146901
|
+
} else if (!movedSymbols.has(symbol) && every(symbol.declarations, (decl) => isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile)) {
|
|
146902
|
+
targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite);
|
|
146450
146903
|
}
|
|
146451
146904
|
});
|
|
146452
146905
|
}
|
|
@@ -146480,16 +146933,6 @@ function getUsageInfo(oldFile, toMove, checker, existingTargetLocals = /* @__PUR
|
|
|
146480
146933
|
return !!jsxNamespaceSymbol2 && some(jsxNamespaceSymbol2.declarations, isInImport) ? jsxNamespaceSymbol2 : void 0;
|
|
146481
146934
|
}
|
|
146482
146935
|
}
|
|
146483
|
-
function isGlobalType(checker, symbol) {
|
|
146484
|
-
return !!checker.resolveName(
|
|
146485
|
-
symbol.name,
|
|
146486
|
-
/*location*/
|
|
146487
|
-
void 0,
|
|
146488
|
-
788968 /* Type */,
|
|
146489
|
-
/*excludeGlobals*/
|
|
146490
|
-
false
|
|
146491
|
-
);
|
|
146492
|
-
}
|
|
146493
146936
|
function makeUniqueFilename(proposedFilename, extension, inDirectory, host) {
|
|
146494
146937
|
let newFilename = proposedFilename;
|
|
146495
146938
|
for (let i = 1; ; i++) {
|
|
@@ -146708,6 +147151,9 @@ function addTargetFileImports(oldFile, importsToCopy, targetFileImportsFromOldFi
|
|
|
146708
147151
|
const targetSymbol = skipAlias(symbol, checker);
|
|
146709
147152
|
if (checker.isUnknownSymbol(targetSymbol)) {
|
|
146710
147153
|
importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor((_a = symbol.declarations) == null ? void 0 : _a[0], isAnyImportOrRequireStatement)));
|
|
147154
|
+
} else if (targetSymbol.parent === void 0) {
|
|
147155
|
+
Debug.assert(declaration !== void 0, "expected module symbol to have a declaration");
|
|
147156
|
+
importAdder.addImportForModuleSymbol(symbol, isValidTypeOnlyUseSite, declaration);
|
|
146711
147157
|
} else {
|
|
146712
147158
|
importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
|
|
146713
147159
|
}
|
|
@@ -151309,8 +151755,7 @@ var invalidOperationsInPartialSemanticMode = [
|
|
|
151309
151755
|
"provideCallHierarchyOutgoingCalls",
|
|
151310
151756
|
"provideInlayHints",
|
|
151311
151757
|
"getSupportedCodeFixes",
|
|
151312
|
-
"getPasteEdits"
|
|
151313
|
-
"getImports"
|
|
151758
|
+
"getPasteEdits"
|
|
151314
151759
|
];
|
|
151315
151760
|
var invalidOperationsInSyntacticMode = [
|
|
151316
151761
|
...invalidOperationsInPartialSemanticMode,
|
|
@@ -151792,7 +152237,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
151792
152237
|
synchronizeHostData();
|
|
151793
152238
|
return ts_Completions_exports.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences);
|
|
151794
152239
|
}
|
|
151795
|
-
function getQuickInfoAtPosition(fileName, position) {
|
|
152240
|
+
function getQuickInfoAtPosition(fileName, position, verbosityLevel) {
|
|
151796
152241
|
synchronizeHostData();
|
|
151797
152242
|
const sourceFile = getValidSourceFile(fileName);
|
|
151798
152243
|
const node = getTouchingPropertyName(sourceFile, position);
|
|
@@ -151808,19 +152253,41 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
151808
152253
|
kind: "" /* unknown */,
|
|
151809
152254
|
kindModifiers: "" /* none */,
|
|
151810
152255
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
|
151811
|
-
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(
|
|
152256
|
+
displayParts: typeChecker.runWithCancellationToken(cancellationToken, (typeChecker2) => typeToDisplayParts(
|
|
152257
|
+
typeChecker2,
|
|
152258
|
+
type,
|
|
152259
|
+
getContainerNode(nodeForQuickInfo),
|
|
152260
|
+
/*flags*/
|
|
152261
|
+
void 0,
|
|
152262
|
+
verbosityLevel
|
|
152263
|
+
)),
|
|
151812
152264
|
documentation: type.symbol ? type.symbol.getDocumentationComment(typeChecker) : void 0,
|
|
151813
152265
|
tags: type.symbol ? type.symbol.getJsDocTags(typeChecker) : void 0
|
|
151814
152266
|
};
|
|
151815
152267
|
}
|
|
151816
|
-
const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(
|
|
152268
|
+
const { symbolKind, displayParts, documentation, tags, canIncreaseVerbosityLevel } = typeChecker.runWithCancellationToken(
|
|
152269
|
+
cancellationToken,
|
|
152270
|
+
(typeChecker2) => ts_SymbolDisplay_exports.getSymbolDisplayPartsDocumentationAndSymbolKind(
|
|
152271
|
+
typeChecker2,
|
|
152272
|
+
symbol,
|
|
152273
|
+
sourceFile,
|
|
152274
|
+
getContainerNode(nodeForQuickInfo),
|
|
152275
|
+
nodeForQuickInfo,
|
|
152276
|
+
/*semanticMeaning*/
|
|
152277
|
+
void 0,
|
|
152278
|
+
/*alias*/
|
|
152279
|
+
void 0,
|
|
152280
|
+
verbosityLevel
|
|
152281
|
+
)
|
|
152282
|
+
);
|
|
151817
152283
|
return {
|
|
151818
152284
|
kind: symbolKind,
|
|
151819
152285
|
kindModifiers: ts_SymbolDisplay_exports.getSymbolModifiers(typeChecker, symbol),
|
|
151820
152286
|
textSpan: createTextSpanFromNode(nodeForQuickInfo, sourceFile),
|
|
151821
152287
|
displayParts,
|
|
151822
152288
|
documentation,
|
|
151823
|
-
tags
|
|
152289
|
+
tags,
|
|
152290
|
+
canIncreaseVerbosityLevel
|
|
151824
152291
|
};
|
|
151825
152292
|
}
|
|
151826
152293
|
function preparePasteEditsForFile(fileName, copiedTextRange) {
|
|
@@ -152562,18 +153029,6 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
152562
153029
|
preferences
|
|
152563
153030
|
);
|
|
152564
153031
|
}
|
|
152565
|
-
function getImports(fileName) {
|
|
152566
|
-
var _a2, _b;
|
|
152567
|
-
synchronizeHostData();
|
|
152568
|
-
const file = getValidSourceFile(fileName);
|
|
152569
|
-
let imports;
|
|
152570
|
-
for (const specifier of file.imports) {
|
|
152571
|
-
if (nodeIsSynthesized(specifier)) continue;
|
|
152572
|
-
const name = (_b = (_a2 = program.getResolvedModuleFromModuleSpecifier(specifier, file)) == null ? void 0 : _a2.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
152573
|
-
if (name) (imports ?? (imports = /* @__PURE__ */ new Set())).add(name);
|
|
152574
|
-
}
|
|
152575
|
-
return imports ? arrayFrom(imports) : emptyArray;
|
|
152576
|
-
}
|
|
152577
153032
|
const ls = {
|
|
152578
153033
|
dispose,
|
|
152579
153034
|
cleanupSemanticCache,
|
|
@@ -152647,8 +153102,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
152647
153102
|
getSupportedCodeFixes,
|
|
152648
153103
|
preparePasteEditsForFile,
|
|
152649
153104
|
getPasteEdits,
|
|
152650
|
-
mapCode: mapCode2
|
|
152651
|
-
getImports
|
|
153105
|
+
mapCode: mapCode2
|
|
152652
153106
|
};
|
|
152653
153107
|
switch (languageServiceMode) {
|
|
152654
153108
|
case 0 /* Semantic */:
|
|
@@ -156926,7 +157380,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
156926
157380
|
const removeExisting = /* @__PURE__ */ new Set();
|
|
156927
157381
|
const verbatimImports = /* @__PURE__ */ new Set();
|
|
156928
157382
|
const newImports = /* @__PURE__ */ new Map();
|
|
156929
|
-
return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes, hasFixes, addImportForUnresolvedIdentifier, addImportForNonExistentExport, removeExistingImport, addVerbatimImport };
|
|
157383
|
+
return { addImportFromDiagnostic, addImportFromExportedSymbol, addImportForModuleSymbol, writeFixes, hasFixes, addImportForUnresolvedIdentifier, addImportForNonExistentExport, removeExistingImport, addVerbatimImport };
|
|
156930
157384
|
function addVerbatimImport(declaration) {
|
|
156931
157385
|
verbatimImports.add(declaration);
|
|
156932
157386
|
}
|
|
@@ -156942,7 +157396,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
156942
157396
|
}
|
|
156943
157397
|
function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite, referenceImport) {
|
|
156944
157398
|
var _a, _b;
|
|
156945
|
-
const moduleSymbol = Debug.checkDefined(exportedSymbol.parent);
|
|
157399
|
+
const moduleSymbol = Debug.checkDefined(exportedSymbol.parent, "Expected exported symbol to have module symbol as parent");
|
|
156946
157400
|
const symbolName2 = getNameForExportedSymbol(exportedSymbol, getEmitScriptTarget(compilerOptions));
|
|
156947
157401
|
const checker = program.getTypeChecker();
|
|
156948
157402
|
const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker));
|
|
@@ -156992,6 +157446,75 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
156992
157446
|
addImport({ fix, symbolName: localName ?? symbolName2, errorIdentifierText: void 0 });
|
|
156993
157447
|
}
|
|
156994
157448
|
}
|
|
157449
|
+
function addImportForModuleSymbol(symbolAlias, isValidTypeOnlyUseSite, referenceImport) {
|
|
157450
|
+
var _a, _b, _c;
|
|
157451
|
+
const checker = program.getTypeChecker();
|
|
157452
|
+
const moduleSymbol = checker.getAliasedSymbol(symbolAlias);
|
|
157453
|
+
Debug.assert(moduleSymbol.flags & 1536 /* Module */, "Expected symbol to be a module");
|
|
157454
|
+
const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host);
|
|
157455
|
+
const moduleSpecifierResult = ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
|
|
157456
|
+
moduleSymbol,
|
|
157457
|
+
checker,
|
|
157458
|
+
compilerOptions,
|
|
157459
|
+
sourceFile,
|
|
157460
|
+
moduleSpecifierResolutionHost,
|
|
157461
|
+
preferences,
|
|
157462
|
+
/*options*/
|
|
157463
|
+
void 0,
|
|
157464
|
+
/*forAutoImport*/
|
|
157465
|
+
true
|
|
157466
|
+
);
|
|
157467
|
+
const useRequire = shouldUseRequire(sourceFile, program);
|
|
157468
|
+
let addAsTypeOnly = getAddAsTypeOnly(
|
|
157469
|
+
isValidTypeOnlyUseSite,
|
|
157470
|
+
/*isForNewImportDeclaration*/
|
|
157471
|
+
true,
|
|
157472
|
+
/*symbol*/
|
|
157473
|
+
void 0,
|
|
157474
|
+
symbolAlias.flags,
|
|
157475
|
+
program.getTypeChecker(),
|
|
157476
|
+
compilerOptions
|
|
157477
|
+
);
|
|
157478
|
+
addAsTypeOnly = addAsTypeOnly === 1 /* Allowed */ && isTypeOnlyImportDeclaration(referenceImport) ? 2 /* Required */ : 1 /* Allowed */;
|
|
157479
|
+
const importKind = isImportDeclaration(referenceImport) ? isDefaultImport(referenceImport) ? 1 /* Default */ : 2 /* Namespace */ : isImportSpecifier(referenceImport) ? 0 /* Named */ : isImportClause(referenceImport) && !!referenceImport.name ? 1 /* Default */ : 2 /* Namespace */;
|
|
157480
|
+
const exportInfo = [{
|
|
157481
|
+
symbol: symbolAlias,
|
|
157482
|
+
moduleSymbol,
|
|
157483
|
+
moduleFileName: (_c = (_b = (_a = moduleSymbol.declarations) == null ? void 0 : _a[0]) == null ? void 0 : _b.getSourceFile()) == null ? void 0 : _c.fileName,
|
|
157484
|
+
exportKind: 4 /* Module */,
|
|
157485
|
+
targetFlags: symbolAlias.flags,
|
|
157486
|
+
isFromPackageJson: false
|
|
157487
|
+
}];
|
|
157488
|
+
const existingFix = getImportFixForSymbol(
|
|
157489
|
+
sourceFile,
|
|
157490
|
+
exportInfo,
|
|
157491
|
+
program,
|
|
157492
|
+
/*position*/
|
|
157493
|
+
void 0,
|
|
157494
|
+
!!isValidTypeOnlyUseSite,
|
|
157495
|
+
useRequire,
|
|
157496
|
+
host,
|
|
157497
|
+
preferences
|
|
157498
|
+
);
|
|
157499
|
+
let fix;
|
|
157500
|
+
if (existingFix && importKind !== 2 /* Namespace */) {
|
|
157501
|
+
fix = {
|
|
157502
|
+
...existingFix,
|
|
157503
|
+
addAsTypeOnly,
|
|
157504
|
+
importKind
|
|
157505
|
+
};
|
|
157506
|
+
} else {
|
|
157507
|
+
fix = {
|
|
157508
|
+
kind: 3 /* AddNew */,
|
|
157509
|
+
moduleSpecifierKind: existingFix !== void 0 ? existingFix.moduleSpecifierKind : moduleSpecifierResult.kind,
|
|
157510
|
+
moduleSpecifier: existingFix !== void 0 ? existingFix.moduleSpecifier : first(moduleSpecifierResult.moduleSpecifiers),
|
|
157511
|
+
importKind,
|
|
157512
|
+
addAsTypeOnly,
|
|
157513
|
+
useRequire
|
|
157514
|
+
};
|
|
157515
|
+
}
|
|
157516
|
+
addImport({ fix, symbolName: symbolAlias.name, errorIdentifierText: void 0 });
|
|
157517
|
+
}
|
|
156995
157518
|
function addImportForNonExistentExport(exportName, exportingFileName, exportKind, exportedMeanings, isImportUsageValidAsTypeOnly) {
|
|
156996
157519
|
const exportingSourceFile = program.getSourceFile(exportingFileName);
|
|
156997
157520
|
const useRequire = shouldUseRequire(sourceFile, program);
|
|
@@ -157440,7 +157963,8 @@ function getAllExportInfoForSymbol(importingFile, symbol, symbolName2, moduleSym
|
|
|
157440
157963
|
const moduleSourceFile = isFileExcluded && mergedModuleSymbol.declarations && getDeclarationOfKind(mergedModuleSymbol, 307 /* SourceFile */);
|
|
157441
157964
|
const moduleSymbolExcluded = moduleSourceFile && isFileExcluded(moduleSourceFile);
|
|
157442
157965
|
return getExportInfoMap(importingFile, host, program, preferences, cancellationToken).search(importingFile.path, preferCapitalized, (name) => name === symbolName2, (info) => {
|
|
157443
|
-
|
|
157966
|
+
const checker = getChecker(info[0].isFromPackageJson);
|
|
157967
|
+
if (checker.getMergedSymbol(skipAlias(info[0].symbol, checker)) === symbol && (moduleSymbolExcluded || info.some((i) => checker.getMergedSymbol(i.moduleSymbol) === moduleSymbol || i.symbol.parent === moduleSymbol))) {
|
|
157444
157968
|
return info;
|
|
157445
157969
|
}
|
|
157446
157970
|
});
|
|
@@ -157869,6 +158393,8 @@ function getImportKind(importingFile, exportKind, program, forceImportKeyword) {
|
|
|
157869
158393
|
return getExportEqualsImportKind(importingFile, program.getCompilerOptions(), !!forceImportKeyword);
|
|
157870
158394
|
case 3 /* UMD */:
|
|
157871
158395
|
return getUmdImportKind(importingFile, program, !!forceImportKeyword);
|
|
158396
|
+
case 4 /* Module */:
|
|
158397
|
+
return 2 /* Namespace */;
|
|
157872
158398
|
default:
|
|
157873
158399
|
return Debug.assertNever(exportKind);
|
|
157874
158400
|
}
|
|
@@ -159306,7 +159832,8 @@ var errorCodes28 = [
|
|
|
159306
159832
|
Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code,
|
|
159307
159833
|
Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code,
|
|
159308
159834
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code,
|
|
159309
|
-
Diagnostics.Cannot_find_name_0.code
|
|
159835
|
+
Diagnostics.Cannot_find_name_0.code,
|
|
159836
|
+
Diagnostics.Type_0_does_not_satisfy_the_expected_type_1.code
|
|
159310
159837
|
];
|
|
159311
159838
|
registerCodeFix({
|
|
159312
159839
|
errorCodes: errorCodes28,
|
|
@@ -159343,9 +159870,9 @@ registerCodeFix({
|
|
|
159343
159870
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
159344
159871
|
eachDiagnostic(context, errorCodes28, (diag2) => {
|
|
159345
159872
|
const info = getInfo10(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
159346
|
-
if (
|
|
159347
|
-
|
|
159348
|
-
|
|
159873
|
+
if (info === void 0) return;
|
|
159874
|
+
const nodeId = getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier || getNodeId(info.token) : info.token.text);
|
|
159875
|
+
if (!addToSeen(seen, nodeId)) return;
|
|
159349
159876
|
if (fixId56 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
159350
159877
|
addFunctionDeclaration(changes, context, info);
|
|
159351
159878
|
} else if (fixId56 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
@@ -159389,7 +159916,7 @@ registerCodeFix({
|
|
|
159389
159916
|
}
|
|
159390
159917
|
});
|
|
159391
159918
|
function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
159392
|
-
var _a, _b
|
|
159919
|
+
var _a, _b;
|
|
159393
159920
|
const token = getTokenAtPosition(sourceFile, tokenPos);
|
|
159394
159921
|
const parent2 = token.parent;
|
|
159395
159922
|
if (errorCode === Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) {
|
|
@@ -159411,23 +159938,25 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159411
159938
|
if (!length(properties)) return void 0;
|
|
159412
159939
|
return { kind: 3 /* ObjectLiteral */, token: param.name, identifier: param.name.text, properties, parentDeclaration: parent2 };
|
|
159413
159940
|
}
|
|
159414
|
-
if (token.kind === 19 /* OpenBraceToken */
|
|
159415
|
-
const
|
|
159416
|
-
|
|
159417
|
-
checker.
|
|
159418
|
-
|
|
159419
|
-
|
|
159420
|
-
|
|
159421
|
-
|
|
159422
|
-
|
|
159423
|
-
|
|
159424
|
-
|
|
159425
|
-
|
|
159426
|
-
|
|
159941
|
+
if (token.kind === 19 /* OpenBraceToken */ || isSatisfiesExpression(parent2) || isReturnStatement(parent2)) {
|
|
159942
|
+
const expression = (isSatisfiesExpression(parent2) || isReturnStatement(parent2)) && parent2.expression ? parent2.expression : parent2;
|
|
159943
|
+
if (isObjectLiteralExpression(expression)) {
|
|
159944
|
+
const targetType = isSatisfiesExpression(parent2) ? checker.getTypeFromTypeNode(parent2.type) : checker.getContextualType(expression) || checker.getTypeAtLocation(expression);
|
|
159945
|
+
const properties = arrayFrom(checker.getUnmatchedProperties(
|
|
159946
|
+
checker.getTypeAtLocation(parent2),
|
|
159947
|
+
targetType.getNonNullableType(),
|
|
159948
|
+
/*requireOptionalProperties*/
|
|
159949
|
+
false,
|
|
159950
|
+
/*matchDiscriminantProperties*/
|
|
159951
|
+
false
|
|
159952
|
+
));
|
|
159953
|
+
if (!length(properties)) return void 0;
|
|
159954
|
+
return { kind: 3 /* ObjectLiteral */, token: parent2, identifier: void 0, properties, parentDeclaration: expression, indentation: isReturnStatement(expression.parent) || isYieldExpression(expression.parent) ? 0 : void 0 };
|
|
159955
|
+
}
|
|
159427
159956
|
}
|
|
159428
159957
|
if (!isMemberName(token)) return void 0;
|
|
159429
159958
|
if (isIdentifier(token) && hasInitializer(parent2) && parent2.initializer && isObjectLiteralExpression(parent2.initializer)) {
|
|
159430
|
-
const targetType = (
|
|
159959
|
+
const targetType = (_a = checker.getContextualType(token) || checker.getTypeAtLocation(token)) == null ? void 0 : _a.getNonNullableType();
|
|
159431
159960
|
const properties = arrayFrom(checker.getUnmatchedProperties(
|
|
159432
159961
|
checker.getTypeAtLocation(parent2.initializer),
|
|
159433
159962
|
targetType,
|
|
@@ -159446,7 +159975,7 @@ function getInfo10(sourceFile, tokenPos, errorCode, checker, program) {
|
|
|
159446
159975
|
return { kind: 4 /* JsxAttributes */, token, attributes, parentDeclaration: token.parent };
|
|
159447
159976
|
}
|
|
159448
159977
|
if (isIdentifier(token)) {
|
|
159449
|
-
const type = (
|
|
159978
|
+
const type = (_b = checker.getContextualType(token)) == null ? void 0 : _b.getNonNullableType();
|
|
159450
159979
|
if (type && getObjectFlags(type) & 16 /* Anonymous */) {
|
|
159451
159980
|
const signature = firstOrUndefined(checker.getSignaturesOfType(type, 0 /* Call */));
|
|
159452
159981
|
if (signature === void 0) return void 0;
|
|
@@ -163887,12 +164416,10 @@ function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, s
|
|
|
163887
164416
|
return typeNodeToAutoImportableTypeNode(typeNode, importAdder, scriptTarget);
|
|
163888
164417
|
}
|
|
163889
164418
|
function typeNodeToAutoImportableTypeNode(typeNode, importAdder, scriptTarget) {
|
|
163890
|
-
|
|
163891
|
-
|
|
163892
|
-
|
|
163893
|
-
|
|
163894
|
-
typeNode = importableReference.typeNode;
|
|
163895
|
-
}
|
|
164419
|
+
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
|
|
164420
|
+
if (importableReference) {
|
|
164421
|
+
importSymbols(importAdder, importableReference.symbols);
|
|
164422
|
+
typeNode = importableReference.typeNode;
|
|
163896
164423
|
}
|
|
163897
164424
|
return getSynthesizedDeepClone(typeNode);
|
|
163898
164425
|
}
|
|
@@ -176824,7 +177351,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
176824
177351
|
}
|
|
176825
177352
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
176826
177353
|
}
|
|
176827
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
177354
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias, verbosityLevel) {
|
|
176828
177355
|
var _a;
|
|
176829
177356
|
const displayParts = [];
|
|
176830
177357
|
let documentation = [];
|
|
@@ -176836,6 +177363,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
176836
177363
|
let documentationFromAlias;
|
|
176837
177364
|
let tagsFromAlias;
|
|
176838
177365
|
let hasMultipleSignatures = false;
|
|
177366
|
+
const typeWriterOut = verbosityLevel !== void 0 ? { couldUnfoldMore: false } : void 0;
|
|
176839
177367
|
if (location.kind === 110 /* ThisKeyword */ && !isThisExpression) {
|
|
176840
177368
|
return { displayParts: [keywordPart(110 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: void 0 };
|
|
176841
177369
|
}
|
|
@@ -176995,7 +177523,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
176995
177523
|
displayParts.push(spacePart());
|
|
176996
177524
|
displayParts.push(operatorPart(64 /* EqualsToken */));
|
|
176997
177525
|
displayParts.push(spacePart());
|
|
176998
|
-
addRange(
|
|
177526
|
+
addRange(
|
|
177527
|
+
displayParts,
|
|
177528
|
+
typeToDisplayParts(
|
|
177529
|
+
typeChecker,
|
|
177530
|
+
location.parent && isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol),
|
|
177531
|
+
enclosingDeclaration,
|
|
177532
|
+
8388608 /* InTypeAlias */,
|
|
177533
|
+
verbosityLevel,
|
|
177534
|
+
typeWriterOut
|
|
177535
|
+
)
|
|
177536
|
+
);
|
|
176999
177537
|
}
|
|
177000
177538
|
if (symbolFlags & 384 /* Enum */) {
|
|
177001
177539
|
prefixNextMeaning();
|
|
@@ -177154,12 +177692,32 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177154
177692
|
displayParts.push(spacePart());
|
|
177155
177693
|
if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */ && symbolKind !== "index" /* indexSignatureElement */) {
|
|
177156
177694
|
const typeParameterParts = mapToDisplayParts((writer) => {
|
|
177157
|
-
const param = typeChecker.typeParameterToDeclaration(
|
|
177695
|
+
const param = typeChecker.typeParameterToDeclaration(
|
|
177696
|
+
type,
|
|
177697
|
+
enclosingDeclaration,
|
|
177698
|
+
symbolDisplayNodeBuilderFlags,
|
|
177699
|
+
/*internalFlags*/
|
|
177700
|
+
void 0,
|
|
177701
|
+
/*tracker*/
|
|
177702
|
+
void 0,
|
|
177703
|
+
verbosityLevel
|
|
177704
|
+
);
|
|
177158
177705
|
getPrinter().writeNode(4 /* Unspecified */, param, getSourceFileOfNode(getParseTreeNode(enclosingDeclaration)), writer);
|
|
177159
177706
|
});
|
|
177160
177707
|
addRange(displayParts, typeParameterParts);
|
|
177161
177708
|
} else {
|
|
177162
|
-
addRange(
|
|
177709
|
+
addRange(
|
|
177710
|
+
displayParts,
|
|
177711
|
+
typeToDisplayParts(
|
|
177712
|
+
typeChecker,
|
|
177713
|
+
type,
|
|
177714
|
+
enclosingDeclaration,
|
|
177715
|
+
/*flags*/
|
|
177716
|
+
void 0,
|
|
177717
|
+
verbosityLevel,
|
|
177718
|
+
typeWriterOut
|
|
177719
|
+
)
|
|
177720
|
+
);
|
|
177163
177721
|
}
|
|
177164
177722
|
if (isTransientSymbol(symbol) && symbol.links.target && isTransientSymbol(symbol.links.target) && symbol.links.target.links.tupleLabelDeclaration) {
|
|
177165
177723
|
const labelDecl = symbol.links.target.links.tupleLabelDeclaration;
|
|
@@ -177224,7 +177782,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177224
177782
|
if (tags.length === 0 && tagsFromAlias) {
|
|
177225
177783
|
tags = tagsFromAlias;
|
|
177226
177784
|
}
|
|
177227
|
-
return {
|
|
177785
|
+
return {
|
|
177786
|
+
displayParts,
|
|
177787
|
+
documentation,
|
|
177788
|
+
symbolKind,
|
|
177789
|
+
tags: tags.length === 0 ? void 0 : tags,
|
|
177790
|
+
canIncreaseVerbosityLevel: typeWriterOut == null ? void 0 : typeWriterOut.couldUnfoldMore
|
|
177791
|
+
};
|
|
177228
177792
|
function getPrinter() {
|
|
177229
177793
|
return createPrinterWithRemoveComments();
|
|
177230
177794
|
}
|
|
@@ -177337,7 +177901,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
177337
177901
|
addRange(displayParts, typeParameterParts);
|
|
177338
177902
|
}
|
|
177339
177903
|
}
|
|
177340
|
-
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
177904
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias, verbosityLevel) {
|
|
177341
177905
|
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
177342
177906
|
typeChecker,
|
|
177343
177907
|
symbol,
|
|
@@ -177347,7 +177911,8 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
177347
177911
|
/*type*/
|
|
177348
177912
|
void 0,
|
|
177349
177913
|
semanticMeaning,
|
|
177350
|
-
alias
|
|
177914
|
+
alias,
|
|
177915
|
+
verbosityLevel
|
|
177351
177916
|
);
|
|
177352
177917
|
}
|
|
177353
177918
|
function isLocalVariableOrFunction(symbol) {
|
|
@@ -193033,8 +193598,8 @@ var Session3 = class _Session {
|
|
|
193033
193598
|
["mapCode" /* MapCode */]: (request) => {
|
|
193034
193599
|
return this.requiredResponse(this.mapCode(request.arguments));
|
|
193035
193600
|
},
|
|
193036
|
-
["copilotRelated" /* CopilotRelated */]: (
|
|
193037
|
-
return this.requiredResponse(this.getCopilotRelatedInfo(
|
|
193601
|
+
["copilotRelated" /* CopilotRelated */]: () => {
|
|
193602
|
+
return this.requiredResponse(this.getCopilotRelatedInfo());
|
|
193038
193603
|
}
|
|
193039
193604
|
}));
|
|
193040
193605
|
this.host = opts.host;
|
|
@@ -193982,10 +194547,9 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
193982
194547
|
const changes = languageService.mapCode(file, args.mapping.contents, focusLocations, formatOptions, preferences);
|
|
193983
194548
|
return this.mapTextChangesToCodeEdits(changes);
|
|
193984
194549
|
}
|
|
193985
|
-
getCopilotRelatedInfo(
|
|
193986
|
-
const { file, project } = this.getFileAndProject(args);
|
|
194550
|
+
getCopilotRelatedInfo() {
|
|
193987
194551
|
return {
|
|
193988
|
-
relatedFiles:
|
|
194552
|
+
relatedFiles: []
|
|
193989
194553
|
};
|
|
193990
194554
|
}
|
|
193991
194555
|
setCompilerOptionsForInferredProjects(args) {
|
|
@@ -194290,7 +194854,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
194290
194854
|
getQuickInfoWorker(args, simplifiedResult) {
|
|
194291
194855
|
const { file, project } = this.getFileAndProject(args);
|
|
194292
194856
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
194293
|
-
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo));
|
|
194857
|
+
const quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo), args.verbosityLevel);
|
|
194294
194858
|
if (!quickInfo) {
|
|
194295
194859
|
return void 0;
|
|
194296
194860
|
}
|
|
@@ -194304,7 +194868,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
194304
194868
|
end: scriptInfo.positionToLineOffset(textSpanEnd(quickInfo.textSpan)),
|
|
194305
194869
|
displayString,
|
|
194306
194870
|
documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation),
|
|
194307
|
-
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts)
|
|
194871
|
+
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts),
|
|
194872
|
+
canIncreaseVerbosityLevel: quickInfo.canIncreaseVerbosityLevel
|
|
194308
194873
|
};
|
|
194309
194874
|
} else {
|
|
194310
194875
|
return useDisplayParts ? quickInfo : {
|
|
@@ -194785,6 +195350,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
194785
195350
|
}
|
|
194786
195351
|
getPasteEdits(args) {
|
|
194787
195352
|
const { file, project } = this.getFileAndProject(args);
|
|
195353
|
+
if (isDynamicFileName(file)) return void 0;
|
|
194788
195354
|
const copiedFrom = args.copiedFrom ? { file: args.copiedFrom.file, range: args.copiedFrom.spans.map((copies) => this.getRange({ file: args.copiedFrom.file, startLine: copies.start.line, startOffset: copies.start.offset, endLine: copies.end.line, endOffset: copies.end.offset }, project.getScriptInfoForNormalizedPath(toNormalizedPath(args.copiedFrom.file)))) } : void 0;
|
|
194789
195355
|
const result = project.getLanguageService().getPasteEdits(
|
|
194790
195356
|
{
|