diff --git a/lib/tsc.js b/lib/tsc.js index 6addc1d5ee94d..4af6416de6425 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -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"); } diff --git a/lib/tsserver.js b/lib/tsserver.js index 6158bf4eb0a40..79c6930dacd75 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -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, diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index d18ae2db12b4b..4cdee5ee4564c 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -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, diff --git a/lib/typescript.js b/lib/typescript.js index 4c5d21f4b46c0..06dfb5d36b63b 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -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, diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 9829c4b9ef38c..39786f7035a05 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -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 */); diff --git a/package.json b/package.json index 9bf31add9adc8..3cb61b057424c 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 78bf9e1f3a682..b08550bf7d6b5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -84,7 +84,6 @@ import { getContainingClass, getEffectiveContainerForJSDocTemplateTag, getElementOrPropertyAccessName, - getEmitModuleResolutionKind, getEmitScriptTarget, getEnclosingBlockScopeContainer, getErrorSpanForNode, @@ -241,7 +240,6 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, - ModuleResolutionKind, Mutable, NamespaceExportDeclaration, Node, @@ -279,6 +277,7 @@ import { setValueDeclaration, ShorthandPropertyAssignment, shouldPreserveConstEnums, + shouldResolveJsRequire, SignatureDeclaration, skipParentheses, sliceAfter, @@ -3532,7 +3531,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === SyntaxKind.VariableDeclaration ? node : node.parent.parent; if (isInJSFile(node) && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler && + shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & ModifierFlags.Export) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 406313020adff..dca3a2a9f5275 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -934,6 +934,7 @@ import { ShorthandPropertyAssignment, shouldAllowImportingTsExtension, shouldPreserveConstEnums, + shouldResolveJsRequire, Signature, SignatureDeclaration, SignatureFlags, @@ -3995,7 +3996,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { 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 >= ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; const exportEqualsSymbol = moduleSymbol.exports!.get(InternalSymbolName.ExportEquals); const exportAssignment = exportEqualsSymbol!.valueDeclaration; @@ -4138,7 +4139,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!isIdentifier(name)) { return undefined; } - const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions)); + const suppressInteropError = name.escapedText === InternalSymbolName.Default && allowSyntheticDefaultImports; const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -9177,7 +9178,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === InternalSymbolName.ExportEquals && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === InternalSymbolName.ExportEquals && allowSyntheticDefaultImports) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match verbatimTargetName = InternalSymbolName.Default; } @@ -33993,7 +33994,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isCommonJsRequire(node)) { + if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 629063de29808..b88f6325ba0af 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1104,6 +1104,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ 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, + transpileOptionValue: undefined, }, { name: "resolvePackageJsonExports", diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 00780e262d647..3b82d4ba0c26d 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -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. diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index be81d789c57d0..cd0d806794c31 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5684,7 +5684,7 @@ namespace Parser { // Just like in parseUpdateExpression, we need to avoid parsing type assertions when // in JSX and we see an expression like "+ bar". if (languageVariant === LanguageVariant.JSX) { - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, /*topInvalidNodePosition*/ undefined, /*openingTag*/ undefined, /*mustBeUnary*/ true); } // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): @@ -5911,7 +5911,7 @@ namespace Parser { return finishNode(factoryCreatePropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext: boolean, topInvalidNodePosition?: number, openingTag?: JsxOpeningElement | JsxOpeningFragment): JsxElement | JsxSelfClosingElement | JsxFragment { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext: boolean, topInvalidNodePosition?: number, openingTag?: JsxOpeningElement | JsxOpeningFragment, mustBeUnary = false): JsxElement | JsxSelfClosingElement | JsxFragment { const pos = getNodePos(); const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); let result: JsxElement | JsxSelfClosingElement | JsxFragment; @@ -5968,7 +5968,9 @@ namespace Parser { // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === SyntaxKind.LessThanToken) { + // If we are in a unary context, we can't do this recovery; the binary expression we return here is not + // a valid UnaryExpression and will cause problems later. + if (!mustBeUnary && inExpressionContext && token() === SyntaxKind.LessThanToken) { const topBadPos = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; const invalidElement = tryParse(() => parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos)); if (invalidElement) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a3d49f9b600f1..0dbb3adcec3f6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -284,6 +284,7 @@ import { setParentRecursive, setResolvedModule, setResolvedTypeReferenceDirective, + shouldResolveJsRequire, skipTrivia, skipTypeChecking, some, @@ -3207,8 +3208,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg collectModuleReferences(node, /*inAmbientModule*/ false); } - // `require` has no special meaning in `--moduleResolution bundler` - const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler; + const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options); if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || shouldProcessRequires) { collectDynamicImportOrRequireCalls(file); } @@ -4252,9 +4252,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg if (moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.UMD || moduleKind === ModuleKind.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"); } diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 76a24cfaebb50..7f03c26b80f55 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -2977,11 +2977,11 @@ export function transformClassFields(context: TransformationContext): (x: Source } function visitArrayAssignmentElement(node: Expression): Expression { - 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: PropertyAssignment) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index af4730f848460..57b02beea9432 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -8421,6 +8421,12 @@ export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResol || moduleResolution === ModuleResolutionKind.Bundler; } +/** @internal */ +export function shouldResolveJsRequire(compilerOptions: CompilerOptions): boolean { + // `bundler` doesn't support resolving `require`, but needs to in `noDtsResolution` to support Find Source Definition + return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler; +} + /** @internal */ export function getResolvePackageJsonExports(compilerOptions: CompilerOptions) { const moduleResolution = getEmitModuleResolutionKind(compilerOptions); diff --git a/src/testRunner/unittests/services/transpile.ts b/src/testRunner/unittests/services/transpile.ts index f20efec044f93..b9f8bc915eca2 100644 --- a/src/testRunner/unittests/services/transpile.ts +++ b/src/testRunner/unittests/services/transpile.ts @@ -606,4 +606,18 @@ export * as alias from './file';`, { testVerbatimModuleSyntax: "only" } ); + + transpilesCorrectly("Can transpile .ts extensions without error", + `import { foo } from "./foo.ts";`, { + options: { compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ESNext } }, + testVerbatimModuleSyntax: true + } + ); + + transpilesCorrectly("Ignores `allowImportingTsExtensions` without `noEmit` error", + `import { foo } from "./foo.ts";`, { + options: { compilerOptions: { module: ts.ModuleKind.ESNext, allowImportingTsExtensions: true, target: ts.ScriptTarget.ESNext } }, + testVerbatimModuleSyntax: true + } + ); }); diff --git a/tests/baselines/reference/goToSource15_bundler.baseline.jsonc b/tests/baselines/reference/goToSource15_bundler.baseline.jsonc new file mode 100644 index 0000000000000..dc233e8fa79f4 --- /dev/null +++ b/tests/baselines/reference/goToSource15_bundler.baseline.jsonc @@ -0,0 +1,34 @@ +// === goToSourceDefinition === +// === /node_modules/react/cjs/react.production.min.js === +// 'use strict';exports.[|{| defId: 0 |}useState|]=function(a){};exports.version='16.8.6'; + +// === /node_modules/react/cjs/react.development.js === +// 'use strict'; +// if (process.env.NODE_ENV !== 'production') { +// (function() { +// function useState(initialState) {} +// exports.[|{| defId: 1 |}useState|] = useState; +// exports.version = '16.8.6'; +// }()); +// } + +// === /index.ts === +// import { /*GOTO SOURCE DEF*/useState } from 'react'; + + // === Details === + [ + { + "defId": 0, + "containerKind": "", + "containerName": "", + "kind": "", + "name": "" + }, + { + "defId": 1, + "containerKind": "", + "containerName": "", + "kind": "", + "name": "" + } + ] \ No newline at end of file diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.errors.txt b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.errors.txt new file mode 100644 index 0000000000000..6f638b4a2230f --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/a.js(1,4): error TS1003: Identifier expected. +tests/cases/compiler/a.js(1,5): error TS1109: Expression expected. + + +==== tests/cases/compiler/a.js (2 errors) ==== + ~< < + ~ +!!! error TS1003: Identifier expected. + +!!! error TS1109: Expression expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.js b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.js new file mode 100644 index 0000000000000..64357a51dc64e --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.js @@ -0,0 +1,7 @@ +//// [a.js] +~< < + + +//// [a.js] +~< /> < +; diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.symbols b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.symbols new file mode 100644 index 0000000000000..e6ed11e193527 --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/a.js === + +~< < + diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.types b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.types new file mode 100644 index 0000000000000..ec5c50b31c5b0 --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash1.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.js === +~< < +>~< < : boolean +>~< : number +>< : any +> : any + +> : any + diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.errors.txt b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.errors.txt new file mode 100644 index 0000000000000..4ae236bce12a4 --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/a.js(1,9): error TS1109: Expression expected. + + +==== tests/cases/compiler/a.js (1 errors) ==== + ~<> < + +!!! error TS1109: Expression expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.js b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.js new file mode 100644 index 0000000000000..0a9f06793a66f --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.js @@ -0,0 +1,7 @@ +//// [a.js] +~<> < + + +//// [a.js] +~<> < +; diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.symbols b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.symbols new file mode 100644 index 0000000000000..d6832b40cd279 --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/a.js === + +~<> < + diff --git a/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.types b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.types new file mode 100644 index 0000000000000..0c0fce49f7382 --- /dev/null +++ b/tests/baselines/reference/parseJsxElementInUnaryExpressionNoCrash2.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/a.js === +~<> < +>~<> < : boolean +>~<> : number +><> : any + +> : any + diff --git a/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.errors.txt b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.errors.txt new file mode 100644 index 0000000000000..7f4ed01bc6ab5 --- /dev/null +++ b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. +tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts(1,8): error TS1109: Expression expected. + + +==== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts (2 errors) ==== + [#abc]= + ~~~~ +!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. + +!!! error TS1109: Expression expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.js b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.js new file mode 100644 index 0000000000000..e4cdd66647ff4 --- /dev/null +++ b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.js @@ -0,0 +1,6 @@ +//// [parserPrivateIdentifierInArrayAssignment.ts] +[#abc]= + + +//// [parserPrivateIdentifierInArrayAssignment.js] +#abc = [0]; diff --git a/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.symbols b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.symbols new file mode 100644 index 0000000000000..a2f582a5ba398 --- /dev/null +++ b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts === + +[#abc]= + diff --git a/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.types b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.types new file mode 100644 index 0000000000000..8c7531c314117 --- /dev/null +++ b/tests/baselines/reference/parserPrivateIdentifierInArrayAssignment.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts === +[#abc]= +>[#abc]= : any +>[#abc] : [any] + +> : any + diff --git a/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).js b/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).js new file mode 100644 index 0000000000000..9a1ba82b5b69f --- /dev/null +++ b/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).js @@ -0,0 +1,2 @@ +import { foo } from "./foo.ts"; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).oldTranspile.js b/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).oldTranspile.js new file mode 100644 index 0000000000000..9a1ba82b5b69f --- /dev/null +++ b/tests/baselines/reference/transpile/Can transpile .ts extensions without error (verbatimModuleSyntax=true).oldTranspile.js @@ -0,0 +1,2 @@ +import { foo } from "./foo.ts"; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Can transpile .ts extensions without error.js b/tests/baselines/reference/transpile/Can transpile .ts extensions without error.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Can transpile .ts extensions without error.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Can transpile .ts extensions without error.oldTranspile.js b/tests/baselines/reference/transpile/Can transpile .ts extensions without error.oldTranspile.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Can transpile .ts extensions without error.oldTranspile.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).errors.txt b/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).errors.txt index e2c1781e29fad..3d6bff97de1a3 100644 --- a/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).errors.txt +++ b/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).errors.txt @@ -1,8 +1,6 @@ -error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. ==== input.js (0 errors) ==== x; \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).oldTranspile.errors.txt b/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).oldTranspile.errors.txt index e2c1781e29fad..3d6bff97de1a3 100644 --- a/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Does not support setting isolatedModules (verbatimModuleSyntax=true).oldTranspile.errors.txt @@ -1,8 +1,6 @@ -error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. ==== input.js (0 errors) ==== x; \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).js b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).js new file mode 100644 index 0000000000000..9a1ba82b5b69f --- /dev/null +++ b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).js @@ -0,0 +1,2 @@ +import { foo } from "./foo.ts"; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).oldTranspile.js b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).oldTranspile.js new file mode 100644 index 0000000000000..9a1ba82b5b69f --- /dev/null +++ b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error (verbatimModuleSyntax=true).oldTranspile.js @@ -0,0 +1,2 @@ +import { foo } from "./foo.ts"; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.js b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.oldTranspile.js b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.oldTranspile.js new file mode 100644 index 0000000000000..e113dbc728253 --- /dev/null +++ b/tests/baselines/reference/transpile/Ignores allowImportingTsExtensions without noEmit error.oldTranspile.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt index e9851f75ee188..4be77662da807 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt @@ -4,7 +4,6 @@ error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functi error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'. -error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. error TS5104: Option 'preserveValueImports' is redundant and cannot be specified with option 'verbatimModuleSyntax'. error TS5105: Option 'verbatimModuleSyntax' cannot be used when 'module' is set to 'UMD', 'AMD', or 'System'. @@ -15,7 +14,6 @@ error TS5105: Option 'verbatimModuleSyntax' cannot be used when 'module' is set !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. !!! error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'. -!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. !!! error TS5104: Option 'preserveValueImports' is redundant and cannot be specified with option 'verbatimModuleSyntax'. !!! error TS5105: Option 'verbatimModuleSyntax' cannot be used when 'module' is set to 'UMD', 'AMD', or 'System'. ==== tests/cases/conformance/externalModules/verbatimModuleSyntaxCompat.ts (0 errors) ==== diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt index 8efe570e1eac1..2c8fcfcbb1eee 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt @@ -1,4 +1,3 @@ -/tsconfig.json(4,9): error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. /tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. /tsconfig.json(5,9): error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. @@ -8,13 +7,11 @@ /tsconfig.json(6,9): error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'. -==== /tsconfig.json (6 errors) ==== +==== /tsconfig.json (5 errors) ==== { "compilerOptions": { "verbatimModuleSyntax": true, "isolatedModules": true, - ~~~~~~~~~~~~~~~~~ -!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. "preserveValueImports": true, ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt index cca2512076220..df27893087b07 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt @@ -1,4 +1,3 @@ -/tsconfig.json(4,9): error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. /tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. /tsconfig.json(5,9): error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. @@ -8,13 +7,11 @@ /tsconfig.json(6,9): error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'. -==== /tsconfig.json (6 errors) ==== +==== /tsconfig.json (5 errors) ==== { "extends": "./tsconfig.base.json", "compilerOptions": { "isolatedModules": true, - ~~~~~~~~~~~~~~~~~ -!!! error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'. "preserveValueImports": true, ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. diff --git a/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash1.ts b/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash1.ts new file mode 100644 index 0000000000000..177022396f4ad --- /dev/null +++ b/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash1.ts @@ -0,0 +1,4 @@ +// @allowJs: true +// @outDir: ./out +// @filename: a.js +~< < diff --git a/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash2.ts b/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash2.ts new file mode 100644 index 0000000000000..0fbf4b3eb2abb --- /dev/null +++ b/tests/cases/compiler/parseJsxElementInUnaryExpressionNoCrash2.ts @@ -0,0 +1,4 @@ +// @allowJs: true +// @outDir: ./out +// @filename: a.js +~<> < diff --git a/tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts b/tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts new file mode 100755 index 0000000000000..f59bd76e18200 --- /dev/null +++ b/tests/cases/compiler/parserPrivateIdentifierInArrayAssignment.ts @@ -0,0 +1 @@ +[#abc]= diff --git a/tests/cases/fourslash/server/goToSource15_bundler.ts b/tests/cases/fourslash/server/goToSource15_bundler.ts new file mode 100644 index 0000000000000..290caa62cbba3 --- /dev/null +++ b/tests/cases/fourslash/server/goToSource15_bundler.ts @@ -0,0 +1,34 @@ +/// + +// @Filename: /tsconfig.json +//// { "compilerOptions": { "module": "esnext", "moduleResolution": "bundler" } } + +// @Filename: /node_modules/react/package.json +//// { "name": "react", "version": "16.8.6", "main": "index.js" } + +// @Filename: /node_modules/react/index.js +//// 'use strict'; +//// +//// if (process.env.NODE_ENV === 'production') { +//// module.exports = require('./cjs/react.production.min.js'); +//// } else { +//// module.exports = require('./cjs/react.development.js'); +//// } + +// @Filename: /node_modules/react/cjs/react.production.min.js +//// 'use strict';exports./*production*/useState=function(a){};exports.version='16.8.6'; + +// @Filename: /node_modules/react/cjs/react.development.js +//// 'use strict'; +//// if (process.env.NODE_ENV !== 'production') { +//// (function() { +//// function useState(initialState) {} +//// exports./*development*/useState = useState; +//// exports.version = '16.8.6'; +//// }()); +//// } + +// @Filename: /index.ts +//// import { [|/*start*/useState|] } from 'react'; + +verify.goToSourceDefinition("start", ["production", "development"]); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy