mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Bump version to 5.5.2 and LKG
This commit is contained in:
+129
-202
@@ -18,7 +18,7 @@ and limitations under the License.
|
||||
|
||||
// src/compiler/corePublic.ts
|
||||
var versionMajorMinor = "5.5";
|
||||
var version = "5.5.1-rc";
|
||||
var version = "5.5.2";
|
||||
|
||||
// src/compiler/core.ts
|
||||
var emptyArray = [];
|
||||
@@ -5923,7 +5923,6 @@ var Diagnostics = {
|
||||
_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
||||
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
|
||||
_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
|
||||
ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve: diag(1293, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve_1293", "ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'."),
|
||||
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
||||
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
||||
The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
|
||||
@@ -12459,6 +12458,9 @@ function createSymbolTable(symbols) {
|
||||
function isTransientSymbol(symbol) {
|
||||
return (symbol.flags & 33554432 /* Transient */) !== 0;
|
||||
}
|
||||
function isExternalModuleSymbol(moduleSymbol) {
|
||||
return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.escapedName.charCodeAt(0) === 34 /* doubleQuote */;
|
||||
}
|
||||
var stringWriter = createSingleLineStringWriter();
|
||||
function createSingleLineStringWriter() {
|
||||
var str = "";
|
||||
@@ -14736,23 +14738,6 @@ function isFunctionSymbol(symbol) {
|
||||
const decl = symbol.valueDeclaration;
|
||||
return decl.kind === 262 /* FunctionDeclaration */ || isVariableDeclaration(decl) && decl.initializer && isFunctionLike(decl.initializer);
|
||||
}
|
||||
function canHaveModuleSpecifier(node) {
|
||||
switch (node == null ? void 0 : node.kind) {
|
||||
case 260 /* VariableDeclaration */:
|
||||
case 208 /* BindingElement */:
|
||||
case 272 /* ImportDeclaration */:
|
||||
case 278 /* ExportDeclaration */:
|
||||
case 271 /* ImportEqualsDeclaration */:
|
||||
case 273 /* ImportClause */:
|
||||
case 280 /* NamespaceExport */:
|
||||
case 274 /* NamespaceImport */:
|
||||
case 281 /* ExportSpecifier */:
|
||||
case 276 /* ImportSpecifier */:
|
||||
case 205 /* ImportType */:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function tryGetModuleSpecifierFromDeclaration(node) {
|
||||
var _a, _b;
|
||||
switch (node.kind) {
|
||||
@@ -17470,8 +17455,8 @@ function walkTreeForJSXTags(node) {
|
||||
function isFileModuleFromUsingJSXTag(file) {
|
||||
return !file.isDeclarationFile ? walkTreeForJSXTags(file) : void 0;
|
||||
}
|
||||
function isFileForcedToBeModuleByFormat(file, options) {
|
||||
return (getImpliedNodeFormatForEmitWorker(file, options) === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
|
||||
function isFileForcedToBeModuleByFormat(file) {
|
||||
return (file.impliedNodeFormat === 99 /* ESNext */ || fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */])) && !file.isDeclarationFile ? true : void 0;
|
||||
}
|
||||
function getSetExternalModuleIndicator(options) {
|
||||
switch (getEmitModuleDetectionKind(options)) {
|
||||
@@ -17490,14 +17475,10 @@ function getSetExternalModuleIndicator(options) {
|
||||
}
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
const combined = or(...checks);
|
||||
const callback = (file) => void (file.externalModuleIndicator = combined(file, options));
|
||||
const callback = (file) => void (file.externalModuleIndicator = combined(file));
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
function importSyntaxAffectsModuleResolution(options) {
|
||||
const moduleResolution = getEmitModuleResolutionKind(options);
|
||||
return 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */ || getResolvePackageJsonExports(options) || getResolvePackageJsonImports(options);
|
||||
}
|
||||
function createComputedCompilerOptions(options) {
|
||||
return options;
|
||||
}
|
||||
@@ -19171,7 +19152,7 @@ function createNameResolver({
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (isSelfReferenceLocation(location)) {
|
||||
if (isSelfReferenceLocation(location, lastLocation)) {
|
||||
lastSelfReferenceLocation = location;
|
||||
}
|
||||
lastLocation = location;
|
||||
@@ -19272,8 +19253,10 @@ function createNameResolver({
|
||||
}
|
||||
return !getImmediatelyInvokedFunctionExpression(location);
|
||||
}
|
||||
function isSelfReferenceLocation(node) {
|
||||
function isSelfReferenceLocation(node, lastLocation) {
|
||||
switch (node.kind) {
|
||||
case 169 /* Parameter */:
|
||||
return !!lastLocation && lastLocation === node.name;
|
||||
case 262 /* FunctionDeclaration */:
|
||||
case 263 /* ClassDeclaration */:
|
||||
case 264 /* InterfaceDeclaration */:
|
||||
@@ -26655,7 +26638,7 @@ function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFacto
|
||||
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
||||
let namedBindings;
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || getImpliedNodeFormatForEmitWorker(sourceFile, compilerOptions) === 99 /* ESNext */) {
|
||||
if (moduleKind >= 5 /* ES2015 */ && moduleKind <= 99 /* ESNext */ || sourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
||||
const helpers = getEmitHelpers(sourceFile);
|
||||
if (helpers) {
|
||||
const helperNames = [];
|
||||
@@ -26720,7 +26703,8 @@ function getOrCreateExternalHelpersModuleNameIfNeeded(factory2, node, compilerOp
|
||||
if (externalHelpersModuleName) {
|
||||
return externalHelpersModuleName;
|
||||
}
|
||||
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && getEmitModuleFormatOfFileWorker(node, compilerOptions) < 4 /* System */;
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
let create = (hasExportStarsToExportValues || getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || node.impliedNodeFormat === 1 /* CommonJS */);
|
||||
if (!create) {
|
||||
const helpers = getEmitHelpers(node);
|
||||
if (helpers) {
|
||||
@@ -44129,15 +44113,13 @@ function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignatu
|
||||
}
|
||||
|
||||
// src/compiler/moduleSpecifiers.ts
|
||||
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, host, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
||||
function getModuleSpecifierPreferences({ importModuleSpecifierPreference, importModuleSpecifierEnding }, compilerOptions, importingSourceFile, oldImportSpecifier) {
|
||||
const filePreferredEnding = getPreferredEnding();
|
||||
return {
|
||||
relativePreference: oldImportSpecifier !== void 0 ? isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */ : importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : 2 /* Shortest */,
|
||||
getAllowedEndingsInPreferredOrder: (syntaxImpliedNodeFormat) => {
|
||||
const impliedNodeFormat = getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions);
|
||||
const preferredEnding = syntaxImpliedNodeFormat !== impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
||||
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
||||
if ((syntaxImpliedNodeFormat ?? impliedNodeFormat) === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
|
||||
const preferredEnding = syntaxImpliedNodeFormat !== importingSourceFile.impliedNodeFormat ? getPreferredEnding(syntaxImpliedNodeFormat) : filePreferredEnding;
|
||||
if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === 99 /* ESNext */) {
|
||||
if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) {
|
||||
return [3 /* TsExtension */, 2 /* JsExtension */];
|
||||
}
|
||||
@@ -44168,7 +44150,7 @@ function getModuleSpecifierPreferences({ importModuleSpecifierPreference, import
|
||||
}
|
||||
return getModuleSpecifierEndingPreference(
|
||||
importModuleSpecifierEnding,
|
||||
resolutionMode ?? getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions),
|
||||
resolutionMode ?? importingSourceFile.impliedNodeFormat,
|
||||
compilerOptions,
|
||||
isFullSourceFile(importingSourceFile) ? importingSourceFile : void 0
|
||||
);
|
||||
@@ -44226,16 +44208,12 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
||||
}
|
||||
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
||||
const info = getInfo(importingSourceFile.fileName, host);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, host, compilerOptions, importingSourceFile);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, compilerOptions, importingSourceFile);
|
||||
const existingSpecifier = isFullSourceFile(importingSourceFile) && forEach(modulePaths, (modulePath) => forEach(
|
||||
host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
|
||||
(reason) => {
|
||||
if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path) return void 0;
|
||||
const existingMode = host.getModeForResolutionAtIndex(importingSourceFile, reason.index);
|
||||
const targetMode = options.overrideImportMode ?? host.getDefaultResolutionModeForFile(importingSourceFile);
|
||||
if (existingMode !== targetMode && existingMode !== void 0 && targetMode !== void 0) {
|
||||
return void 0;
|
||||
}
|
||||
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return void 0;
|
||||
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
||||
return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
|
||||
}
|
||||
@@ -44750,7 +44728,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
||||
if (!parts) {
|
||||
return void 0;
|
||||
}
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, host, options, importingSourceFile);
|
||||
const preferences = getModuleSpecifierPreferences(userPreferences, options, importingSourceFile);
|
||||
const allowedEndings = preferences.getAllowedEndingsInPreferredOrder();
|
||||
let moduleSpecifier = path;
|
||||
let isPackageRootPath = false;
|
||||
@@ -44800,7 +44778,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
||||
const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
||||
if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
|
||||
const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || tryParseJson(host.readFile(packageJsonPath));
|
||||
const importMode = overrideMode || getDefaultResolutionModeForFile(importingSourceFile, host, options);
|
||||
const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
||||
if (getResolvePackageJsonExports(options)) {
|
||||
const nodeModulesDirectoryName2 = packageRootPath.substring(parts.topLevelPackageNameIndex + 1);
|
||||
const packageName2 = getPackageNameFromTypesPackageName(nodeModulesDirectoryName2);
|
||||
@@ -44950,9 +44928,6 @@ function getRelativePathIfInSameVolume(path, directoryPath, getCanonicalFileName
|
||||
function isPathRelativeToParent(path) {
|
||||
return startsWith(path, "..");
|
||||
}
|
||||
function getDefaultResolutionModeForFile(file, host, compilerOptions) {
|
||||
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
||||
}
|
||||
|
||||
// src/compiler/checker.ts
|
||||
var ambientModuleSymbolRegex = /^".+"$/;
|
||||
@@ -47159,28 +47134,22 @@ function createTypeChecker(host) {
|
||||
function isSyntacticDefault(node) {
|
||||
return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
|
||||
}
|
||||
function getEmitSyntaxForModuleSpecifierExpression(usage) {
|
||||
return isStringLiteralLike(usage) ? host.getEmitSyntaxForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
||||
function getUsageModeForExpression(usage) {
|
||||
return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
||||
}
|
||||
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
||||
return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
|
||||
}
|
||||
function isOnlyImportableAsDefault(usage) {
|
||||
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
||||
const usageMode = getEmitSyntaxForModuleSpecifierExpression(usage);
|
||||
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
||||
}
|
||||
return false;
|
||||
function isOnlyImportedAsDefault(usage) {
|
||||
const usageMode = getUsageModeForExpression(usage);
|
||||
return usageMode === 99 /* ESNext */ && endsWith(usage.text, ".json" /* Json */);
|
||||
}
|
||||
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
||||
const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
|
||||
if (file && usageMode !== void 0) {
|
||||
const targetMode = host.getImpliedNodeFormatForEmit(file);
|
||||
if (usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */ && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
||||
return true;
|
||||
}
|
||||
if (usageMode === 99 /* ESNext */ && targetMode === 99 /* ESNext */) {
|
||||
return false;
|
||||
const usageMode = file && getUsageModeForExpression(usage);
|
||||
if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
||||
const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
||||
if (usageMode === 99 /* ESNext */ || result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (!allowSyntheticDefaultImports) {
|
||||
@@ -47239,7 +47208,7 @@ function createTypeChecker(host) {
|
||||
if (!specifier) {
|
||||
return exportDefaultSymbol;
|
||||
}
|
||||
const hasDefaultOnly = isOnlyImportableAsDefault(specifier);
|
||||
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
|
||||
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
||||
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
||||
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
|
||||
@@ -47440,7 +47409,7 @@ function createTypeChecker(host) {
|
||||
let symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
||||
if (symbolFromModule === void 0 && name.escapedText === "default" /* Default */) {
|
||||
const file = (_a = moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
||||
if (isOnlyImportableAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
||||
if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
||||
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
||||
}
|
||||
}
|
||||
@@ -48040,7 +48009,7 @@ function createTypeChecker(host) {
|
||||
/*requireStringLiteralLikeArgument*/
|
||||
true
|
||||
) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, isImportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression) || ((_f = findAncestor(location, isExportDeclaration)) == null ? void 0 : _f.moduleSpecifier);
|
||||
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : host.getDefaultResolutionModeForFile(currentSourceFile);
|
||||
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
||||
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
||||
const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
|
||||
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
||||
@@ -48284,7 +48253,7 @@ function createTypeChecker(host) {
|
||||
return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
|
||||
}
|
||||
const targetFile = (_a = moduleSymbol == null ? void 0 : moduleSymbol.declarations) == null ? void 0 : _a.find(isSourceFile);
|
||||
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), host.getImpliedNodeFormatForEmit(targetFile));
|
||||
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat);
|
||||
if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
|
||||
let sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
|
||||
if (!sigs || !sigs.length) {
|
||||
@@ -50890,10 +50859,8 @@ function createTypeChecker(host) {
|
||||
}
|
||||
return getSourceFileOfNode(getNonAugmentationDeclaration(symbol)).fileName;
|
||||
}
|
||||
const enclosingDeclaration = getOriginalNode(context.enclosingDeclaration);
|
||||
const originalModuleSpecifier = canHaveModuleSpecifier(enclosingDeclaration) ? tryGetModuleSpecifierFromDeclaration(enclosingDeclaration) : void 0;
|
||||
const contextFile = context.enclosingFile;
|
||||
const resolutionMode = overrideImportMode || originalModuleSpecifier && host.getModeForUsageLocation(contextFile, originalModuleSpecifier) || contextFile && host.getDefaultResolutionModeForFile(contextFile);
|
||||
const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
|
||||
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
||||
const links = getSymbolLinks(symbol);
|
||||
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
||||
@@ -51715,7 +51682,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
if (isJSDocTypeLiteral(node)) {
|
||||
return factory.createTypeLiteralNode(map(node.jsDocPropertyTags, (t) => {
|
||||
const name = isIdentifier(t.name) ? t.name : t.name.right;
|
||||
const name = visitNode(isIdentifier(t.name) ? t.name : t.name.right, visitExistingNodeTreeSymbols, isIdentifier);
|
||||
const typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode2(context, node), name.escapedText);
|
||||
const overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode2(context, t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : void 0;
|
||||
return factory.createPropertySignature(
|
||||
@@ -51759,7 +51726,7 @@ function createTypeChecker(host) {
|
||||
void 0,
|
||||
getEffectiveDotDotDotForParameter(p),
|
||||
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
||||
p.questionToken,
|
||||
factory.cloneNode(p.questionToken),
|
||||
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
||||
/*initializer*/
|
||||
void 0
|
||||
@@ -51774,7 +51741,7 @@ function createTypeChecker(host) {
|
||||
void 0,
|
||||
getEffectiveDotDotDotForParameter(p),
|
||||
setTextRange2(context, factory.createIdentifier(getNameForJSDocFunctionParameter(p, i)), p),
|
||||
p.questionToken,
|
||||
factory.cloneNode(p.questionToken),
|
||||
visitNode(p.type, visitExistingNodeTreeSymbols, isTypeNode),
|
||||
/*initializer*/
|
||||
void 0
|
||||
@@ -51793,7 +51760,7 @@ function createTypeChecker(host) {
|
||||
if (isTypeParameterDeclaration(node)) {
|
||||
return factory.updateTypeParameterDeclaration(
|
||||
node,
|
||||
node.modifiers,
|
||||
visitNodes2(node.modifiers, visitExistingNodeTreeSymbols, isModifier),
|
||||
setTextRange2(context, typeParameterToName(getDeclaredTypeOfSymbol(getSymbolOfDeclaration(node)), context), node),
|
||||
visitNode(node.constraint, visitExistingNodeTreeSymbols, isTypeNode),
|
||||
visitNode(node.default, visitExistingNodeTreeSymbols, isTypeNode)
|
||||
@@ -51825,8 +51792,8 @@ function createTypeChecker(host) {
|
||||
return factory.updateImportTypeNode(
|
||||
node,
|
||||
factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)),
|
||||
node.attributes,
|
||||
node.qualifier,
|
||||
visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
|
||||
visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
|
||||
visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
|
||||
node.isTypeOf
|
||||
);
|
||||
@@ -51862,8 +51829,28 @@ function createTypeChecker(host) {
|
||||
} else {
|
||||
const type = getWidenedType(getRegularTypeOfExpression(node.expression));
|
||||
const computedPropertyNameType = typeToTypeNodeHelper(type, context);
|
||||
Debug.assertNode(computedPropertyNameType, isLiteralTypeNode);
|
||||
const literal = computedPropertyNameType.literal;
|
||||
let literal;
|
||||
if (isLiteralTypeNode(computedPropertyNameType)) {
|
||||
literal = computedPropertyNameType.literal;
|
||||
} else {
|
||||
const evaluated = evaluateEntityNameExpression(node.expression);
|
||||
const literalNode = typeof evaluated.value === "string" ? factory.createStringLiteral(
|
||||
evaluated.value,
|
||||
/*isSingleQuote*/
|
||||
void 0
|
||||
) : typeof evaluated.value === "number" ? factory.createNumericLiteral(
|
||||
evaluated.value,
|
||||
/*numericLiteralFlags*/
|
||||
0
|
||||
) : void 0;
|
||||
if (!literalNode) {
|
||||
if (isImportTypeNode(computedPropertyNameType)) {
|
||||
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
literal = literalNode;
|
||||
}
|
||||
if (literal.kind === 11 /* StringLiteral */ && isIdentifierText(literal.text, getEmitScriptTarget(compilerOptions))) {
|
||||
return factory.createIdentifier(literal.text);
|
||||
}
|
||||
@@ -51880,9 +51867,9 @@ function createTypeChecker(host) {
|
||||
hadError = hadError || introducesError;
|
||||
parameterName = result;
|
||||
} else {
|
||||
parameterName = node.parameterName;
|
||||
parameterName = factory.cloneNode(node.parameterName);
|
||||
}
|
||||
return factory.updateTypePredicateNode(node, node.assertsModifier, parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
||||
return factory.updateTypePredicateNode(node, factory.cloneNode(node.assertsModifier), parameterName, visitNode(node.type, visitExistingNodeTreeSymbols, isTypeNode));
|
||||
}
|
||||
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
||||
const visited = visitEachChild2(node, visitExistingNodeTreeSymbols);
|
||||
@@ -51973,7 +51960,7 @@ function createTypeChecker(host) {
|
||||
/*yieldModuleSymbol*/
|
||||
true
|
||||
)[0];
|
||||
if (parentSymbol && parentSymbol.flags & 1536 /* Module */) {
|
||||
if (parentSymbol && isExternalModuleSymbol(parentSymbol)) {
|
||||
name = getSpecifierForModuleSymbol(parentSymbol, context);
|
||||
} else {
|
||||
const targetFile = getExternalModuleFileFromDeclaration(parent);
|
||||
@@ -75357,7 +75344,7 @@ function createTypeChecker(host) {
|
||||
return createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, emptyArray);
|
||||
}
|
||||
function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
|
||||
const hasDefaultOnly = isOnlyImportableAsDefault(moduleSpecifier);
|
||||
const hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
|
||||
if (hasDefaultOnly && type && !isErrorType(type)) {
|
||||
const synthType = type;
|
||||
if (!synthType.defaultOnlyType) {
|
||||
@@ -80584,7 +80571,7 @@ function createTypeChecker(host) {
|
||||
});
|
||||
}
|
||||
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
||||
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) >= 5 /* ES2015 */) {
|
||||
if (moduleKind >= 5 /* ES2015 */ && !(moduleKind >= 100 /* Node16 */ && getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
return;
|
||||
}
|
||||
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
||||
@@ -82005,7 +81992,7 @@ function createTypeChecker(host) {
|
||||
}
|
||||
}
|
||||
function checkClassNameCollisionWithObject(name) {
|
||||
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && host.getEmitModuleFormatOfFile(getSourceFileOfNode(name)) < 5 /* ES2015 */) {
|
||||
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(name).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]);
|
||||
}
|
||||
}
|
||||
@@ -83086,7 +83073,7 @@ function createTypeChecker(host) {
|
||||
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
||||
}
|
||||
}
|
||||
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(node.parent) === 1 /* CommonJS */) {
|
||||
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 95 /* ExportKeyword */);
|
||||
if (exportModifier) {
|
||||
error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
||||
@@ -83296,10 +83283,8 @@ function createTypeChecker(host) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
||||
if (compilerOptions.verbatimModuleSyntax && node.kind !== 271 /* ImportEqualsDeclaration */ && !isInJSFile(node) && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
||||
} else if (moduleKind === 200 /* Preserve */ && node.kind !== 271 /* ImportEqualsDeclaration */ && node.kind !== 260 /* VariableDeclaration */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
||||
error(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve);
|
||||
}
|
||||
}
|
||||
if (isImportSpecifier(node)) {
|
||||
@@ -83338,7 +83323,7 @@ function createTypeChecker(host) {
|
||||
function checkImportBinding(node) {
|
||||
checkCollisionsForDeclarationName(node, node.name);
|
||||
checkAliasSymbol(node);
|
||||
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
|
||||
if (node.kind === 276 /* ImportSpecifier */ && idText(node.propertyName || node.name) === "default" && getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
||||
}
|
||||
}
|
||||
@@ -83359,7 +83344,7 @@ function createTypeChecker(host) {
|
||||
if (validForTypeAttributes && override) {
|
||||
return;
|
||||
}
|
||||
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
|
||||
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
||||
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
||||
const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
|
||||
return grammarErrorOnNode(node, message);
|
||||
@@ -83392,7 +83377,7 @@ function createTypeChecker(host) {
|
||||
if (importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === 274 /* NamespaceImport */) {
|
||||
checkImportBinding(importClause.namedBindings);
|
||||
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && getESModuleInterop(compilerOptions)) {
|
||||
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && getESModuleInterop(compilerOptions)) {
|
||||
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
||||
}
|
||||
} else {
|
||||
@@ -83432,7 +83417,7 @@ function createTypeChecker(host) {
|
||||
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
||||
}
|
||||
} else {
|
||||
if (5 /* ES2015 */ <= moduleKind && moduleKind <= 99 /* ESNext */ && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
||||
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
||||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
||||
}
|
||||
}
|
||||
@@ -83461,7 +83446,7 @@ function createTypeChecker(host) {
|
||||
} else if (node.exportClause) {
|
||||
checkAliasSymbol(node.exportClause);
|
||||
}
|
||||
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */) {
|
||||
if (moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
if (node.exportClause) {
|
||||
if (getESModuleInterop(compilerOptions)) {
|
||||
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
||||
@@ -83514,7 +83499,7 @@ function createTypeChecker(host) {
|
||||
markLinkedReferences(node, 7 /* ExportSpecifier */);
|
||||
}
|
||||
} else {
|
||||
if (getESModuleInterop(compilerOptions) && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && idText(node.propertyName || node.name) === "default") {
|
||||
if (getESModuleInterop(compilerOptions) && moduleKind !== 4 /* System */ && (moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && idText(node.propertyName || node.name) === "default") {
|
||||
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
||||
}
|
||||
}
|
||||
@@ -83540,7 +83525,7 @@ function createTypeChecker(host) {
|
||||
if (typeAnnotationNode) {
|
||||
checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression);
|
||||
}
|
||||
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */;
|
||||
const isIllegalExportDefaultInCJS = !node.isExportEquals && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */);
|
||||
if (node.expression.kind === 80 /* Identifier */) {
|
||||
const id = node.expression;
|
||||
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
||||
@@ -83620,7 +83605,7 @@ function createTypeChecker(host) {
|
||||
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
||||
}
|
||||
if (node.isExportEquals) {
|
||||
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && host.getImpliedNodeFormatForEmit(getSourceFileOfNode(node)) !== 1 /* CommonJS */)) {
|
||||
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
||||
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
||||
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
||||
@@ -86118,7 +86103,7 @@ function createTypeChecker(host) {
|
||||
break;
|
||||
case 95 /* ExportKeyword */:
|
||||
if (compilerOptions.verbatimModuleSyntax && !(node.flags & 33554432 /* Ambient */) && node.kind !== 265 /* TypeAliasDeclaration */ && node.kind !== 264 /* InterfaceDeclaration */ && // ModuleDeclaration needs to be checked that it is uninstantiated later
|
||||
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) === 1 /* CommonJS */) {
|
||||
node.kind !== 267 /* ModuleDeclaration */ && node.parent.kind === 307 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */)) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
||||
}
|
||||
if (flags & 32 /* Export */) {
|
||||
@@ -87027,7 +87012,7 @@ function createTypeChecker(host) {
|
||||
const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type ? Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations : Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
||||
return grammarErrorOnNode(node.exclamationToken, message);
|
||||
}
|
||||
if (host.getEmitModuleFormatOfFile(getSourceFileOfNode(node)) < 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
|
||||
if ((moduleKind < 5 /* ES2015 */ || getSourceFileOfNode(node).impliedNodeFormat === 1 /* CommonJS */) && moduleKind !== 4 /* System */ && !(node.parent.parent.flags & 33554432 /* Ambient */) && hasSyntacticModifier(node.parent.parent, 32 /* Export */)) {
|
||||
checkESModuleMarker(node.name);
|
||||
}
|
||||
return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name);
|
||||
@@ -87528,9 +87513,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
|
||||
isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
|
||||
fileExists: (fileName) => host.fileExists(fileName),
|
||||
getFileIncludeReasons: () => host.getFileIncludeReasons(),
|
||||
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0,
|
||||
getDefaultResolutionModeForFile: (file) => host.getDefaultResolutionModeForFile(file),
|
||||
getModeForResolutionAtIndex: (file, index) => host.getModeForResolutionAtIndex(file, index)
|
||||
readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
|
||||
};
|
||||
}
|
||||
var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
||||
@@ -107195,7 +107178,7 @@ function transformModule(context) {
|
||||
case 354 /* PartiallyEmittedExpression */:
|
||||
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
||||
case 213 /* CallExpression */:
|
||||
if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
|
||||
if (isImportCall(node) && currentSourceFile.impliedNodeFormat === void 0) {
|
||||
return visitImportCallExpression(node);
|
||||
}
|
||||
break;
|
||||
@@ -110190,8 +110173,8 @@ function transformECMAScriptModule(context) {
|
||||
}
|
||||
}
|
||||
|
||||
// src/compiler/transformers/module/impliedNodeFormatDependent.ts
|
||||
function transformImpliedNodeFormatDependentModule(context) {
|
||||
// src/compiler/transformers/module/node.ts
|
||||
function transformNodeModule(context) {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
const esmTransform = transformECMAScriptModule(context);
|
||||
@@ -110202,7 +110185,6 @@ function transformImpliedNodeFormatDependentModule(context) {
|
||||
const cjsTransform = transformModule(context);
|
||||
const cjsOnSubstituteNode = context.onSubstituteNode;
|
||||
const cjsOnEmitNode = context.onEmitNode;
|
||||
const getEmitModuleFormatOfFile = (file) => context.getEmitHost().getEmitModuleFormatOfFile(file);
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.enableSubstitution(307 /* SourceFile */);
|
||||
@@ -110217,7 +110199,7 @@ function transformImpliedNodeFormatDependentModule(context) {
|
||||
if (!currentSourceFile) {
|
||||
return previousOnSubstituteNode(hint, node);
|
||||
}
|
||||
if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
|
||||
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
||||
return esmOnSubstituteNode(hint, node);
|
||||
}
|
||||
return cjsOnSubstituteNode(hint, node);
|
||||
@@ -110230,13 +110212,13 @@ function transformImpliedNodeFormatDependentModule(context) {
|
||||
if (!currentSourceFile) {
|
||||
return previousOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
if (getEmitModuleFormatOfFile(currentSourceFile) >= 5 /* ES2015 */) {
|
||||
if (currentSourceFile.impliedNodeFormat === 99 /* ESNext */) {
|
||||
return esmOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
return cjsOnEmitNode(hint, node, emitCallback);
|
||||
}
|
||||
function getModuleTransformForFile(file) {
|
||||
return getEmitModuleFormatOfFile(file) >= 5 /* ES2015 */ ? esmTransform : cjsTransform;
|
||||
return file.impliedNodeFormat === 99 /* ESNext */ ? esmTransform : cjsTransform;
|
||||
}
|
||||
function transformSourceFile(node) {
|
||||
if (node.isDeclarationFile) {
|
||||
@@ -112356,18 +112338,17 @@ function isProcessedComponent(node) {
|
||||
// src/compiler/transformer.ts
|
||||
function getModuleTransformer(moduleKind) {
|
||||
switch (moduleKind) {
|
||||
case 200 /* Preserve */:
|
||||
return transformECMAScriptModule;
|
||||
case 99 /* ESNext */:
|
||||
case 7 /* ES2022 */:
|
||||
case 6 /* ES2020 */:
|
||||
case 5 /* ES2015 */:
|
||||
case 100 /* Node16 */:
|
||||
case 199 /* NodeNext */:
|
||||
case 1 /* CommonJS */:
|
||||
return transformImpliedNodeFormatDependentModule;
|
||||
case 200 /* Preserve */:
|
||||
return transformECMAScriptModule;
|
||||
case 4 /* System */:
|
||||
return transformSystemModule;
|
||||
case 100 /* Node16 */:
|
||||
case 199 /* NodeNext */:
|
||||
return transformNodeModule;
|
||||
default:
|
||||
return transformModule;
|
||||
}
|
||||
@@ -113086,7 +113067,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
||||
newLine: compilerOptions.newLine,
|
||||
noEmitHelpers: compilerOptions.noEmitHelpers,
|
||||
module: getEmitModuleKind(compilerOptions),
|
||||
moduleResolution: getEmitModuleResolutionKind(compilerOptions),
|
||||
target: getEmitScriptTarget(compilerOptions),
|
||||
sourceMap: compilerOptions.sourceMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
@@ -113149,7 +113129,6 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
||||
newLine: compilerOptions.newLine,
|
||||
noEmitHelpers: true,
|
||||
module: compilerOptions.module,
|
||||
moduleResolution: compilerOptions.moduleResolution,
|
||||
target: compilerOptions.target,
|
||||
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
@@ -118607,6 +118586,9 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
|
||||
function getModeForFileReference(ref, containingFileMode) {
|
||||
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
||||
}
|
||||
function getModeForResolutionAtIndex(file, index, compilerOptions) {
|
||||
return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
|
||||
}
|
||||
function isExclusivelyTypeOnlyImportOrExport(decl) {
|
||||
var _a;
|
||||
if (isExportDeclaration(decl)) {
|
||||
@@ -118621,6 +118603,7 @@ function getModeForUsageLocation(file, usage, compilerOptions) {
|
||||
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
||||
}
|
||||
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
||||
var _a;
|
||||
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
||||
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
||||
if (isTypeOnly) {
|
||||
@@ -118636,28 +118619,19 @@ function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
||||
return override;
|
||||
}
|
||||
}
|
||||
if (compilerOptions && importSyntaxAffectsModuleResolution(compilerOptions)) {
|
||||
return getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions);
|
||||
if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
||||
return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
|
||||
usage.parent,
|
||||
/*requireStringLiteralLikeArgument*/
|
||||
false
|
||||
) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
||||
}
|
||||
}
|
||||
function getEmitSyntaxForUsageLocationWorker(file, usage, compilerOptions) {
|
||||
var _a;
|
||||
if (!compilerOptions) {
|
||||
return void 0;
|
||||
if (file.impliedNodeFormat === void 0) return void 0;
|
||||
if (file.impliedNodeFormat !== 99 /* ESNext */) {
|
||||
return isImportCall(walkUpParenthesizedExpressions(usage.parent)) ? 99 /* ESNext */ : 1 /* CommonJS */;
|
||||
}
|
||||
const exprParentParent = (_a = walkUpParenthesizedExpressions(usage.parent)) == null ? void 0 : _a.parent;
|
||||
if (exprParentParent && isImportEqualsDeclaration(exprParentParent) || isRequireCall(
|
||||
usage.parent,
|
||||
/*requireStringLiteralLikeArgument*/
|
||||
false
|
||||
)) {
|
||||
return 1 /* CommonJS */;
|
||||
}
|
||||
if (isImportCall(walkUpParenthesizedExpressions(usage.parent))) {
|
||||
return shouldTransformImportCallWorker(file, compilerOptions) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
||||
}
|
||||
const fileEmitMode = getEmitModuleFormatOfFileWorker(file, compilerOptions);
|
||||
return fileEmitMode === 1 /* CommonJS */ ? 1 /* CommonJS */ : emitModuleKindIsNonNodeESM(fileEmitMode) || fileEmitMode === 200 /* Preserve */ ? 99 /* ESNext */ : void 0;
|
||||
return exprParentParent && isImportEqualsDeclaration(exprParentParent) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
||||
}
|
||||
function getResolutionModeOverride(node, grammarErrorOnNode) {
|
||||
if (!node) return void 0;
|
||||
@@ -118714,7 +118688,7 @@ function getTypeReferenceResolutionName(entry) {
|
||||
}
|
||||
var typeReferenceResolutionNameAndModeGetter = {
|
||||
getName: getTypeReferenceResolutionName,
|
||||
getMode: (entry, file, compilerOptions) => getModeForFileReference(entry, file && getDefaultResolutionModeForFileWorker(file, compilerOptions))
|
||||
getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
|
||||
};
|
||||
function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
||||
return {
|
||||
@@ -118884,7 +118858,13 @@ function getConfigFileParsingDiagnostics(configFileParseResult) {
|
||||
return configFileParseResult.options.configFile ? [...configFileParseResult.options.configFile.parseDiagnostics, ...configFileParseResult.errors] : configFileParseResult.errors;
|
||||
}
|
||||
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
||||
return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
|
||||
switch (getEmitModuleResolutionKind(options)) {
|
||||
case 3 /* Node16 */:
|
||||
case 99 /* NodeNext */:
|
||||
return fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? 99 /* ESNext */ : fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? 1 /* CommonJS */ : fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : void 0;
|
||||
default:
|
||||
return void 0;
|
||||
}
|
||||
function lookupFromPackageJson() {
|
||||
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
||||
const packageJsonLocations = [];
|
||||
@@ -119343,8 +119323,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
isSourceFileFromExternalLibrary,
|
||||
isSourceFileDefaultLibrary,
|
||||
getModeForUsageLocation: getModeForUsageLocation2,
|
||||
getEmitSyntaxForUsageLocation,
|
||||
getModeForResolutionAtIndex,
|
||||
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
||||
getSourceFileFromReference,
|
||||
getLibFileFromReference,
|
||||
sourceFileToPackageName,
|
||||
@@ -119372,11 +119351,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
||||
isSourceOfProjectReferenceRedirect,
|
||||
getRedirectReferenceForResolutionFromSourceOfProject,
|
||||
getCompilerOptionsForFile,
|
||||
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
||||
getEmitModuleFormatOfFile,
|
||||
getImpliedNodeFormatForEmit,
|
||||
shouldTransformImportCall,
|
||||
emitBuildInfo,
|
||||
fileExists,
|
||||
readFile,
|
||||
@@ -119959,10 +119933,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
getSymlinkCache,
|
||||
writeFile: writeFileCallback || writeFile2,
|
||||
isEmitBlocked,
|
||||
shouldTransformImportCall,
|
||||
getEmitModuleFormatOfFile,
|
||||
getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
|
||||
getModeForResolutionAtIndex,
|
||||
readFile: (f) => host.readFile(f),
|
||||
fileExists: (f) => {
|
||||
const path = toPath3(f);
|
||||
@@ -121012,14 +120982,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
const resolvedTypeReferenceDirective = resolutions[index];
|
||||
const fileName = ref.fileName;
|
||||
resolutionsInFile.set(fileName, getModeForFileReference(ref, file.impliedNodeFormat), resolvedTypeReferenceDirective);
|
||||
const mode = ref.resolutionMode || getDefaultResolutionModeForFile2(file);
|
||||
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
||||
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
|
||||
}
|
||||
}
|
||||
function getCompilerOptionsForFile(file) {
|
||||
var _a2;
|
||||
return ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
||||
}
|
||||
function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
|
||||
var _a2, _b2;
|
||||
(_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
|
||||
@@ -121120,12 +121086,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
return host.getCanonicalFileName(fileName);
|
||||
}
|
||||
function processImportedModules(file) {
|
||||
var _a2;
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
const moduleNames = getModuleNames(file);
|
||||
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
const optionsForFile = getCompilerOptionsForFile(file);
|
||||
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
||||
const resolutionsInFile = createModeAwareCache();
|
||||
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
||||
for (let index = 0; index < moduleNames.length; index++) {
|
||||
@@ -121681,7 +121648,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
redirectInfo = cachedChain.redirectInfo;
|
||||
} else {
|
||||
reasons == null ? void 0 : reasons.forEach(processReason);
|
||||
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
|
||||
redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file);
|
||||
}
|
||||
if (fileProcessingReason) processReason(fileProcessingReason);
|
||||
const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
|
||||
@@ -122039,53 +122006,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
||||
return symlinks;
|
||||
}
|
||||
function getModeForUsageLocation2(file, usage) {
|
||||
return getModeForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
||||
var _a2;
|
||||
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
||||
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
||||
}
|
||||
function getEmitSyntaxForUsageLocation(file, usage) {
|
||||
return getEmitSyntaxForUsageLocationWorker(file, usage, getCompilerOptionsForFile(file));
|
||||
}
|
||||
function getModeForResolutionAtIndex(file, index) {
|
||||
function getModeForResolutionAtIndex2(file, index) {
|
||||
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
||||
}
|
||||
function getDefaultResolutionModeForFile2(sourceFile) {
|
||||
return getDefaultResolutionModeForFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
function getImpliedNodeFormatForEmit(sourceFile) {
|
||||
return getImpliedNodeFormatForEmitWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
function getEmitModuleFormatOfFile(sourceFile) {
|
||||
return getEmitModuleFormatOfFileWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
function shouldTransformImportCall(sourceFile) {
|
||||
return shouldTransformImportCallWorker(sourceFile, getCompilerOptionsForFile(sourceFile));
|
||||
}
|
||||
}
|
||||
function shouldTransformImportCallWorker(sourceFile, options) {
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */) {
|
||||
return false;
|
||||
}
|
||||
return getEmitModuleFormatOfFileWorker(sourceFile, options) < 5 /* ES2015 */;
|
||||
}
|
||||
function getEmitModuleFormatOfFileWorker(sourceFile, options) {
|
||||
return getImpliedNodeFormatForEmitWorker(sourceFile, options) ?? getEmitModuleKind(options);
|
||||
}
|
||||
function getImpliedNodeFormatForEmitWorker(sourceFile, options) {
|
||||
var _a, _b;
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
||||
return sourceFile.impliedNodeFormat;
|
||||
}
|
||||
if (sourceFile.impliedNodeFormat === 1 /* CommonJS */ && (((_a = sourceFile.packageJsonScope) == null ? void 0 : _a.contents.packageJsonContent.type) === "commonjs" || fileExtensionIsOneOf(sourceFile.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) {
|
||||
return 1 /* CommonJS */;
|
||||
}
|
||||
if (sourceFile.impliedNodeFormat === 99 /* ESNext */ && (((_b = sourceFile.packageJsonScope) == null ? void 0 : _b.contents.packageJsonContent.type) === "module" || fileExtensionIsOneOf(sourceFile.fileName, [".mjs" /* Mjs */, ".mts" /* Mts */]))) {
|
||||
return 99 /* ESNext */;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
function getDefaultResolutionModeForFileWorker(sourceFile, options) {
|
||||
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmitWorker(sourceFile, options) : void 0;
|
||||
}
|
||||
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
||||
let setOfDeclarationDirectories;
|
||||
@@ -125269,10 +125196,10 @@ function explainFiles(program, write) {
|
||||
for (const file of program.getSourceFiles()) {
|
||||
write(`${toFileName(file, relativeFileName)}`);
|
||||
(_a = reasons.get(file.path)) == null ? void 0 : _a.forEach((reason) => write(` ${fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText}`));
|
||||
(_b = explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file), relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
||||
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) == null ? void 0 : _b.forEach((d) => write(` ${d.messageText}`));
|
||||
}
|
||||
}
|
||||
function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConvertor) {
|
||||
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
||||
var _a;
|
||||
let result;
|
||||
if (file.path !== file.resolvedPath) {
|
||||
@@ -125292,7 +125219,7 @@ function explainIfFileIsRedirectAndImpliedFormat(file, options, fileNameConverto
|
||||
));
|
||||
}
|
||||
if (isExternalOrCommonJsModule(file)) {
|
||||
switch (getImpliedNodeFormatForEmitWorker(file, options)) {
|
||||
switch (file.impliedNodeFormat) {
|
||||
case 99 /* ESNext */:
|
||||
if (file.packageJsonScope) {
|
||||
(result ?? (result = [])).push(chainDiagnosticMessages(
|
||||
|
||||
Vendored
+22
-89
@@ -6014,67 +6014,19 @@ declare namespace ts {
|
||||
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
||||
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
|
||||
* settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
|
||||
* which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
|
||||
* overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
|
||||
* Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This function only returns a result
|
||||
* when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided
|
||||
* via import attributes, which cause an `import` or `require` condition to be used during resolution regardless of module resolution
|
||||
* settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the
|
||||
* usage would emit to JavaScript. Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
* Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
|
||||
* explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
|
||||
* `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
|
||||
* input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
|
||||
* `undefined`, as the result would have no impact on module resolution, emit, or type checking.
|
||||
*/
|
||||
getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
|
||||
getProjectReferences(): readonly ProjectReference[] | undefined;
|
||||
@@ -9427,43 +9379,24 @@ declare namespace ts {
|
||||
function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
/**
|
||||
* Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
|
||||
* Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
|
||||
* settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
|
||||
* which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
|
||||
* overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
|
||||
* Some examples:
|
||||
*
|
||||
* ```ts
|
||||
* // tsc foo.mts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
|
||||
*
|
||||
* // tsc foo.cts --module nodenext
|
||||
* import {} from "mod";
|
||||
* // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution bundler
|
||||
* import {} from "mod";
|
||||
* // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
|
||||
* // supports conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module preserve --moduleResolution node10
|
||||
* import {} from "mod";
|
||||
* // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
|
||||
* // does not support conditional imports/exports
|
||||
*
|
||||
* // tsc foo.ts --module commonjs --moduleResolution node10
|
||||
* import type {} from "mod" with { "resolution-mode": "import" };
|
||||
* // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
|
||||
* ```
|
||||
*
|
||||
* Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
|
||||
* attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
|
||||
* depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
|
||||
* `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
|
||||
* impact on module resolution, emit, or type checking.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
|
||||
* should be the options of the referenced project, not the referencing project.
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike, compilerOptions: CompilerOptions): ResolutionMode;
|
||||
function getModeForUsageLocation(
|
||||
file: {
|
||||
impliedNodeFormat?: ResolutionMode;
|
||||
},
|
||||
usage: StringLiteralLike,
|
||||
compilerOptions: CompilerOptions,
|
||||
): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
|
||||
/**
|
||||
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
||||
|
||||
+186
-312
File diff suppressed because it is too large
Load Diff
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "typescript",
|
||||
"version": "5.5.1-rc",
|
||||
"version": "5.5.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "typescript",
|
||||
"version": "5.5.1-rc",
|
||||
"version": "5.5.2",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "https://www.typescriptlang.org/",
|
||||
"version": "5.5.1-rc",
|
||||
"version": "5.5.2",
|
||||
"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.1-rc" as string;
|
||||
export const version = "5.5.2" as string;
|
||||
|
||||
/**
|
||||
* Type of objects whose values are all of the same type.
|
||||
|
||||
Reference in New Issue
Block a user