@typescript-deploys/pr-build 5.5.0-pr-57772-2 → 5.5.0-pr-57465-110
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 +126 -179
- package/lib/tsserver.js +126 -179
- package/lib/typescript.js +126 -179
- package/lib/typingsInstaller.js +1 -1
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -2327,7 +2327,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2327
2327
|
|
|
2328
2328
|
// src/compiler/corePublic.ts
|
|
2329
2329
|
var versionMajorMinor = "5.5";
|
|
2330
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2330
|
+
var version = `${versionMajorMinor}.0-insiders.20240315`;
|
|
2331
2331
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2332
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2333
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -44512,7 +44512,7 @@ function createBinder() {
|
|
|
44512
44512
|
inAssignmentPattern = saveInAssignmentPattern;
|
|
44513
44513
|
return;
|
|
44514
44514
|
}
|
|
44515
|
-
if (node.kind >= 243 /* FirstStatement */ && node.kind <= 259 /* LastStatement */ && !options.allowUnreachableCode) {
|
|
44515
|
+
if (node.kind >= 243 /* FirstStatement */ && node.kind <= 259 /* LastStatement */ && (!options.allowUnreachableCode || node.kind === 253 /* ReturnStatement */)) {
|
|
44516
44516
|
node.flowNode = currentFlow;
|
|
44517
44517
|
}
|
|
44518
44518
|
switch (node.kind) {
|
|
@@ -52540,18 +52540,7 @@ function createTypeChecker(host) {
|
|
|
52540
52540
|
function createNodeBuilder() {
|
|
52541
52541
|
return {
|
|
52542
52542
|
typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
52543
|
-
|
|
52544
|
-
serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(
|
|
52545
|
-
context,
|
|
52546
|
-
type,
|
|
52547
|
-
symbol,
|
|
52548
|
-
enclosingDeclaration,
|
|
52549
|
-
/*includePrivateSymbol*/
|
|
52550
|
-
void 0,
|
|
52551
|
-
/*bundled*/
|
|
52552
|
-
void 0,
|
|
52553
|
-
addUndefined
|
|
52554
|
-
)),
|
|
52543
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
|
|
52555
52544
|
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
52556
52545
|
indexInfo,
|
|
52557
52546
|
context,
|
|
@@ -52573,47 +52562,6 @@ function createTypeChecker(host) {
|
|
|
52573
52562
|
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker, bundled) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context, bundled)),
|
|
52574
52563
|
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
|
52575
52564
|
};
|
|
52576
|
-
function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
|
|
52577
|
-
if (expr) {
|
|
52578
|
-
const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
|
|
52579
|
-
if (typeNode && !isConstTypeReference(typeNode)) {
|
|
52580
|
-
const result = tryReuseExistingTypeNode(context, typeNode, type, expr.parent, addUndefined);
|
|
52581
|
-
if (result) {
|
|
52582
|
-
return result;
|
|
52583
|
-
}
|
|
52584
|
-
}
|
|
52585
|
-
}
|
|
52586
|
-
if (addUndefined) {
|
|
52587
|
-
type = getOptionalType(type);
|
|
52588
|
-
}
|
|
52589
|
-
return typeToTypeNodeHelper(type, context);
|
|
52590
|
-
}
|
|
52591
|
-
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined, includePrivateSymbol, bundled) {
|
|
52592
|
-
const originalType = type;
|
|
52593
|
-
if (addUndefined) {
|
|
52594
|
-
type = getOptionalType(type);
|
|
52595
|
-
}
|
|
52596
|
-
const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2, includePrivateSymbol, bundled);
|
|
52597
|
-
if (clone2) {
|
|
52598
|
-
return clone2;
|
|
52599
|
-
}
|
|
52600
|
-
if (addUndefined && originalType !== type) {
|
|
52601
|
-
const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2, includePrivateSymbol, bundled);
|
|
52602
|
-
if (cloneMissingUndefined) {
|
|
52603
|
-
return factory.createUnionTypeNode([cloneMissingUndefined, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
52604
|
-
}
|
|
52605
|
-
}
|
|
52606
|
-
return void 0;
|
|
52607
|
-
}
|
|
52608
|
-
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, includePrivateSymbol, bundled, annotationType) {
|
|
52609
|
-
if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
52610
|
-
const result = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
52611
|
-
if (result) {
|
|
52612
|
-
return result;
|
|
52613
|
-
}
|
|
52614
|
-
}
|
|
52615
|
-
return void 0;
|
|
52616
|
-
}
|
|
52617
52565
|
function symbolToNode(symbol, context, meaning) {
|
|
52618
52566
|
if (context.flags & 1073741824 /* WriteComputedProps */) {
|
|
52619
52567
|
if (symbol.valueDeclaration) {
|
|
@@ -53055,8 +53003,8 @@ function createTypeChecker(host) {
|
|
|
53055
53003
|
if (isInstantiationExpressionType) {
|
|
53056
53004
|
const instantiationExpressionType = type2;
|
|
53057
53005
|
const existing = instantiationExpressionType.node;
|
|
53058
|
-
if (isTypeQueryNode(existing)) {
|
|
53059
|
-
const typeNode =
|
|
53006
|
+
if (isTypeQueryNode(existing) && getTypeFromTypeNode(existing) === type2) {
|
|
53007
|
+
const typeNode = serializeExistingTypeNode(context, existing);
|
|
53060
53008
|
if (typeNode) {
|
|
53061
53009
|
return typeNode;
|
|
53062
53010
|
}
|
|
@@ -53719,10 +53667,7 @@ function createTypeChecker(host) {
|
|
|
53719
53667
|
let returnTypeNode;
|
|
53720
53668
|
const typePredicate = getTypePredicateOfSignature(signature);
|
|
53721
53669
|
if (typePredicate) {
|
|
53722
|
-
|
|
53723
|
-
const parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? setEmitFlags(factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : factory.createThisTypeNode();
|
|
53724
|
-
const typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
|
|
53725
|
-
returnTypeNode = factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
|
|
53670
|
+
returnTypeNode = typePredicateToTypePredicateNodeHelper(typePredicate, context);
|
|
53726
53671
|
} else {
|
|
53727
53672
|
const returnType = getReturnTypeOfSignature(signature);
|
|
53728
53673
|
if (returnType && !(suppressAny && isTypeAny(returnType))) {
|
|
@@ -53848,6 +53793,12 @@ function createTypeChecker(host) {
|
|
|
53848
53793
|
const constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
53849
53794
|
return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
|
|
53850
53795
|
}
|
|
53796
|
+
function typePredicateToTypePredicateNodeHelper(typePredicate, context) {
|
|
53797
|
+
const assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? factory.createToken(131 /* AssertsKeyword */) : void 0;
|
|
53798
|
+
const parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? setEmitFlags(factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : factory.createThisTypeNode();
|
|
53799
|
+
const typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
|
|
53800
|
+
return factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
|
|
53801
|
+
}
|
|
53851
53802
|
function getEffectiveParameterDeclaration(parameterSymbol) {
|
|
53852
53803
|
const parameterDeclaration = getDeclarationOfKind(parameterSymbol, 169 /* Parameter */);
|
|
53853
53804
|
if (parameterDeclaration) {
|
|
@@ -53859,9 +53810,11 @@ function createTypeChecker(host) {
|
|
|
53859
53810
|
}
|
|
53860
53811
|
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
|
|
53861
53812
|
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
53862
|
-
|
|
53863
|
-
|
|
53864
|
-
|
|
53813
|
+
let parameterType = getTypeOfSymbol(parameterSymbol);
|
|
53814
|
+
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
|
53815
|
+
parameterType = getOptionalType(parameterType);
|
|
53816
|
+
}
|
|
53817
|
+
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
53865
53818
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
53866
53819
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
53867
53820
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
@@ -54451,15 +54404,16 @@ function createTypeChecker(host) {
|
|
|
54451
54404
|
}
|
|
54452
54405
|
return enclosingDeclaration;
|
|
54453
54406
|
}
|
|
54454
|
-
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled
|
|
54455
|
-
var _a;
|
|
54407
|
+
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
54456
54408
|
if (!isErrorType(type) && enclosingDeclaration) {
|
|
54457
54409
|
const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
|
|
54458
54410
|
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
54459
54411
|
const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
54460
|
-
|
|
54461
|
-
|
|
54462
|
-
|
|
54412
|
+
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
54413
|
+
const result2 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
54414
|
+
if (result2) {
|
|
54415
|
+
return result2;
|
|
54416
|
+
}
|
|
54463
54417
|
}
|
|
54464
54418
|
}
|
|
54465
54419
|
}
|
|
@@ -54467,17 +54421,16 @@ function createTypeChecker(host) {
|
|
|
54467
54421
|
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
|
|
54468
54422
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
54469
54423
|
}
|
|
54470
|
-
const
|
|
54471
|
-
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
|
|
54472
|
-
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
|
|
54424
|
+
const result = typeToTypeNodeHelper(type, context);
|
|
54473
54425
|
context.flags = oldFlags;
|
|
54474
54426
|
return result;
|
|
54475
54427
|
}
|
|
54476
|
-
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type
|
|
54428
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
54429
|
+
const typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
54477
54430
|
if (typeFromTypeNode === type) {
|
|
54478
54431
|
return true;
|
|
54479
54432
|
}
|
|
54480
|
-
if (
|
|
54433
|
+
if (isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
54481
54434
|
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
54482
54435
|
}
|
|
54483
54436
|
return false;
|
|
@@ -54489,9 +54442,11 @@ function createTypeChecker(host) {
|
|
|
54489
54442
|
if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
|
|
54490
54443
|
const annotated = getTypeFromTypeNode(annotation);
|
|
54491
54444
|
const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
|
|
54492
|
-
|
|
54493
|
-
|
|
54494
|
-
|
|
54445
|
+
if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
|
|
54446
|
+
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
|
|
54447
|
+
if (result) {
|
|
54448
|
+
return result;
|
|
54449
|
+
}
|
|
54495
54450
|
}
|
|
54496
54451
|
}
|
|
54497
54452
|
}
|
|
@@ -54520,9 +54475,7 @@ function createTypeChecker(host) {
|
|
|
54520
54475
|
/*shouldComputeAliasesToMakeVisible*/
|
|
54521
54476
|
false
|
|
54522
54477
|
).accessibility !== 0 /* Accessible */) {
|
|
54523
|
-
|
|
54524
|
-
introducesError = true;
|
|
54525
|
-
}
|
|
54478
|
+
introducesError = true;
|
|
54526
54479
|
} else {
|
|
54527
54480
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
|
|
54528
54481
|
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
@@ -54660,31 +54613,6 @@ function createTypeChecker(host) {
|
|
|
54660
54613
|
node.isTypeOf
|
|
54661
54614
|
);
|
|
54662
54615
|
}
|
|
54663
|
-
if (isParameter(node)) {
|
|
54664
|
-
if (!node.type && !node.initializer) {
|
|
54665
|
-
return factory.updateParameterDeclaration(
|
|
54666
|
-
node,
|
|
54667
|
-
/*modifiers*/
|
|
54668
|
-
void 0,
|
|
54669
|
-
node.dotDotDotToken,
|
|
54670
|
-
visitEachChild(
|
|
54671
|
-
node.name,
|
|
54672
|
-
visitExistingNodeTreeSymbols,
|
|
54673
|
-
/*context*/
|
|
54674
|
-
void 0
|
|
54675
|
-
),
|
|
54676
|
-
node.questionToken,
|
|
54677
|
-
factory.createKeywordTypeNode(133 /* AnyKeyword */),
|
|
54678
|
-
/*initializer*/
|
|
54679
|
-
void 0
|
|
54680
|
-
);
|
|
54681
|
-
}
|
|
54682
|
-
}
|
|
54683
|
-
if (isPropertySignature(node)) {
|
|
54684
|
-
if (!node.type && !node.initializer) {
|
|
54685
|
-
return factory.updatePropertySignature(node, node.modifiers, node.name, node.questionToken, factory.createKeywordTypeNode(133 /* AnyKeyword */));
|
|
54686
|
-
}
|
|
54687
|
-
}
|
|
54688
54616
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
54689
54617
|
const { introducesError, node: result } = trackExistingEntityName(node, context, includePrivateSymbol);
|
|
54690
54618
|
hadError = hadError || introducesError;
|
|
@@ -54692,7 +54620,7 @@ function createTypeChecker(host) {
|
|
|
54692
54620
|
return result;
|
|
54693
54621
|
}
|
|
54694
54622
|
}
|
|
54695
|
-
if (file && isTupleTypeNode(node) &&
|
|
54623
|
+
if (file && isTupleTypeNode(node) && getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line) {
|
|
54696
54624
|
setEmitFlags(node, 1 /* SingleLine */);
|
|
54697
54625
|
}
|
|
54698
54626
|
return visitEachChild(
|
|
@@ -55216,15 +55144,7 @@ function createTypeChecker(host) {
|
|
|
55216
55144
|
context.flags |= 8388608 /* InTypeAlias */;
|
|
55217
55145
|
const oldEnclosingDecl = context.enclosingDeclaration;
|
|
55218
55146
|
context.enclosingDeclaration = jsdocAliasDecl;
|
|
55219
|
-
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) &&
|
|
55220
|
-
context,
|
|
55221
|
-
jsdocAliasDecl.typeExpression.type,
|
|
55222
|
-
aliasType,
|
|
55223
|
-
/*host*/
|
|
55224
|
-
void 0,
|
|
55225
|
-
includePrivateSymbol,
|
|
55226
|
-
bundled
|
|
55227
|
-
) || typeToTypeNodeHelper(aliasType, context);
|
|
55147
|
+
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context);
|
|
55228
55148
|
addResult(
|
|
55229
55149
|
setSyntheticLeadingComments(
|
|
55230
55150
|
factory.createTypeAliasDeclaration(
|
|
@@ -55457,15 +55377,7 @@ function createTypeChecker(host) {
|
|
|
55457
55377
|
}
|
|
55458
55378
|
return cleanup(factory.createExpressionWithTypeArguments(
|
|
55459
55379
|
expr,
|
|
55460
|
-
map(e.typeArguments, (a) =>
|
|
55461
|
-
context,
|
|
55462
|
-
a,
|
|
55463
|
-
getTypeFromTypeNode(a),
|
|
55464
|
-
/*host*/
|
|
55465
|
-
void 0,
|
|
55466
|
-
includePrivateSymbol,
|
|
55467
|
-
bundled
|
|
55468
|
-
) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
|
|
55380
|
+
map(e.typeArguments, (a) => serializeExistingTypeNode(context, a, includePrivateSymbol, bundled) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
|
|
55469
55381
|
));
|
|
55470
55382
|
function cleanup(result2) {
|
|
55471
55383
|
context.enclosingDeclaration = oldEnclosing;
|
|
@@ -55924,10 +55836,8 @@ function createTypeChecker(host) {
|
|
|
55924
55836
|
}
|
|
55925
55837
|
}
|
|
55926
55838
|
function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
|
|
55927
|
-
var _a2;
|
|
55928
55839
|
const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
|
|
55929
|
-
return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !
|
|
55930
|
-
!length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
|
|
55840
|
+
return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
|
|
55931
55841
|
!!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
|
|
55932
55842
|
!getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
|
|
55933
55843
|
if (!isIdentifierText(symbolName(p), languageVersion)) {
|
|
@@ -56250,12 +56160,8 @@ function createTypeChecker(host) {
|
|
|
56250
56160
|
function typePredicateToString(typePredicate, enclosingDeclaration, flags = 16384 /* UseAliasDefinedOutsideCurrentScope */, writer) {
|
|
56251
56161
|
return writer ? typePredicateToStringWorker(writer).getText() : usingSingleLineStringWriter(typePredicateToStringWorker);
|
|
56252
56162
|
function typePredicateToStringWorker(writer2) {
|
|
56253
|
-
const
|
|
56254
|
-
|
|
56255
|
-
typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? factory.createIdentifier(typePredicate.parameterName) : factory.createThisTypeNode(),
|
|
56256
|
-
typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)
|
|
56257
|
-
// TODO: GH#18217
|
|
56258
|
-
);
|
|
56163
|
+
const nodeBuilderFlags = toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */;
|
|
56164
|
+
const predicate = nodeBuilder.typePredicateToTypePredicateNode(typePredicate, enclosingDeclaration, nodeBuilderFlags);
|
|
56259
56165
|
const printer = createPrinterWithRemoveComments();
|
|
56260
56166
|
const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
|
|
56261
56167
|
printer.writeNode(
|
|
@@ -60506,7 +60412,15 @@ function createTypeChecker(host) {
|
|
|
60506
60412
|
jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
|
|
60507
60413
|
}
|
|
60508
60414
|
}
|
|
60509
|
-
|
|
60415
|
+
if (type || jsdocPredicate) {
|
|
60416
|
+
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
60417
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
60418
|
+
const { declaration } = signature;
|
|
60419
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
60420
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
60421
|
+
} else {
|
|
60422
|
+
signature.resolvedTypePredicate = noTypePredicate;
|
|
60423
|
+
}
|
|
60510
60424
|
}
|
|
60511
60425
|
Debug.assert(!!signature.resolvedTypePredicate);
|
|
60512
60426
|
}
|
|
@@ -62694,6 +62608,7 @@ function createTypeChecker(host) {
|
|
|
62694
62608
|
return links.resolvedType;
|
|
62695
62609
|
}
|
|
62696
62610
|
function getTemplateLiteralType(texts, types) {
|
|
62611
|
+
var _a, _b;
|
|
62697
62612
|
const unionIndex = findIndex(types, (t) => !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)));
|
|
62698
62613
|
if (unionIndex >= 0) {
|
|
62699
62614
|
return checkCrossProductUnion(types) ? mapType(types[unionIndex], (t) => getTemplateLiteralType(texts, replaceElement(types, unionIndex, t))) : errorType;
|
|
@@ -62701,6 +62616,9 @@ function createTypeChecker(host) {
|
|
|
62701
62616
|
if (contains(types, wildcardType)) {
|
|
62702
62617
|
return wildcardType;
|
|
62703
62618
|
}
|
|
62619
|
+
if (texts.length === 2 && texts[0] === "" && texts[1] === "" && !(types[0].flags & 2944 /* Literal */) && !((_b = (_a = types[0].symbol) == null ? void 0 : _a.declarations) == null ? void 0 : _b.some((d) => d.parent.kind === 195 /* InferType */)) && isTypeAssignableTo(types[0], stringType)) {
|
|
62620
|
+
return types[0];
|
|
62621
|
+
}
|
|
62704
62622
|
const newTypes = [];
|
|
62705
62623
|
const newTexts = [];
|
|
62706
62624
|
let text = texts[0];
|
|
@@ -78936,6 +78854,67 @@ function createTypeChecker(host) {
|
|
|
78936
78854
|
return false;
|
|
78937
78855
|
}
|
|
78938
78856
|
}
|
|
78857
|
+
function getTypePredicateFromBody(func) {
|
|
78858
|
+
switch (func.kind) {
|
|
78859
|
+
case 176 /* Constructor */:
|
|
78860
|
+
case 177 /* GetAccessor */:
|
|
78861
|
+
case 178 /* SetAccessor */:
|
|
78862
|
+
return void 0;
|
|
78863
|
+
}
|
|
78864
|
+
const functionFlags = getFunctionFlags(func);
|
|
78865
|
+
if (functionFlags !== 0 /* Normal */)
|
|
78866
|
+
return void 0;
|
|
78867
|
+
let singleReturn;
|
|
78868
|
+
if (func.body && func.body.kind !== 241 /* Block */) {
|
|
78869
|
+
singleReturn = func.body;
|
|
78870
|
+
} else {
|
|
78871
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
78872
|
+
if (singleReturn || !returnStatement.expression)
|
|
78873
|
+
return true;
|
|
78874
|
+
singleReturn = returnStatement.expression;
|
|
78875
|
+
});
|
|
78876
|
+
if (bailedEarly || !singleReturn || functionHasImplicitReturn(func))
|
|
78877
|
+
return void 0;
|
|
78878
|
+
}
|
|
78879
|
+
return checkIfExpressionRefinesAnyParameter(func, singleReturn);
|
|
78880
|
+
}
|
|
78881
|
+
function checkIfExpressionRefinesAnyParameter(func, expr) {
|
|
78882
|
+
expr = skipParentheses(
|
|
78883
|
+
expr,
|
|
78884
|
+
/*excludeJSDocTypeAssertions*/
|
|
78885
|
+
true
|
|
78886
|
+
);
|
|
78887
|
+
const returnType = checkExpressionCached(expr);
|
|
78888
|
+
if (!(returnType.flags & 16 /* Boolean */))
|
|
78889
|
+
return void 0;
|
|
78890
|
+
return forEach(func.parameters, (param, i) => {
|
|
78891
|
+
const initType = getTypeOfSymbol(param.symbol);
|
|
78892
|
+
if (!initType || initType.flags & 16 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
78893
|
+
return;
|
|
78894
|
+
}
|
|
78895
|
+
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
78896
|
+
if (trueType2) {
|
|
78897
|
+
return createTypePredicate(1 /* Identifier */, unescapeLeadingUnderscores(param.name.escapedText), i, trueType2);
|
|
78898
|
+
}
|
|
78899
|
+
});
|
|
78900
|
+
}
|
|
78901
|
+
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
78902
|
+
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
|
|
78903
|
+
const trueCondition = {
|
|
78904
|
+
flags: 32 /* TrueCondition */,
|
|
78905
|
+
node: expr,
|
|
78906
|
+
antecedent
|
|
78907
|
+
};
|
|
78908
|
+
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
78909
|
+
if (trueType2 === initType)
|
|
78910
|
+
return void 0;
|
|
78911
|
+
const falseCondition = {
|
|
78912
|
+
...trueCondition,
|
|
78913
|
+
flags: 64 /* FalseCondition */
|
|
78914
|
+
};
|
|
78915
|
+
const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
|
|
78916
|
+
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
78917
|
+
}
|
|
78939
78918
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
78940
78919
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
78941
78920
|
return;
|
|
@@ -87688,34 +87667,14 @@ function createTypeChecker(host) {
|
|
|
87688
87667
|
return factory.createToken(133 /* AnyKeyword */);
|
|
87689
87668
|
}
|
|
87690
87669
|
const symbol = getSymbolOfDeclaration(declaration);
|
|
87691
|
-
|
|
87692
|
-
|
|
87693
|
-
|
|
87694
|
-
function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
|
|
87695
|
-
return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
|
|
87696
|
-
}
|
|
87697
|
-
function getPossibleTypeNodeReuseExpression(declaration) {
|
|
87698
|
-
var _a;
|
|
87699
|
-
return isFunctionLike(declaration) && !isSetAccessor(declaration) ? getSingleReturnExpression(declaration) : isExportAssignment(declaration) ? declaration.expression : !!declaration.initializer ? declaration.initializer : isParameter(declaration) && isSetAccessor(declaration.parent) ? getSingleReturnExpression(getAllAccessorDeclarations((_a = getSymbolOfDeclaration(declaration.parent)) == null ? void 0 : _a.declarations, declaration.parent).getAccessor) : void 0;
|
|
87700
|
-
}
|
|
87701
|
-
function getSingleReturnExpression(declaration) {
|
|
87702
|
-
let candidateExpr;
|
|
87703
|
-
if (declaration && !nodeIsMissing(declaration.body)) {
|
|
87704
|
-
const body = declaration.body;
|
|
87705
|
-
if (body && isBlock(body)) {
|
|
87706
|
-
forEachReturnStatement(body, (s) => {
|
|
87707
|
-
if (!candidateExpr) {
|
|
87708
|
-
candidateExpr = s.expression;
|
|
87709
|
-
} else {
|
|
87710
|
-
candidateExpr = void 0;
|
|
87711
|
-
return true;
|
|
87712
|
-
}
|
|
87713
|
-
});
|
|
87714
|
-
} else {
|
|
87715
|
-
candidateExpr = body;
|
|
87716
|
-
}
|
|
87670
|
+
let type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
|
|
87671
|
+
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol) {
|
|
87672
|
+
flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
87717
87673
|
}
|
|
87718
|
-
|
|
87674
|
+
if (addUndefined) {
|
|
87675
|
+
type = getOptionalType(type);
|
|
87676
|
+
}
|
|
87677
|
+
return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87719
87678
|
}
|
|
87720
87679
|
function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
|
|
87721
87680
|
const signatureDeclaration = getParseTreeNode(signatureDeclarationIn, isFunctionLike);
|
|
@@ -87723,15 +87682,11 @@ function createTypeChecker(host) {
|
|
|
87723
87682
|
return factory.createToken(133 /* AnyKeyword */);
|
|
87724
87683
|
}
|
|
87725
87684
|
const signature = getSignatureFromDeclaration(signatureDeclaration);
|
|
87726
|
-
|
|
87727
|
-
|
|
87728
|
-
|
|
87729
|
-
|
|
87730
|
-
|
|
87731
|
-
enclosingDeclaration,
|
|
87732
|
-
flags | 1024 /* MultilineObjectLiterals */,
|
|
87733
|
-
tracker
|
|
87734
|
-
);
|
|
87685
|
+
const typePredicate = getTypePredicateOfSignature(signature);
|
|
87686
|
+
if (typePredicate) {
|
|
87687
|
+
return nodeBuilder.typePredicateToTypePredicateNode(typePredicate, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87688
|
+
}
|
|
87689
|
+
return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87735
87690
|
}
|
|
87736
87691
|
function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
|
|
87737
87692
|
const expr = getParseTreeNode(exprIn, isExpression);
|
|
@@ -87739,15 +87694,7 @@ function createTypeChecker(host) {
|
|
|
87739
87694
|
return factory.createToken(133 /* AnyKeyword */);
|
|
87740
87695
|
}
|
|
87741
87696
|
const type = getWidenedType(getRegularTypeOfExpression(expr));
|
|
87742
|
-
return nodeBuilder.
|
|
87743
|
-
type,
|
|
87744
|
-
expr,
|
|
87745
|
-
/*addUndefined*/
|
|
87746
|
-
void 0,
|
|
87747
|
-
enclosingDeclaration,
|
|
87748
|
-
flags | 1024 /* MultilineObjectLiterals */,
|
|
87749
|
-
tracker
|
|
87750
|
-
);
|
|
87697
|
+
return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87751
87698
|
}
|
|
87752
87699
|
function hasGlobalName(name) {
|
|
87753
87700
|
return globals.has(escapeLeadingUnderscores(name));
|