@typescript-deploys/pr-build 5.5.0-pr-58610-9 → 5.5.0-pr-58650-7
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 +257 -142
- package/lib/typescript.d.ts +29 -0
- package/lib/typescript.js +517 -149
- package/package.json +3 -1
package/lib/typescript.js
CHANGED
|
@@ -112,6 +112,7 @@ __export(typescript_exports, {
|
|
|
112
112
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
113
113
|
ListFormat: () => ListFormat,
|
|
114
114
|
LogLevel: () => LogLevel,
|
|
115
|
+
MapCode: () => ts_MapCode_exports,
|
|
115
116
|
MemberOverrideStatus: () => MemberOverrideStatus,
|
|
116
117
|
ModifierFlags: () => ModifierFlags,
|
|
117
118
|
ModuleDetectionKind: () => ModuleDetectionKind,
|
|
@@ -2369,7 +2370,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2369
2370
|
|
|
2370
2371
|
// src/compiler/corePublic.ts
|
|
2371
2372
|
var versionMajorMinor = "5.5";
|
|
2372
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2373
|
+
var version = `${versionMajorMinor}.0-insiders.20240524`;
|
|
2373
2374
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2374
2375
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2375
2376
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -11119,6 +11120,7 @@ var Diagnostics = {
|
|
|
11119
11120
|
Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
|
|
11120
11121
|
Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
|
|
11121
11122
|
Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations: diag(9038, 1 /* Error */, "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038", "Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."),
|
|
11123
|
+
Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations: diag(9039, 1 /* Error */, "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039", "Type containing private name '{0}' can't be used with --isolatedDeclarations."),
|
|
11122
11124
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
11123
11125
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
11124
11126
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
@@ -51035,7 +51037,12 @@ function createTypeChecker(host) {
|
|
|
51035
51037
|
if (resolvedTarget === unknownSymbol) {
|
|
51036
51038
|
return source;
|
|
51037
51039
|
}
|
|
51038
|
-
|
|
51040
|
+
if (!(resolvedTarget.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | resolvedTarget.flags) & 67108864 /* Assignment */) {
|
|
51041
|
+
target = cloneSymbol(resolvedTarget);
|
|
51042
|
+
} else {
|
|
51043
|
+
reportMergeSymbolError(target, source);
|
|
51044
|
+
return source;
|
|
51045
|
+
}
|
|
51039
51046
|
}
|
|
51040
51047
|
if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
|
|
51041
51048
|
target.constEnumOnlyModule = false;
|
|
@@ -51065,27 +51072,30 @@ function createTypeChecker(host) {
|
|
|
51065
51072
|
);
|
|
51066
51073
|
}
|
|
51067
51074
|
} else {
|
|
51068
|
-
|
|
51069
|
-
|
|
51075
|
+
reportMergeSymbolError(target, source);
|
|
51076
|
+
}
|
|
51077
|
+
return target;
|
|
51078
|
+
function reportMergeSymbolError(target2, source2) {
|
|
51079
|
+
const isEitherEnum = !!(target2.flags & 384 /* Enum */ || source2.flags & 384 /* Enum */);
|
|
51080
|
+
const isEitherBlockScoped = !!(target2.flags & 2 /* BlockScopedVariable */ || source2.flags & 2 /* BlockScopedVariable */);
|
|
51070
51081
|
const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
|
|
51071
|
-
const sourceSymbolFile =
|
|
51072
|
-
const targetSymbolFile =
|
|
51082
|
+
const sourceSymbolFile = source2.declarations && getSourceFileOfNode(source2.declarations[0]);
|
|
51083
|
+
const targetSymbolFile = target2.declarations && getSourceFileOfNode(target2.declarations[0]);
|
|
51073
51084
|
const isSourcePlainJs = isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
51074
51085
|
const isTargetPlainJs = isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
51075
|
-
const symbolName2 = symbolToString(
|
|
51086
|
+
const symbolName2 = symbolToString(source2);
|
|
51076
51087
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
51077
51088
|
const firstFile = comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile;
|
|
51078
51089
|
const secondFile = firstFile === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
|
|
51079
51090
|
const filesDuplicates = getOrUpdate(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () => ({ firstFile, secondFile, conflictingSymbols: /* @__PURE__ */ new Map() }));
|
|
51080
51091
|
const conflictingSymbolInfo = getOrUpdate(filesDuplicates.conflictingSymbols, symbolName2, () => ({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] }));
|
|
51081
|
-
if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations,
|
|
51082
|
-
if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations,
|
|
51092
|
+
if (!isSourcePlainJs) addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source2);
|
|
51093
|
+
if (!isTargetPlainJs) addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target2);
|
|
51083
51094
|
} else {
|
|
51084
|
-
if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(
|
|
51085
|
-
if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(
|
|
51095
|
+
if (!isSourcePlainJs) addDuplicateDeclarationErrorsForSymbols(source2, message, symbolName2, target2);
|
|
51096
|
+
if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target2, message, symbolName2, source2);
|
|
51086
51097
|
}
|
|
51087
51098
|
}
|
|
51088
|
-
return target;
|
|
51089
51099
|
function addDuplicateLocations(locs, symbol) {
|
|
51090
51100
|
if (symbol.declarations) {
|
|
51091
51101
|
for (const decl of symbol.declarations) {
|
|
@@ -53931,6 +53941,9 @@ function createTypeChecker(host) {
|
|
|
53931
53941
|
function isClassInstanceSide(type) {
|
|
53932
53942
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(type.flags & 524288 /* Object */) && !!(getObjectFlags(type) & 16777216 /* IsClassInstanceClone */));
|
|
53933
53943
|
}
|
|
53944
|
+
function getTypeFromTypeNodeWithoutContext(node) {
|
|
53945
|
+
return getTypeFromTypeNode(node);
|
|
53946
|
+
}
|
|
53934
53947
|
function createNodeBuilder() {
|
|
53935
53948
|
return {
|
|
53936
53949
|
typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
@@ -53959,6 +53972,12 @@ function createTypeChecker(host) {
|
|
|
53959
53972
|
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
|
|
53960
53973
|
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext2(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
|
53961
53974
|
};
|
|
53975
|
+
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
|
53976
|
+
const type = getTypeFromTypeNodeWithoutContext(node);
|
|
53977
|
+
if (!context.mapper) return type;
|
|
53978
|
+
const mappedType = instantiateType(type, context.mapper);
|
|
53979
|
+
return noMappedTypes && mappedType !== type ? void 0 : mappedType;
|
|
53980
|
+
}
|
|
53962
53981
|
function setTextRange2(context, range, location) {
|
|
53963
53982
|
if (!nodeIsSynthesized(range) && !(range.flags & 16 /* Synthesized */) && (!context.enclosingFile || context.enclosingFile !== getSourceFileOfNode(range))) {
|
|
53964
53983
|
range = factory.cloneNode(range);
|
|
@@ -54004,7 +54023,7 @@ function createTypeChecker(host) {
|
|
|
54004
54023
|
}
|
|
54005
54024
|
const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
|
|
54006
54025
|
if (clone2) {
|
|
54007
|
-
if (addUndefined && !someType(
|
|
54026
|
+
if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
|
|
54008
54027
|
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
54009
54028
|
}
|
|
54010
54029
|
return clone2;
|
|
@@ -54017,8 +54036,13 @@ function createTypeChecker(host) {
|
|
|
54017
54036
|
}
|
|
54018
54037
|
return void 0;
|
|
54019
54038
|
}
|
|
54020
|
-
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType
|
|
54021
|
-
|
|
54039
|
+
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType = getTypeFromTypeNode2(
|
|
54040
|
+
context,
|
|
54041
|
+
existing,
|
|
54042
|
+
/*noMappedTypes*/
|
|
54043
|
+
true
|
|
54044
|
+
)) {
|
|
54045
|
+
if (annotationType && typeNodeIsEquivalentToType(host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
54022
54046
|
const result = tryReuseExistingTypeNodeHelper(context, existing);
|
|
54023
54047
|
if (result) {
|
|
54024
54048
|
return result;
|
|
@@ -54065,7 +54089,8 @@ function createTypeChecker(host) {
|
|
|
54065
54089
|
mustCreateTypeParametersNamesLookups: true,
|
|
54066
54090
|
typeParameterNames: void 0,
|
|
54067
54091
|
typeParameterNamesByText: void 0,
|
|
54068
|
-
typeParameterNamesByTextNextNameCount: void 0
|
|
54092
|
+
typeParameterNamesByTextNextNameCount: void 0,
|
|
54093
|
+
mapper: void 0
|
|
54069
54094
|
};
|
|
54070
54095
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
|
54071
54096
|
const resultingNode = cb(context);
|
|
@@ -54356,8 +54381,8 @@ function createTypeChecker(host) {
|
|
|
54356
54381
|
context.inferTypeParameters = type2.root.inferTypeParameters;
|
|
54357
54382
|
const extendsTypeNode2 = typeToTypeNodeHelper(instantiateType(type2.root.extendsType, newMapper), context);
|
|
54358
54383
|
context.inferTypeParameters = saveInferTypeParameters2;
|
|
54359
|
-
const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(
|
|
54360
|
-
const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(
|
|
54384
|
+
const trueTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.trueType), newMapper));
|
|
54385
|
+
const falseTypeNode2 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode2(context, type2.root.node.falseType), newMapper));
|
|
54361
54386
|
return factory.createConditionalTypeNode(
|
|
54362
54387
|
checkTypeNode,
|
|
54363
54388
|
factory.createInferTypeNode(factory.createTypeParameterDeclaration(
|
|
@@ -54440,7 +54465,7 @@ function createTypeChecker(host) {
|
|
|
54440
54465
|
context.approximateLength += 10;
|
|
54441
54466
|
const result = setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
54442
54467
|
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
54443
|
-
const originalConstraint = instantiateType(getConstraintOfTypeParameter(
|
|
54468
|
+
const originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode2(context, type2.declaration.typeParameter.constraint.type)) || unknownType, type2.mapper);
|
|
54444
54469
|
return factory.createConditionalTypeNode(
|
|
54445
54470
|
typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context),
|
|
54446
54471
|
factory.createInferTypeNode(factory.createTypeParameterDeclaration(
|
|
@@ -55067,7 +55092,7 @@ function createTypeChecker(host) {
|
|
|
55067
55092
|
/*skipUnionExpanding*/
|
|
55068
55093
|
true
|
|
55069
55094
|
)[0];
|
|
55070
|
-
const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters);
|
|
55095
|
+
const cleanup = enterNewScope(context, signature.declaration, expandedParams, signature.typeParameters, signature.parameters, signature.mapper);
|
|
55071
55096
|
context.approximateLength += 3;
|
|
55072
55097
|
if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) {
|
|
55073
55098
|
typeArguments = signature.target.typeParameters.map((parameter) => typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context));
|
|
@@ -55175,11 +55200,15 @@ function createTypeChecker(host) {
|
|
|
55175
55200
|
function getParametersInScope(node) {
|
|
55176
55201
|
return isFunctionLike(node) || isJSDocSignature(node) ? getSignatureFromDeclaration(node).parameters : void 0;
|
|
55177
55202
|
}
|
|
55178
|
-
function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters) {
|
|
55203
|
+
function enterNewScope(context, declaration, expandedParams, typeParameters, originalParameters, mapper) {
|
|
55179
55204
|
const cleanupContext = cloneNodeBuilderContext(context);
|
|
55180
55205
|
let cleanupParams;
|
|
55181
55206
|
let cleanupTypeParams;
|
|
55182
55207
|
const oldEnclosingDecl = context.enclosingDeclaration;
|
|
55208
|
+
const oldMapper = context.mapper;
|
|
55209
|
+
if (mapper) {
|
|
55210
|
+
context.mapper = mapper;
|
|
55211
|
+
}
|
|
55183
55212
|
if (context.enclosingDeclaration && declaration) {
|
|
55184
55213
|
let pushFakeScope2 = function(kind, addAll) {
|
|
55185
55214
|
Debug.assert(context.enclosingDeclaration);
|
|
@@ -55278,6 +55307,7 @@ function createTypeChecker(host) {
|
|
|
55278
55307
|
cleanupTypeParams == null ? void 0 : cleanupTypeParams();
|
|
55279
55308
|
cleanupContext();
|
|
55280
55309
|
context.enclosingDeclaration = oldEnclosingDecl;
|
|
55310
|
+
context.mapper = oldMapper;
|
|
55281
55311
|
};
|
|
55282
55312
|
}
|
|
55283
55313
|
function tryGetThisParameterDeclaration(signature, context) {
|
|
@@ -55295,7 +55325,7 @@ function createTypeChecker(host) {
|
|
|
55295
55325
|
"this",
|
|
55296
55326
|
/*questionToken*/
|
|
55297
55327
|
void 0,
|
|
55298
|
-
typeToTypeNodeHelper(
|
|
55328
|
+
typeToTypeNodeHelper(getTypeFromTypeNode2(context, thisTag.typeExpression), context)
|
|
55299
55329
|
);
|
|
55300
55330
|
}
|
|
55301
55331
|
}
|
|
@@ -55933,31 +55963,32 @@ function createTypeChecker(host) {
|
|
|
55933
55963
|
var _a;
|
|
55934
55964
|
const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
|
|
55935
55965
|
const enclosingDeclaration = context.enclosingDeclaration;
|
|
55966
|
+
const oldFlags = context.flags;
|
|
55967
|
+
if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
|
|
55968
|
+
syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, context);
|
|
55969
|
+
}
|
|
55970
|
+
context.flags |= -2147483648 /* NoSyntacticPrinter */;
|
|
55936
55971
|
if (enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
|
|
55937
|
-
const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol
|
|
55972
|
+
const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
|
|
55938
55973
|
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
55939
55974
|
const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
55940
|
-
const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
|
|
55975
|
+
const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
|
|
55941
55976
|
if (result2) {
|
|
55977
|
+
context.flags = oldFlags;
|
|
55942
55978
|
return result2;
|
|
55943
55979
|
}
|
|
55944
55980
|
}
|
|
55945
55981
|
}
|
|
55946
|
-
const oldFlags = context.flags;
|
|
55947
55982
|
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
|
|
55948
55983
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
55949
55984
|
}
|
|
55950
55985
|
const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
55951
55986
|
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
|
|
55952
|
-
if (decl && hasInferredType(decl) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
|
|
55953
|
-
syntacticNodeBuilder.serializeTypeOfDeclaration(decl, context);
|
|
55954
|
-
}
|
|
55955
|
-
context.flags |= -2147483648 /* NoSyntacticPrinter */;
|
|
55956
55987
|
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
|
|
55957
55988
|
context.flags = oldFlags;
|
|
55958
55989
|
return result;
|
|
55959
55990
|
}
|
|
55960
|
-
function typeNodeIsEquivalentToType(
|
|
55991
|
+
function typeNodeIsEquivalentToType(annotatedDeclaration, type, typeFromTypeNode) {
|
|
55961
55992
|
if (typeFromTypeNode === type) {
|
|
55962
55993
|
return true;
|
|
55963
55994
|
}
|
|
@@ -55987,13 +56018,10 @@ function createTypeChecker(host) {
|
|
|
55987
56018
|
function serializeReturnTypeForSignatureWorker(context, signature) {
|
|
55988
56019
|
const typePredicate = getTypePredicateOfSignature(signature);
|
|
55989
56020
|
const type = getReturnTypeOfSignature(signature);
|
|
55990
|
-
if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */)) {
|
|
56021
|
+
if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
|
|
55991
56022
|
const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
|
|
55992
|
-
|
|
55993
|
-
|
|
55994
|
-
const annotated = getTypeFromTypeNode(annotation);
|
|
55995
|
-
const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
|
|
55996
|
-
const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, thisInstantiated);
|
|
56023
|
+
if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
|
|
56024
|
+
const result = tryReuseExistingTypeNodeHelper(context, annotation);
|
|
55997
56025
|
if (result) {
|
|
55998
56026
|
return result;
|
|
55999
56027
|
}
|
|
@@ -56059,6 +56087,9 @@ function createTypeChecker(host) {
|
|
|
56059
56087
|
symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
|
|
56060
56088
|
symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
|
|
56061
56089
|
) {
|
|
56090
|
+
if (symAtLocation !== unknownSymbol) {
|
|
56091
|
+
context.tracker.reportInferenceFallback(node);
|
|
56092
|
+
}
|
|
56062
56093
|
introducesError = true;
|
|
56063
56094
|
return { introducesError, node, sym };
|
|
56064
56095
|
}
|
|
@@ -56077,6 +56108,7 @@ function createTypeChecker(host) {
|
|
|
56077
56108
|
/*shouldComputeAliasesToMakeVisible*/
|
|
56078
56109
|
false
|
|
56079
56110
|
).accessibility !== 0 /* Accessible */) {
|
|
56111
|
+
context.tracker.reportInferenceFallback(node);
|
|
56080
56112
|
introducesError = true;
|
|
56081
56113
|
} else {
|
|
56082
56114
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
@@ -56132,13 +56164,26 @@ function createTypeChecker(host) {
|
|
|
56132
56164
|
!(length(existing.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))));
|
|
56133
56165
|
}
|
|
56134
56166
|
}
|
|
56167
|
+
if (isThisTypeNode(existing)) {
|
|
56168
|
+
if (context.mapper === void 0) return true;
|
|
56169
|
+
const type = getTypeFromTypeNode2(
|
|
56170
|
+
context,
|
|
56171
|
+
existing,
|
|
56172
|
+
/*noMappedTypes*/
|
|
56173
|
+
true
|
|
56174
|
+
);
|
|
56175
|
+
return !!type;
|
|
56176
|
+
}
|
|
56135
56177
|
if (isTypeReferenceNode(existing)) {
|
|
56136
56178
|
if (isConstTypeReference(existing)) return false;
|
|
56137
56179
|
const type = getTypeFromTypeReference(existing);
|
|
56138
56180
|
const symbol = getNodeLinks(existing).resolvedSymbol;
|
|
56139
56181
|
if (!symbol) return false;
|
|
56140
56182
|
if (symbol.flags & 262144 /* TypeParameter */) {
|
|
56141
|
-
|
|
56183
|
+
const type2 = getDeclaredTypeOfSymbol(symbol);
|
|
56184
|
+
if (context.mapper && getMappedType(type2, context.mapper) !== type2) {
|
|
56185
|
+
return false;
|
|
56186
|
+
}
|
|
56142
56187
|
}
|
|
56143
56188
|
if (isInJSDoc(existing)) {
|
|
56144
56189
|
return existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) && !getIntendedTypeFromJSDocTypeReference(existing) && symbol.flags & 788968 /* Type */;
|
|
@@ -56151,7 +56196,7 @@ function createTypeChecker(host) {
|
|
|
56151
56196
|
return true;
|
|
56152
56197
|
}
|
|
56153
56198
|
function serializeExistingTypeNode(context, typeNode) {
|
|
56154
|
-
const type =
|
|
56199
|
+
const type = getTypeFromTypeNode2(context, typeNode);
|
|
56155
56200
|
return typeToTypeNodeHelper(type, context);
|
|
56156
56201
|
}
|
|
56157
56202
|
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
@@ -56199,8 +56244,8 @@ function createTypeChecker(host) {
|
|
|
56199
56244
|
if (isJSDocTypeLiteral(node)) {
|
|
56200
56245
|
return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
|
|
56201
56246
|
const name = isIdentifier(t.name) ? t.name : t.name.right;
|
|
56202
|
-
const typeViaParent = getTypeOfPropertyOfType(
|
|
56203
|
-
const overrideTypeNode = typeViaParent && t.typeExpression &&
|
|
56247
|
+
const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
|
|
56248
|
+
const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
|
|
56204
56249
|
return factory.createPropertySignature(
|
|
56205
56250
|
/*modifiers*/
|
|
56206
56251
|
void 0,
|
|
@@ -56241,7 +56286,7 @@ function createTypeChecker(host) {
|
|
|
56241
56286
|
/*modifiers*/
|
|
56242
56287
|
void 0,
|
|
56243
56288
|
getEffectiveDotDotDotForParameter(p),
|
|
56244
|
-
getNameForJSDocFunctionParameter(p, i),
|
|
56289
|
+
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56245
56290
|
p.questionToken,
|
|
56246
56291
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56247
56292
|
/*initializer*/
|
|
@@ -56256,7 +56301,7 @@ function createTypeChecker(host) {
|
|
|
56256
56301
|
/*modifiers*/
|
|
56257
56302
|
void 0,
|
|
56258
56303
|
getEffectiveDotDotDotForParameter(p),
|
|
56259
|
-
getNameForJSDocFunctionParameter(p, i),
|
|
56304
|
+
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
|
56260
56305
|
p.questionToken,
|
|
56261
56306
|
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56262
56307
|
/*initializer*/
|
|
@@ -56266,6 +56311,21 @@ function createTypeChecker(host) {
|
|
|
56266
56311
|
);
|
|
56267
56312
|
}
|
|
56268
56313
|
}
|
|
56314
|
+
if (isThisTypeNode(node)) {
|
|
56315
|
+
if (canReuseTypeNode(context, node)) {
|
|
56316
|
+
return node;
|
|
56317
|
+
}
|
|
56318
|
+
return serializeExistingTypeNode(context, node);
|
|
56319
|
+
}
|
|
56320
|
+
if (isTypeParameterDeclaration(node)) {
|
|
56321
|
+
return factory.updateTypeParameterDeclaration(
|
|
56322
|
+
node,
|
|
56323
|
+
node.modifiers,
|
|
56324
|
+
setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
|
|
56325
|
+
visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
|
|
56326
|
+
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
|
|
56327
|
+
);
|
|
56328
|
+
}
|
|
56269
56329
|
if (isTypeReferenceNode(node)) {
|
|
56270
56330
|
if (canReuseTypeNode(context, node)) {
|
|
56271
56331
|
const { introducesError, node: newName } = trackExistingEntityName(node.typeName, context);
|
|
@@ -56297,7 +56357,7 @@ function createTypeChecker(host) {
|
|
|
56297
56357
|
if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
|
|
56298
56358
|
(!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
56299
56359
|
!(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
|
|
56300
|
-
return setTextRange2(context, typeToTypeNodeHelper(
|
|
56360
|
+
return setTextRange2(context, typeToTypeNodeHelper(getTypeFromTypeNode2(context, node), context), node);
|
|
56301
56361
|
}
|
|
56302
56362
|
return factory.updateImportTypeNode(
|
|
56303
56363
|
node,
|
|
@@ -56367,10 +56427,16 @@ function createTypeChecker(host) {
|
|
|
56367
56427
|
return factory.updateComputedPropertyName(node, literal);
|
|
56368
56428
|
}
|
|
56369
56429
|
}
|
|
56370
|
-
if (isTypePredicateNode(node)
|
|
56371
|
-
|
|
56372
|
-
|
|
56373
|
-
|
|
56430
|
+
if (isTypePredicateNode(node)) {
|
|
56431
|
+
let parameterName;
|
|
56432
|
+
if (isIdentifier(node.parameterName)) {
|
|
56433
|
+
const { node: result, introducesError } = trackExistingEntityName(node.parameterName, context);
|
|
56434
|
+
hadError = hadError || introducesError;
|
|
56435
|
+
parameterName = result;
|
|
56436
|
+
} else {
|
|
56437
|
+
parameterName = node.parameterName;
|
|
56438
|
+
}
|
|
56439
|
+
return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
|
56374
56440
|
}
|
|
56375
56441
|
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
56376
56442
|
const visited = visitEachChild(
|
|
@@ -57146,7 +57212,7 @@ function createTypeChecker(host) {
|
|
|
57146
57212
|
}
|
|
57147
57213
|
return cleanup(factory.createExpressionWithTypeArguments(
|
|
57148
57214
|
expr,
|
|
57149
|
-
map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a,
|
|
57215
|
+
map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode2(context, a)) || typeToTypeNodeHelper(getTypeFromTypeNode2(context, a), context))
|
|
57150
57216
|
));
|
|
57151
57217
|
function cleanup(result2) {
|
|
57152
57218
|
context.enclosingDeclaration = oldEnclosing;
|
|
@@ -70462,12 +70528,17 @@ function createTypeChecker(host) {
|
|
|
70462
70528
|
}
|
|
70463
70529
|
}
|
|
70464
70530
|
function applyToReturnTypes(source, target, callback) {
|
|
70465
|
-
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
70466
70531
|
const targetTypePredicate = getTypePredicateOfSignature(target);
|
|
70467
|
-
if (
|
|
70468
|
-
|
|
70469
|
-
|
|
70470
|
-
|
|
70532
|
+
if (targetTypePredicate) {
|
|
70533
|
+
const sourceTypePredicate = getTypePredicateOfSignature(source);
|
|
70534
|
+
if (sourceTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
|
|
70535
|
+
callback(sourceTypePredicate.type, targetTypePredicate.type);
|
|
70536
|
+
return;
|
|
70537
|
+
}
|
|
70538
|
+
}
|
|
70539
|
+
const targetReturnType = getReturnTypeOfSignature(target);
|
|
70540
|
+
if (couldContainTypeVariables(targetReturnType)) {
|
|
70541
|
+
callback(getReturnTypeOfSignature(source), targetReturnType);
|
|
70471
70542
|
}
|
|
70472
70543
|
}
|
|
70473
70544
|
function createInferenceContext(typeParameters, signature, flags, compareTypes) {
|
|
@@ -89639,6 +89710,7 @@ function createTypeChecker(host) {
|
|
|
89639
89710
|
function getSingleReturnExpression(declaration) {
|
|
89640
89711
|
let candidateExpr;
|
|
89641
89712
|
if (declaration && !nodeIsMissing(declaration.body)) {
|
|
89713
|
+
if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
|
|
89642
89714
|
const body = declaration.body;
|
|
89643
89715
|
if (body && isBlock(body)) {
|
|
89644
89716
|
forEachReturnStatement(body, (s) => {
|
|
@@ -97222,10 +97294,9 @@ function transformClassFields(context) {
|
|
|
97222
97294
|
}
|
|
97223
97295
|
}
|
|
97224
97296
|
}
|
|
97225
|
-
function
|
|
97297
|
+
function tryGetClassThis() {
|
|
97226
97298
|
const lex = getClassLexicalEnvironment();
|
|
97227
|
-
|
|
97228
|
-
return Debug.checkDefined(classThis);
|
|
97299
|
+
return lex.classThis ?? lex.classConstructor ?? (currentClassContainer == null ? void 0 : currentClassContainer.name);
|
|
97229
97300
|
}
|
|
97230
97301
|
function transformAutoAccessor(node) {
|
|
97231
97302
|
const commentRange = getCommentRange(node);
|
|
@@ -97253,7 +97324,7 @@ function transformClassFields(context) {
|
|
|
97253
97324
|
setOriginalNode(backingField, node);
|
|
97254
97325
|
setEmitFlags(backingField, 3072 /* NoComments */);
|
|
97255
97326
|
setSourceMapRange(backingField, sourceMapRange);
|
|
97256
|
-
const receiver = isStatic(node) ?
|
|
97327
|
+
const receiver = isStatic(node) ? tryGetClassThis() ?? factory2.createThis() : factory2.createThis();
|
|
97257
97328
|
const getter = createAccessorPropertyGetRedirector(factory2, node, modifiers, getterName, receiver);
|
|
97258
97329
|
setOriginalNode(getter, node);
|
|
97259
97330
|
setCommentRange(getter, commentRange);
|
|
@@ -97819,7 +97890,7 @@ function transformClassFields(context) {
|
|
|
97819
97890
|
var _a;
|
|
97820
97891
|
let facts = 0 /* None */;
|
|
97821
97892
|
const original = getOriginalNode(node);
|
|
97822
|
-
if (
|
|
97893
|
+
if (isClassLike(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) {
|
|
97823
97894
|
facts |= 1 /* ClassWasDecorated */;
|
|
97824
97895
|
}
|
|
97825
97896
|
if (shouldTransformPrivateElementsOrClassStaticBlocks && (classHasClassThisAssignment(node) || classHasExplicitlyAssignedName(node))) {
|
|
@@ -115005,6 +115076,9 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115005
115076
|
if (heritageClause) {
|
|
115006
115077
|
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
|
115007
115078
|
}
|
|
115079
|
+
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
|
115080
|
+
return createEntityInTypeNodeError(node);
|
|
115081
|
+
}
|
|
115008
115082
|
Debug.type(node);
|
|
115009
115083
|
switch (node.kind) {
|
|
115010
115084
|
case 177 /* GetAccessor */:
|
|
@@ -115040,8 +115114,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115040
115114
|
}
|
|
115041
115115
|
}
|
|
115042
115116
|
function findNearestDeclaration(node) {
|
|
115043
|
-
const result = findAncestor(node, (n) => isExportAssignment(n) ||
|
|
115044
|
-
return
|
|
115117
|
+
const result = findAncestor(node, (n) => isExportAssignment(n) || isStatement(n) || isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n));
|
|
115118
|
+
if (!result) return void 0;
|
|
115119
|
+
if (isExportAssignment(result)) return result;
|
|
115120
|
+
if (isReturnStatement(result)) {
|
|
115121
|
+
return findAncestor(result, (n) => isFunctionLikeDeclaration(n) && !isConstructorDeclaration(n));
|
|
115122
|
+
}
|
|
115123
|
+
return isStatement(result) ? void 0 : result;
|
|
115045
115124
|
}
|
|
115046
115125
|
function createAccessorTypeError(node) {
|
|
115047
115126
|
const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
|
|
@@ -115055,11 +115134,10 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115055
115134
|
}
|
|
115056
115135
|
return diag2;
|
|
115057
115136
|
}
|
|
115058
|
-
function
|
|
115059
|
-
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115137
|
+
function addParentDeclarationRelatedInfo(node, diag2) {
|
|
115060
115138
|
const parentDeclaration = findNearestDeclaration(node);
|
|
115061
115139
|
if (parentDeclaration) {
|
|
115062
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115140
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
115063
115141
|
parentDeclaration.name,
|
|
115064
115142
|
/*includeTrivia*/
|
|
115065
115143
|
false
|
|
@@ -115068,30 +115146,19 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115068
115146
|
}
|
|
115069
115147
|
return diag2;
|
|
115070
115148
|
}
|
|
115149
|
+
function createObjectLiteralError(node) {
|
|
115150
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115151
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115152
|
+
return diag2;
|
|
115153
|
+
}
|
|
115071
115154
|
function createArrayLiteralError(node) {
|
|
115072
115155
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115073
|
-
|
|
115074
|
-
if (parentDeclaration) {
|
|
115075
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115076
|
-
parentDeclaration.name,
|
|
115077
|
-
/*includeTrivia*/
|
|
115078
|
-
false
|
|
115079
|
-
);
|
|
115080
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
115081
|
-
}
|
|
115156
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115082
115157
|
return diag2;
|
|
115083
115158
|
}
|
|
115084
115159
|
function createReturnTypeError(node) {
|
|
115085
115160
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
115086
|
-
|
|
115087
|
-
if (parentDeclaration) {
|
|
115088
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115089
|
-
parentDeclaration.name,
|
|
115090
|
-
/*includeTrivia*/
|
|
115091
|
-
false
|
|
115092
|
-
);
|
|
115093
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
115094
|
-
}
|
|
115161
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115095
115162
|
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
|
|
115096
115163
|
return diag2;
|
|
115097
115164
|
}
|
|
@@ -115129,11 +115196,20 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
115129
115196
|
function createClassExpressionError(node) {
|
|
115130
115197
|
return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
|
|
115131
115198
|
}
|
|
115199
|
+
function createEntityInTypeNodeError(node) {
|
|
115200
|
+
const diag2 = createDiagnosticForNode(node, Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations, getTextOfNode(
|
|
115201
|
+
node,
|
|
115202
|
+
/*includeTrivia*/
|
|
115203
|
+
false
|
|
115204
|
+
));
|
|
115205
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
115206
|
+
return diag2;
|
|
115207
|
+
}
|
|
115132
115208
|
function createExpressionError(node, diagnosticMessage) {
|
|
115133
115209
|
const parentDeclaration = findNearestDeclaration(node);
|
|
115134
115210
|
let diag2;
|
|
115135
115211
|
if (parentDeclaration) {
|
|
115136
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
115212
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
115137
115213
|
parentDeclaration.name,
|
|
115138
115214
|
/*includeTrivia*/
|
|
115139
115215
|
false
|
|
@@ -115859,13 +115935,18 @@ function transformDeclarations(context) {
|
|
|
115859
115935
|
if (isDeclaration(input)) {
|
|
115860
115936
|
if (isDeclarationAndNotVisible(input)) return;
|
|
115861
115937
|
if (hasDynamicName(input)) {
|
|
115862
|
-
if (isolatedDeclarations
|
|
115863
|
-
|
|
115864
|
-
|
|
115865
|
-
|
|
115866
|
-
|
|
115867
|
-
|
|
115868
|
-
|
|
115938
|
+
if (isolatedDeclarations) {
|
|
115939
|
+
if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
|
|
115940
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
|
|
115941
|
+
return;
|
|
115942
|
+
} else if (
|
|
115943
|
+
// Type declarations just need to double-check that the input computed name is an entity name expression
|
|
115944
|
+
(isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
|
|
115945
|
+
) {
|
|
115946
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
|
|
115947
|
+
return;
|
|
115948
|
+
}
|
|
115949
|
+
} else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
|
|
115869
115950
|
return;
|
|
115870
115951
|
}
|
|
115871
115952
|
}
|
|
@@ -126828,6 +126909,7 @@ var BuilderState;
|
|
|
126828
126909
|
getKeys: (v) => reverse.get(v),
|
|
126829
126910
|
getValues: (k) => forward.get(k),
|
|
126830
126911
|
keys: () => forward.keys(),
|
|
126912
|
+
size: () => forward.size,
|
|
126831
126913
|
deleteKey: (k) => {
|
|
126832
126914
|
(deleted || (deleted = /* @__PURE__ */ new Set())).add(k);
|
|
126833
126915
|
const set = forward.get(k);
|
|
@@ -126954,12 +127036,15 @@ var BuilderState;
|
|
|
126954
127036
|
return oldState && !oldState.referencedMap === !newReferencedMap;
|
|
126955
127037
|
}
|
|
126956
127038
|
BuilderState2.canReuseOldState = canReuseOldState;
|
|
127039
|
+
function createReferencedMap(options) {
|
|
127040
|
+
return options.module !== 0 /* None */ && !options.outFile ? createManyToManyPathMap() : void 0;
|
|
127041
|
+
}
|
|
127042
|
+
BuilderState2.createReferencedMap = createReferencedMap;
|
|
126957
127043
|
function create(newProgram, oldState, disableUseFileVersionAsSignature) {
|
|
126958
127044
|
var _a, _b;
|
|
126959
127045
|
const fileInfos = /* @__PURE__ */ new Map();
|
|
126960
127046
|
const options = newProgram.getCompilerOptions();
|
|
126961
|
-
const
|
|
126962
|
-
const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
|
|
127047
|
+
const referencedMap = createReferencedMap(options);
|
|
126963
127048
|
const useOldState = canReuseOldState(referencedMap, oldState);
|
|
126964
127049
|
newProgram.getTypeChecker();
|
|
126965
127050
|
for (const sourceFile of newProgram.getSourceFiles()) {
|
|
@@ -126976,7 +127061,7 @@ var BuilderState;
|
|
|
126976
127061
|
version: version2,
|
|
126977
127062
|
signature,
|
|
126978
127063
|
// No need to calculate affectsGlobalScope with --out since its not used at all
|
|
126979
|
-
affectsGlobalScope: !
|
|
127064
|
+
affectsGlobalScope: !options.outFile ? isFileAffectingGlobalScope(sourceFile) || void 0 : void 0,
|
|
126980
127065
|
impliedFormat: sourceFile.impliedNodeFormat
|
|
126981
127066
|
});
|
|
126982
127067
|
}
|
|
@@ -127265,7 +127350,7 @@ function createBuilderProgramState(newProgram, oldState) {
|
|
|
127265
127350
|
if (emitDiagnostics) {
|
|
127266
127351
|
(state.emitDiagnosticsPerFile ?? (state.emitDiagnosticsPerFile = /* @__PURE__ */ new Map())).set(
|
|
127267
127352
|
sourceFilePath,
|
|
127268
|
-
oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
|
|
127353
|
+
oldState.hasReusableDiagnostic ? convertToDiagnostics(emitDiagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(emitDiagnostics, newProgram)
|
|
127269
127354
|
);
|
|
127270
127355
|
}
|
|
127271
127356
|
if (canCopySemanticDiagnostics) {
|
|
@@ -127275,7 +127360,7 @@ function createBuilderProgramState(newProgram, oldState) {
|
|
|
127275
127360
|
if (diagnostics) {
|
|
127276
127361
|
state.semanticDiagnosticsPerFile.set(
|
|
127277
127362
|
sourceFilePath,
|
|
127278
|
-
oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
|
|
127363
|
+
oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, sourceFilePath, newProgram) : repopulateDiagnostics(diagnostics, newProgram)
|
|
127279
127364
|
);
|
|
127280
127365
|
(state.semanticDiagnosticsFromOldState ?? (state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set())).add(sourceFilePath);
|
|
127281
127366
|
}
|
|
@@ -127362,17 +127447,17 @@ function convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram
|
|
|
127362
127447
|
function convertOrRepopulateDiagnosticMessageChainArray(array, sourceFile, newProgram, repopulateInfo) {
|
|
127363
127448
|
return sameMap(array, (chain) => convertOrRepopulateDiagnosticMessageChain(chain, sourceFile, newProgram, repopulateInfo));
|
|
127364
127449
|
}
|
|
127365
|
-
function convertToDiagnostics(diagnostics, newProgram) {
|
|
127450
|
+
function convertToDiagnostics(diagnostics, diagnosticFilePath, newProgram) {
|
|
127366
127451
|
if (!diagnostics.length) return emptyArray;
|
|
127367
127452
|
let buildInfoDirectory;
|
|
127368
127453
|
return diagnostics.map((diagnostic) => {
|
|
127369
|
-
const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPathInBuildInfoDirectory);
|
|
127454
|
+
const result = convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory);
|
|
127370
127455
|
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
|
|
127371
127456
|
result.reportsDeprecated = diagnostic.reportDeprecated;
|
|
127372
127457
|
result.source = diagnostic.source;
|
|
127373
127458
|
result.skippedOn = diagnostic.skippedOn;
|
|
127374
127459
|
const { relatedInformation } = diagnostic;
|
|
127375
|
-
result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
|
|
127460
|
+
result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToDiagnosticRelatedInformation(r, diagnosticFilePath, newProgram, toPathInBuildInfoDirectory)) : [] : void 0;
|
|
127376
127461
|
return result;
|
|
127377
127462
|
});
|
|
127378
127463
|
function toPathInBuildInfoDirectory(path) {
|
|
@@ -127380,9 +127465,9 @@ function convertToDiagnostics(diagnostics, newProgram) {
|
|
|
127380
127465
|
return toPath(path, buildInfoDirectory, newProgram.getCanonicalFileName);
|
|
127381
127466
|
}
|
|
127382
127467
|
}
|
|
127383
|
-
function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
|
|
127468
|
+
function convertToDiagnosticRelatedInformation(diagnostic, diagnosticFilePath, newProgram, toPath3) {
|
|
127384
127469
|
const { file } = diagnostic;
|
|
127385
|
-
const sourceFile = file ? newProgram.getSourceFileByPath(toPath3(file)) : void 0;
|
|
127470
|
+
const sourceFile = file !== false ? newProgram.getSourceFileByPath(file ? toPath3(file) : diagnosticFilePath) : void 0;
|
|
127386
127471
|
return {
|
|
127387
127472
|
...diagnostic,
|
|
127388
127473
|
file: sourceFile,
|
|
@@ -127698,7 +127783,7 @@ function isProgramBundleEmitBuildInfo(info) {
|
|
|
127698
127783
|
return !!((_a = info.options) == null ? void 0 : _a.outFile);
|
|
127699
127784
|
}
|
|
127700
127785
|
function getBuildInfo2(state) {
|
|
127701
|
-
var _a;
|
|
127786
|
+
var _a, _b;
|
|
127702
127787
|
const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
|
|
127703
127788
|
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
|
|
127704
127789
|
const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
|
|
@@ -127735,7 +127820,7 @@ function getBuildInfo2(state) {
|
|
|
127735
127820
|
let fileNamesToFileIdListId;
|
|
127736
127821
|
let emitSignatures;
|
|
127737
127822
|
const fileInfos = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
|
|
127738
|
-
var _a2,
|
|
127823
|
+
var _a2, _b2;
|
|
127739
127824
|
const fileId = toFileId(key);
|
|
127740
127825
|
tryAddRoot(key, fileId);
|
|
127741
127826
|
Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key));
|
|
@@ -127744,7 +127829,7 @@ function getBuildInfo2(state) {
|
|
|
127744
127829
|
if (state.compilerOptions.composite) {
|
|
127745
127830
|
const file = state.program.getSourceFileByPath(key);
|
|
127746
127831
|
if (!isJsonSourceFile(file) && sourceFileMayBeEmitted(file, state.program)) {
|
|
127747
|
-
const emitSignature = (
|
|
127832
|
+
const emitSignature = (_b2 = state.emitSignatures) == null ? void 0 : _b2.get(key);
|
|
127748
127833
|
if (emitSignature !== actualSignature) {
|
|
127749
127834
|
emitSignatures = append(
|
|
127750
127835
|
emitSignatures,
|
|
@@ -127778,15 +127863,15 @@ function getBuildInfo2(state) {
|
|
|
127778
127863
|
);
|
|
127779
127864
|
});
|
|
127780
127865
|
let referencedMap;
|
|
127781
|
-
if (state.referencedMap) {
|
|
127866
|
+
if ((_a = state.referencedMap) == null ? void 0 : _a.size()) {
|
|
127782
127867
|
referencedMap = arrayFrom(state.referencedMap.keys()).sort(compareStringsCaseSensitive).map((key) => [
|
|
127783
127868
|
toFileId(key),
|
|
127784
127869
|
toFileIdListId(state.referencedMap.getValues(key))
|
|
127785
127870
|
]);
|
|
127786
127871
|
}
|
|
127787
|
-
const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(
|
|
127872
|
+
const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics();
|
|
127788
127873
|
let affectedFilesPendingEmit;
|
|
127789
|
-
if ((
|
|
127874
|
+
if ((_b = state.affectedFilesPendingEmit) == null ? void 0 : _b.size) {
|
|
127790
127875
|
const fullEmitForOptions = getBuilderFileEmit(state.compilerOptions);
|
|
127791
127876
|
const seenFiles = /* @__PURE__ */ new Set();
|
|
127792
127877
|
for (const path of arrayFrom(state.affectedFilesPendingEmit.keys()).sort(compareStringsCaseSensitive)) {
|
|
@@ -127814,7 +127899,7 @@ function getBuildInfo2(state) {
|
|
|
127814
127899
|
changeFileSet = append(changeFileSet, toFileId(path));
|
|
127815
127900
|
}
|
|
127816
127901
|
}
|
|
127817
|
-
const emitDiagnosticsPerFile =
|
|
127902
|
+
const emitDiagnosticsPerFile = convertToProgramBuildInfoEmitDiagnostics();
|
|
127818
127903
|
const program = {
|
|
127819
127904
|
fileNames,
|
|
127820
127905
|
fileInfos,
|
|
@@ -127906,40 +127991,53 @@ function getBuildInfo2(state) {
|
|
|
127906
127991
|
}
|
|
127907
127992
|
return value;
|
|
127908
127993
|
}
|
|
127909
|
-
function convertToProgramBuildInfoDiagnostics(
|
|
127994
|
+
function convertToProgramBuildInfoDiagnostics() {
|
|
127910
127995
|
let result;
|
|
127911
|
-
|
|
127912
|
-
|
|
127913
|
-
|
|
127914
|
-
|
|
127915
|
-
|
|
127916
|
-
|
|
127917
|
-
|
|
127918
|
-
|
|
127919
|
-
|
|
127920
|
-
);
|
|
127996
|
+
state.fileInfos.forEach((_value, key) => {
|
|
127997
|
+
var _a2;
|
|
127998
|
+
const value = (_a2 = state.semanticDiagnosticsPerFile) == null ? void 0 : _a2.get(key);
|
|
127999
|
+
if (!value) {
|
|
128000
|
+
if (!state.changedFilesSet.has(key)) result = append(result, toFileId(key));
|
|
128001
|
+
} else if (value.length) {
|
|
128002
|
+
result = append(result, [
|
|
128003
|
+
toFileId(key),
|
|
128004
|
+
convertToReusableDiagnostics(value, key)
|
|
128005
|
+
]);
|
|
127921
128006
|
}
|
|
128007
|
+
});
|
|
128008
|
+
return result;
|
|
128009
|
+
}
|
|
128010
|
+
function convertToProgramBuildInfoEmitDiagnostics() {
|
|
128011
|
+
var _a2;
|
|
128012
|
+
let result;
|
|
128013
|
+
if (!((_a2 = state.emitDiagnosticsPerFile) == null ? void 0 : _a2.size)) return result;
|
|
128014
|
+
for (const key of arrayFrom(state.emitDiagnosticsPerFile.keys()).sort(compareStringsCaseSensitive)) {
|
|
128015
|
+
const value = state.emitDiagnosticsPerFile.get(key);
|
|
128016
|
+
result = append(result, [
|
|
128017
|
+
toFileId(key),
|
|
128018
|
+
convertToReusableDiagnostics(value, key)
|
|
128019
|
+
]);
|
|
127922
128020
|
}
|
|
127923
128021
|
return result;
|
|
127924
128022
|
}
|
|
127925
|
-
function convertToReusableDiagnostics(diagnostics) {
|
|
128023
|
+
function convertToReusableDiagnostics(diagnostics, diagnosticFilePath) {
|
|
127926
128024
|
Debug.assert(!!diagnostics.length);
|
|
127927
128025
|
return diagnostics.map((diagnostic) => {
|
|
127928
|
-
const result = convertToReusableDiagnosticRelatedInformation(diagnostic);
|
|
128026
|
+
const result = convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath);
|
|
127929
128027
|
result.reportsUnnecessary = diagnostic.reportsUnnecessary;
|
|
127930
128028
|
result.reportDeprecated = diagnostic.reportsDeprecated;
|
|
127931
128029
|
result.source = diagnostic.source;
|
|
127932
128030
|
result.skippedOn = diagnostic.skippedOn;
|
|
127933
128031
|
const { relatedInformation } = diagnostic;
|
|
127934
|
-
result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r)) : [] : void 0;
|
|
128032
|
+
result.relatedInformation = relatedInformation ? relatedInformation.length ? relatedInformation.map((r) => convertToReusableDiagnosticRelatedInformation(r, diagnosticFilePath)) : [] : void 0;
|
|
127935
128033
|
return result;
|
|
127936
128034
|
});
|
|
127937
128035
|
}
|
|
127938
|
-
function convertToReusableDiagnosticRelatedInformation(diagnostic) {
|
|
128036
|
+
function convertToReusableDiagnosticRelatedInformation(diagnostic, diagnosticFilePath) {
|
|
127939
128037
|
const { file } = diagnostic;
|
|
127940
128038
|
return {
|
|
127941
128039
|
...diagnostic,
|
|
127942
|
-
file: file ? relativeToBuildInfo(file.resolvedPath) :
|
|
128040
|
+
file: file ? file.resolvedPath === diagnosticFilePath ? void 0 : relativeToBuildInfo(file.resolvedPath) : false,
|
|
127943
128041
|
messageText: isString(diagnostic.messageText) ? diagnostic.messageText : convertToReusableDiagnosticMessageChain(diagnostic.messageText)
|
|
127944
128042
|
};
|
|
127945
128043
|
}
|
|
@@ -128338,16 +128436,17 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
|
|
|
128338
128436
|
);
|
|
128339
128437
|
}
|
|
128340
128438
|
});
|
|
128439
|
+
const changedFilesSet = new Set(map(program.changeFileSet, toFilePath));
|
|
128341
128440
|
const fullEmitForOptions = program.affectedFilesPendingEmit ? getBuilderFileEmit(program.options || {}) : void 0;
|
|
128342
128441
|
state = {
|
|
128343
128442
|
fileInfos,
|
|
128344
128443
|
compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
|
|
128345
|
-
referencedMap: toManyToManyPathMap(program.referencedMap),
|
|
128346
|
-
semanticDiagnosticsPerFile:
|
|
128347
|
-
emitDiagnosticsPerFile:
|
|
128444
|
+
referencedMap: toManyToManyPathMap(program.referencedMap, program.options ?? {}),
|
|
128445
|
+
semanticDiagnosticsPerFile: toPerFileSemanticDiagnostics(program.semanticDiagnosticsPerFile, fileInfos, changedFilesSet),
|
|
128446
|
+
emitDiagnosticsPerFile: toPerFileEmitDiagnostics(program.emitDiagnosticsPerFile),
|
|
128348
128447
|
hasReusableDiagnostic: true,
|
|
128349
128448
|
affectedFilesPendingEmit: program.affectedFilesPendingEmit && arrayToMap(program.affectedFilesPendingEmit, (value) => toFilePath(isNumber(value) ? value : value[0]), (value) => toBuilderFileEmit(value, fullEmitForOptions)),
|
|
128350
|
-
changedFilesSet
|
|
128449
|
+
changedFilesSet,
|
|
128351
128450
|
latestChangedDtsFile,
|
|
128352
128451
|
emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0
|
|
128353
128452
|
};
|
|
@@ -128389,16 +128488,27 @@ function createBuilderProgramUsingProgramBuildInfo(buildInfo, buildInfoPath, hos
|
|
|
128389
128488
|
function toFilePathsSet(fileIdsListId) {
|
|
128390
128489
|
return filePathsSetList[fileIdsListId - 1];
|
|
128391
128490
|
}
|
|
128392
|
-
function toManyToManyPathMap(referenceMap) {
|
|
128393
|
-
|
|
128394
|
-
|
|
128395
|
-
}
|
|
128396
|
-
const map2 = BuilderState.createManyToManyPathMap();
|
|
128491
|
+
function toManyToManyPathMap(referenceMap, options) {
|
|
128492
|
+
const map2 = BuilderState.createReferencedMap(options);
|
|
128493
|
+
if (!map2 || !referenceMap) return map2;
|
|
128397
128494
|
referenceMap.forEach(([fileId, fileIdListId]) => map2.set(toFilePath(fileId), toFilePathsSet(fileIdListId)));
|
|
128398
128495
|
return map2;
|
|
128399
128496
|
}
|
|
128400
|
-
function
|
|
128401
|
-
|
|
128497
|
+
function toPerFileSemanticDiagnostics(diagnostics, fileInfos, changedFilesSet) {
|
|
128498
|
+
const semanticDiagnostics = new Map(
|
|
128499
|
+
mapDefinedIterator(
|
|
128500
|
+
fileInfos.keys(),
|
|
128501
|
+
(key) => !changedFilesSet.has(key) ? [key, emptyArray] : void 0
|
|
128502
|
+
)
|
|
128503
|
+
);
|
|
128504
|
+
diagnostics == null ? void 0 : diagnostics.forEach((value) => {
|
|
128505
|
+
if (isNumber(value)) semanticDiagnostics.delete(toFilePath(value));
|
|
128506
|
+
else semanticDiagnostics.set(toFilePath(value[0]), value[1]);
|
|
128507
|
+
});
|
|
128508
|
+
return semanticDiagnostics.size ? semanticDiagnostics : void 0;
|
|
128509
|
+
}
|
|
128510
|
+
function toPerFileEmitDiagnostics(diagnostics) {
|
|
128511
|
+
return diagnostics && arrayToMap(diagnostics, (value) => toFilePath(value[0]), (value) => value[1]);
|
|
128402
128512
|
}
|
|
128403
128513
|
}
|
|
128404
128514
|
function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
|
|
@@ -131989,7 +132099,7 @@ function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime,
|
|
|
131989
132099
|
}
|
|
131990
132100
|
}
|
|
131991
132101
|
function getUpToDateStatusWorker(state, project, resolvedPath) {
|
|
131992
|
-
var _a, _b, _c;
|
|
132102
|
+
var _a, _b, _c, _d;
|
|
131993
132103
|
if (!project.fileNames.length && !canJsonReportNoInputFiles(project.raw)) {
|
|
131994
132104
|
return {
|
|
131995
132105
|
type: 15 /* ContainerOnly */
|
|
@@ -132061,7 +132171,7 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
|
|
|
132061
132171
|
};
|
|
132062
132172
|
}
|
|
132063
132173
|
if (buildInfo.program) {
|
|
132064
|
-
if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) :
|
|
132174
|
+
if (((_a = buildInfo.program.changeFileSet) == null ? void 0 : _a.length) || (!project.options.noEmit ? ((_b = buildInfo.program.affectedFilesPendingEmit) == null ? void 0 : _b.length) || ((_c = buildInfo.program.emitDiagnosticsPerFile) == null ? void 0 : _c.length) : (_d = buildInfo.program.semanticDiagnosticsPerFile) == null ? void 0 : _d.length)) {
|
|
132065
132175
|
return {
|
|
132066
132176
|
type: 7 /* OutOfDateBuildInfo */,
|
|
132067
132177
|
buildInfoFile: buildInfoPath
|
|
@@ -133933,8 +134043,8 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
133933
134043
|
serializeReturnTypeForSignature,
|
|
133934
134044
|
serializeTypeOfExpression
|
|
133935
134045
|
};
|
|
133936
|
-
function serializeExistingTypeAnnotation(type) {
|
|
133937
|
-
return type
|
|
134046
|
+
function serializeExistingTypeAnnotation(type, addUndefined) {
|
|
134047
|
+
return type !== void 0 && (!addUndefined || type && canAddUndefined(type)) ? true : void 0;
|
|
133938
134048
|
}
|
|
133939
134049
|
function serializeTypeOfExpression(expr, context, addUndefined, preserveLiterals) {
|
|
133940
134050
|
return typeFromExpression(
|
|
@@ -134055,12 +134165,17 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
134055
134165
|
const declaredType = getEffectiveTypeAnnotationNode(node);
|
|
134056
134166
|
const addUndefined = resolver.requiresAddingImplicitUndefined(node);
|
|
134057
134167
|
let resultType;
|
|
134058
|
-
if (
|
|
134059
|
-
|
|
134060
|
-
|
|
134061
|
-
}
|
|
134168
|
+
if (declaredType) {
|
|
134169
|
+
resultType = serializeExistingTypeAnnotation(declaredType, addUndefined);
|
|
134170
|
+
} else {
|
|
134062
134171
|
if (node.initializer && isIdentifier(node.name)) {
|
|
134063
|
-
resultType = typeFromExpression(
|
|
134172
|
+
resultType = typeFromExpression(
|
|
134173
|
+
node.initializer,
|
|
134174
|
+
context,
|
|
134175
|
+
/*isConstContext*/
|
|
134176
|
+
void 0,
|
|
134177
|
+
addUndefined
|
|
134178
|
+
);
|
|
134064
134179
|
}
|
|
134065
134180
|
}
|
|
134066
134181
|
return resultType ?? inferTypeOfDeclaration(node, context);
|
|
@@ -134323,6 +134438,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
134323
134438
|
function typeFromSingleReturnExpression(declaration, context) {
|
|
134324
134439
|
let candidateExpr;
|
|
134325
134440
|
if (declaration && !nodeIsMissing(declaration.body)) {
|
|
134441
|
+
if (getFunctionFlags(declaration) & 3 /* AsyncGenerator */) return void 0;
|
|
134326
134442
|
const body = declaration.body;
|
|
134327
134443
|
if (body && isBlock(body)) {
|
|
134328
134444
|
forEachReturnStatement(body, (s) => {
|
|
@@ -142898,7 +143014,7 @@ registerRefactor(refactorNameForMoveToFile, {
|
|
|
142898
143014
|
if (!interactiveRefactorArguments) {
|
|
142899
143015
|
return emptyArray;
|
|
142900
143016
|
}
|
|
142901
|
-
if (context.endPosition !== void 0) {
|
|
143017
|
+
if (context.triggerReason === "implicit" && context.endPosition !== void 0) {
|
|
142902
143018
|
const startNodeAncestor = findAncestor(getTokenAtPosition(file, context.startPosition), isBlockLike);
|
|
142903
143019
|
const endNodeAncestor = findAncestor(getTokenAtPosition(file, context.endPosition), isBlockLike);
|
|
142904
143020
|
if (startNodeAncestor && !isSourceFile(startNodeAncestor) && endNodeAncestor && !isSourceFile(endNodeAncestor)) {
|
|
@@ -143889,11 +144005,19 @@ registerRefactor(refactorName5, {
|
|
|
143889
144005
|
kinds: [moveToNewFileAction.kind],
|
|
143890
144006
|
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
143891
144007
|
const statements = getStatementsToMove(context);
|
|
144008
|
+
const file = context.file;
|
|
144009
|
+
if (context.triggerReason === "implicit" && context.endPosition !== void 0) {
|
|
144010
|
+
const startNodeAncestor = findAncestor(getTokenAtPosition(file, context.startPosition), isBlockLike);
|
|
144011
|
+
const endNodeAncestor = findAncestor(getTokenAtPosition(file, context.endPosition), isBlockLike);
|
|
144012
|
+
if (startNodeAncestor && !isSourceFile(startNodeAncestor) && endNodeAncestor && !isSourceFile(endNodeAncestor)) {
|
|
144013
|
+
return emptyArray;
|
|
144014
|
+
}
|
|
144015
|
+
}
|
|
143892
144016
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
143893
|
-
const
|
|
144017
|
+
const file2 = context.file;
|
|
143894
144018
|
const affectedTextRange = {
|
|
143895
|
-
start: { line: getLineAndCharacterOfPosition(
|
|
143896
|
-
end: { line: getLineAndCharacterOfPosition(
|
|
144019
|
+
start: { line: getLineAndCharacterOfPosition(file2, statements.all[0].getStart(file2)).line, offset: getLineAndCharacterOfPosition(file2, statements.all[0].getStart(file2)).character },
|
|
144020
|
+
end: { line: getLineAndCharacterOfPosition(file2, last(statements.all).end).line, offset: getLineAndCharacterOfPosition(file2, last(statements.all).end).character }
|
|
143897
144021
|
};
|
|
143898
144022
|
return [{ name: refactorName5, description: description2, actions: [{ ...moveToNewFileAction, range: affectedTextRange }] }];
|
|
143899
144023
|
}
|
|
@@ -149397,6 +149521,16 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
149397
149521
|
const sourceFile = getValidSourceFile(fileName);
|
|
149398
149522
|
return ts_InlayHints_exports.provideInlayHints(getInlayHintsContext(sourceFile, span, preferences));
|
|
149399
149523
|
}
|
|
149524
|
+
function mapCode2(sourceFile, contents, focusLocations, formatOptions, preferences) {
|
|
149525
|
+
return ts_MapCode_exports.mapCode(
|
|
149526
|
+
syntaxTreeCache.getCurrentSourceFile(sourceFile),
|
|
149527
|
+
contents,
|
|
149528
|
+
focusLocations,
|
|
149529
|
+
host,
|
|
149530
|
+
ts_formatting_exports.getFormatContext(formatOptions, host),
|
|
149531
|
+
preferences
|
|
149532
|
+
);
|
|
149533
|
+
}
|
|
149400
149534
|
const ls = {
|
|
149401
149535
|
dispose,
|
|
149402
149536
|
cleanupSemanticCache,
|
|
@@ -149467,7 +149601,8 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
149467
149601
|
uncommentSelection,
|
|
149468
149602
|
provideInlayHints: provideInlayHints2,
|
|
149469
149603
|
getSupportedCodeFixes,
|
|
149470
|
-
getPasteEdits
|
|
149604
|
+
getPasteEdits,
|
|
149605
|
+
mapCode: mapCode2
|
|
149471
149606
|
};
|
|
149472
149607
|
switch (languageServiceMode) {
|
|
149473
149608
|
case 0 /* Semantic */:
|
|
@@ -158065,6 +158200,7 @@ var errorCodes47 = [
|
|
|
158065
158200
|
Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
|
|
158066
158201
|
Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
|
|
158067
158202
|
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
|
|
158203
|
+
Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations.code,
|
|
158068
158204
|
Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code
|
|
158069
158205
|
];
|
|
158070
158206
|
var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
|
|
@@ -158225,7 +158361,7 @@ function withContext(context, typePrintMode, cb) {
|
|
|
158225
158361
|
if (findAncestor(targetNode, isEnumMember)) {
|
|
158226
158362
|
return void 0;
|
|
158227
158363
|
}
|
|
158228
|
-
if (isExpressionTarget && findAncestor(targetNode, isHeritageClause)) {
|
|
158364
|
+
if (isExpressionTarget && (findAncestor(targetNode, isHeritageClause) || findAncestor(targetNode, isTypeNode))) {
|
|
158229
158365
|
return void 0;
|
|
158230
158366
|
}
|
|
158231
158367
|
if (isSpreadElement(targetNode)) {
|
|
@@ -170754,6 +170890,213 @@ function getRightHandSideOfAssignment(rightHandSide) {
|
|
|
170754
170890
|
}
|
|
170755
170891
|
}
|
|
170756
170892
|
|
|
170893
|
+
// src/services/_namespaces/ts.MapCode.ts
|
|
170894
|
+
var ts_MapCode_exports = {};
|
|
170895
|
+
__export(ts_MapCode_exports, {
|
|
170896
|
+
mapCode: () => mapCode
|
|
170897
|
+
});
|
|
170898
|
+
|
|
170899
|
+
// src/services/mapCode.ts
|
|
170900
|
+
function mapCode(sourceFile, contents, focusLocations, host, formatContext, preferences) {
|
|
170901
|
+
return ts_textChanges_exports.ChangeTracker.with(
|
|
170902
|
+
{ host, formatContext, preferences },
|
|
170903
|
+
(changeTracker) => {
|
|
170904
|
+
const parsed = contents.map((c) => parse(sourceFile, c));
|
|
170905
|
+
const flattenedLocations = focusLocations && flatten(focusLocations);
|
|
170906
|
+
for (const nodes of parsed) {
|
|
170907
|
+
placeNodeGroup(
|
|
170908
|
+
sourceFile,
|
|
170909
|
+
changeTracker,
|
|
170910
|
+
nodes,
|
|
170911
|
+
flattenedLocations
|
|
170912
|
+
);
|
|
170913
|
+
}
|
|
170914
|
+
}
|
|
170915
|
+
);
|
|
170916
|
+
}
|
|
170917
|
+
function parse(sourceFile, content) {
|
|
170918
|
+
const nodeKinds = [
|
|
170919
|
+
{
|
|
170920
|
+
parse: () => createSourceFile(
|
|
170921
|
+
"__mapcode_content_nodes.ts",
|
|
170922
|
+
content,
|
|
170923
|
+
sourceFile.languageVersion,
|
|
170924
|
+
/*setParentNodes*/
|
|
170925
|
+
true,
|
|
170926
|
+
sourceFile.scriptKind
|
|
170927
|
+
),
|
|
170928
|
+
body: (sf) => sf.statements
|
|
170929
|
+
},
|
|
170930
|
+
{
|
|
170931
|
+
parse: () => createSourceFile(
|
|
170932
|
+
"__mapcode_class_content_nodes.ts",
|
|
170933
|
+
`class __class {
|
|
170934
|
+
${content}
|
|
170935
|
+
}`,
|
|
170936
|
+
sourceFile.languageVersion,
|
|
170937
|
+
/*setParentNodes*/
|
|
170938
|
+
true,
|
|
170939
|
+
sourceFile.scriptKind
|
|
170940
|
+
),
|
|
170941
|
+
body: (cw) => cw.statements[0].members
|
|
170942
|
+
}
|
|
170943
|
+
];
|
|
170944
|
+
const parsedNodes = [];
|
|
170945
|
+
for (const { parse: parse2, body: body2 } of nodeKinds) {
|
|
170946
|
+
const sourceFile2 = parse2();
|
|
170947
|
+
const bod = body2(sourceFile2);
|
|
170948
|
+
if (bod.length && sourceFile2.parseDiagnostics.length === 0) {
|
|
170949
|
+
return bod;
|
|
170950
|
+
} else if (bod.length) {
|
|
170951
|
+
parsedNodes.push({ sourceFile: sourceFile2, body: bod });
|
|
170952
|
+
}
|
|
170953
|
+
}
|
|
170954
|
+
const { body } = parsedNodes.sort(
|
|
170955
|
+
(a, b) => a.sourceFile.parseDiagnostics.length - b.sourceFile.parseDiagnostics.length
|
|
170956
|
+
)[0];
|
|
170957
|
+
return body;
|
|
170958
|
+
}
|
|
170959
|
+
function placeNodeGroup(originalFile, changeTracker, changes, focusLocations) {
|
|
170960
|
+
if (isClassElement(changes[0]) || isTypeElement(changes[0])) {
|
|
170961
|
+
placeClassNodeGroup(
|
|
170962
|
+
originalFile,
|
|
170963
|
+
changeTracker,
|
|
170964
|
+
changes,
|
|
170965
|
+
focusLocations
|
|
170966
|
+
);
|
|
170967
|
+
} else {
|
|
170968
|
+
placeStatements(
|
|
170969
|
+
originalFile,
|
|
170970
|
+
changeTracker,
|
|
170971
|
+
changes,
|
|
170972
|
+
focusLocations
|
|
170973
|
+
);
|
|
170974
|
+
}
|
|
170975
|
+
}
|
|
170976
|
+
function placeClassNodeGroup(originalFile, changeTracker, changes, focusLocations) {
|
|
170977
|
+
let classOrInterface;
|
|
170978
|
+
if (!focusLocations || !focusLocations.length) {
|
|
170979
|
+
classOrInterface = find(originalFile.statements, or(isClassLike, isInterfaceDeclaration));
|
|
170980
|
+
} else {
|
|
170981
|
+
classOrInterface = forEach(focusLocations, (location) => findAncestor(
|
|
170982
|
+
getTokenAtPosition(originalFile, location.start),
|
|
170983
|
+
or(isClassLike, isInterfaceDeclaration)
|
|
170984
|
+
));
|
|
170985
|
+
}
|
|
170986
|
+
if (!classOrInterface) {
|
|
170987
|
+
return;
|
|
170988
|
+
}
|
|
170989
|
+
const firstMatch = classOrInterface.members.find((member) => changes.some((change) => matchNode(change, member)));
|
|
170990
|
+
if (firstMatch) {
|
|
170991
|
+
const lastMatch = findLast(
|
|
170992
|
+
classOrInterface.members,
|
|
170993
|
+
(member) => changes.some((change) => matchNode(change, member))
|
|
170994
|
+
);
|
|
170995
|
+
forEach(changes, wipeNode);
|
|
170996
|
+
changeTracker.replaceNodeRangeWithNodes(
|
|
170997
|
+
originalFile,
|
|
170998
|
+
firstMatch,
|
|
170999
|
+
lastMatch,
|
|
171000
|
+
changes
|
|
171001
|
+
);
|
|
171002
|
+
return;
|
|
171003
|
+
}
|
|
171004
|
+
forEach(changes, wipeNode);
|
|
171005
|
+
changeTracker.insertNodesAfter(
|
|
171006
|
+
originalFile,
|
|
171007
|
+
classOrInterface.members[classOrInterface.members.length - 1],
|
|
171008
|
+
changes
|
|
171009
|
+
);
|
|
171010
|
+
}
|
|
171011
|
+
function placeStatements(originalFile, changeTracker, changes, focusLocations) {
|
|
171012
|
+
if (!(focusLocations == null ? void 0 : focusLocations.length)) {
|
|
171013
|
+
changeTracker.insertNodesAtEndOfFile(
|
|
171014
|
+
originalFile,
|
|
171015
|
+
changes,
|
|
171016
|
+
/*blankLineBetween*/
|
|
171017
|
+
false
|
|
171018
|
+
);
|
|
171019
|
+
return;
|
|
171020
|
+
}
|
|
171021
|
+
for (const location of focusLocations) {
|
|
171022
|
+
const scope = findAncestor(
|
|
171023
|
+
getTokenAtPosition(originalFile, location.start),
|
|
171024
|
+
(block) => or(isBlock, isSourceFile)(block) && some(block.statements, (origStmt) => changes.some((newStmt) => matchNode(newStmt, origStmt)))
|
|
171025
|
+
);
|
|
171026
|
+
if (scope) {
|
|
171027
|
+
const start = scope.statements.find((stmt) => changes.some((node) => matchNode(node, stmt)));
|
|
171028
|
+
if (start) {
|
|
171029
|
+
const end = findLast(scope.statements, (stmt) => changes.some((node) => matchNode(node, stmt)));
|
|
171030
|
+
forEach(changes, wipeNode);
|
|
171031
|
+
changeTracker.replaceNodeRangeWithNodes(
|
|
171032
|
+
originalFile,
|
|
171033
|
+
start,
|
|
171034
|
+
end,
|
|
171035
|
+
changes
|
|
171036
|
+
);
|
|
171037
|
+
return;
|
|
171038
|
+
}
|
|
171039
|
+
}
|
|
171040
|
+
}
|
|
171041
|
+
let scopeStatements = originalFile.statements;
|
|
171042
|
+
for (const location of focusLocations) {
|
|
171043
|
+
const block = findAncestor(
|
|
171044
|
+
getTokenAtPosition(originalFile, location.start),
|
|
171045
|
+
isBlock
|
|
171046
|
+
);
|
|
171047
|
+
if (block) {
|
|
171048
|
+
scopeStatements = block.statements;
|
|
171049
|
+
break;
|
|
171050
|
+
}
|
|
171051
|
+
}
|
|
171052
|
+
forEach(changes, wipeNode);
|
|
171053
|
+
changeTracker.insertNodesAfter(
|
|
171054
|
+
originalFile,
|
|
171055
|
+
scopeStatements[scopeStatements.length - 1],
|
|
171056
|
+
changes
|
|
171057
|
+
);
|
|
171058
|
+
}
|
|
171059
|
+
function matchNode(a, b) {
|
|
171060
|
+
var _a, _b, _c, _d, _e, _f;
|
|
171061
|
+
if (a.kind !== b.kind) {
|
|
171062
|
+
return false;
|
|
171063
|
+
}
|
|
171064
|
+
if (a.kind === 176 /* Constructor */) {
|
|
171065
|
+
return a.kind === b.kind;
|
|
171066
|
+
}
|
|
171067
|
+
if (isNamedDeclaration(a) && isNamedDeclaration(b)) {
|
|
171068
|
+
return a.name.getText() === b.name.getText();
|
|
171069
|
+
}
|
|
171070
|
+
if (isIfStatement(a) && isIfStatement(b)) {
|
|
171071
|
+
return a.expression.getText() === b.expression.getText();
|
|
171072
|
+
}
|
|
171073
|
+
if (isWhileStatement(a) && isWhileStatement(b)) {
|
|
171074
|
+
return a.expression.getText() === b.expression.getText();
|
|
171075
|
+
}
|
|
171076
|
+
if (isForStatement(a) && isForStatement(b)) {
|
|
171077
|
+
return ((_a = a.initializer) == null ? void 0 : _a.getText()) === ((_b = b.initializer) == null ? void 0 : _b.getText()) && ((_c = a.incrementor) == null ? void 0 : _c.getText()) === ((_d = b.incrementor) == null ? void 0 : _d.getText()) && ((_e = a.condition) == null ? void 0 : _e.getText()) === ((_f = b.condition) == null ? void 0 : _f.getText());
|
|
171078
|
+
}
|
|
171079
|
+
if (isForInOrOfStatement(a) && isForInOrOfStatement(b)) {
|
|
171080
|
+
return a.expression.getText() === b.expression.getText() && a.initializer.getText() === b.initializer.getText();
|
|
171081
|
+
}
|
|
171082
|
+
if (isLabeledStatement(a) && isLabeledStatement(b)) {
|
|
171083
|
+
return a.label.getText() === b.label.getText();
|
|
171084
|
+
}
|
|
171085
|
+
if (a.getText() === b.getText()) {
|
|
171086
|
+
return true;
|
|
171087
|
+
}
|
|
171088
|
+
return false;
|
|
171089
|
+
}
|
|
171090
|
+
function wipeNode(node) {
|
|
171091
|
+
resetNodePositions(node);
|
|
171092
|
+
node.parent = void 0;
|
|
171093
|
+
}
|
|
171094
|
+
function resetNodePositions(node) {
|
|
171095
|
+
node.pos = -1;
|
|
171096
|
+
node.end = -1;
|
|
171097
|
+
node.forEachChild(resetNodePositions);
|
|
171098
|
+
}
|
|
171099
|
+
|
|
170757
171100
|
// src/services/_namespaces/ts.OrganizeImports.ts
|
|
170758
171101
|
var ts_OrganizeImports_exports = {};
|
|
170759
171102
|
__export(ts_OrganizeImports_exports, {
|
|
@@ -173046,7 +173389,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symb
|
|
|
173046
173389
|
typeChecker,
|
|
173047
173390
|
resolvedSymbol,
|
|
173048
173391
|
getSourceFileOfNode(resolvedNode),
|
|
173049
|
-
|
|
173392
|
+
enclosingDeclaration,
|
|
173050
173393
|
declarationName,
|
|
173051
173394
|
type,
|
|
173052
173395
|
semanticMeaning,
|
|
@@ -177541,6 +177884,7 @@ __export(ts_exports2, {
|
|
|
177541
177884
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
177542
177885
|
ListFormat: () => ListFormat,
|
|
177543
177886
|
LogLevel: () => LogLevel,
|
|
177887
|
+
MapCode: () => ts_MapCode_exports,
|
|
177544
177888
|
MemberOverrideStatus: () => MemberOverrideStatus,
|
|
177545
177889
|
ModifierFlags: () => ModifierFlags,
|
|
177546
177890
|
ModuleDetectionKind: () => ModuleDetectionKind,
|
|
@@ -180722,6 +181066,7 @@ var CommandTypes = /* @__PURE__ */ ((CommandTypes2) => {
|
|
|
180722
181066
|
CommandTypes2["ProvideCallHierarchyOutgoingCalls"] = "provideCallHierarchyOutgoingCalls";
|
|
180723
181067
|
CommandTypes2["ProvideInlayHints"] = "provideInlayHints";
|
|
180724
181068
|
CommandTypes2["WatchChange"] = "watchChange";
|
|
181069
|
+
CommandTypes2["MapCode"] = "mapCode";
|
|
180725
181070
|
return CommandTypes2;
|
|
180726
181071
|
})(CommandTypes || {});
|
|
180727
181072
|
var WatchFileKind2 = /* @__PURE__ */ ((WatchFileKind3) => {
|
|
@@ -188662,6 +189007,9 @@ var Session3 = class _Session {
|
|
|
188662
189007
|
},
|
|
188663
189008
|
["provideInlayHints" /* ProvideInlayHints */]: (request) => {
|
|
188664
189009
|
return this.requiredResponse(this.provideInlayHints(request.arguments));
|
|
189010
|
+
},
|
|
189011
|
+
["mapCode" /* MapCode */]: (request) => {
|
|
189012
|
+
return this.requiredResponse(this.mapCode(request.arguments));
|
|
188665
189013
|
}
|
|
188666
189014
|
}));
|
|
188667
189015
|
this.host = opts.host;
|
|
@@ -189524,6 +189872,25 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
189524
189872
|
};
|
|
189525
189873
|
});
|
|
189526
189874
|
}
|
|
189875
|
+
mapCode(args) {
|
|
189876
|
+
var _a;
|
|
189877
|
+
const formatOptions = this.getHostFormatOptions();
|
|
189878
|
+
const preferences = this.getHostPreferences();
|
|
189879
|
+
const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args);
|
|
189880
|
+
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
189881
|
+
const focusLocations = (_a = args.mapping.focusLocations) == null ? void 0 : _a.map((spans) => {
|
|
189882
|
+
return spans.map((loc) => {
|
|
189883
|
+
const start = scriptInfo.lineOffsetToPosition(loc.start.line, loc.start.offset);
|
|
189884
|
+
const end = scriptInfo.lineOffsetToPosition(loc.end.line, loc.end.offset);
|
|
189885
|
+
return {
|
|
189886
|
+
start,
|
|
189887
|
+
length: end - start
|
|
189888
|
+
};
|
|
189889
|
+
});
|
|
189890
|
+
});
|
|
189891
|
+
const changes = languageService.mapCode(file, args.mapping.contents, focusLocations, formatOptions, preferences);
|
|
189892
|
+
return this.mapTextChangesToCodeEdits(changes);
|
|
189893
|
+
}
|
|
189527
189894
|
setCompilerOptionsForInferredProjects(args) {
|
|
189528
189895
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
189529
189896
|
}
|
|
@@ -191948,6 +192315,7 @@ if (typeof console !== "undefined") {
|
|
|
191948
192315
|
LexicalEnvironmentFlags,
|
|
191949
192316
|
ListFormat,
|
|
191950
192317
|
LogLevel,
|
|
192318
|
+
MapCode,
|
|
191951
192319
|
MemberOverrideStatus,
|
|
191952
192320
|
ModifierFlags,
|
|
191953
192321
|
ModuleDetectionKind,
|