This commit is contained in:
TypeScript Bot 2024-07-22 20:55:36 +00:00
Родитель c0ded048e0
Коммит c8a7d589e6
6 изменённых файлов: 314 добавлений и 150 удалений

10
lib/lib.es2023.array.d.ts поставляемый
Просмотреть файл

@ -203,7 +203,7 @@ interface Int8Array {
/**
* Copies the array and returns the copy with the elements in reverse order.
*/
toReversed(): Uint8Array;
toReversed(): Int8Array;
/**
* Copies and sorts the array.
@ -211,11 +211,11 @@ interface Int8Array {
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* const myNums = Uint8Array.from([11, 2, 22, 1]);
* myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22]
* const myNums = Int8Array.from([11, 2, 22, 1]);
* myNums.toSorted((a, b) => a - b) // Int8Array(4) [1, 2, 11, 22]
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Uint8Array;
toSorted(compareFn?: (a: number, b: number) => number): Int8Array;
/**
* Copies the array and inserts the given number at the provided index.
@ -224,7 +224,7 @@ interface Int8Array {
* @param value The value to insert into the copied array.
* @returns A copy of the original array with the inserted value.
*/
with(index: number, value: number): Uint8Array;
with(index: number, value: number): Int8Array;
}
interface Uint8Array {

Просмотреть файл

@ -18,7 +18,7 @@ and limitations under the License.
// src/compiler/corePublic.ts
var versionMajorMinor = "5.5";
var version = "5.5.3";
var version = "5.5.4";
// src/compiler/core.ts
var emptyArray = [];
@ -2509,10 +2509,12 @@ function tryGetPerformance() {
if (isNodeLikeSystem()) {
try {
const { performance: performance2 } = require("perf_hooks");
return {
shouldWriteNativeEvents: false,
performance: performance2
};
if (performance2) {
return {
shouldWriteNativeEvents: false,
performance: performance2
};
}
} catch {
}
}
@ -8547,6 +8549,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
var tokenFlags;
var commentDirectives;
var skipJsDocLeadingAsterisks = 0;
var asteriskSeen = false;
var scriptKind = 0 /* Unknown */;
var jsDocParsingMode = 0 /* ParseAll */;
setText(text, start, length2);
@ -8598,6 +8601,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
resetTokenState,
setTextPos: resetTokenState,
setSkipJsDocLeadingAsterisks,
hasLeadingAsterisks,
tryScan,
lookAhead,
scanRange
@ -9204,7 +9208,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
function scan() {
fullStartPos = pos;
tokenFlags = 0 /* None */;
let asteriskSeen = false;
asteriskSeen = false;
while (true) {
tokenStart = pos;
if (pos >= end) {
@ -11007,6 +11011,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
function setSkipJsDocLeadingAsterisks(skip) {
skipJsDocLeadingAsterisks += skip ? 1 : -1;
}
function hasLeadingAsterisks() {
return asteriskSeen;
}
}
function codePointAt(s, i) {
return s.codePointAt(i);
@ -12745,7 +12752,7 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
}
if (isJSDocNode(node) || node.kind === 12 /* JsxText */) {
return skipTrivia(
(sourceFile || getSourceFileOfNode(node)).text,
(sourceFile ?? getSourceFileOfNode(node)).text,
node.pos,
/*stopAfterLineBreak*/
false,
@ -12757,13 +12764,14 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
return getTokenPosOfNode(node.jsDoc[0], sourceFile);
}
if (node.kind === 352 /* SyntaxList */) {
const first2 = firstOrUndefined(getNodeChildren(node));
sourceFile ?? (sourceFile = getSourceFileOfNode(node));
const first2 = firstOrUndefined(getNodeChildren(node, sourceFile));
if (first2) {
return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
}
}
return skipTrivia(
(sourceFile || getSourceFileOfNode(node)).text,
(sourceFile ?? getSourceFileOfNode(node)).text,
node.pos,
/*stopAfterLineBreak*/
false,
@ -16086,11 +16094,11 @@ function getOwnEmitOutputFilePath(fileName, host, extension) {
return emitOutputFilePathWithoutExtension + extension;
}
function getDeclarationEmitOutputFilePath(fileName, host) {
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f));
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host);
}
function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
function getDeclarationEmitOutputFilePathWorker(fileName, options, host) {
const outputDir = options.declarationDir || options.outDir;
const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName;
const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f)) : fileName;
const declarationExtension = getDeclarationEmitExtensionForPath(path);
return removeFileExtension(path) + declarationExtension;
}
@ -23436,7 +23444,7 @@ function createNodeFactory(flags, baseFactory2) {
}
function createSyntaxList(children) {
const node = createBaseNode(352 /* SyntaxList */);
setNodeChildren(node, children);
node._children = children;
return node;
}
function createNotEmittedStatement(original) {
@ -26204,17 +26212,31 @@ function isJSDocImportTag(node) {
}
// src/compiler/factory/nodeChildren.ts
var nodeChildren = /* @__PURE__ */ new WeakMap();
function getNodeChildren(node) {
if (!isNodeKind(node.kind)) return emptyArray;
return nodeChildren.get(node);
var sourceFileToNodeChildren = /* @__PURE__ */ new WeakMap();
function getNodeChildren(node, sourceFile) {
var _a;
const kind = node.kind;
if (!isNodeKind(kind)) {
return emptyArray;
}
if (kind === 352 /* SyntaxList */) {
return node._children;
}
return (_a = sourceFileToNodeChildren.get(sourceFile)) == null ? void 0 : _a.get(node);
}
function setNodeChildren(node, children) {
nodeChildren.set(node, children);
return children;
function unsetNodeChildren(node, origSourceFile) {
var _a;
if (node.kind === 352 /* SyntaxList */) {
Debug.fail("Did not expect to unset the children of a SyntaxList.");
}
(_a = sourceFileToNodeChildren.get(origSourceFile)) == null ? void 0 : _a.delete(node);
}
function unsetNodeChildren(node) {
nodeChildren.delete(node);
function transferSourceFileChildren(sourceFile, targetSourceFile) {
const map2 = sourceFileToNodeChildren.get(sourceFile);
if (map2 !== void 0) {
sourceFileToNodeChildren.delete(sourceFile);
sourceFileToNodeChildren.set(targetSourceFile, map2);
}
}
// src/compiler/factory/utilities.ts
@ -28849,7 +28871,7 @@ var Parser;
function createIdentifier(isIdentifier3, diagnosticMessage, privateIdentifierDiagnosticMessage) {
if (isIdentifier3) {
identifierCount++;
const pos = getNodePos();
const pos = scanner.hasLeadingAsterisks() ? scanner.getTokenStart() : getNodePos();
const originalKeywordKind = token();
const text = internIdentifier(scanner.getTokenValue());
const hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
@ -34785,6 +34807,7 @@ var IncrementalParser;
aggressiveChecks
);
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
transferSourceFileChildren(sourceFile, result);
return result;
}
IncrementalParser2.updateSourceFile = updateSourceFile;
@ -34820,7 +34843,7 @@ var IncrementalParser;
}
}
}
function moveElementEntirelyPastChangeRange(element, isArray2, delta, oldText, newText, aggressiveChecks) {
function moveElementEntirelyPastChangeRange(element, origSourceFile, isArray2, delta, oldText, newText, aggressiveChecks) {
if (isArray2) {
visitArray2(element);
} else {
@ -34832,7 +34855,7 @@ var IncrementalParser;
if (aggressiveChecks && shouldCheckNode(node)) {
text = oldText.substring(node.pos, node.end);
}
unsetNodeChildren(node);
unsetNodeChildren(node, origSourceFile);
setTextRangePosEnd(node, node.pos + delta, node.end + delta);
if (aggressiveChecks && shouldCheckNode(node)) {
Debug.assert(text === newText.substring(node.pos, node.end));
@ -34906,6 +34929,7 @@ var IncrementalParser;
if (child.pos > changeRangeOldEnd) {
moveElementEntirelyPastChangeRange(
child,
sourceFile,
/*isArray*/
false,
delta,
@ -34918,7 +34942,7 @@ var IncrementalParser;
const fullEnd = child.end;
if (fullEnd >= changeStart) {
markAsIntersectingIncrementalChange(child);
unsetNodeChildren(child);
unsetNodeChildren(child, sourceFile);
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
forEachChild(child, visitNode3, visitArray2);
if (hasJSDocNodes(child)) {
@ -34936,6 +34960,7 @@ var IncrementalParser;
if (array.pos > changeRangeOldEnd) {
moveElementEntirelyPastChangeRange(
array,
sourceFile,
/*isArray*/
true,
delta,
@ -35636,7 +35661,6 @@ var commonOptionsWithBuild = [
affectsBuildInfo: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
transpileOptionValue: void 0,
defaultValueDescription: false,
description: Diagnostics.Create_sourcemaps_for_d_ts_files
},
@ -35962,6 +35986,7 @@ var commandOptionsWithoutBuild = [
type: "boolean",
affectsEmit: true,
affectsBuildInfo: true,
affectsSourceFile: true,
category: Diagnostics.Emit,
description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
defaultValueDescription: false
@ -36426,6 +36451,7 @@ var commandOptionsWithoutBuild = [
affectsEmit: true,
affectsBuildInfo: true,
affectsModuleResolution: true,
affectsSourceFile: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
defaultValueDescription: "react"
@ -45124,7 +45150,8 @@ function createTypeChecker(host) {
isUndefinedIdentifierExpression(node) {
Debug.assert(isExpressionNode(node));
return getSymbolAtLocation(node) === undefinedSymbol;
}
},
isDefinitelyReferenceToGlobalSymbolObject
});
var evaluate = createEvaluator({
evaluateElementAccessExpression,
@ -45954,6 +45981,7 @@ function createTypeChecker(host) {
};
var amalgamatedDuplicates;
var reverseMappedCache = /* @__PURE__ */ new Map();
var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
var ambientModulesCache;
var patternAmbientModules;
var patternAmbientModuleAugmentations;
@ -46081,6 +46109,21 @@ function createTypeChecker(host) {
];
initializeTypeChecker();
return checker;
function isDefinitelyReferenceToGlobalSymbolObject(node) {
if (!isPropertyAccessExpression(node)) return false;
if (!isIdentifier(node.name)) return false;
if (!isPropertyAccessExpression(node.expression) && !isIdentifier(node.expression)) return false;
if (isIdentifier(node.expression)) {
return idText(node.expression) === "Symbol" && getResolvedSymbol(node.expression) === (getGlobalSymbol(
"Symbol",
111551 /* Value */ | 1048576 /* ExportValue */,
/*diagnostic*/
void 0
) || unknownSymbol);
}
if (!isIdentifier(node.expression.expression)) return false;
return idText(node.expression.name) === "Symbol" && idText(node.expression.expression) === "globalThis" && getResolvedSymbol(node.expression.expression) === globalThisSymbol;
}
function getCachedType(key) {
return key ? cachedTypes.get(key) : void 0;
}
@ -49293,11 +49336,11 @@ function createTypeChecker(host) {
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
const originalType = type;
if (addUndefined) {
type = getOptionalType(type);
type = getOptionalType(type, !isParameter(host2));
}
const clone = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
if (clone) {
if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
if (addUndefined && containsNonMissingUndefinedType(type) && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
return factory.createUnionTypeNode([clone, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
}
return clone;
@ -50157,7 +50200,21 @@ function createTypeChecker(host) {
}
function shouldUsePlaceholderForProperty(propertySymbol, context) {
var _a;
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
const depth = 3;
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */) || isDeeplyNestedReverseMappedTypeProperty());
function isDeeplyNestedReverseMappedTypeProperty() {
var _a2;
if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
return false;
}
for (let i = 0; i < depth; i++) {
const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
return false;
}
}
return true;
}
}
function addPropertyToElementList(propertySymbol, context, typeElements) {
var _a;
@ -51244,8 +51301,8 @@ function createTypeChecker(host) {
return enclosingDeclaration;
}
function serializeTypeForDeclaration(context, declaration, type, symbol) {
var _a;
const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
var _a, _b;
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
const enclosingDeclaration = context.enclosingDeclaration;
const oldFlags = context.flags;
if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
@ -51256,6 +51313,7 @@ function createTypeChecker(host) {
const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
const addUndefined = addUndefinedForParameter || !!(symbol.flags & 4 /* Property */ && symbol.flags & 16777216 /* Optional */ && isOptionalDeclaration(declWithExistingAnnotation) && ((_a = symbol.links) == null ? void 0 : _a.mappedType) && containsNonMissingUndefinedType(type));
const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
if (result2) {
context.flags = oldFlags;
@ -51266,9 +51324,9 @@ function createTypeChecker(host) {
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
}
const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
const decl = declaration ?? symbol.valueDeclaration ?? ((_b = symbol.declarations) == null ? void 0 : _b[0]);
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefinedForParameter);
context.flags = oldFlags;
return result;
}
@ -51303,9 +51361,9 @@ function createTypeChecker(host) {
const typePredicate = getTypePredicateOfSignature(signature);
const type = getReturnTypeOfSignature(signature);
if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
const result = tryReuseExistingTypeNodeHelper(context, annotation);
const annotation = getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
if (annotation) {
const result = tryReuseExistingTypeNode(context, annotation, type, context.enclosingDeclaration);
if (result) {
return result;
}
@ -51799,7 +51857,10 @@ function createTypeChecker(host) {
);
}
if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
if (!(context.flags & 1 /* AllowUnresolvedNames */ && hasDynamicName(node) && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
if (!hasDynamicName(node)) {
return visitEachChild2(node, visitExistingNodeTreeSymbols);
}
if (!(context.flags & 1 /* AllowUnresolvedNames */ && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
return void 0;
}
}
@ -51929,7 +51990,7 @@ function createTypeChecker(host) {
if (result) {
if (result.pos !== -1 || result.end !== -1) {
if (result === nodes) {
result = factory.createNodeArray(nodes, nodes.hasTrailingComma);
result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma);
}
setTextRangePosEnd(result, -1, -1);
}
@ -57886,7 +57947,7 @@ function createTypeChecker(host) {
);
}
function createSignatureTypeMapper(signature, typeArguments) {
return createTypeMapper(signature.typeParameters, typeArguments);
return createTypeMapper(sameMap(signature.typeParameters, (tp) => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
}
function getErasedSignature(signature) {
return signature.typeParameters ? signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : signature;
@ -62529,6 +62590,10 @@ function createTypeChecker(host) {
function containsUndefinedType(type) {
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
}
function containsNonMissingUndefinedType(type) {
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
}
function isStringIndexSignatureOnlyType(type) {
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
}
@ -66177,11 +66242,11 @@ function createTypeChecker(host) {
}
function inferTypeForHomomorphicMappedType(source, target, constraint) {
const cacheKey = source.id + "," + target.id + "," + constraint.id;
if (reverseMappedCache.has(cacheKey)) {
return reverseMappedCache.get(cacheKey);
if (reverseHomomorphicMappedCache.has(cacheKey)) {
return reverseHomomorphicMappedCache.get(cacheKey);
}
const type = createReverseMappedType(source, target, constraint);
reverseMappedCache.set(cacheKey, type);
reverseHomomorphicMappedCache.set(cacheKey, type);
return type;
}
function isPartiallyInferableType(type) {
@ -69409,7 +69474,7 @@ function createTypeChecker(host) {
if (!canCollectSymbolAliasAccessabilityData) {
return;
}
if (location.flags & 33554432 /* Ambient */) {
if (location.flags & 33554432 /* Ambient */ && !isPropertySignature(location) && !isPropertyDeclaration(location)) {
return;
}
switch (hint) {
@ -72413,7 +72478,7 @@ function createTypeChecker(host) {
checkGrammarJsxElement(node);
}
checkJsxPreconditions(node);
markLinkedReferences(node, 4 /* Jsx */);
markJsxAliasReferenced(node);
if (isNodeOpeningLikeElement) {
const jsxOpeningLikeNode = node;
const sig = getResolvedSignature(jsxOpeningLikeNode);
@ -85149,15 +85214,14 @@ function createTypeChecker(host) {
function checkChildIdentifiers(node2) {
forEachNodeRecursively(node2, checkIdentifiers);
}
function isExpressionNodeOrShorthandPropertyAssignmentName(node2) {
return isExpressionNode(node2) || isShorthandPropertyAssignment(node2.parent) && (node2.parent.objectAssignmentInitializer ?? node2.parent.name) === node2;
}
function checkSingleIdentifier(node2) {
const nodeLinks2 = getNodeLinks(node2);
nodeLinks2.calculatedFlags |= 536870912 /* ConstructorReference */ | 16384 /* CapturedBlockScopedBinding */ | 32768 /* BlockScopedBindingInLoop */;
if (isIdentifier(node2) && isExpressionNode(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
const s = getSymbolAtLocation(
node2,
/*ignoreErrors*/
true
);
if (isIdentifier(node2) && isExpressionNodeOrShorthandPropertyAssignmentName(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
const s = getResolvedSymbol(node2);
if (s && s !== unknownSymbol) {
checkIdentifierCalculateNodeCheckFlags(node2, s);
}
@ -85625,7 +85689,8 @@ function createTypeChecker(host) {
resolveExternalModuleSymbol(sym);
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
},
isImportRequiredByAugmentation
isImportRequiredByAugmentation,
isDefinitelyReferenceToGlobalSymbolObject
};
function isImportRequiredByAugmentation(node) {
const file = getSourceFileOfNode(node);
@ -110759,6 +110824,7 @@ function transformDeclarations(context) {
}
function reportInferenceFallback(node) {
if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
if (getSourceFileOfNode(node) !== currentSourceFile) return;
if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
reportExpandoFunctionErrors(node);
} else {
@ -111397,15 +111463,17 @@ function transformDeclarations(context) {
if (isDeclarationAndNotVisible(input)) return;
if (hasDynamicName(input)) {
if (isolatedDeclarations) {
if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
return;
} else if (
// Type declarations just need to double-check that the input computed name is an entity name expression
(isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
return;
if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
return;
} else if (
// Type declarations just need to double-check that the input computed name is an entity name expression
(isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
return;
}
}
} else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
return;
@ -113130,7 +113198,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
noEmitHelpers: true,
module: compilerOptions.module,
target: compilerOptions.target,
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
sourceMap: emitOnly !== 2 /* BuilderSignature */ && compilerOptions.declarationMap,
inlineSourceMap: compilerOptions.inlineSourceMap,
extendedDiagnostics: compilerOptions.extendedDiagnostics,
onlyPrintJsDocStyle: true,
@ -113353,7 +113421,8 @@ var notImplementedResolver = {
getJsxFragmentFactoryEntity: notImplemented,
isBindingCapturedByNode: notImplemented,
getDeclarationStatementsForSourceFile: notImplemented,
isImportRequiredByAugmentation: notImplemented
isImportRequiredByAugmentation: notImplemented,
isDefinitelyReferenceToGlobalSymbolObject: notImplemented
};
var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@ -121383,7 +121452,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
if (options.outDir || // there is --outDir specified
options.rootDir || // there is --rootDir specified
options.sourceRoot || // there is --sourceRoot specified
options.mapRoot) {
options.mapRoot || // there is --mapRoot specified
getEmitDeclarations(options) && options.declarationDir) {
const dir = getCommonSourceDirectory2();
if (options.outDir && dir === "" && files.some((file) => getRootLength(file.fileName) > 1)) {
createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
@ -122468,8 +122538,7 @@ var BuilderState;
);
},
cancellationToken,
/*emitOnly*/
true,
2 /* BuilderSignature */,
/*customTransformers*/
void 0,
/*forceDtsEmit*/
@ -129606,7 +129675,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
expression,
/*includeBigInt*/
false
)) {
) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
context.tracker.reportInferenceFallback(prop.name);
result = false;
}

Просмотреть файл

@ -2254,6 +2254,7 @@ __export(typescript_exports, {
trace: () => trace,
tracing: () => tracing,
tracingEnabled: () => tracingEnabled,
transferSourceFileChildren: () => transferSourceFileChildren,
transform: () => transform,
transformClassFields: () => transformClassFields,
transformDeclarations: () => transformDeclarations,
@ -2366,7 +2367,7 @@ module.exports = __toCommonJS(typescript_exports);
// src/compiler/corePublic.ts
var versionMajorMinor = "5.5";
var version = "5.5.3";
var version = "5.5.4";
var Comparison = /* @__PURE__ */ ((Comparison3) => {
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@ -5239,10 +5240,12 @@ function tryGetPerformance() {
if (isNodeLikeSystem()) {
try {
const { performance: performance2 } = require("perf_hooks");
return {
shouldWriteNativeEvents: false,
performance: performance2
};
if (performance2) {
return {
shouldWriteNativeEvents: false,
performance: performance2
};
}
} catch {
}
}
@ -6280,6 +6283,7 @@ var FilePreprocessingDiagnosticsKind = /* @__PURE__ */ ((FilePreprocessingDiagno
var EmitOnly = /* @__PURE__ */ ((EmitOnly4) => {
EmitOnly4[EmitOnly4["Js"] = 0] = "Js";
EmitOnly4[EmitOnly4["Dts"] = 1] = "Dts";
EmitOnly4[EmitOnly4["BuilderSignature"] = 2] = "BuilderSignature";
return EmitOnly4;
})(EmitOnly || {});
var StructureIsReused = /* @__PURE__ */ ((StructureIsReused2) => {
@ -12149,6 +12153,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
var tokenFlags;
var commentDirectives;
var skipJsDocLeadingAsterisks = 0;
var asteriskSeen = false;
var scriptKind = 0 /* Unknown */;
var jsDocParsingMode = 0 /* ParseAll */;
setText(text, start, length2);
@ -12200,6 +12205,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
resetTokenState,
setTextPos: resetTokenState,
setSkipJsDocLeadingAsterisks,
hasLeadingAsterisks,
tryScan,
lookAhead,
scanRange
@ -12806,7 +12812,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
function scan() {
fullStartPos = pos;
tokenFlags = 0 /* None */;
let asteriskSeen = false;
asteriskSeen = false;
while (true) {
tokenStart = pos;
if (pos >= end) {
@ -14609,6 +14615,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
function setSkipJsDocLeadingAsterisks(skip) {
skipJsDocLeadingAsterisks += skip ? 1 : -1;
}
function hasLeadingAsterisks() {
return asteriskSeen;
}
}
function codePointAt(s, i) {
return s.codePointAt(i);
@ -16552,7 +16561,7 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
}
if (isJSDocNode(node) || node.kind === 12 /* JsxText */) {
return skipTrivia(
(sourceFile || getSourceFileOfNode(node)).text,
(sourceFile ?? getSourceFileOfNode(node)).text,
node.pos,
/*stopAfterLineBreak*/
false,
@ -16564,13 +16573,14 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
return getTokenPosOfNode(node.jsDoc[0], sourceFile);
}
if (node.kind === 352 /* SyntaxList */) {
const first2 = firstOrUndefined(getNodeChildren(node));
sourceFile ?? (sourceFile = getSourceFileOfNode(node));
const first2 = firstOrUndefined(getNodeChildren(node, sourceFile));
if (first2) {
return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
}
}
return skipTrivia(
(sourceFile || getSourceFileOfNode(node)).text,
(sourceFile ?? getSourceFileOfNode(node)).text,
node.pos,
/*stopAfterLineBreak*/
false,
@ -20113,11 +20123,11 @@ function getOwnEmitOutputFilePath(fileName, host, extension) {
return emitOutputFilePathWithoutExtension + extension;
}
function getDeclarationEmitOutputFilePath(fileName, host) {
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f));
return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host);
}
function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
function getDeclarationEmitOutputFilePathWorker(fileName, options, host) {
const outputDir = options.declarationDir || options.outDir;
const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName;
const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, host.getCurrentDirectory(), host.getCommonSourceDirectory(), (f) => host.getCanonicalFileName(f)) : fileName;
const declarationExtension = getDeclarationEmitExtensionForPath(path);
return removeFileExtension(path) + declarationExtension;
}
@ -27685,7 +27695,7 @@ function createNodeFactory(flags, baseFactory2) {
}
function createSyntaxList3(children) {
const node = createBaseNode(352 /* SyntaxList */);
setNodeChildren(node, children);
node._children = children;
return node;
}
function createNotEmittedStatement(original) {
@ -30578,17 +30588,43 @@ function isSyntaxList(n) {
}
// src/compiler/factory/nodeChildren.ts
var nodeChildren = /* @__PURE__ */ new WeakMap();
function getNodeChildren(node) {
if (!isNodeKind(node.kind)) return emptyArray;
return nodeChildren.get(node);
var sourceFileToNodeChildren = /* @__PURE__ */ new WeakMap();
function getNodeChildren(node, sourceFile) {
var _a;
const kind = node.kind;
if (!isNodeKind(kind)) {
return emptyArray;
}
if (kind === 352 /* SyntaxList */) {
return node._children;
}
return (_a = sourceFileToNodeChildren.get(sourceFile)) == null ? void 0 : _a.get(node);
}
function setNodeChildren(node, children) {
nodeChildren.set(node, children);
function setNodeChildren(node, sourceFile, children) {
if (node.kind === 352 /* SyntaxList */) {
Debug.fail("Should not need to re-set the children of a SyntaxList.");
}
let map2 = sourceFileToNodeChildren.get(sourceFile);
if (map2 === void 0) {
map2 = /* @__PURE__ */ new WeakMap();
sourceFileToNodeChildren.set(sourceFile, map2);
}
map2.set(node, children);
return children;
}
function unsetNodeChildren(node) {
nodeChildren.delete(node);
function unsetNodeChildren(node, origSourceFile) {
var _a;
if (node.kind === 352 /* SyntaxList */) {
Debug.fail("Did not expect to unset the children of a SyntaxList.");
}
(_a = sourceFileToNodeChildren.get(origSourceFile)) == null ? void 0 : _a.delete(node);
}
function transferSourceFileChildren(sourceFile, targetSourceFile) {
const map2 = sourceFileToNodeChildren.get(sourceFile);
if (map2 !== void 0) {
sourceFileToNodeChildren.delete(sourceFile);
sourceFileToNodeChildren.set(targetSourceFile, map2);
}
}
// src/compiler/factory/utilities.ts
@ -33264,7 +33300,7 @@ var Parser;
function createIdentifier(isIdentifier3, diagnosticMessage, privateIdentifierDiagnosticMessage) {
if (isIdentifier3) {
identifierCount++;
const pos = getNodePos();
const pos = scanner2.hasLeadingAsterisks() ? scanner2.getTokenStart() : getNodePos();
const originalKeywordKind = token();
const text = internIdentifier(scanner2.getTokenValue());
const hasExtendedUnicodeEscape = scanner2.hasExtendedUnicodeEscape();
@ -39200,6 +39236,7 @@ var IncrementalParser;
aggressiveChecks
);
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
transferSourceFileChildren(sourceFile, result);
return result;
}
IncrementalParser2.updateSourceFile = updateSourceFile2;
@ -39235,7 +39272,7 @@ var IncrementalParser;
}
}
}
function moveElementEntirelyPastChangeRange(element, isArray2, delta, oldText, newText, aggressiveChecks) {
function moveElementEntirelyPastChangeRange(element, origSourceFile, isArray2, delta, oldText, newText, aggressiveChecks) {
if (isArray2) {
visitArray2(element);
} else {
@ -39247,7 +39284,7 @@ var IncrementalParser;
if (aggressiveChecks && shouldCheckNode(node)) {
text = oldText.substring(node.pos, node.end);
}
unsetNodeChildren(node);
unsetNodeChildren(node, origSourceFile);
setTextRangePosEnd(node, node.pos + delta, node.end + delta);
if (aggressiveChecks && shouldCheckNode(node)) {
Debug.assert(text === newText.substring(node.pos, node.end));
@ -39321,6 +39358,7 @@ var IncrementalParser;
if (child.pos > changeRangeOldEnd) {
moveElementEntirelyPastChangeRange(
child,
sourceFile,
/*isArray*/
false,
delta,
@ -39333,7 +39371,7 @@ var IncrementalParser;
const fullEnd = child.end;
if (fullEnd >= changeStart) {
markAsIntersectingIncrementalChange(child);
unsetNodeChildren(child);
unsetNodeChildren(child, sourceFile);
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
forEachChild(child, visitNode3, visitArray2);
if (hasJSDocNodes(child)) {
@ -39351,6 +39389,7 @@ var IncrementalParser;
if (array.pos > changeRangeOldEnd) {
moveElementEntirelyPastChangeRange(
array,
sourceFile,
/*isArray*/
true,
delta,
@ -40051,7 +40090,6 @@ var commonOptionsWithBuild = [
affectsBuildInfo: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
transpileOptionValue: void 0,
defaultValueDescription: false,
description: Diagnostics.Create_sourcemaps_for_d_ts_files
},
@ -40377,6 +40415,7 @@ var commandOptionsWithoutBuild = [
type: "boolean",
affectsEmit: true,
affectsBuildInfo: true,
affectsSourceFile: true,
category: Diagnostics.Emit,
description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file,
defaultValueDescription: false
@ -40841,6 +40880,7 @@ var commandOptionsWithoutBuild = [
affectsEmit: true,
affectsBuildInfo: true,
affectsModuleResolution: true,
affectsSourceFile: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Specify_module_specifier_used_to_import_the_JSX_factory_functions_when_using_jsx_Colon_react_jsx_Asterisk,
defaultValueDescription: "react"
@ -49888,7 +49928,8 @@ function createTypeChecker(host) {
isUndefinedIdentifierExpression(node) {
Debug.assert(isExpressionNode(node));
return getSymbolAtLocation(node) === undefinedSymbol;
}
},
isDefinitelyReferenceToGlobalSymbolObject
});
var evaluate = createEvaluator({
evaluateElementAccessExpression,
@ -50718,6 +50759,7 @@ function createTypeChecker(host) {
};
var amalgamatedDuplicates;
var reverseMappedCache = /* @__PURE__ */ new Map();
var reverseHomomorphicMappedCache = /* @__PURE__ */ new Map();
var ambientModulesCache;
var patternAmbientModules;
var patternAmbientModuleAugmentations;
@ -50845,6 +50887,21 @@ function createTypeChecker(host) {
];
initializeTypeChecker();
return checker;
function isDefinitelyReferenceToGlobalSymbolObject(node) {
if (!isPropertyAccessExpression(node)) return false;
if (!isIdentifier(node.name)) return false;
if (!isPropertyAccessExpression(node.expression) && !isIdentifier(node.expression)) return false;
if (isIdentifier(node.expression)) {
return idText(node.expression) === "Symbol" && getResolvedSymbol(node.expression) === (getGlobalSymbol(
"Symbol",
111551 /* Value */ | 1048576 /* ExportValue */,
/*diagnostic*/
void 0
) || unknownSymbol);
}
if (!isIdentifier(node.expression.expression)) return false;
return idText(node.expression.name) === "Symbol" && idText(node.expression.expression) === "globalThis" && getResolvedSymbol(node.expression.expression) === globalThisSymbol;
}
function getCachedType(key) {
return key ? cachedTypes.get(key) : void 0;
}
@ -54057,11 +54114,11 @@ function createTypeChecker(host) {
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
const originalType = type;
if (addUndefined) {
type = getOptionalType(type);
type = getOptionalType(type, !isParameter(host2));
}
const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
if (clone2) {
if (addUndefined && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
if (addUndefined && containsNonMissingUndefinedType(type) && !someType(getTypeFromTypeNode2(context, typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
}
return clone2;
@ -54921,7 +54978,21 @@ function createTypeChecker(host) {
}
function shouldUsePlaceholderForProperty(propertySymbol, context) {
var _a;
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */));
const depth = 3;
return !!(getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) && (contains(context.reverseMappedStack, propertySymbol) || ((_a = context.reverseMappedStack) == null ? void 0 : _a[0]) && !(getObjectFlags(last(context.reverseMappedStack).links.propertyType) & 16 /* Anonymous */) || isDeeplyNestedReverseMappedTypeProperty());
function isDeeplyNestedReverseMappedTypeProperty() {
var _a2;
if ((((_a2 = context.reverseMappedStack) == null ? void 0 : _a2.length) ?? 0) < depth) {
return false;
}
for (let i = 0; i < depth; i++) {
const prop = context.reverseMappedStack[context.reverseMappedStack.length - 1 - i];
if (prop.links.mappedType.symbol !== propertySymbol.links.mappedType.symbol) {
return false;
}
}
return true;
}
}
function addPropertyToElementList(propertySymbol, context, typeElements) {
var _a;
@ -56008,8 +56079,8 @@ function createTypeChecker(host) {
return enclosingDeclaration;
}
function serializeTypeForDeclaration(context, declaration, type, symbol) {
var _a;
const addUndefined = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
var _a, _b;
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration);
const enclosingDeclaration = context.enclosingDeclaration;
const oldFlags = context.flags;
if (declaration && hasInferredType(declaration) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
@ -56020,6 +56091,7 @@ function createTypeChecker(host) {
const declWithExistingAnnotation = declaration && getNonlocalEffectiveTypeAnnotationNode(declaration) ? declaration : getDeclarationWithTypeAnnotation(symbol);
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
const addUndefined = addUndefinedForParameter || !!(symbol.flags & 4 /* Property */ && symbol.flags & 16777216 /* Optional */ && isOptionalDeclaration(declWithExistingAnnotation) && ((_a = symbol.links) == null ? void 0 : _a.mappedType) && containsNonMissingUndefinedType(type));
const result2 = !isTypePredicateNode(existing) && tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
if (result2) {
context.flags = oldFlags;
@ -56030,9 +56102,9 @@ function createTypeChecker(host) {
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
}
const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
const decl = declaration ?? symbol.valueDeclaration ?? ((_b = symbol.declarations) == null ? void 0 : _b[0]);
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefinedForParameter);
context.flags = oldFlags;
return result;
}
@ -56067,9 +56139,9 @@ function createTypeChecker(host) {
const typePredicate = getTypePredicateOfSignature(signature);
const type = getReturnTypeOfSignature(signature);
if (context.enclosingDeclaration && (!isErrorType(type) || context.flags & 1 /* AllowUnresolvedNames */) && signature.declaration && !nodeIsSynthesized(signature.declaration)) {
const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
if (annotation && getTypeFromTypeNode2(context, annotation) === type) {
const result = tryReuseExistingTypeNodeHelper(context, annotation);
const annotation = getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
if (annotation) {
const result = tryReuseExistingTypeNode(context, annotation, type, context.enclosingDeclaration);
if (result) {
return result;
}
@ -56563,7 +56635,10 @@ function createTypeChecker(host) {
);
}
if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
if (!(context.flags & 1 /* AllowUnresolvedNames */ && hasDynamicName(node) && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
if (!hasDynamicName(node)) {
return visitEachChild2(node, visitExistingNodeTreeSymbols);
}
if (!(context.flags & 1 /* AllowUnresolvedNames */ && isEntityNameExpression(node.name.expression) && checkComputedPropertyName(node.name).flags & 1 /* Any */)) {
return void 0;
}
}
@ -56693,7 +56768,7 @@ function createTypeChecker(host) {
if (result) {
if (result.pos !== -1 || result.end !== -1) {
if (result === nodes) {
result = factory.createNodeArray(nodes, nodes.hasTrailingComma);
result = factory.createNodeArray(nodes.slice(), nodes.hasTrailingComma);
}
setTextRangePosEnd(result, -1, -1);
}
@ -62650,7 +62725,7 @@ function createTypeChecker(host) {
);
}
function createSignatureTypeMapper(signature, typeArguments) {
return createTypeMapper(signature.typeParameters, typeArguments);
return createTypeMapper(sameMap(signature.typeParameters, (tp) => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
}
function getErasedSignature(signature) {
return signature.typeParameters ? signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : signature;
@ -67293,6 +67368,10 @@ function createTypeChecker(host) {
function containsUndefinedType(type) {
return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */);
}
function containsNonMissingUndefinedType(type) {
const candidate = type.flags & 1048576 /* Union */ ? type.types[0] : type;
return !!(candidate.flags & 32768 /* Undefined */) && candidate !== missingType;
}
function isStringIndexSignatureOnlyType(type) {
return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || type.flags & 3145728 /* UnionOrIntersection */ && every(type.types, isStringIndexSignatureOnlyType) || false;
}
@ -70941,11 +71020,11 @@ function createTypeChecker(host) {
}
function inferTypeForHomomorphicMappedType(source, target, constraint) {
const cacheKey = source.id + "," + target.id + "," + constraint.id;
if (reverseMappedCache.has(cacheKey)) {
return reverseMappedCache.get(cacheKey);
if (reverseHomomorphicMappedCache.has(cacheKey)) {
return reverseHomomorphicMappedCache.get(cacheKey);
}
const type = createReverseMappedType(source, target, constraint);
reverseMappedCache.set(cacheKey, type);
reverseHomomorphicMappedCache.set(cacheKey, type);
return type;
}
function isPartiallyInferableType(type) {
@ -74173,7 +74252,7 @@ function createTypeChecker(host) {
if (!canCollectSymbolAliasAccessabilityData) {
return;
}
if (location.flags & 33554432 /* Ambient */) {
if (location.flags & 33554432 /* Ambient */ && !isPropertySignature(location) && !isPropertyDeclaration(location)) {
return;
}
switch (hint) {
@ -77177,7 +77256,7 @@ function createTypeChecker(host) {
checkGrammarJsxElement(node);
}
checkJsxPreconditions(node);
markLinkedReferences(node, 4 /* Jsx */);
markJsxAliasReferenced(node);
if (isNodeOpeningLikeElement) {
const jsxOpeningLikeNode = node;
const sig = getResolvedSignature(jsxOpeningLikeNode);
@ -89913,15 +89992,14 @@ function createTypeChecker(host) {
function checkChildIdentifiers(node2) {
forEachNodeRecursively(node2, checkIdentifiers);
}
function isExpressionNodeOrShorthandPropertyAssignmentName(node2) {
return isExpressionNode(node2) || isShorthandPropertyAssignment(node2.parent) && (node2.parent.objectAssignmentInitializer ?? node2.parent.name) === node2;
}
function checkSingleIdentifier(node2) {
const nodeLinks2 = getNodeLinks(node2);
nodeLinks2.calculatedFlags |= 536870912 /* ConstructorReference */ | 16384 /* CapturedBlockScopedBinding */ | 32768 /* BlockScopedBindingInLoop */;
if (isIdentifier(node2) && isExpressionNode(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
const s = getSymbolAtLocation(
node2,
/*ignoreErrors*/
true
);
if (isIdentifier(node2) && isExpressionNodeOrShorthandPropertyAssignmentName(node2) && !(isPropertyAccessExpression(node2.parent) && node2.parent.name === node2)) {
const s = getResolvedSymbol(node2);
if (s && s !== unknownSymbol) {
checkIdentifierCalculateNodeCheckFlags(node2, s);
}
@ -90389,7 +90467,8 @@ function createTypeChecker(host) {
resolveExternalModuleSymbol(sym);
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
},
isImportRequiredByAugmentation
isImportRequiredByAugmentation,
isDefinitelyReferenceToGlobalSymbolObject
};
function isImportRequiredByAugmentation(node) {
const file = getSourceFileOfNode(node);
@ -115705,6 +115784,7 @@ function transformDeclarations(context) {
}
function reportInferenceFallback(node) {
if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
if (getSourceFileOfNode(node) !== currentSourceFile) return;
if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
reportExpandoFunctionErrors(node);
} else {
@ -116343,15 +116423,17 @@ function transformDeclarations(context) {
if (isDeclarationAndNotVisible(input)) return;
if (hasDynamicName(input)) {
if (isolatedDeclarations) {
if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
return;
} else if (
// Type declarations just need to double-check that the input computed name is an entity name expression
(isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
return;
if (!resolver.isDefinitelyReferenceToGlobalSymbolObject(input.name.expression)) {
if (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent)) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
return;
} else if (
// Type declarations just need to double-check that the input computed name is an entity name expression
(isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)
) {
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
return;
}
}
} else if (!resolver.isLateBound(getParseTreeNode(input)) || !isEntityNameExpression(input.name.expression)) {
return;
@ -118087,7 +118169,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
noEmitHelpers: true,
module: compilerOptions.module,
target: compilerOptions.target,
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
sourceMap: emitOnly !== 2 /* BuilderSignature */ && compilerOptions.declarationMap,
inlineSourceMap: compilerOptions.inlineSourceMap,
extendedDiagnostics: compilerOptions.extendedDiagnostics,
onlyPrintJsDocStyle: true,
@ -118310,7 +118392,8 @@ var notImplementedResolver = {
getJsxFragmentFactoryEntity: notImplemented,
isBindingCapturedByNode: notImplemented,
getDeclarationStatementsForSourceFile: notImplemented,
isImportRequiredByAugmentation: notImplemented
isImportRequiredByAugmentation: notImplemented,
isDefinitelyReferenceToGlobalSymbolObject: notImplemented
};
var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
@ -126383,7 +126466,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
if (options.outDir || // there is --outDir specified
options.rootDir || // there is --rootDir specified
options.sourceRoot || // there is --sourceRoot specified
options.mapRoot) {
options.mapRoot || // there is --mapRoot specified
getEmitDeclarations(options) && options.declarationDir) {
const dir = getCommonSourceDirectory2();
if (options.outDir && dir === "" && files.some((file) => getRootLength(file.fileName) > 1)) {
createDiagnosticForOptionName(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
@ -127482,8 +127566,7 @@ var BuilderState;
);
},
cancellationToken,
/*emitOnly*/
true,
2 /* BuilderSignature */,
/*customTransformers*/
void 0,
/*forceDtsEmit*/
@ -134703,7 +134786,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
expression,
/*includeBigInt*/
false
)) {
) && !resolver.isDefinitelyReferenceToGlobalSymbolObject(expression)) {
context.tracker.reportInferenceFallback(prop.name);
result = false;
}
@ -138675,6 +138758,7 @@ function isImportableSymbol(symbol, checker) {
function forEachNameOfDefaultExport(defaultExport, checker, compilerOptions, preferCapitalizedNames, cb) {
let chain;
let current = defaultExport;
const seen = /* @__PURE__ */ new Map();
while (current) {
const fromDeclaration = getDefaultLikeExportNameFromDeclaration(current);
if (fromDeclaration) {
@ -138686,6 +138770,7 @@ function forEachNameOfDefaultExport(defaultExport, checker, compilerOptions, pre
if (final) return final;
}
chain = append(chain, current);
if (!addToSeen(seen, current)) break;
current = current.flags & 2097152 /* Alias */ ? checker.getImmediateAliasedSymbol(current) : void 0;
}
for (const symbol of chain ?? emptyArray) {
@ -141124,7 +141209,7 @@ function getSourceMapper(host) {
}
const options = program.getCompilerOptions();
const outPath = options.outFile;
const declarationPath = outPath ? removeFileExtension(outPath) + ".d.ts" /* Dts */ : getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName);
const declarationPath = outPath ? removeFileExtension(outPath) + ".d.ts" /* Dts */ : getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), program);
if (declarationPath === void 0) return void 0;
const newLoc = getDocumentPositionMapper2(declarationPath, info.fileName).getGeneratedPosition(info);
return newLoc === info ? void 0 : newLoc;
@ -147943,9 +148028,9 @@ var NodeObject = class {
getChildAt(index, sourceFile) {
return this.getChildren(sourceFile)[index];
}
getChildren(sourceFile) {
getChildren(sourceFile = getSourceFileOfNode(this)) {
this.assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine");
return getNodeChildren(this) ?? setNodeChildren(this, createChildren(this, sourceFile));
return getNodeChildren(this, sourceFile) ?? setNodeChildren(this, sourceFile, createChildren(this, sourceFile));
}
getFirstToken(sourceFile) {
this.assertHasRealPosition();
@ -148026,7 +148111,7 @@ function createSyntaxList(nodes, parent2) {
pos = node.end;
}
addSyntheticNodes(children, pos, nodes.end, parent2);
setNodeChildren(list, children);
list._children = children;
return list;
}
var TokenOrIdentifierObject = class {
@ -161234,6 +161319,14 @@ function tryGetAutoImportableReferenceFromTypeNode(importTypeNode, scriptTarget)
function visit(node) {
if (isLiteralImportTypeNode(node) && node.qualifier) {
const firstIdentifier = getFirstIdentifier(node.qualifier);
if (!firstIdentifier.symbol) {
return visitEachChild(
node,
visit,
/*context*/
void 0
);
}
const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
const qualifier = name !== firstIdentifier.text ? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name)) : node.qualifier;
symbols = append(symbols, firstIdentifier.symbol);
@ -167625,7 +167718,7 @@ function getContainingModuleSymbol(importer, checker) {
return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol);
}
function getSourceFileLikeForImportDeclaration(node) {
if (node.kind === 213 /* CallExpression */) {
if (node.kind === 213 /* CallExpression */ || node.kind === 351 /* JSDocImportTag */) {
return node.getSourceFile();
}
const { parent: parent2 } = node;
@ -180368,6 +180461,7 @@ __export(ts_exports2, {
trace: () => trace,
tracing: () => tracing,
tracingEnabled: () => tracingEnabled,
transferSourceFileChildren: () => transferSourceFileChildren,
transform: () => transform,
transformClassFields: () => transformClassFields,
transformDeclarations: () => transformDeclarations,
@ -183190,7 +183284,7 @@ var Project3 = class _Project {
this.generatedFilesMap.forEach((watcher, source) => {
const sourceFile = this.program.getSourceFileByPath(source);
if (!sourceFile || sourceFile.resolvedPath !== source || !this.isValidGeneratedFileWatcher(
getDeclarationEmitOutputFilePathWorker(sourceFile.fileName, this.compilerOptions, this.currentDirectory, this.program.getCommonSourceDirectory(), this.getCanonicalFileName),
getDeclarationEmitOutputFilePathWorker(sourceFile.fileName, this.compilerOptions, this.program),
watcher
)) {
closeFileWatcherOf(watcher);
@ -194798,6 +194892,7 @@ if (typeof console !== "undefined") {
trace,
tracing,
tracingEnabled,
transferSourceFileChildren,
transform,
transformClassFields,
transformDeclarations,

4
package-lock.json сгенерированный
Просмотреть файл

@ -1,12 +1,12 @@
{
"name": "typescript",
"version": "5.5.3",
"version": "5.5.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "typescript",
"version": "5.5.3",
"version": "5.5.4",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",

Просмотреть файл

@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "5.5.3",
"version": "5.5.4",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [

Просмотреть файл

@ -3,7 +3,7 @@
export const versionMajorMinor = "5.5";
// The following is baselined as a literal template type without intervention
/** The version of the TypeScript compiler release */
export const version = "5.5.3" as string;
export const version = "5.5.4" as string;
/**
* Type of objects whose values are all of the same type.