This commit is contained in:
TypeScript Bot 2023-04-05 23:26:35 +00:00
Родитель dc7e5a738a
Коммит 3b45f4db12
7 изменённых файлов: 127 добавлений и 79 удалений

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

@ -23,7 +23,7 @@ var __export = (target, all) => {
// src/compiler/corePublic.ts
var versionMajorMinor = "5.0";
var version = "5.0.3";
var version = "5.0.4";
// src/compiler/core.ts
var emptyArray = [];
@ -16192,6 +16192,9 @@ function getAllowSyntheticDefaultImports(compilerOptions) {
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function shouldResolveJsRequire(compilerOptions) {
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
}
function getResolvePackageJsonExports(compilerOptions) {
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@ -29242,6 +29245,12 @@ var Parser;
if (languageVariant === 1 /* JSX */) {
return parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
true,
/*topInvalidNodePosition*/
void 0,
/*openingTag*/
void 0,
/*mustBeUnary*/
true
);
}
@ -29346,7 +29355,7 @@ var Parser;
true
)), pos);
}
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
const pos = getNodePos();
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result;
@ -29384,7 +29393,7 @@ var Parser;
Debug.assert(opening.kind === 282 /* JsxSelfClosingElement */);
result = opening;
}
if (inExpressionContext && token() === 29 /* LessThanToken */) {
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
@ -34074,7 +34083,8 @@ var commandOptionsWithoutBuild = [
affectsSemanticDiagnostics: true,
category: Diagnostics.Modules,
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
defaultValueDescription: false
defaultValueDescription: false,
transpileOptionValue: void 0
},
{
name: "resolvePackageJsonExports",
@ -41311,7 +41321,7 @@ function createBinder() {
}
if (!isBindingPattern(node.name)) {
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
} else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@ -44849,7 +44859,7 @@ function createTypeChecker(host) {
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
const exportAssignment = exportEqualsSymbol.valueDeclaration;
@ -45017,7 +45027,7 @@ function createTypeChecker(host) {
if (!isIdentifier(name)) {
return void 0;
}
const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
const targetSymbol = resolveESModuleSymbol(
moduleSymbol,
moduleSpecifier,
@ -49646,7 +49656,7 @@ function createTypeChecker(host) {
return;
}
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
verbatimTargetName = "default" /* Default */;
}
const targetName = getInternalSymbolName(target, verbatimTargetName);
@ -70737,7 +70747,7 @@ function createTypeChecker(host) {
return anyType;
}
}
if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
}
const returnType = getReturnTypeOfSignature(signature);
@ -89240,11 +89250,12 @@ function transformClassFields(context) {
return visitEachChild(node, visitor, context);
}
function visitArrayAssignmentElement(node) {
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
if (isArrayBindingOrAssignmentElement(node)) {
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
}
return visitEachChild(node, visitor, context);
}
function visitAssignmentProperty(node) {
@ -114357,7 +114368,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
false
);
}
const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
collectDynamicImportOrRequireCalls(file);
}
@ -115285,9 +115296,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
}
if (options.isolatedModules) {
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
}
if (options.preserveValueImports) {
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
}

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

@ -2070,6 +2070,7 @@ __export(server_exports, {
setValueDeclaration: () => setValueDeclaration,
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
shouldResolveJsRequire: () => shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
showModuleSpecifier: () => showModuleSpecifier,
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@ -2286,7 +2287,7 @@ module.exports = __toCommonJS(server_exports);
// src/compiler/corePublic.ts
var versionMajorMinor = "5.0";
var version = "5.0.3";
var version = "5.0.4";
var Comparison = /* @__PURE__ */ ((Comparison3) => {
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@ -20263,6 +20264,9 @@ function getAllowSyntheticDefaultImports(compilerOptions) {
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function shouldResolveJsRequire(compilerOptions) {
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
}
function getResolvePackageJsonExports(compilerOptions) {
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@ -33580,6 +33584,12 @@ var Parser;
if (languageVariant === 1 /* JSX */) {
return parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
true,
/*topInvalidNodePosition*/
void 0,
/*openingTag*/
void 0,
/*mustBeUnary*/
true
);
}
@ -33684,7 +33694,7 @@ var Parser;
true
)), pos);
}
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
const pos = getNodePos();
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result;
@ -33722,7 +33732,7 @@ var Parser;
Debug.assert(opening.kind === 282 /* JsxSelfClosingElement */);
result = opening;
}
if (inExpressionContext && token() === 29 /* LessThanToken */) {
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
@ -38412,7 +38422,8 @@ var commandOptionsWithoutBuild = [
affectsSemanticDiagnostics: true,
category: Diagnostics.Modules,
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
defaultValueDescription: false
defaultValueDescription: false,
transpileOptionValue: void 0
},
{
name: "resolvePackageJsonExports",
@ -45862,7 +45873,7 @@ function createBinder() {
}
if (!isBindingPattern(node.name)) {
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
} else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@ -49448,7 +49459,7 @@ function createTypeChecker(host) {
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
const exportAssignment = exportEqualsSymbol.valueDeclaration;
@ -49616,7 +49627,7 @@ function createTypeChecker(host) {
if (!isIdentifier(name)) {
return void 0;
}
const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
const targetSymbol = resolveESModuleSymbol(
moduleSymbol,
moduleSpecifier,
@ -54245,7 +54256,7 @@ function createTypeChecker(host) {
return;
}
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
verbatimTargetName = "default" /* Default */;
}
const targetName = getInternalSymbolName(target, verbatimTargetName);
@ -75336,7 +75347,7 @@ function createTypeChecker(host) {
return anyType;
}
}
if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
}
const returnType = getReturnTypeOfSignature(signature);
@ -94010,11 +94021,12 @@ function transformClassFields(context) {
return visitEachChild(node, visitor, context);
}
function visitArrayAssignmentElement(node) {
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
if (isArrayBindingOrAssignmentElement(node)) {
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
}
return visitEachChild(node, visitor, context);
}
function visitAssignmentProperty(node) {
@ -119192,7 +119204,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
false
);
}
const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
collectDynamicImportOrRequireCalls(file);
}
@ -120120,9 +120132,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
}
if (options.isolatedModules) {
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
}
if (options.preserveValueImports) {
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
}
@ -169780,6 +169789,7 @@ __export(ts_exports3, {
setValueDeclaration: () => setValueDeclaration,
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
shouldResolveJsRequire: () => shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
showModuleSpecifier: () => showModuleSpecifier,
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@ -183727,6 +183737,7 @@ start(initializeNodeSystem(), require("os").platform());
setValueDeclaration,
shouldAllowImportingTsExtension,
shouldPreserveConstEnums,
shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules,
showModuleSpecifier,
signatureHasLiteralTypes,

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

@ -35,7 +35,7 @@ var ts = (() => {
"src/compiler/corePublic.ts"() {
"use strict";
versionMajorMinor = "5.0";
version = "5.0.3";
version = "5.0.4";
Comparison = /* @__PURE__ */ ((Comparison3) => {
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@ -17991,6 +17991,9 @@ ${lanes.join("\n")}
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function shouldResolveJsRequire(compilerOptions) {
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
}
function getResolvePackageJsonExports(compilerOptions) {
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@ -31692,6 +31695,12 @@ ${lanes.join("\n")}
if (languageVariant === 1 /* JSX */) {
return parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
true,
/*topInvalidNodePosition*/
void 0,
/*openingTag*/
void 0,
/*mustBeUnary*/
true
);
}
@ -31796,7 +31805,7 @@ ${lanes.join("\n")}
true
)), pos);
}
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
const pos = getNodePos();
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result;
@ -31834,7 +31843,7 @@ ${lanes.join("\n")}
Debug.assert(opening.kind === 282 /* JsxSelfClosingElement */);
result = opening;
}
if (inExpressionContext && token() === 29 /* LessThanToken */) {
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
@ -38066,7 +38075,8 @@ ${lanes.join("\n")}
affectsSemanticDiagnostics: true,
category: Diagnostics.Modules,
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
defaultValueDescription: false
defaultValueDescription: false,
transpileOptionValue: void 0
},
{
name: "resolvePackageJsonExports",
@ -43764,7 +43774,7 @@ ${lanes.join("\n")}
}
if (!isBindingPattern(node.name)) {
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
} else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@ -47258,7 +47268,7 @@ ${lanes.join("\n")}
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
const exportAssignment = exportEqualsSymbol.valueDeclaration;
@ -47426,7 +47436,7 @@ ${lanes.join("\n")}
if (!isIdentifier(name)) {
return void 0;
}
const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
const targetSymbol = resolveESModuleSymbol(
moduleSymbol,
moduleSpecifier,
@ -52055,7 +52065,7 @@ ${lanes.join("\n")}
return;
}
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
verbatimTargetName = "default" /* Default */;
}
const targetName = getInternalSymbolName(target, verbatimTargetName);
@ -73146,7 +73156,7 @@ ${lanes.join("\n")}
return anyType;
}
}
if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
}
const returnType = getReturnTypeOfSignature(signature);
@ -91995,11 +92005,12 @@ ${lanes.join("\n")}
return visitEachChild(node, visitor, context);
}
function visitArrayAssignmentElement(node) {
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
if (isArrayBindingOrAssignmentElement(node)) {
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
}
return visitEachChild(node, visitor, context);
}
function visitAssignmentProperty(node) {
@ -117210,7 +117221,7 @@ ${lanes.join("\n")}
false
);
}
const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
collectDynamicImportOrRequireCalls(file);
}
@ -118138,9 +118149,6 @@ ${lanes.join("\n")}
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
}
if (options.isolatedModules) {
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
}
if (options.preserveValueImports) {
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
}
@ -180367,6 +180375,7 @@ ${e.message}`;
setValueDeclaration: () => setValueDeclaration,
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
shouldResolveJsRequire: () => shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
showModuleSpecifier: () => showModuleSpecifier,
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
@ -182725,6 +182734,7 @@ ${e.message}`;
setValueDeclaration: () => setValueDeclaration,
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
shouldResolveJsRequire: () => shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
showModuleSpecifier: () => showModuleSpecifier,
signatureHasLiteralTypes: () => signatureHasLiteralTypes,

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

@ -35,7 +35,7 @@ var ts = (() => {
"src/compiler/corePublic.ts"() {
"use strict";
versionMajorMinor = "5.0";
version = "5.0.3";
version = "5.0.4";
Comparison = /* @__PURE__ */ ((Comparison3) => {
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@ -17991,6 +17991,9 @@ ${lanes.join("\n")}
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function shouldResolveJsRequire(compilerOptions) {
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
}
function getResolvePackageJsonExports(compilerOptions) {
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
@ -31692,6 +31695,12 @@ ${lanes.join("\n")}
if (languageVariant === 1 /* JSX */) {
return parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
true,
/*topInvalidNodePosition*/
void 0,
/*openingTag*/
void 0,
/*mustBeUnary*/
true
);
}
@ -31796,7 +31805,7 @@ ${lanes.join("\n")}
true
)), pos);
}
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
const pos = getNodePos();
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result;
@ -31834,7 +31843,7 @@ ${lanes.join("\n")}
Debug.assert(opening.kind === 282 /* JsxSelfClosingElement */);
result = opening;
}
if (inExpressionContext && token() === 29 /* LessThanToken */) {
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
@ -38066,7 +38075,8 @@ ${lanes.join("\n")}
affectsSemanticDiagnostics: true,
category: Diagnostics.Modules,
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
defaultValueDescription: false
defaultValueDescription: false,
transpileOptionValue: void 0
},
{
name: "resolvePackageJsonExports",
@ -43764,7 +43774,7 @@ ${lanes.join("\n")}
}
if (!isBindingPattern(node.name)) {
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
} else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
@ -47258,7 +47268,7 @@ ${lanes.join("\n")}
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
const exportAssignment = exportEqualsSymbol.valueDeclaration;
@ -47426,7 +47436,7 @@ ${lanes.join("\n")}
if (!isIdentifier(name)) {
return void 0;
}
const suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions));
const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
const targetSymbol = resolveESModuleSymbol(
moduleSymbol,
moduleSpecifier,
@ -52055,7 +52065,7 @@ ${lanes.join("\n")}
return;
}
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
if (verbatimTargetName === "export=" /* ExportEquals */ && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
verbatimTargetName = "default" /* Default */;
}
const targetName = getInternalSymbolName(target, verbatimTargetName);
@ -73146,7 +73156,7 @@ ${lanes.join("\n")}
return anyType;
}
}
if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */ && isCommonJsRequire(node)) {
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
}
const returnType = getReturnTypeOfSignature(signature);
@ -91995,11 +92005,12 @@ ${lanes.join("\n")}
return visitEachChild(node, visitor, context);
}
function visitArrayAssignmentElement(node) {
Debug.assertNode(node, isArrayBindingOrAssignmentElement);
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
if (isArrayBindingOrAssignmentElement(node)) {
if (isSpreadElement(node))
return visitAssignmentRestElement(node);
if (!isOmittedExpression(node))
return visitAssignmentElement(node);
}
return visitEachChild(node, visitor, context);
}
function visitAssignmentProperty(node) {
@ -117210,7 +117221,7 @@ ${lanes.join("\n")}
false
);
}
const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== 100 /* Bundler */;
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
collectDynamicImportOrRequireCalls(file);
}
@ -118138,9 +118149,6 @@ ${lanes.join("\n")}
if (moduleKind === 2 /* AMD */ || moduleKind === 3 /* UMD */ || moduleKind === 4 /* System */) {
createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
}
if (options.isolatedModules) {
createRedundantOptionDiagnostic("isolatedModules", "verbatimModuleSyntax");
}
if (options.preserveValueImports) {
createRedundantOptionDiagnostic("preserveValueImports", "verbatimModuleSyntax");
}
@ -169548,6 +169556,7 @@ ${options.prefix}` : "\n" : options.prefix
setValueDeclaration: () => setValueDeclaration,
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
shouldResolveJsRequire: () => shouldResolveJsRequire,
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
showModuleSpecifier: () => showModuleSpecifier,
signatureHasLiteralTypes: () => signatureHasLiteralTypes,

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

@ -54,7 +54,7 @@ var path = __toESM(require("path"));
// src/compiler/corePublic.ts
var versionMajorMinor = "5.0";
var version = "5.0.3";
var version = "5.0.4";
// src/compiler/core.ts
var emptyArray = [];
@ -11947,6 +11947,9 @@ function unusedLabelIsError(options) {
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
}
function shouldResolveJsRequire(compilerOptions) {
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
}
function getResolveJsonModule(compilerOptions) {
if (compilerOptions.resolveJsonModule !== void 0) {
return compilerOptions.resolveJsonModule;
@ -22092,6 +22095,12 @@ var Parser;
if (languageVariant === 1 /* JSX */) {
return parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
true,
/*topInvalidNodePosition*/
void 0,
/*openingTag*/
void 0,
/*mustBeUnary*/
true
);
}
@ -22196,7 +22205,7 @@ var Parser;
true
)), pos);
}
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) {
function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag, mustBeUnary = false) {
const pos = getNodePos();
const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
let result;
@ -22234,7 +22243,7 @@ var Parser;
Debug.assert(opening.kind === 282 /* JsxSelfClosingElement */);
result = opening;
}
if (inExpressionContext && token() === 29 /* LessThanToken */) {
if (!mustBeUnary && inExpressionContext && token() === 29 /* LessThanToken */) {
const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(
/*inExpressionContext*/
@ -26924,7 +26933,8 @@ var commandOptionsWithoutBuild = [
affectsSemanticDiagnostics: true,
category: Diagnostics.Modules,
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
defaultValueDescription: false
defaultValueDescription: false,
transpileOptionValue: void 0
},
{
name: "resolvePackageJsonExports",
@ -32226,7 +32236,7 @@ function createBinder() {
}
if (!isBindingPattern(node.name)) {
const possibleVariableDecl = node.kind === 257 /* VariableDeclaration */ ? node : node.parent.parent;
if (isInJSFile(node) && getEmitModuleResolutionKind(options) !== 100 /* Bundler */ && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
} else if (isBlockOrCatchScoped(node)) {
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);

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

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

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

@ -4,7 +4,7 @@ export const versionMajorMinor = "5.0";
// The following is baselined as a literal template type without intervention
/** The version of the TypeScript compiler release */
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
export const version = "5.0.3" as string;
export const version = "5.0.4" as string;
/**
* Type of objects whose values are all of the same type.