@typescript-deploys/pr-build 5.5.0-pr-58525-2 → 5.5.0-pr-58495-31
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 +201 -77
- package/lib/typescript.js +214 -89
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240515`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6732,7 +6732,6 @@ var Diagnostics = {
|
|
|
6732
6732
|
Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
|
|
6733
6733
|
Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
|
|
6734
6734
|
Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
|
|
6735
|
-
Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
|
|
6736
6735
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
6737
6736
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
|
|
6738
6737
|
Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
|
|
@@ -13652,7 +13651,8 @@ function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
|
|
|
13652
13651
|
}
|
|
13653
13652
|
function getJSDocCommentRanges(node, text) {
|
|
13654
13653
|
const commentRanges = node.kind === 169 /* Parameter */ || node.kind === 168 /* TypeParameter */ || node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */ || node.kind === 217 /* ParenthesizedExpression */ || node.kind === 260 /* VariableDeclaration */ || node.kind === 281 /* ExportSpecifier */ ? concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRanges(text, node.pos);
|
|
13655
|
-
return filter(commentRanges, (comment) =>
|
|
13654
|
+
return filter(commentRanges, (comment) => comment.end <= node.end && // Due to parse errors sometime empty parameter may get comments assigned to it that end up not in parameter range
|
|
13655
|
+
text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
|
|
13656
13656
|
}
|
|
13657
13657
|
var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
|
13658
13658
|
var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
|
@@ -49020,7 +49020,7 @@ function createTypeChecker(host) {
|
|
|
49020
49020
|
return { accessibility: 0 /* Accessible */ };
|
|
49021
49021
|
}
|
|
49022
49022
|
return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
|
|
49023
|
-
accessibility:
|
|
49023
|
+
accessibility: 3 /* NotResolved */,
|
|
49024
49024
|
errorSymbolName: getTextOfNode(firstIdentifier),
|
|
49025
49025
|
errorNode: firstIdentifier
|
|
49026
49026
|
};
|
|
@@ -49158,6 +49158,7 @@ function createTypeChecker(host) {
|
|
|
49158
49158
|
if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
|
|
49159
49159
|
range = factory.cloneNode(range);
|
|
49160
49160
|
}
|
|
49161
|
+
if (range === location) return range;
|
|
49161
49162
|
if (!location) {
|
|
49162
49163
|
return range;
|
|
49163
49164
|
}
|
|
@@ -51294,6 +51295,57 @@ function createTypeChecker(host) {
|
|
|
51294
51295
|
return updated;
|
|
51295
51296
|
}
|
|
51296
51297
|
}
|
|
51298
|
+
function serializeTypeName(context, node, isTypeOf, typeArguments) {
|
|
51299
|
+
const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
|
|
51300
|
+
const symbol = resolveEntityName(
|
|
51301
|
+
node,
|
|
51302
|
+
meaning,
|
|
51303
|
+
/*ignoreErrors*/
|
|
51304
|
+
true
|
|
51305
|
+
);
|
|
51306
|
+
if (!symbol) return void 0;
|
|
51307
|
+
const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
|
|
51308
|
+
if (isSymbolAccessible(
|
|
51309
|
+
symbol,
|
|
51310
|
+
context.enclosingDeclaration,
|
|
51311
|
+
meaning,
|
|
51312
|
+
/*shouldComputeAliasesToMakeVisible*/
|
|
51313
|
+
false
|
|
51314
|
+
).accessibility !== 0 /* Accessible */) return void 0;
|
|
51315
|
+
return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
|
|
51316
|
+
}
|
|
51317
|
+
function canReuseTypeNode(context, existing) {
|
|
51318
|
+
if (isInJSFile(existing)) {
|
|
51319
|
+
if (isLiteralImportTypeNode(existing)) {
|
|
51320
|
+
void getTypeFromImportTypeNode(existing);
|
|
51321
|
+
const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
|
|
51322
|
+
return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
|
|
51323
|
+
(!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
51324
|
+
!(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
|
|
51325
|
+
}
|
|
51326
|
+
}
|
|
51327
|
+
if (isTypeReferenceNode(existing)) {
|
|
51328
|
+
if (isConstTypeReference(existing)) return false;
|
|
51329
|
+
const type = getTypeFromTypeReference(existing);
|
|
51330
|
+
const symbol = getNodeLinks(existing).resolvedSymbol;
|
|
51331
|
+
if (!symbol) return false;
|
|
51332
|
+
if (symbol.flags & 262144 /* TypeParameter */) {
|
|
51333
|
+
return true;
|
|
51334
|
+
}
|
|
51335
|
+
if (isInJSDoc(existing)) {
|
|
51336
|
+
return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
|
|
51337
|
+
}
|
|
51338
|
+
}
|
|
51339
|
+
if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
|
|
51340
|
+
const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
|
|
51341
|
+
return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
|
|
51342
|
+
}
|
|
51343
|
+
return true;
|
|
51344
|
+
}
|
|
51345
|
+
function serializeExistingTypeNode(context, typeNode) {
|
|
51346
|
+
const type = getTypeFromTypeNode(typeNode);
|
|
51347
|
+
return typeToTypeNodeHelper(type, context);
|
|
51348
|
+
}
|
|
51297
51349
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
51298
51350
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
51299
51351
|
cancellationToken.throwIfCancellationRequested();
|
|
@@ -51303,6 +51355,7 @@ function createTypeChecker(host) {
|
|
|
51303
51355
|
if (hadError) {
|
|
51304
51356
|
return void 0;
|
|
51305
51357
|
}
|
|
51358
|
+
context.approximateLength += existing.end - existing.pos;
|
|
51306
51359
|
return transformed;
|
|
51307
51360
|
function visitExistingNodeTreeSymbols(node) {
|
|
51308
51361
|
const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
|
|
@@ -51402,20 +51455,38 @@ function createTypeChecker(host) {
|
|
|
51402
51455
|
);
|
|
51403
51456
|
}
|
|
51404
51457
|
}
|
|
51405
|
-
if (isTypeReferenceNode(node)
|
|
51406
|
-
node
|
|
51407
|
-
|
|
51408
|
-
|
|
51409
|
-
|
|
51410
|
-
|
|
51411
|
-
|
|
51458
|
+
if (isTypeReferenceNode(node)) {
|
|
51459
|
+
if (canReuseTypeNode(context, node)) {
|
|
51460
|
+
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
|
|
51461
|
+
const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
|
|
51462
|
+
if (!introducesError) {
|
|
51463
|
+
const updated = factory.updateTypeReferenceNode(
|
|
51464
|
+
node,
|
|
51465
|
+
newName,
|
|
51466
|
+
typeArguments
|
|
51467
|
+
);
|
|
51468
|
+
return setTextRange2(context, updated, node);
|
|
51469
|
+
} else {
|
|
51470
|
+
const serializedName = serializeTypeName(
|
|
51471
|
+
context,
|
|
51472
|
+
node.typeName,
|
|
51473
|
+
/*isTypeOf*/
|
|
51474
|
+
false,
|
|
51475
|
+
typeArguments
|
|
51476
|
+
);
|
|
51477
|
+
if (serializedName) {
|
|
51478
|
+
return setTextRange2(context, serializedName, node.typeName);
|
|
51479
|
+
}
|
|
51480
|
+
}
|
|
51481
|
+
}
|
|
51482
|
+
return serializeExistingTypeNode(context, node);
|
|
51412
51483
|
}
|
|
51413
51484
|
if (isLiteralImportTypeNode(node)) {
|
|
51414
51485
|
const nodeSymbol = getNodeLinks(node).resolvedSymbol;
|
|
51415
51486
|
if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
|
|
51416
51487
|
(!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
51417
51488
|
!(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
|
|
51418
|
-
return
|
|
51489
|
+
return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51419
51490
|
}
|
|
51420
51491
|
return factory.updateImportTypeNode(
|
|
51421
51492
|
node,
|
|
@@ -51447,13 +51518,48 @@ function createTypeChecker(host) {
|
|
|
51447
51518
|
}
|
|
51448
51519
|
return visited;
|
|
51449
51520
|
}
|
|
51450
|
-
if (
|
|
51451
|
-
|
|
51452
|
-
|
|
51521
|
+
if (isTypeQueryNode(node)) {
|
|
51522
|
+
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
|
|
51523
|
+
if (introducesError) {
|
|
51524
|
+
const serializedName = serializeTypeName(
|
|
51525
|
+
context,
|
|
51526
|
+
node.exprName,
|
|
51527
|
+
/*isTypeOf*/
|
|
51528
|
+
true
|
|
51529
|
+
);
|
|
51530
|
+
if (serializedName) {
|
|
51531
|
+
return setTextRange2(context, serializedName, node.exprName);
|
|
51532
|
+
}
|
|
51533
|
+
return serializeExistingTypeNode(context, node);
|
|
51453
51534
|
}
|
|
51454
|
-
|
|
51535
|
+
return factory.updateTypeQueryNode(
|
|
51536
|
+
node,
|
|
51537
|
+
exprName,
|
|
51538
|
+
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
51539
|
+
);
|
|
51540
|
+
}
|
|
51541
|
+
if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
|
|
51542
|
+
const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
|
|
51543
|
+
if (!introducesError) {
|
|
51544
|
+
return factory.updateComputedPropertyName(node, result);
|
|
51545
|
+
} else {
|
|
51546
|
+
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
|
51547
|
+
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
|
51548
|
+
Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
|
|
51549
|
+
const literal = computedPropertyNameType.literal;
|
|
51550
|
+
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
|
51551
|
+
return factory.createIdentifier(literal.text);
|
|
51552
|
+
}
|
|
51553
|
+
if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
|
|
51554
|
+
return literal;
|
|
51555
|
+
}
|
|
51556
|
+
return factory.updateComputedPropertyName(node, literal);
|
|
51557
|
+
}
|
|
51558
|
+
}
|
|
51559
|
+
if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
|
|
51560
|
+
const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
|
|
51455
51561
|
hadError = hadError || introducesError;
|
|
51456
|
-
return result;
|
|
51562
|
+
return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
51457
51563
|
}
|
|
51458
51564
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
51459
51565
|
const visited = visitEachChild(
|
|
@@ -51487,6 +51593,11 @@ function createTypeChecker(host) {
|
|
|
51487
51593
|
falseType2
|
|
51488
51594
|
);
|
|
51489
51595
|
}
|
|
51596
|
+
if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
|
|
51597
|
+
if (!canReuseTypeNode(context, node)) {
|
|
51598
|
+
return serializeExistingTypeNode(context, node);
|
|
51599
|
+
}
|
|
51600
|
+
}
|
|
51490
51601
|
return visitEachChild(
|
|
51491
51602
|
node,
|
|
51492
51603
|
visitExistingNodeTreeSymbols,
|
|
@@ -57273,10 +57384,14 @@ function createTypeChecker(host) {
|
|
|
57273
57384
|
}
|
|
57274
57385
|
if (type || jsdocPredicate) {
|
|
57275
57386
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
57276
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
57387
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & (16 /* Boolean */ | 49152 /* VoidLike */)) && getParameterCount(signature) > 0) {
|
|
57277
57388
|
const { declaration } = signature;
|
|
57278
57389
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
57279
|
-
signature.
|
|
57390
|
+
if (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) {
|
|
57391
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
57392
|
+
} else if (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 49152 /* VoidLike */) {
|
|
57393
|
+
signature.resolvedTypePredicate = getTypeAssertionFromBody(declaration) || noTypePredicate;
|
|
57394
|
+
}
|
|
57280
57395
|
} else {
|
|
57281
57396
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
57282
57397
|
}
|
|
@@ -76074,6 +76189,48 @@ function createTypeChecker(host) {
|
|
|
76074
76189
|
const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
|
|
76075
76190
|
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
76076
76191
|
}
|
|
76192
|
+
function getTypeAssertionFromBody(func) {
|
|
76193
|
+
switch (func.kind) {
|
|
76194
|
+
case 176 /* Constructor */:
|
|
76195
|
+
case 177 /* GetAccessor */:
|
|
76196
|
+
case 178 /* SetAccessor */:
|
|
76197
|
+
case 219 /* ArrowFunction */:
|
|
76198
|
+
case 218 /* FunctionExpression */:
|
|
76199
|
+
case 174 /* MethodDeclaration */:
|
|
76200
|
+
return void 0;
|
|
76201
|
+
}
|
|
76202
|
+
const functionFlags = getFunctionFlags(func);
|
|
76203
|
+
if (functionFlags !== 0 /* Normal */ || !func.body) return void 0;
|
|
76204
|
+
const returnFlowNodes = [];
|
|
76205
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
76206
|
+
if (!returnStatement.flowNode) {
|
|
76207
|
+
return true;
|
|
76208
|
+
}
|
|
76209
|
+
returnFlowNodes.push(returnStatement.flowNode);
|
|
76210
|
+
});
|
|
76211
|
+
if (bailedEarly) return void 0;
|
|
76212
|
+
if (functionHasImplicitReturn(func)) {
|
|
76213
|
+
returnFlowNodes.push(func.endFlowNode);
|
|
76214
|
+
}
|
|
76215
|
+
if (!returnFlowNodes.length) return void 0;
|
|
76216
|
+
return forEach(func.parameters, (param, i) => {
|
|
76217
|
+
const initType = getTypeOfSymbol(param.symbol);
|
|
76218
|
+
if (!initType || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
76219
|
+
return;
|
|
76220
|
+
}
|
|
76221
|
+
const typesAtReturn = [];
|
|
76222
|
+
const bailedEarly2 = forEach(returnFlowNodes, (flowNode) => {
|
|
76223
|
+
const type = getFlowTypeOfReference(param.name, initType, initType, func, flowNode);
|
|
76224
|
+
if (type === initType) return true;
|
|
76225
|
+
typesAtReturn.push(type);
|
|
76226
|
+
});
|
|
76227
|
+
if (bailedEarly2) return;
|
|
76228
|
+
const assertedType = getUnionType(typesAtReturn, 2 /* Subtype */);
|
|
76229
|
+
const patchedInitType = mapType(initType, (t) => t.flags & 16384 /* Void */ ? undefinedType : t.flags & 1 /* Any */ ? unknownType : t);
|
|
76230
|
+
if (isTypeAssignableTo(patchedInitType, assertedType)) return;
|
|
76231
|
+
return createTypePredicate(3 /* AssertsIdentifier */, unescapeLeadingUnderscores(param.name.escapedText), i, assertedType);
|
|
76232
|
+
});
|
|
76233
|
+
}
|
|
76077
76234
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
76078
76235
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
76079
76236
|
return;
|
|
@@ -77452,6 +77609,10 @@ function createTypeChecker(host) {
|
|
|
77452
77609
|
texts.push(span.literal.text);
|
|
77453
77610
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
77454
77611
|
}
|
|
77612
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
|
|
77613
|
+
if (evaluated) {
|
|
77614
|
+
return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
|
|
77615
|
+
}
|
|
77455
77616
|
if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(
|
|
77456
77617
|
node,
|
|
77457
77618
|
/*contextFlags*/
|
|
@@ -77459,8 +77620,7 @@ function createTypeChecker(host) {
|
|
|
77459
77620
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
77460
77621
|
return getTemplateLiteralType(texts, types);
|
|
77461
77622
|
}
|
|
77462
|
-
|
|
77463
|
-
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
77623
|
+
return stringType;
|
|
77464
77624
|
}
|
|
77465
77625
|
function isTemplateLiteralContextualType(type) {
|
|
77466
77626
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
|
|
@@ -110150,7 +110310,7 @@ function transformDeclarations(context) {
|
|
|
110150
110310
|
}
|
|
110151
110311
|
}
|
|
110152
110312
|
}
|
|
110153
|
-
} else {
|
|
110313
|
+
} else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
|
|
110154
110314
|
const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
|
|
110155
110315
|
if (errorInfo) {
|
|
110156
110316
|
if (errorInfo.typeName) {
|
|
@@ -118150,11 +118310,11 @@ function getReferencedFileLocation(program, ref) {
|
|
|
118150
118310
|
var _a, _b, _c, _d;
|
|
118151
118311
|
const file = Debug.checkDefined(program.getSourceFileByPath(ref.file));
|
|
118152
118312
|
const { kind, index } = ref;
|
|
118153
|
-
let pos, end, packageId
|
|
118313
|
+
let pos, end, packageId;
|
|
118154
118314
|
switch (kind) {
|
|
118155
118315
|
case 3 /* Import */:
|
|
118156
118316
|
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
118157
|
-
packageId = (_b = (_a = program.
|
|
118317
|
+
packageId = (_b = (_a = program.getResolvedModuleFromModuleSpecifier(importLiteral, file)) == null ? void 0 : _a.resolvedModule) == null ? void 0 : _b.packageId;
|
|
118158
118318
|
if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text };
|
|
118159
118319
|
pos = skipTrivia(file.text, importLiteral.pos);
|
|
118160
118320
|
end = importLiteral.end;
|
|
@@ -118163,8 +118323,8 @@ function getReferencedFileLocation(program, ref) {
|
|
|
118163
118323
|
({ pos, end } = file.referencedFiles[index]);
|
|
118164
118324
|
break;
|
|
118165
118325
|
case 5 /* TypeReferenceDirective */:
|
|
118166
|
-
({ pos, end
|
|
118167
|
-
packageId = (_d = (_c = program.
|
|
118326
|
+
({ pos, end } = file.typeReferenceDirectives[index]);
|
|
118327
|
+
packageId = (_d = (_c = program.getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(file.typeReferenceDirectives[index], file)) == null ? void 0 : _c.resolvedTypeReferenceDirective) == null ? void 0 : _d.packageId;
|
|
118168
118328
|
break;
|
|
118169
118329
|
case 7 /* LibReferenceDirective */:
|
|
118170
118330
|
({ pos, end } = file.libReferenceDirectives[index]);
|
|
@@ -118364,7 +118524,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118364
118524
|
let reasonToRelatedInfo;
|
|
118365
118525
|
const cachedBindAndCheckDiagnosticsForFile = {};
|
|
118366
118526
|
const cachedDeclarationDiagnosticsForFile = {};
|
|
118367
|
-
let resolvedTypeReferenceDirectives = createModeAwareCache();
|
|
118368
118527
|
let fileProcessingDiagnostics;
|
|
118369
118528
|
let automaticTypeDirectiveNames;
|
|
118370
118529
|
let automaticTypeDirectiveResolutions;
|
|
@@ -118670,7 +118829,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118670
118829
|
getInstantiationCount: () => getTypeChecker().getInstantiationCount(),
|
|
118671
118830
|
getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
|
|
118672
118831
|
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
|
118673
|
-
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
|
|
118674
118832
|
getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
|
|
118675
118833
|
getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
|
|
118676
118834
|
isSourceFileFromExternalLibrary,
|
|
@@ -118689,6 +118847,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118689
118847
|
getResolvedModule,
|
|
118690
118848
|
getResolvedModuleFromModuleSpecifier,
|
|
118691
118849
|
getResolvedTypeReferenceDirective,
|
|
118850
|
+
getResolvedTypeReferenceDirectiveFromTypeReferenceDirective,
|
|
118692
118851
|
forEachResolvedModule,
|
|
118693
118852
|
forEachResolvedTypeReferenceDirective,
|
|
118694
118853
|
getCurrentPackagesMap: () => packageMap,
|
|
@@ -118784,8 +118943,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118784
118943
|
var _a2;
|
|
118785
118944
|
return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
|
|
118786
118945
|
}
|
|
118787
|
-
function getResolvedModuleFromModuleSpecifier(moduleSpecifier) {
|
|
118788
|
-
|
|
118946
|
+
function getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile) {
|
|
118947
|
+
sourceFile ?? (sourceFile = getSourceFileOfNode(moduleSpecifier));
|
|
118789
118948
|
Debug.assertIsDefined(sourceFile, "`moduleSpecifier` must have a `SourceFile` ancestor. Use `program.getResolvedModule` instead to provide the containing file and resolution mode.");
|
|
118790
118949
|
return getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation2(sourceFile, moduleSpecifier));
|
|
118791
118950
|
}
|
|
@@ -118793,6 +118952,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
118793
118952
|
var _a2;
|
|
118794
118953
|
return (_a2 = resolvedTypeReferenceDirectiveNames == null ? void 0 : resolvedTypeReferenceDirectiveNames.get(file.path)) == null ? void 0 : _a2.get(typeDirectiveName, mode);
|
|
118795
118954
|
}
|
|
118955
|
+
function getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef, sourceFile) {
|
|
118956
|
+
return getResolvedTypeReferenceDirective(sourceFile, typeRef.fileName, typeRef.resolutionMode || sourceFile.impliedNodeFormat);
|
|
118957
|
+
}
|
|
118796
118958
|
function forEachResolvedModule(callback, file) {
|
|
118797
118959
|
forEachResolution(resolvedModules, callback, file);
|
|
118798
118960
|
}
|
|
@@ -119261,7 +119423,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119261
119423
|
files = newSourceFiles;
|
|
119262
119424
|
fileReasons = oldProgram.getFileIncludeReasons();
|
|
119263
119425
|
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
|
119264
|
-
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
|
|
119265
119426
|
automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
|
|
119266
119427
|
automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
|
|
119267
119428
|
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
|
|
@@ -120351,53 +120512,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120351
120512
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
120352
120513
|
}
|
|
120353
120514
|
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
|
|
120354
|
-
var _a2;
|
|
120355
120515
|
addResolutionDiagnostics(resolution);
|
|
120356
|
-
const previousResolution = (_a2 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
|
|
120357
|
-
if (previousResolution && previousResolution.primary) {
|
|
120358
|
-
return;
|
|
120359
|
-
}
|
|
120360
|
-
let saveResolution = true;
|
|
120361
120516
|
const { resolvedTypeReferenceDirective } = resolution;
|
|
120362
120517
|
if (resolvedTypeReferenceDirective) {
|
|
120363
120518
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++;
|
|
120364
|
-
|
|
120365
|
-
|
|
120366
|
-
|
|
120367
|
-
|
|
120368
|
-
|
|
120369
|
-
|
|
120370
|
-
|
|
120371
|
-
|
|
120372
|
-
|
|
120373
|
-
);
|
|
120374
|
-
} else {
|
|
120375
|
-
if (previousResolution) {
|
|
120376
|
-
if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
|
|
120377
|
-
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
|
|
120378
|
-
const existingFile = getSourceFile(previousResolution.resolvedFileName);
|
|
120379
|
-
if (otherFileText !== existingFile.text) {
|
|
120380
|
-
addFilePreprocessingFileExplainingDiagnostic(
|
|
120381
|
-
existingFile,
|
|
120382
|
-
reason,
|
|
120383
|
-
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
|
|
120384
|
-
[typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName]
|
|
120385
|
-
);
|
|
120386
|
-
}
|
|
120387
|
-
}
|
|
120388
|
-
saveResolution = false;
|
|
120389
|
-
} else {
|
|
120390
|
-
processSourceFile(
|
|
120391
|
-
resolvedTypeReferenceDirective.resolvedFileName,
|
|
120392
|
-
/*isDefaultLib*/
|
|
120393
|
-
false,
|
|
120394
|
-
/*ignoreNoDefaultLib*/
|
|
120395
|
-
false,
|
|
120396
|
-
resolvedTypeReferenceDirective.packageId,
|
|
120397
|
-
reason
|
|
120398
|
-
);
|
|
120399
|
-
}
|
|
120400
|
-
}
|
|
120519
|
+
processSourceFile(
|
|
120520
|
+
resolvedTypeReferenceDirective.resolvedFileName,
|
|
120521
|
+
/*isDefaultLib*/
|
|
120522
|
+
false,
|
|
120523
|
+
/*ignoreNoDefaultLib*/
|
|
120524
|
+
false,
|
|
120525
|
+
resolvedTypeReferenceDirective.packageId,
|
|
120526
|
+
reason
|
|
120527
|
+
);
|
|
120401
120528
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
|
|
120402
120529
|
} else {
|
|
120403
120530
|
addFilePreprocessingFileExplainingDiagnostic(
|
|
@@ -120408,9 +120535,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120408
120535
|
[typeReferenceDirective]
|
|
120409
120536
|
);
|
|
120410
120537
|
}
|
|
120411
|
-
if (saveResolution) {
|
|
120412
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
|
|
120413
|
-
}
|
|
120414
120538
|
}
|
|
120415
120539
|
function pathForLibFile(libFileName) {
|
|
120416
120540
|
const existing = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName);
|
package/lib/typescript.js
CHANGED
|
@@ -2368,7 +2368,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2368
2368
|
|
|
2369
2369
|
// src/compiler/corePublic.ts
|
|
2370
2370
|
var versionMajorMinor = "5.5";
|
|
2371
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2371
|
+
var version = `${versionMajorMinor}.0-insiders.20240515`;
|
|
2372
2372
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2373
2373
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2374
2374
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6394,6 +6394,7 @@ var SymbolAccessibility = /* @__PURE__ */ ((SymbolAccessibility2) => {
|
|
|
6394
6394
|
SymbolAccessibility2[SymbolAccessibility2["Accessible"] = 0] = "Accessible";
|
|
6395
6395
|
SymbolAccessibility2[SymbolAccessibility2["NotAccessible"] = 1] = "NotAccessible";
|
|
6396
6396
|
SymbolAccessibility2[SymbolAccessibility2["CannotBeNamed"] = 2] = "CannotBeNamed";
|
|
6397
|
+
SymbolAccessibility2[SymbolAccessibility2["NotResolved"] = 3] = "NotResolved";
|
|
6397
6398
|
return SymbolAccessibility2;
|
|
6398
6399
|
})(SymbolAccessibility || {});
|
|
6399
6400
|
var SyntheticSymbolKind = /* @__PURE__ */ ((SyntheticSymbolKind2) => {
|
|
@@ -10338,7 +10339,6 @@ var Diagnostics = {
|
|
|
10338
10339
|
Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
|
|
10339
10340
|
Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
|
|
10340
10341
|
Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
|
|
10341
|
-
Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
|
|
10342
10342
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
10343
10343
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
|
|
10344
10344
|
Property_0_of_exported_class_expression_may_not_be_private_or_protected: diag(4094, 1 /* Error */, "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094", "Property '{0}' of exported class expression may not be private or protected."),
|
|
@@ -17551,7 +17551,8 @@ function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
|
|
|
17551
17551
|
}
|
|
17552
17552
|
function getJSDocCommentRanges(node, text) {
|
|
17553
17553
|
const commentRanges = node.kind === 169 /* Parameter */ || node.kind === 168 /* TypeParameter */ || node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */ || node.kind === 217 /* ParenthesizedExpression */ || node.kind === 260 /* VariableDeclaration */ || node.kind === 281 /* ExportSpecifier */ ? concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRanges(text, node.pos);
|
|
17554
|
-
return filter(commentRanges, (comment) =>
|
|
17554
|
+
return filter(commentRanges, (comment) => comment.end <= node.end && // Due to parse errors sometime empty parameter may get comments assigned to it that end up not in parameter range
|
|
17555
|
+
text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && text.charCodeAt(comment.pos + 3) !== 47 /* slash */);
|
|
17555
17556
|
}
|
|
17556
17557
|
var fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
|
17557
17558
|
var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
|
@@ -53814,7 +53815,7 @@ function createTypeChecker(host) {
|
|
|
53814
53815
|
return { accessibility: 0 /* Accessible */ };
|
|
53815
53816
|
}
|
|
53816
53817
|
return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
|
|
53817
|
-
accessibility:
|
|
53818
|
+
accessibility: 3 /* NotResolved */,
|
|
53818
53819
|
errorSymbolName: getTextOfNode(firstIdentifier),
|
|
53819
53820
|
errorNode: firstIdentifier
|
|
53820
53821
|
};
|
|
@@ -53952,6 +53953,7 @@ function createTypeChecker(host) {
|
|
|
53952
53953
|
if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
|
|
53953
53954
|
range = factory.cloneNode(range);
|
|
53954
53955
|
}
|
|
53956
|
+
if (range === location) return range;
|
|
53955
53957
|
if (!location) {
|
|
53956
53958
|
return range;
|
|
53957
53959
|
}
|
|
@@ -56088,6 +56090,57 @@ function createTypeChecker(host) {
|
|
|
56088
56090
|
return updated;
|
|
56089
56091
|
}
|
|
56090
56092
|
}
|
|
56093
|
+
function serializeTypeName(context, node, isTypeOf, typeArguments) {
|
|
56094
|
+
const meaning = isTypeOf ? 111551 /* Value */ : 788968 /* Type */;
|
|
56095
|
+
const symbol = resolveEntityName(
|
|
56096
|
+
node,
|
|
56097
|
+
meaning,
|
|
56098
|
+
/*ignoreErrors*/
|
|
56099
|
+
true
|
|
56100
|
+
);
|
|
56101
|
+
if (!symbol) return void 0;
|
|
56102
|
+
const resolvedSymbol = symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol;
|
|
56103
|
+
if (isSymbolAccessible(
|
|
56104
|
+
symbol,
|
|
56105
|
+
context.enclosingDeclaration,
|
|
56106
|
+
meaning,
|
|
56107
|
+
/*shouldComputeAliasesToMakeVisible*/
|
|
56108
|
+
false
|
|
56109
|
+
).accessibility !== 0 /* Accessible */) return void 0;
|
|
56110
|
+
return symbolToTypeNode(resolvedSymbol, context, meaning, typeArguments);
|
|
56111
|
+
}
|
|
56112
|
+
function canReuseTypeNode(context, existing) {
|
|
56113
|
+
if (isInJSFile(existing)) {
|
|
56114
|
+
if (isLiteralImportTypeNode(existing)) {
|
|
56115
|
+
void getTypeFromImportTypeNode(existing);
|
|
56116
|
+
const nodeSymbol = getNodeLinks(existing).resolvedSymbol;
|
|
56117
|
+
return !nodeSymbol || !// The import type resolved using jsdoc fallback logic
|
|
56118
|
+
(!existing.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
56119
|
+
!(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
|
|
56120
|
+
}
|
|
56121
|
+
}
|
|
56122
|
+
if (isTypeReferenceNode(existing)) {
|
|
56123
|
+
if (isConstTypeReference(existing)) return false;
|
|
56124
|
+
const type = getTypeFromTypeReference(existing);
|
|
56125
|
+
const symbol = getNodeLinks(existing).resolvedSymbol;
|
|
56126
|
+
if (!symbol) return false;
|
|
56127
|
+
if (symbol.flags & 262144 /* TypeParameter */) {
|
|
56128
|
+
return true;
|
|
56129
|
+
}
|
|
56130
|
+
if (isInJSDoc(existing)) {
|
|
56131
|
+
return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
|
|
56132
|
+
}
|
|
56133
|
+
}
|
|
56134
|
+
if (isTypeOperatorNode(existing) && existing.operator === 158 /* UniqueKeyword */ && existing.type.kind === 155 /* SymbolKeyword */) {
|
|
56135
|
+
const effectiveEnclosingContext = context.enclosingDeclaration && getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
|
|
56136
|
+
return !!findAncestor(existing, (n) => n === effectiveEnclosingContext);
|
|
56137
|
+
}
|
|
56138
|
+
return true;
|
|
56139
|
+
}
|
|
56140
|
+
function serializeExistingTypeNode(context, typeNode) {
|
|
56141
|
+
const type = getTypeFromTypeNode(typeNode);
|
|
56142
|
+
return typeToTypeNodeHelper(type, context);
|
|
56143
|
+
}
|
|
56091
56144
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
56092
56145
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
56093
56146
|
cancellationToken.throwIfCancellationRequested();
|
|
@@ -56097,6 +56150,7 @@ function createTypeChecker(host) {
|
|
|
56097
56150
|
if (hadError) {
|
|
56098
56151
|
return void 0;
|
|
56099
56152
|
}
|
|
56153
|
+
context.approximateLength += existing.end - existing.pos;
|
|
56100
56154
|
return transformed;
|
|
56101
56155
|
function visitExistingNodeTreeSymbols(node) {
|
|
56102
56156
|
const onExitNewScope = isNewScopeNode(node) ? onEnterNewScope(node) : void 0;
|
|
@@ -56196,20 +56250,38 @@ function createTypeChecker(host) {
|
|
|
56196
56250
|
);
|
|
56197
56251
|
}
|
|
56198
56252
|
}
|
|
56199
|
-
if (isTypeReferenceNode(node)
|
|
56200
|
-
node
|
|
56201
|
-
|
|
56202
|
-
|
|
56203
|
-
|
|
56204
|
-
|
|
56205
|
-
|
|
56253
|
+
if (isTypeReferenceNode(node)) {
|
|
56254
|
+
if (canReuseTypeNode(context, node)) {
|
|
56255
|
+
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
|
|
56256
|
+
const typeArguments = visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode);
|
|
56257
|
+
if (!introducesError) {
|
|
56258
|
+
const updated = factory.updateTypeReferenceNode(
|
|
56259
|
+
node,
|
|
56260
|
+
newName,
|
|
56261
|
+
typeArguments
|
|
56262
|
+
);
|
|
56263
|
+
return setTextRange2(context, updated, node);
|
|
56264
|
+
} else {
|
|
56265
|
+
const serializedName = serializeTypeName(
|
|
56266
|
+
context,
|
|
56267
|
+
node.typeName,
|
|
56268
|
+
/*isTypeOf*/
|
|
56269
|
+
false,
|
|
56270
|
+
typeArguments
|
|
56271
|
+
);
|
|
56272
|
+
if (serializedName) {
|
|
56273
|
+
return setTextRange2(context, serializedName, node.typeName);
|
|
56274
|
+
}
|
|
56275
|
+
}
|
|
56276
|
+
}
|
|
56277
|
+
return serializeExistingTypeNode(context, node);
|
|
56206
56278
|
}
|
|
56207
56279
|
if (isLiteralImportTypeNode(node)) {
|
|
56208
56280
|
const nodeSymbol = getNodeLinks(node).resolvedSymbol;
|
|
56209
56281
|
if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
|
|
56210
56282
|
(!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
56211
56283
|
!(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
|
|
56212
|
-
return
|
|
56284
|
+
return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
56213
56285
|
}
|
|
56214
56286
|
return factory.updateImportTypeNode(
|
|
56215
56287
|
node,
|
|
@@ -56241,13 +56313,48 @@ function createTypeChecker(host) {
|
|
|
56241
56313
|
}
|
|
56242
56314
|
return visited;
|
|
56243
56315
|
}
|
|
56244
|
-
if (
|
|
56245
|
-
|
|
56246
|
-
|
|
56316
|
+
if (isTypeQueryNode(node)) {
|
|
56317
|
+
const { introducesError, node: exprName } = trackExistingEntityName(node.exprName, context);
|
|
56318
|
+
if (introducesError) {
|
|
56319
|
+
const serializedName = serializeTypeName(
|
|
56320
|
+
context,
|
|
56321
|
+
node.exprName,
|
|
56322
|
+
/*isTypeOf*/
|
|
56323
|
+
true
|
|
56324
|
+
);
|
|
56325
|
+
if (serializedName) {
|
|
56326
|
+
return setTextRange2(context, serializedName, node.exprName);
|
|
56327
|
+
}
|
|
56328
|
+
return serializeExistingTypeNode(context, node);
|
|
56247
56329
|
}
|
|
56248
|
-
|
|
56330
|
+
return factory.updateTypeQueryNode(
|
|
56331
|
+
node,
|
|
56332
|
+
exprName,
|
|
56333
|
+
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode)
|
|
56334
|
+
);
|
|
56335
|
+
}
|
|
56336
|
+
if (isComputedPropertyName(node) && isEntityNameExpression(node.expression)) {
|
|
56337
|
+
const { node: result, introducesError } = trackExistingEntityName(node.expression, context);
|
|
56338
|
+
if (!introducesError) {
|
|
56339
|
+
return factory.updateComputedPropertyName(node, result);
|
|
56340
|
+
} else {
|
|
56341
|
+
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
|
56342
|
+
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
|
56343
|
+
Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
|
|
56344
|
+
const literal = computedPropertyNameType.literal;
|
|
56345
|
+
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
|
56346
|
+
return factory.createIdentifier(literal.text);
|
|
56347
|
+
}
|
|
56348
|
+
if (literal.kind === 9 /* NumericLiteral */ && !literal.text.startsWith("-")) {
|
|
56349
|
+
return literal;
|
|
56350
|
+
}
|
|
56351
|
+
return factory.updateComputedPropertyName(node, literal);
|
|
56352
|
+
}
|
|
56353
|
+
}
|
|
56354
|
+
if (isTypePredicateNode(node) && isIdentifier(node.parameterName)) {
|
|
56355
|
+
const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
|
|
56249
56356
|
hadError = hadError || introducesError;
|
|
56250
|
-
return result;
|
|
56357
|
+
return factory.updateTypePredicateNode(node, node.assertsModifier, result, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
56251
56358
|
}
|
|
56252
56359
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
56253
56360
|
const visited = visitEachChild(
|
|
@@ -56281,6 +56388,11 @@ function createTypeChecker(host) {
|
|
|
56281
56388
|
falseType2
|
|
56282
56389
|
);
|
|
56283
56390
|
}
|
|
56391
|
+
if (isTypeOperatorNode(node) && node.operator === 158 /* UniqueKeyword */ && node.type.kind === 155 /* SymbolKeyword */) {
|
|
56392
|
+
if (!canReuseTypeNode(context, node)) {
|
|
56393
|
+
return serializeExistingTypeNode(context, node);
|
|
56394
|
+
}
|
|
56395
|
+
}
|
|
56284
56396
|
return visitEachChild(
|
|
56285
56397
|
node,
|
|
56286
56398
|
visitExistingNodeTreeSymbols,
|
|
@@ -62067,10 +62179,14 @@ function createTypeChecker(host) {
|
|
|
62067
62179
|
}
|
|
62068
62180
|
if (type || jsdocPredicate) {
|
|
62069
62181
|
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
62070
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) && getParameterCount(signature) > 0) {
|
|
62182
|
+
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & (16 /* Boolean */ | 49152 /* VoidLike */)) && getParameterCount(signature) > 0) {
|
|
62071
62183
|
const { declaration } = signature;
|
|
62072
62184
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
62073
|
-
signature.
|
|
62185
|
+
if (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */) {
|
|
62186
|
+
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
62187
|
+
} else if (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 49152 /* VoidLike */) {
|
|
62188
|
+
signature.resolvedTypePredicate = getTypeAssertionFromBody(declaration) || noTypePredicate;
|
|
62189
|
+
}
|
|
62074
62190
|
} else {
|
|
62075
62191
|
signature.resolvedTypePredicate = noTypePredicate;
|
|
62076
62192
|
}
|
|
@@ -80868,6 +80984,48 @@ function createTypeChecker(host) {
|
|
|
80868
80984
|
const falseSubtype = getFlowTypeOfReference(param.name, initType, trueType2, func, falseCondition);
|
|
80869
80985
|
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
80870
80986
|
}
|
|
80987
|
+
function getTypeAssertionFromBody(func) {
|
|
80988
|
+
switch (func.kind) {
|
|
80989
|
+
case 176 /* Constructor */:
|
|
80990
|
+
case 177 /* GetAccessor */:
|
|
80991
|
+
case 178 /* SetAccessor */:
|
|
80992
|
+
case 219 /* ArrowFunction */:
|
|
80993
|
+
case 218 /* FunctionExpression */:
|
|
80994
|
+
case 174 /* MethodDeclaration */:
|
|
80995
|
+
return void 0;
|
|
80996
|
+
}
|
|
80997
|
+
const functionFlags = getFunctionFlags(func);
|
|
80998
|
+
if (functionFlags !== 0 /* Normal */ || !func.body) return void 0;
|
|
80999
|
+
const returnFlowNodes = [];
|
|
81000
|
+
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
81001
|
+
if (!returnStatement.flowNode) {
|
|
81002
|
+
return true;
|
|
81003
|
+
}
|
|
81004
|
+
returnFlowNodes.push(returnStatement.flowNode);
|
|
81005
|
+
});
|
|
81006
|
+
if (bailedEarly) return void 0;
|
|
81007
|
+
if (functionHasImplicitReturn(func)) {
|
|
81008
|
+
returnFlowNodes.push(func.endFlowNode);
|
|
81009
|
+
}
|
|
81010
|
+
if (!returnFlowNodes.length) return void 0;
|
|
81011
|
+
return forEach(func.parameters, (param, i) => {
|
|
81012
|
+
const initType = getTypeOfSymbol(param.symbol);
|
|
81013
|
+
if (!initType || !isIdentifier(param.name) || isSymbolAssigned(param.symbol) || isRestParameter(param)) {
|
|
81014
|
+
return;
|
|
81015
|
+
}
|
|
81016
|
+
const typesAtReturn = [];
|
|
81017
|
+
const bailedEarly2 = forEach(returnFlowNodes, (flowNode) => {
|
|
81018
|
+
const type = getFlowTypeOfReference(param.name, initType, initType, func, flowNode);
|
|
81019
|
+
if (type === initType) return true;
|
|
81020
|
+
typesAtReturn.push(type);
|
|
81021
|
+
});
|
|
81022
|
+
if (bailedEarly2) return;
|
|
81023
|
+
const assertedType = getUnionType(typesAtReturn, 2 /* Subtype */);
|
|
81024
|
+
const patchedInitType = mapType(initType, (t) => t.flags & 16384 /* Void */ ? undefinedType : t.flags & 1 /* Any */ ? unknownType : t);
|
|
81025
|
+
if (isTypeAssignableTo(patchedInitType, assertedType)) return;
|
|
81026
|
+
return createTypePredicate(3 /* AssertsIdentifier */, unescapeLeadingUnderscores(param.name.escapedText), i, assertedType);
|
|
81027
|
+
});
|
|
81028
|
+
}
|
|
80871
81029
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
80872
81030
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
80873
81031
|
return;
|
|
@@ -82246,6 +82404,10 @@ function createTypeChecker(host) {
|
|
|
82246
82404
|
texts.push(span.literal.text);
|
|
82247
82405
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
82248
82406
|
}
|
|
82407
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node).value;
|
|
82408
|
+
if (evaluated) {
|
|
82409
|
+
return getFreshTypeOfLiteralType(getStringLiteralType(evaluated));
|
|
82410
|
+
}
|
|
82249
82411
|
if (isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType2(
|
|
82250
82412
|
node,
|
|
82251
82413
|
/*contextFlags*/
|
|
@@ -82253,8 +82415,7 @@ function createTypeChecker(host) {
|
|
|
82253
82415
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
82254
82416
|
return getTemplateLiteralType(texts, types);
|
|
82255
82417
|
}
|
|
82256
|
-
|
|
82257
|
-
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
82418
|
+
return stringType;
|
|
82258
82419
|
}
|
|
82259
82420
|
function isTemplateLiteralContextualType(type) {
|
|
82260
82421
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */));
|
|
@@ -115126,7 +115287,7 @@ function transformDeclarations(context) {
|
|
|
115126
115287
|
}
|
|
115127
115288
|
}
|
|
115128
115289
|
}
|
|
115129
|
-
} else {
|
|
115290
|
+
} else if (symbolAccessibilityResult.accessibility !== 3 /* NotResolved */) {
|
|
115130
115291
|
const errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
|
|
115131
115292
|
if (errorInfo) {
|
|
115132
115293
|
if (errorInfo.typeName) {
|
|
@@ -123179,11 +123340,11 @@ function getReferencedFileLocation(program, ref) {
|
|
|
123179
123340
|
var _a, _b, _c, _d;
|
|
123180
123341
|
const file = Debug.checkDefined(program.getSourceFileByPath(ref.file));
|
|
123181
123342
|
const { kind, index } = ref;
|
|
123182
|
-
let pos, end, packageId
|
|
123343
|
+
let pos, end, packageId;
|
|
123183
123344
|
switch (kind) {
|
|
123184
123345
|
case 3 /* Import */:
|
|
123185
123346
|
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
123186
|
-
packageId = (_b = (_a = program.
|
|
123347
|
+
packageId = (_b = (_a = program.getResolvedModuleFromModuleSpecifier(importLiteral, file)) == null ? void 0 : _a.resolvedModule) == null ? void 0 : _b.packageId;
|
|
123187
123348
|
if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text };
|
|
123188
123349
|
pos = skipTrivia(file.text, importLiteral.pos);
|
|
123189
123350
|
end = importLiteral.end;
|
|
@@ -123192,8 +123353,8 @@ function getReferencedFileLocation(program, ref) {
|
|
|
123192
123353
|
({ pos, end } = file.referencedFiles[index]);
|
|
123193
123354
|
break;
|
|
123194
123355
|
case 5 /* TypeReferenceDirective */:
|
|
123195
|
-
({ pos, end
|
|
123196
|
-
packageId = (_d = (_c = program.
|
|
123356
|
+
({ pos, end } = file.typeReferenceDirectives[index]);
|
|
123357
|
+
packageId = (_d = (_c = program.getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(file.typeReferenceDirectives[index], file)) == null ? void 0 : _c.resolvedTypeReferenceDirective) == null ? void 0 : _d.packageId;
|
|
123197
123358
|
break;
|
|
123198
123359
|
case 7 /* LibReferenceDirective */:
|
|
123199
123360
|
({ pos, end } = file.libReferenceDirectives[index]);
|
|
@@ -123397,7 +123558,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123397
123558
|
let reasonToRelatedInfo;
|
|
123398
123559
|
const cachedBindAndCheckDiagnosticsForFile = {};
|
|
123399
123560
|
const cachedDeclarationDiagnosticsForFile = {};
|
|
123400
|
-
let resolvedTypeReferenceDirectives = createModeAwareCache();
|
|
123401
123561
|
let fileProcessingDiagnostics;
|
|
123402
123562
|
let automaticTypeDirectiveNames;
|
|
123403
123563
|
let automaticTypeDirectiveResolutions;
|
|
@@ -123703,7 +123863,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123703
123863
|
getInstantiationCount: () => getTypeChecker().getInstantiationCount(),
|
|
123704
123864
|
getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
|
|
123705
123865
|
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
|
123706
|
-
getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
|
|
123707
123866
|
getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
|
|
123708
123867
|
getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
|
|
123709
123868
|
isSourceFileFromExternalLibrary,
|
|
@@ -123722,6 +123881,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123722
123881
|
getResolvedModule,
|
|
123723
123882
|
getResolvedModuleFromModuleSpecifier,
|
|
123724
123883
|
getResolvedTypeReferenceDirective,
|
|
123884
|
+
getResolvedTypeReferenceDirectiveFromTypeReferenceDirective,
|
|
123725
123885
|
forEachResolvedModule,
|
|
123726
123886
|
forEachResolvedTypeReferenceDirective,
|
|
123727
123887
|
getCurrentPackagesMap: () => packageMap,
|
|
@@ -123817,8 +123977,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123817
123977
|
var _a2;
|
|
123818
123978
|
return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
|
|
123819
123979
|
}
|
|
123820
|
-
function getResolvedModuleFromModuleSpecifier(moduleSpecifier) {
|
|
123821
|
-
|
|
123980
|
+
function getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile) {
|
|
123981
|
+
sourceFile ?? (sourceFile = getSourceFileOfNode(moduleSpecifier));
|
|
123822
123982
|
Debug.assertIsDefined(sourceFile, "`moduleSpecifier` must have a `SourceFile` ancestor. Use `program.getResolvedModule` instead to provide the containing file and resolution mode.");
|
|
123823
123983
|
return getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation2(sourceFile, moduleSpecifier));
|
|
123824
123984
|
}
|
|
@@ -123826,6 +123986,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123826
123986
|
var _a2;
|
|
123827
123987
|
return (_a2 = resolvedTypeReferenceDirectiveNames == null ? void 0 : resolvedTypeReferenceDirectiveNames.get(file.path)) == null ? void 0 : _a2.get(typeDirectiveName, mode);
|
|
123828
123988
|
}
|
|
123989
|
+
function getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeRef, sourceFile) {
|
|
123990
|
+
return getResolvedTypeReferenceDirective(sourceFile, typeRef.fileName, typeRef.resolutionMode || sourceFile.impliedNodeFormat);
|
|
123991
|
+
}
|
|
123829
123992
|
function forEachResolvedModule(callback, file) {
|
|
123830
123993
|
forEachResolution(resolvedModules, callback, file);
|
|
123831
123994
|
}
|
|
@@ -124294,7 +124457,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124294
124457
|
files = newSourceFiles;
|
|
124295
124458
|
fileReasons = oldProgram.getFileIncludeReasons();
|
|
124296
124459
|
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
|
124297
|
-
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
|
|
124298
124460
|
automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
|
|
124299
124461
|
automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
|
|
124300
124462
|
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
|
|
@@ -125384,53 +125546,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
125384
125546
|
(_b2 = tracing) == null ? void 0 : _b2.pop();
|
|
125385
125547
|
}
|
|
125386
125548
|
function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
|
|
125387
|
-
var _a2;
|
|
125388
125549
|
addResolutionDiagnostics(resolution);
|
|
125389
|
-
const previousResolution = (_a2 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a2.resolvedTypeReferenceDirective;
|
|
125390
|
-
if (previousResolution && previousResolution.primary) {
|
|
125391
|
-
return;
|
|
125392
|
-
}
|
|
125393
|
-
let saveResolution = true;
|
|
125394
125550
|
const { resolvedTypeReferenceDirective } = resolution;
|
|
125395
125551
|
if (resolvedTypeReferenceDirective) {
|
|
125396
125552
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++;
|
|
125397
|
-
|
|
125398
|
-
|
|
125399
|
-
|
|
125400
|
-
|
|
125401
|
-
|
|
125402
|
-
|
|
125403
|
-
|
|
125404
|
-
|
|
125405
|
-
|
|
125406
|
-
);
|
|
125407
|
-
} else {
|
|
125408
|
-
if (previousResolution) {
|
|
125409
|
-
if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
|
|
125410
|
-
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
|
|
125411
|
-
const existingFile = getSourceFile(previousResolution.resolvedFileName);
|
|
125412
|
-
if (otherFileText !== existingFile.text) {
|
|
125413
|
-
addFilePreprocessingFileExplainingDiagnostic(
|
|
125414
|
-
existingFile,
|
|
125415
|
-
reason,
|
|
125416
|
-
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
|
|
125417
|
-
[typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName]
|
|
125418
|
-
);
|
|
125419
|
-
}
|
|
125420
|
-
}
|
|
125421
|
-
saveResolution = false;
|
|
125422
|
-
} else {
|
|
125423
|
-
processSourceFile(
|
|
125424
|
-
resolvedTypeReferenceDirective.resolvedFileName,
|
|
125425
|
-
/*isDefaultLib*/
|
|
125426
|
-
false,
|
|
125427
|
-
/*ignoreNoDefaultLib*/
|
|
125428
|
-
false,
|
|
125429
|
-
resolvedTypeReferenceDirective.packageId,
|
|
125430
|
-
reason
|
|
125431
|
-
);
|
|
125432
|
-
}
|
|
125433
|
-
}
|
|
125553
|
+
processSourceFile(
|
|
125554
|
+
resolvedTypeReferenceDirective.resolvedFileName,
|
|
125555
|
+
/*isDefaultLib*/
|
|
125556
|
+
false,
|
|
125557
|
+
/*ignoreNoDefaultLib*/
|
|
125558
|
+
false,
|
|
125559
|
+
resolvedTypeReferenceDirective.packageId,
|
|
125560
|
+
reason
|
|
125561
|
+
);
|
|
125434
125562
|
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
|
|
125435
125563
|
} else {
|
|
125436
125564
|
addFilePreprocessingFileExplainingDiagnostic(
|
|
@@ -125441,9 +125569,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
125441
125569
|
[typeReferenceDirective]
|
|
125442
125570
|
);
|
|
125443
125571
|
}
|
|
125444
|
-
if (saveResolution) {
|
|
125445
|
-
resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
|
|
125446
|
-
}
|
|
125447
125572
|
}
|
|
125448
125573
|
function pathForLibFile(libFileName) {
|
|
125449
125574
|
const existing = resolvedLibReferences == null ? void 0 : resolvedLibReferences.get(libFileName);
|
|
@@ -139730,7 +139855,7 @@ function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSou
|
|
|
139730
139855
|
return newFileName === void 0 ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
|
|
139731
139856
|
} else {
|
|
139732
139857
|
const mode = program.getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
139733
|
-
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? program.getResolvedModuleFromModuleSpecifier(importLiteral) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
139858
|
+
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? program.getResolvedModuleFromModuleSpecifier(importLiteral, importingSourceFile) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
139734
139859
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
139735
139860
|
}
|
|
139736
139861
|
}
|
|
@@ -140629,7 +140754,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
140629
140754
|
const importNode = importFromModuleSpecifier(moduleSpecifier);
|
|
140630
140755
|
const name = importNameForConvertToDefaultImport(importNode);
|
|
140631
140756
|
if (!name) continue;
|
|
140632
|
-
const module2 = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
140757
|
+
const module2 = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile)) == null ? void 0 : _a.resolvedModule;
|
|
140633
140758
|
const resolvedFile = module2 && program.getSourceFile(module2.resolvedFileName);
|
|
140634
140759
|
if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
|
140635
140760
|
diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import));
|
|
@@ -152322,7 +152447,7 @@ registerCodeFix({
|
|
|
152322
152447
|
function fixImportOfModuleExports(importingFile, exportingFile, program, changes, quotePreference) {
|
|
152323
152448
|
var _a;
|
|
152324
152449
|
for (const moduleSpecifier of importingFile.imports) {
|
|
152325
|
-
const imported = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
152450
|
+
const imported = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier, importingFile)) == null ? void 0 : _a.resolvedModule;
|
|
152326
152451
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
152327
152452
|
continue;
|
|
152328
152453
|
}
|
|
@@ -154682,7 +154807,7 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
154682
154807
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
154683
154808
|
if (!compilerOptions.allowImportingTsExtensions) {
|
|
154684
154809
|
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
154685
|
-
const resolvedModule = moduleSpecifier && ((_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule);
|
|
154810
|
+
const resolvedModule = moduleSpecifier && ((_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile)) == null ? void 0 : _a.resolvedModule);
|
|
154686
154811
|
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
154687
154812
|
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
154688
154813
|
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
@@ -155356,7 +155481,7 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
155356
155481
|
if (importDeclaration === void 0) return void 0;
|
|
155357
155482
|
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier : void 0;
|
|
155358
155483
|
if (moduleSpecifier === void 0) return void 0;
|
|
155359
|
-
const resolvedModule = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
155484
|
+
const resolvedModule = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier, sourceFile)) == null ? void 0 : _a.resolvedModule;
|
|
155360
155485
|
if (resolvedModule === void 0) return void 0;
|
|
155361
155486
|
const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
155362
155487
|
if (moduleSourceFile === void 0 || isSourceFileFromLibrary(program, moduleSourceFile)) return void 0;
|
|
@@ -155559,7 +155684,7 @@ function getInfo8(sourceFile, pos, context, errorCode) {
|
|
|
155559
155684
|
} else if (isImportSpecifier(parent2) && parent2.name === node) {
|
|
155560
155685
|
Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)");
|
|
155561
155686
|
const importDeclaration = findAncestor(node, isImportDeclaration);
|
|
155562
|
-
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration);
|
|
155687
|
+
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration, sourceFile);
|
|
155563
155688
|
if (resolvedSourceFile && resolvedSourceFile.symbol) {
|
|
155564
155689
|
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol);
|
|
155565
155690
|
}
|
|
@@ -155609,10 +155734,10 @@ function convertSemanticMeaningToSymbolFlags(meaning) {
|
|
|
155609
155734
|
}
|
|
155610
155735
|
return flags;
|
|
155611
155736
|
}
|
|
155612
|
-
function getResolvedSourceFileFromImportDeclaration(context, importDeclaration) {
|
|
155737
|
+
function getResolvedSourceFileFromImportDeclaration(context, importDeclaration, importingFile) {
|
|
155613
155738
|
var _a;
|
|
155614
155739
|
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return void 0;
|
|
155615
|
-
const resolvedModule = (_a = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
155740
|
+
const resolvedModule = (_a = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier, importingFile)) == null ? void 0 : _a.resolvedModule;
|
|
155616
155741
|
if (!resolvedModule) return void 0;
|
|
155617
155742
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
155618
155743
|
}
|
|
@@ -166783,7 +166908,7 @@ function findModuleReferences(program, sourceFiles, searchModuleSymbol) {
|
|
|
166783
166908
|
}
|
|
166784
166909
|
}
|
|
166785
166910
|
for (const ref of referencingFile.typeReferenceDirectives) {
|
|
166786
|
-
const referenced = (_a = program.
|
|
166911
|
+
const referenced = (_a = program.getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(ref, referencingFile)) == null ? void 0 : _a.resolvedTypeReferenceDirective;
|
|
166787
166912
|
if (referenced !== void 0 && referenced.resolvedFileName === searchSourceFile.fileName) {
|
|
166788
166913
|
refs.push({ kind: "reference", referencingFile, ref });
|
|
166789
166914
|
}
|
|
@@ -168995,7 +169120,7 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
|
|
|
168995
169120
|
}
|
|
168996
169121
|
}
|
|
168997
169122
|
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
|
168998
|
-
const ref = (_a = program.getResolvedModuleFromModuleSpecifier(fallbackNode)) == null ? void 0 : _a.resolvedModule;
|
|
169123
|
+
const ref = (_a = program.getResolvedModuleFromModuleSpecifier(fallbackNode, sourceFile)) == null ? void 0 : _a.resolvedModule;
|
|
168999
169124
|
if (ref) {
|
|
169000
169125
|
return [{
|
|
169001
169126
|
name: fallbackNode.text,
|
|
@@ -169092,7 +169217,7 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
169092
169217
|
}
|
|
169093
169218
|
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
|
169094
169219
|
if (typeReferenceDirective) {
|
|
169095
|
-
const reference = (_a = program.
|
|
169220
|
+
const reference = (_a = program.getResolvedTypeReferenceDirectiveFromTypeReferenceDirective(typeReferenceDirective, sourceFile)) == null ? void 0 : _a.resolvedTypeReferenceDirective;
|
|
169096
169221
|
const file = reference && program.getSourceFile(reference.resolvedFileName);
|
|
169097
169222
|
return file && { reference: typeReferenceDirective, fileName: file.fileName, file, unverified: false };
|
|
169098
169223
|
}
|
|
@@ -169104,7 +169229,7 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
169104
169229
|
if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) {
|
|
169105
169230
|
const node = getTouchingToken(sourceFile, position);
|
|
169106
169231
|
let resolution;
|
|
169107
|
-
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node))) {
|
|
169232
|
+
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node, sourceFile))) {
|
|
169108
169233
|
const verifiedFileName = (_b = resolution.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
169109
169234
|
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
|
169110
169235
|
return {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.5.0-pr-
|
|
5
|
+
"version": "5.5.0-pr-58495-31",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|