diff --git a/AUTHORS.md b/AUTHORS.md index b58f1a31efd..e02b495d242 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -169,6 +169,7 @@ TypeScript is authored by: - Gabriel Isenberg - Gabriela Araujo Britto - Gabriela Britto + - Gao Sheng - gb714us - Gilad Peleg - Godfrey Chan diff --git a/package-lock.json b/package-lock.json index 7eaf992be67..46831288f2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -638,9 +638,9 @@ "dev": true }, "@types/node": { - "version": "17.0.29", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.29.tgz", - "integrity": "sha512-tx5jMmMFwx7wBwq/V7OohKDVb/JwJU5qCVkeLMh1//xycAJ/ESuw9aJ9SEtlCZDYi2pBfe4JkisSoAtbOsBNAA==", + "version": "17.0.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.31.tgz", + "integrity": "sha512-AR0x5HbXGqkEx9CadRH3EBYx/VkiUgZIhP4wvPn/+5KIsgpNoyFaRlVe0Zlx9gRtg8fA06a9tskE2MSN7TcG4Q==", "dev": true }, "@types/node-fetch": { @@ -3334,12 +3334,6 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, "gulp": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz", @@ -4328,32 +4322,30 @@ "dev": true }, "mocha": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", - "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz", + "integrity": "sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", "chokidar": "3.5.3", - "debug": "4.3.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", "glob": "7.2.0", - "growl": "1.10.5", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", - "minimatch": "4.2.1", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.1", + "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -4430,9 +4422,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -4570,12 +4562,23 @@ } }, "minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + } } }, "p-limit": { @@ -4651,15 +4654,6 @@ "is-number": "^7.0.0" } }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -4726,9 +4720,9 @@ "optional": true }, "nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true }, "nanomatch": { @@ -6685,9 +6679,9 @@ "dev": true }, "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "wrap-ansi": { diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 10c6db79cf1..84cd23bfc10 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -122,7 +122,9 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, try { setNodeEnvToDevelopment(); - const { exitCode } = await exec("node", args, { cancelToken }); + const { exitCode } = await exec(process.execPath, args, { + cancelToken, + }); if (exitCode !== 0) { errorStatus = exitCode; error = new Error(`Process exited with status code ${errorStatus}.`); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1506c4809ef..8dc1e1df76f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1048,7 +1048,7 @@ namespace ts { const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - // Extensions suggested for path imports when module resolution is node12 or higher. + // Extensions suggested for path imports when module resolution is node16 or higher. // The first element of each tuple is the extension a file has. // The second element of each tuple is the extension that should be used in a path import. // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". @@ -3528,7 +3528,7 @@ namespace ts { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration); const overrideClauseHost = findAncestor(location, l => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l)) as ImportTypeNode | ImportDeclaration | ExportDeclaration | undefined; const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? overrideClauseHost.assertions?.assertClause : overrideClauseHost?.assertClause; @@ -3537,9 +3537,6 @@ namespace ts { if (isSyncImport && sourceFile.impliedNodeFormat === ModuleKind.ESNext && !getResolutionModeOverrideForClause(overrideClause)) { error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); } - if (mode === ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === Extension.Json) { - error(errorNode, Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); - } } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); @@ -3596,7 +3593,7 @@ namespace ts { const tsExtension = tryExtractTSExtension(moduleReference); const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference); const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); - const resolutionIsNode12OrNext = moduleResolutionKind === ModuleResolutionKind.Node12 || + const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; if (tsExtension) { const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; @@ -3617,16 +3614,16 @@ namespace ts { hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } - else if (mode === ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + else if (mode === ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) { const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path)); const suggestedExt = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))?.[1]; if (suggestedExt) { error(errorNode, - Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, + Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); } else { - error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + error(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path); } } else { @@ -6191,7 +6188,7 @@ namespace ts { const targetFile = getSourceFileOfModule(chain[0]); let specifier: string | undefined; let assertion: ImportTypeAssertionContainer | undefined; - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { // An `import` type directed at an esm format file is only going to resolve in esm mode - set the esm mode assertion if (targetFile?.impliedNodeFormat === ModuleKind.ESNext && targetFile.impliedNodeFormat !== contextFile?.impliedNodeFormat) { specifier = getSpecifierForModuleSymbol(chain[0], context, ModuleKind.ESNext); @@ -6208,7 +6205,7 @@ namespace ts { } if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { const oldSpecifier = specifier; - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set const swappedMode = contextFile?.impliedNodeFormat === ModuleKind.ESNext ? ModuleKind.CommonJS : ModuleKind.ESNext; specifier = getSpecifierForModuleSymbol(chain[0], context, swappedMode); @@ -18772,9 +18769,6 @@ namespace ts { return; } reportRelationError(headMessage, source, target); - if (strictNullChecks && source.flags & TypeFlags.TypeVariable && source.symbol?.declarations?.[0] && !getConstraintOfType(source as TypeVariable) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) { - associateRelatedInfo(createDiagnosticForNode(source.symbol.declarations[0], Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint)); - } } function traceUnionsOrIntersectionsTooLarge(source: Type, target: Type): void { @@ -19565,7 +19559,7 @@ namespace ts { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch if (!(sourceFlags & TypeFlags.IndexedAccess && targetFlags & TypeFlags.IndexedAccess)) { const constraint = getConstraintOfType(source as TypeVariable); - if (!strictNullChecks && (!constraint || (sourceFlags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any))) { + if (!constraint || (sourceFlags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive), RecursionFlags.Both)) { resetErrorInfo(saveErrorInfo); @@ -19573,12 +19567,12 @@ namespace ts { } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (constraint && (result = isRelatedTo(constraint, target, RecursionFlags.Source, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(constraint, target, RecursionFlags.Source, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, RecursionFlags.Source, reportErrors && !(targetFlags & sourceFlags & TypeFlags.TypeParameter), /*headMessage*/ undefined, intersectionState))) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, RecursionFlags.Source, reportErrors && !(targetFlags & sourceFlags & TypeFlags.TypeParameter), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -25531,7 +25525,7 @@ namespace ts { if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { const parent = declaration.parent.parent; if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlags(declaration) & NodeFlags.Const || parent.kind === SyntaxKind.Parameter) { - const links = getNodeLinks(location); + const links = getNodeLinks(parent); if (!(links.flags & NodeCheckFlags.InCheckIdentifier)) { links.flags |= NodeCheckFlags.InCheckIdentifier; const parentType = getTypeForBindingElementParent(parent, CheckMode.Normal); @@ -32060,13 +32054,13 @@ namespace ts { } function checkImportMetaProperty(node: MetaProperty) { - if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) { + if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) { if (getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.ESNext) { error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); } } else if (moduleKind < ModuleKind.ES2020 && moduleKind !== ModuleKind.System) { - error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); + error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } const file = getSourceFileOfNode(node); Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag."); @@ -33096,16 +33090,37 @@ namespace ts { if (!hasParseDiagnostics(sourceFile)) { let span: TextSpan | undefined; if (!isEffectiveExternalModule(sourceFile, compilerOptions)) { - if (!span) span = getSpanOfTokenAtPosition(sourceFile, node.pos); + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { - span = getSpanOfTokenAtPosition(sourceFile, node.pos); - const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); - diagnostics.add(diagnostic); + switch (moduleKind) { + case ModuleKind.Node16: + case ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ModuleKind.CommonJS) { + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add( + createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level) + ); + break; + } + // fallthrough + case ModuleKind.ES2022: + case ModuleKind.ESNext: + case ModuleKind.System: + if (languageVersion >= ScriptTarget.ES2017) { + break; + } + // fallthrough + default: + span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); + diagnostics.add( + createFileDiagnostic(sourceFile, span.start, span.length, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher + ) + ); + break; } } } @@ -35809,8 +35824,8 @@ namespace ts { if (node.assertions) { const override = getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode); if (override) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { - grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { + grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } } } @@ -37428,7 +37443,7 @@ namespace ts { function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier | undefined) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node12 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { + if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { return; } @@ -38250,7 +38265,7 @@ namespace ts { return (use & IterationUse.PossiblyOutOfBounds) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; - function getIterationDiagnosticDetails(allowsStrings: boolean, downlevelIteration: boolean | undefined): [DiagnosticMessage, boolean] { + function getIterationDiagnosticDetails(allowsStrings: boolean, downlevelIteration: boolean | undefined): [error: DiagnosticMessage, maybeMissingAwait: boolean] { if (downlevelIteration) { return allowsStrings ? [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] @@ -38260,7 +38275,7 @@ namespace ts { const yieldType = getIterationTypeOfIterable(use, IterationTypeKind.Yield, inputType, /*errorNode*/ undefined); if (yieldType) { - return [Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + return [Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } if (isES2015OrLaterIterable(inputType.symbol?.escapedName)) { @@ -40703,8 +40718,8 @@ namespace ts { const validForTypeAssertions = isExclusivelyTypeOnlyImportOrExport(declaration); const override = getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined); if (validForTypeAssertions && override) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { - return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext); + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { + return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext); } return; // Other grammar checks do not apply to type-only imports with resolution mode assertions } @@ -41898,7 +41913,7 @@ namespace ts { const symbol = getIntrinsicTagSymbol(name.parent as JsxOpeningLikeElement); return symbol === unknownSymbol ? undefined : symbol; } - const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc, getHostSignatureFromJSDoc(name)); + const result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /* dontResolveAlias */ true, getHostSignatureFromJSDoc(name)); if (!result && isJSDoc) { const container = findAncestor(name, or(isClassLike, isInterfaceDeclaration)); if (container) { @@ -43901,6 +43916,9 @@ namespace ts { } function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments | TypeQueryNode) { + if (isExpressionWithTypeArguments(node) && isImportKeyword(node.expression) && node.typeArguments) { + return grammarErrorOnNode(node, Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); + } return checkGrammarTypeArguments(node, node.typeArguments); } @@ -44173,9 +44191,30 @@ namespace ts { diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { - diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); + switch (moduleKind) { + case ModuleKind.Node16: + case ModuleKind.NodeNext: + if (sourceFile.impliedNodeFormat === ModuleKind.CommonJS) { + diagnostics.add( + createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level) + ); + break; + } + // fallthrough + case ModuleKind.ES2022: + case ModuleKind.ESNext: + case ModuleKind.System: + if (languageVersion >= ScriptTarget.ES2017) { + break; + } + // fallthrough + default: + diagnostics.add( + createDiagnosticForNode(forInOrOfStatement.awaitModifier, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher + ) + ); + break; } } } @@ -44947,11 +44986,11 @@ namespace ts { function checkGrammarImportCallExpression(node: ImportCall): boolean { if (moduleKind === ModuleKind.ES2015) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); + return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext); } if (node.typeArguments) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_have_type_arguments); + return grammarErrorOnNode(node, Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments); } const nodeArguments = node.arguments; @@ -44961,7 +45000,7 @@ namespace ts { if (nodeArguments.length > 1) { const assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); + return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_or_nodenext); } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6ed23d16e6b..d60facd264b 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -423,7 +423,7 @@ namespace ts { es2020: ModuleKind.ES2020, es2022: ModuleKind.ES2022, esnext: ModuleKind.ESNext, - node12: ModuleKind.Node12, + node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, })), affectsModuleResolution: true, @@ -781,7 +781,7 @@ namespace ts { type: new Map(getEntries({ node: ModuleResolutionKind.NodeJs, classic: ModuleResolutionKind.Classic, - node12: ModuleResolutionKind.Node12, + node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, @@ -1263,7 +1263,7 @@ namespace ts { affectsModuleResolution: true, description: Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files, category: Diagnostics.Language_and_Environment, - defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules, + defaultValueDescription: Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules, } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 44fed63932d..3e1b4a3ad2d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -900,6 +900,10 @@ "category": "Error", "code": 1308 }, + "The current file is a CommonJS module and cannot use 'await' at the top level.": { + "category": "Error", + "code": 1309 + }, "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": { "category": "Error", "code": 1312 @@ -944,11 +948,11 @@ "category": "Error", "code": 1322 }, - "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.": { + "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'.": { "category": "Error", "code": 1323 }, - "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'.": { + "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'.": { "category": "Error", "code": 1324 }, @@ -956,7 +960,7 @@ "category": "Error", "code": 1325 }, - "Dynamic import cannot have type arguments.": { + "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments.": { "category": "Error", "code": 1326 }, @@ -1016,7 +1020,7 @@ "category": "Error", "code": 1342 }, - "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'.": { + "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.": { "category": "Error", "code": 1343 }, @@ -1140,7 +1144,7 @@ "category": "Message", "code": 1377 }, - "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1378 }, @@ -1348,7 +1352,7 @@ "category": "Error", "code": 1431 }, - "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1432 }, @@ -1420,7 +1424,7 @@ "category": "Error", "code": 1451 }, - "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`.": { + "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.": { "category": "Error", "code": 1452 }, @@ -1465,7 +1469,7 @@ "category": "Message", "code": 1475 }, - "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules.": { + "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules.": { "category": "Message", "code": 1476 }, @@ -1506,10 +1510,6 @@ "category": "Error", "code": 2207 }, - "This type parameter probably needs an `extends object` constraint.": { - "category": "Error", - "code": 2208 - }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -2511,10 +2511,7 @@ "category": "Error", "code": 2568 }, - "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.": { - "category": "Error", - "code": 2569 - }, + "Could not find name '{0}'. Did you mean '{1}'?": { "category": "Error", "code": 2570 @@ -3425,11 +3422,11 @@ "category": "Error", "code": 2833 }, - "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path.": { + "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.": { "category": "Error", "code": 2834 }, - "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?": { + "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?": { "category": "Error", "code": 2835 }, @@ -6113,10 +6110,6 @@ "category": "Error", "code": 7061 }, - "JSON imports are experimental in ES module mode imports.": { - "category": "Error", - "code": 7062 - }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index cbeb8df5e5b..9028c521a13 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -5275,7 +5275,7 @@ namespace ts { hasNoDefaultLib: boolean, libReferences: readonly FileReference[] ) { - const node = baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile) as Mutable; + const node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(SyntaxKind.SourceFile)) as Mutable; for (const p in source) { if (p === "emitNode" || hasProperty(node, p) || !hasProperty(source, p)) continue; (node as any)[p] = (source as any)[p]; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index fc6ee4f898b..fb30f7749bb 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -352,9 +352,9 @@ namespace ts { // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best, // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern - // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution + // resolution" should be (`node16`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do). - if (resolutionMode === ModuleKind.ESNext && (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext)) { + if (resolutionMode === ModuleKind.ESNext && (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } const conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; @@ -448,7 +448,7 @@ namespace ts { } function getDefaultNodeResolutionFeatures(options: CompilerOptions) { - return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default : + return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : NodeResolutionFeatures.None; } @@ -955,8 +955,8 @@ namespace ts { case ModuleKind.CommonJS: moduleResolution = ModuleResolutionKind.NodeJs; break; - case ModuleKind.Node12: - moduleResolution = ModuleResolutionKind.Node12; + case ModuleKind.Node16: + moduleResolution = ModuleResolutionKind.Node16; break; case ModuleKind.NodeNext: moduleResolution = ModuleResolutionKind.NodeNext; @@ -977,8 +977,8 @@ namespace ts { perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { - case ModuleResolutionKind.Node12: - result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + case ModuleResolutionKind.Node16: + result = node16ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); break; case ModuleResolutionKind.NodeNext: result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); @@ -1236,22 +1236,22 @@ namespace ts { // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names Exports = 1 << 3, // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` - // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + // not supported in node 12 - https://github.com/nodejs/Release/issues/690 ExportsPatternTrailers = 1 << 4, AllFeatures = Imports | SelfName | Exports | ExportsPatternTrailers, - Node12Default = Imports | SelfName | Exports, + Node16Default = Imports | SelfName | Exports | ExportsPatternTrailers, NodeNextDefault = AllFeatures, EsmMode = 1 << 5, } - function node12ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, + function node16ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations { return nodeNextModuleNameResolverWorker( - NodeResolutionFeatures.Node12Default, + NodeResolutionFeatures.Node16Default, moduleName, containingFile, compilerOptions, @@ -1316,7 +1316,7 @@ namespace ts { const failedLookupLocations: string[] = []; const affectingLocations: string[] = []; - // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, //it's essentially a set (priority is determined by object insertion order in the object we look at). const conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; if (compilerOptions.noDtsResolution) { diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 270bee0048e..542afb796a9 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -41,7 +41,7 @@ namespace ts.moduleSpecifiers { } function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node12 + if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { return false; } @@ -734,7 +734,7 @@ namespace ts.moduleSpecifiers { const cachedPackageJson = host.getPackageJsonInfoCache?.()?.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { const packageJsonContent = cachedPackageJson?.packageJsonContent || JSON.parse(host.readFile!(packageJsonPath)!); - if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) { + if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext) { // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 884a5b36e38..32e00834bb4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -683,7 +683,7 @@ namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c7f886ea311..14da7655333 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -858,7 +858,7 @@ namespace ts { */ export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined { switch (getEmitModuleResolutionKind(options)) { - case ModuleResolutionKind.Node12: + case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext : fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS : @@ -1210,7 +1210,7 @@ namespace ts { const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (let i = 0; i < typeReferences.length; i++) { - // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode + // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: resolutions[i]?.packageId }); } tracing?.pop(); @@ -3085,8 +3085,8 @@ namespace ts { const fileName = toFileNameLowerCase(ref.fileName); setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); const mode = ref.resolutionMode || file.impliedNodeFormat; - if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node12 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { - programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext)); + if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { + programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index, }); } @@ -3515,7 +3515,7 @@ namespace ts { if (options.resolveJsonModule) { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node12 && + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 7207d8a60d7..bfe70171504 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -9,7 +9,7 @@ namespace ts { return transformECMAScriptModule; case ModuleKind.System: return transformSystemModule; - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return transformNodeModule; default: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 593c18e6e88..3e5c8adb31e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3615,7 +3615,7 @@ namespace ts { languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -6049,11 +6049,12 @@ namespace ts { Classic = 1, NodeJs = 2, // Starting with node12, node's module resolver has significant departures from traditional cjs resolution - // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` - // version-anchored resolution target - Node12 = 3, - NodeNext = 99, // Not simply `Node12` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) + // to better support ecmascript modules and their use within node - however more features are still being added. + // TypeScript's Node ESM support was introduced after Node 12 went end-of-life, and Node 14 is the earliest stable + // version that supports both pattern trailers - *but*, Node 16 is the first version that also supports ECMASCript 2022. + // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target + Node16 = 3, + NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) } export enum ModuleDetectionKind { @@ -6062,7 +6063,7 @@ namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -6281,8 +6282,8 @@ namespace ts { ES2022 = 7, ESNext = 99, - // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext - Node12 = 100, + // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext + Node16 = 100, NodeNext = 199, } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7d860fa7a61..b4a22b298fe 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -808,7 +808,7 @@ namespace ts { } function isCommonJSContainingModuleKind(kind: ModuleKind) { - return kind === ModuleKind.CommonJS || kind === ModuleKind.Node12 || kind === ModuleKind.NodeNext; + return kind === ModuleKind.CommonJS || kind === ModuleKind.Node16 || kind === ModuleKind.NodeNext; } export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) { @@ -6319,7 +6319,7 @@ namespace ts { file.externalModuleIndicator = isFileProbablyExternalModule(file); }; case ModuleDetectionKind.Auto: - // If module is nodenext or node12, all esm format files are modules + // If module is nodenext or node16, all esm format files are modules // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness const checks: ((file: SourceFile) => Node | true | undefined)[] = [isFileProbablyExternalModule]; @@ -6327,7 +6327,7 @@ namespace ts { checks.push(isFileModuleFromUsingJSXTag); } const moduleKind = getEmitModuleKind(options); - if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) { + if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) { checks.push(isFileForcedToBeModuleByFormat); } const combined = or(...checks); @@ -6338,7 +6338,7 @@ namespace ts { export function getEmitScriptTarget(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { return compilerOptions.target || - (compilerOptions.module === ModuleKind.Node12 && ScriptTarget.ES2020) || + (compilerOptions.module === ModuleKind.Node16 && ScriptTarget.ES2022) || (compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) || ScriptTarget.ES3; } @@ -6356,8 +6356,8 @@ namespace ts { case ModuleKind.CommonJS: moduleResolution = ModuleResolutionKind.NodeJs; break; - case ModuleKind.Node12: - moduleResolution = ModuleResolutionKind.Node12; + case ModuleKind.Node16: + moduleResolution = ModuleResolutionKind.Node16; break; case ModuleKind.NodeNext: moduleResolution = ModuleResolutionKind.NodeNext; @@ -6382,7 +6382,7 @@ namespace ts { case ModuleKind.ES2020: case ModuleKind.ES2022: case ModuleKind.ESNext: - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return true; default: @@ -6407,7 +6407,7 @@ namespace ts { return compilerOptions.esModuleInterop; } switch (getEmitModuleKind(compilerOptions)) { - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return true; } diff --git a/src/harness/client.ts b/src/harness/client.ts index 388f6473fa8..7c8869995bb 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -38,6 +38,7 @@ namespace ts.server { private lineMaps = new Map(); private messages: string[] = []; private lastRenameEntry: RenameEntry | undefined; + private preferences: UserPreferences | undefined; constructor(private host: SessionClientHost) { } @@ -124,6 +125,7 @@ namespace ts.server { /*@internal*/ configure(preferences: UserPreferences) { + this.preferences = preferences; const args: protocol.ConfigureRequestArguments = { preferences }; const request = this.processRequest(CommandNames.Configure, args); this.processResponse(request, /*expectEmptyBody*/ true); @@ -488,13 +490,25 @@ namespace ts.server { return notImplemented(); } - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] { + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): RenameLocation[] { if (!this.lastRenameEntry || this.lastRenameEntry.inputs.fileName !== fileName || this.lastRenameEntry.inputs.position !== position || this.lastRenameEntry.inputs.findInStrings !== findInStrings || this.lastRenameEntry.inputs.findInComments !== findInComments) { - this.getRenameInfo(fileName, position, { allowRenameOfImportPath: true }, findInStrings, findInComments); + if (providePrefixAndSuffixTextForRename !== undefined) { + // User preferences have to be set through the `Configure` command + this.configure({ providePrefixAndSuffixTextForRename }); + // Options argument is not used, so don't pass in options + this.getRenameInfo(fileName, position, /*options*/{}, findInStrings, findInComments); + // Restore previous user preferences + if (this.preferences) { + this.configure(this.preferences); + } + } + else { + this.getRenameInfo(fileName, position, /*options*/{}, findInStrings, findInComments); + } } return this.lastRenameEntry!.locations; diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 40e3994b1c9..999c9d4e273 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -249,7 +249,7 @@ namespace compiler { } // establish defaults (aligns with old harness) - if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node12 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; + if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node16 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; if (compilerOptions.newLine === undefined) compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; if (compilerOptions.skipDefaultLibCheck === undefined) compilerOptions.skipDefaultLibCheck = true; if (compilerOptions.noErrorTruncation === undefined) compilerOptions.noErrorTruncation = true; diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index 50a10c7b33e..e13da87bc71 100644 --- a/src/lib/es2020.bigint.d.ts +++ b/src/lib/es2020.bigint.d.ts @@ -673,6 +673,7 @@ interface DataView { * Gets the BigInt64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; @@ -680,6 +681,7 @@ interface DataView { * Gets the BigUint64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; @@ -687,8 +689,7 @@ interface DataView { * Stores a BigInt64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; @@ -696,8 +697,7 @@ interface DataView { * Stores a BigUint64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index d4d0bf3ffa0..75b9539cc75 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -52,13 +52,13 @@ declare function decodeURIComponent(encodedURIComponent: string): string; /** * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. + * @param uri A value representing an unencoded URI. */ declare function encodeURI(uri: string): string; /** * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. + * @param uriComponent A value representing an unencoded URI component. */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; @@ -1669,6 +1669,7 @@ interface DataView { * Gets the Float32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat32(byteOffset: number, littleEndian?: boolean): number; @@ -1676,6 +1677,7 @@ interface DataView { * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getFloat64(byteOffset: number, littleEndian?: boolean): number; @@ -1690,12 +1692,14 @@ interface DataView { * Gets the Int16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getInt32(byteOffset: number, littleEndian?: boolean): number; @@ -1710,6 +1714,7 @@ interface DataView { * Gets the Uint16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint16(byteOffset: number, littleEndian?: boolean): number; @@ -1717,6 +1722,7 @@ interface DataView { * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. + * @param littleEndian If false or undefined, a big-endian value should be read. */ getUint32(byteOffset: number, littleEndian?: boolean): number; @@ -1724,8 +1730,7 @@ interface DataView { * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1733,8 +1738,7 @@ interface DataView { * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1749,8 +1753,7 @@ interface DataView { * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1758,8 +1761,7 @@ interface DataView { * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1774,8 +1776,7 @@ interface DataView { * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1783,8 +1784,7 @@ interface DataView { * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. + * @param littleEndian If false or undefined, a big-endian value should be written. */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 61a90c1c4d7..b20a7942045 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5349,18 +5349,6 @@ - - - - - - - - - - - - @@ -5997,6 +5985,15 @@ + + + + + + + + + @@ -13740,6 +13737,15 @@ + + + + + + + + + @@ -13977,15 +13983,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 22eb8d6477c..f6b570fc6ff 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5349,18 +5349,6 @@ - - - - - - - - - - - - @@ -5997,6 +5985,15 @@ + + + + + + + + + @@ -13740,6 +13737,15 @@ + + + + + + + + + @@ -13977,15 +13983,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1647e0bb4d6..f614e8f1932 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5358,18 +5358,6 @@ - - - - - - - - - - - - @@ -6006,6 +5994,15 @@ + + + + + + + + + @@ -13749,6 +13746,15 @@ + + + + + + + + + @@ -13986,15 +13992,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index c64af472bcb..33b4db6a78c 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5346,18 +5346,6 @@ - - - - - - - - - - - - @@ -5994,6 +5982,15 @@ + + + + + + + + + @@ -13734,6 +13731,15 @@ + + + + + + + + + @@ -13971,15 +13977,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index b6c18f4a981..0892782e82d 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5361,18 +5361,6 @@ - - - - - - - - - - - - @@ -6009,6 +5997,15 @@ + + + + + + + + + @@ -13752,6 +13749,15 @@ + + + + + + + + + @@ -13989,15 +13995,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index bd874578a99..e2263e2549d 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5361,18 +5361,6 @@ - - - - - - - - - - - - @@ -6009,6 +5997,15 @@ + + + + + + + + + @@ -13752,6 +13749,15 @@ + + + + + + + + + @@ -13989,15 +13995,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index c626ecc1200..372de213b24 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5349,18 +5349,6 @@ - - - - - - - - - - - - @@ -5997,6 +5985,15 @@ + + + + + + + + + @@ -13740,6 +13737,15 @@ + + + + + + + + + @@ -13977,15 +13983,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index beb4187452a..e222b1f13d7 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5349,18 +5349,6 @@ - - - - - - - - - - - - @@ -5997,6 +5985,15 @@ + + + + + + + + + @@ -13740,6 +13737,15 @@ + + + + + + + + + @@ -13977,15 +13983,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 76e9e04018e..fb0bd7b0c44 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5349,18 +5349,6 @@ - - - - - - - - - - - - @@ -5997,6 +5985,15 @@ + + + + + + + + + @@ -13740,6 +13737,15 @@ + + + + + + + + + @@ -13977,15 +13983,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1e9219f3e25..102654a92b6 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5339,18 +5339,6 @@ - - - - - - - - - - - - @@ -5987,6 +5975,15 @@ + + + + + + + + + @@ -13727,6 +13724,15 @@ + + + + + + + + + @@ -13964,15 +13970,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1508ab03620..303d5413039 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5342,18 +5342,6 @@ - - - - - - - - - - - - @@ -5990,6 +5978,15 @@ + + + + + + + + + @@ -13730,6 +13727,15 @@ + + + + + + + + + @@ -13967,15 +13973,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 5dfe3d58385..2e8bc37a128 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5348,18 +5348,6 @@ - - - - - - - - - - - - @@ -5996,6 +5984,15 @@ + + + + + + + + + @@ -13739,6 +13736,15 @@ + + + + + + + + + @@ -13976,15 +13982,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 280067f85e8..9ae2836efbf 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -5342,18 +5342,6 @@ - - - - - - - - - - - - @@ -5990,6 +5978,15 @@ + + + + + + + + + @@ -13733,6 +13730,15 @@ + + + + + + + + + @@ -13970,15 +13976,6 @@ - - - - - - - - - diff --git a/src/server/session.ts b/src/server/session.ts index 3345f362eda..8c92d71db1b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -317,6 +317,7 @@ namespace ts.server { projects, defaultProject, initialLocation, + /*isForRename*/ true, (project, location, tryAddToTodo) => { const projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); if (projectOutputs) { @@ -332,8 +333,8 @@ namespace ts.server { return outputs; } - function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition): DocumentPosition | undefined { - const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos); + function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition, isForRename: boolean): DocumentPosition | undefined { + const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename); const info = infos && firstOrUndefined(infos); return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } @@ -350,6 +351,7 @@ namespace ts.server { projects, defaultProject, initialLocation, + /*isForRename*/ false, (project, location, getMappedLocation) => { logger.info(`Finding references to ${location.fileName} position ${location.pos} in project ${project.getProjectName()}`); const projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos); @@ -417,7 +419,8 @@ namespace ts.server { projects: Projects, defaultProject: Project, initialLocation: TLocation, - cb: CombineProjectOutputCallback + isForRename: boolean, + cb: CombineProjectOutputCallback, ): void { const projectService = defaultProject.projectService; let toDo: ProjectAndLocation[] | undefined; @@ -430,7 +433,7 @@ namespace ts.server { // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. if (initialLocation) { - const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation); + const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation, isForRename); if (defaultDefinition) { const getGeneratedDefinition = memoize(() => defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ? defaultDefinition : @@ -1243,7 +1246,7 @@ namespace ts.server { definitions?.forEach(d => definitionSet.add(d)); const noDtsProject = project.getNoDtsResolutionProject([file]); const ls = noDtsProject.getLanguageService(); - const jsDefinitions = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true) + const jsDefinitions = ls.getDefinitionAtPosition(file, position, /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false) ?.filter(d => toNormalizedPath(d.fileName) !== file); if (some(jsDefinitions)) { for (const jsDefinition of jsDefinitions) { @@ -1288,7 +1291,7 @@ namespace ts.server { const compilerOptions = project.getCompilationSettings(); const packageJson = getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); if (!packageJson) return undefined; - // Use fake options instead of actual compiler options to avoid following export map if the project uses node12 or nodenext - + // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - // Mapping from an export map entry across packages is out of scope for now. Returned entrypoints will only be what can be // resolved from the package root under --moduleResolution node const entrypoints = getEntrypointsFromPackageJsonInfo( @@ -1330,7 +1333,7 @@ namespace ts.server { if ((isStringLiteralLike(initialNode) || isIdentifier(initialNode)) && isAccessExpression(initialNode.parent)) { return forEachNameInAccessChainWalkingLeft(initialNode, nameInChain => { if (nameInChain === initialNode) return undefined; - const candidates = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true) + const candidates = ls.getDefinitionAtPosition(file, nameInChain.getStart(), /*searchOtherFilesOnly*/ true, /*stopAtAlias*/ false) ?.filter(d => toNormalizedPath(d.fileName) !== file && d.isAmbient) .map(d => ({ fileName: d.fileName, diff --git a/src/services/codefixes/addMissingAwait.ts b/src/services/codefixes/addMissingAwait.ts index 1a9110227e5..d8b16cd4e54 100644 --- a/src/services/codefixes/addMissingAwait.ts +++ b/src/services/codefixes/addMissingAwait.ts @@ -17,7 +17,7 @@ namespace ts.codefix { Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, Diagnostics.Type_0_is_not_an_array_type.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, - Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, + Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher.code, Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator.code, Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator.code, diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index c2d72d291e3..e60b95f6c27 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -2,8 +2,8 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { const compilerOptions = context.program.getCompilerOptions(); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 94b289cd317..5f908020168 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -864,7 +864,7 @@ namespace ts.codefix { case ModuleKind.None: // Fall back to the `import * as ns` style import. return ImportKind.Namespace; - case ModuleKind.Node12: + case ModuleKind.Node16: case ModuleKind.NodeNext: return importingFile.impliedNodeFormat === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS; default: diff --git a/src/services/completions.ts b/src/services/completions.ts index a81ccfa788d..27066f7b72e 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -164,7 +164,7 @@ namespace ts.Completions { TypeAssertionKeywords, TypeKeywords, TypeKeyword, // Literally just `type` - Last = TypeKeywords + Last = TypeKeyword } const enum GlobalsSearch { Continue, Success, Fail } @@ -574,7 +574,7 @@ namespace ts.Completions { if (keywordFilters !== KeywordCompletionFilters.None) { const entryNames = new Set(entries.map(e => e.name)); for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) { - if (!entryNames.has(keywordEntry.name)) { + if (isTypeOnlyLocation && isTypeKeyword(stringToToken(keywordEntry.name)!) || !entryNames.has(keywordEntry.name)) { insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } @@ -2761,7 +2761,7 @@ namespace ts.Completions { } // Do a relatively cheap check to bail early if all re-exports are non-importable - // due to file location or package.json dependency filtering. For non-node12+ + // due to file location or package.json dependency filtering. For non-node16+ // module resolution modes, getting past this point guarantees that we'll be // able to generate a suitable module specifier, so we can safely show a completion, // even if we defer computing the module specifier. @@ -2770,7 +2770,7 @@ namespace ts.Completions { return; } - // In node12+, module specifier resolution can fail due to modules being blocked + // In node16+, module specifier resolution can fail due to modules being blocked // by package.json `exports`. If that happens, don't show a completion item. // N.B. in this resolution mode we always try to resolve module specifiers here, // because we have to know now if it's going to fail so we can omit the completion diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 5274aed06fd..7141bc12fd7 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -25,7 +25,7 @@ namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -58,7 +58,7 @@ namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 5a9948cd35f..cc5e2b6c41c 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -778,6 +778,13 @@ namespace ts.formatting { let listDynamicIndentation = parentDynamicIndentation; let startLine = parentStartLine; + // node range is outside the target range - do not dive inside + if (!rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) { + if (nodes.end < originalRange.pos) { + formattingScanner.skipToEndOf(nodes); + } + return; + } if (listStartToken !== SyntaxKind.Unknown) { // introduce a new indentation scope for lists (including list start and end tokens) diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 05bbc340416..56ad87770ba 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -12,7 +12,7 @@ namespace ts.formatting { readEOFTokenRange(): TextRangeWithKind; getCurrentLeadingTrivia(): TextRangeWithKind[] | undefined; lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; + skipToEndOf(node: Node | NodeArray): void; skipToStartOf(node: Node): void; } @@ -286,7 +286,7 @@ namespace ts.formatting { return tokenInfo; } - function skipToEndOf(node: Node): void { + function skipToEndOf(node: Node | NodeArray): void { scanner.setTextPos(node.end); savedPos = scanner.getStartPos(); lastScanAction = undefined; diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index b1c8ec28c1b..f9f742e65a4 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.GoToDefinition { - export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number, searchOtherFilesOnly?: boolean): readonly DefinitionInfo[] | undefined { + export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number, searchOtherFilesOnly?: boolean, stopAtAlias?: boolean): readonly DefinitionInfo[] | undefined { const resolvedRef = getReferenceAtPosition(sourceFile, position, program); const fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || emptyArray; if (resolvedRef?.file) { @@ -28,7 +28,7 @@ namespace ts.GoToDefinition { if (isStaticModifier(node) && isClassStaticBlockDeclaration(node.parent)) { const classDecl = node.parent.parent; - const { symbol, failedAliasResolution } = getSymbol(classDecl, typeChecker); + const { symbol, failedAliasResolution } = getSymbol(classDecl, typeChecker, stopAtAlias); const staticBlocks = filter(classDecl.members, isClassStaticBlockDeclaration); const containerName = symbol ? typeChecker.symbolToString(symbol, classDecl) : ""; @@ -40,7 +40,7 @@ namespace ts.GoToDefinition { }); } - let { symbol, failedAliasResolution } = getSymbol(node, typeChecker); + let { symbol, failedAliasResolution } = getSymbol(node, typeChecker, stopAtAlias); let fallbackNode = node; if (searchOtherFilesOnly && failedAliasResolution) { @@ -48,7 +48,7 @@ namespace ts.GoToDefinition { const importDeclaration = forEach([node, ...symbol?.declarations || emptyArray], n => findAncestor(n, isAnyImportOrBareOrAccessedRequire)); const moduleSpecifier = importDeclaration && tryGetModuleSpecifierFromDeclaration(importDeclaration); if (moduleSpecifier) { - ({ symbol, failedAliasResolution } = getSymbol(moduleSpecifier, typeChecker)); + ({ symbol, failedAliasResolution } = getSymbol(moduleSpecifier, typeChecker, stopAtAlias)); fallbackNode = moduleSpecifier; } } @@ -235,7 +235,7 @@ namespace ts.GoToDefinition { return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false); } - const { symbol, failedAliasResolution } = getSymbol(node, typeChecker); + const { symbol, failedAliasResolution } = getSymbol(node, typeChecker, /*stopAtAlias*/ false); if (!symbol) return undefined; const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node); @@ -292,14 +292,14 @@ namespace ts.GoToDefinition { return mapDefined(checker.getIndexInfosAtLocation(node), info => info.declaration && createDefinitionFromSignatureDeclaration(checker, info.declaration)); } - function getSymbol(node: Node, checker: TypeChecker) { + function getSymbol(node: Node, checker: TypeChecker, stopAtAlias: boolean | undefined) { const symbol = checker.getSymbolAtLocation(node); // If this is an alias, and the request came at the declaration location // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. let failedAliasResolution = false; - if (symbol?.declarations && symbol.flags & SymbolFlags.Alias && shouldSkipAlias(node, symbol.declarations[0])) { + if (symbol?.declarations && symbol.flags & SymbolFlags.Alias && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { const aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return { symbol: aliased }; diff --git a/src/services/services.ts b/src/services/services.ts index 20373fa773e..ac731115beb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1768,9 +1768,9 @@ namespace ts { } /// Goto definition - function getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly?: boolean): readonly DefinitionInfo[] | undefined { + function getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly?: boolean, stopAtAlias?: boolean): readonly DefinitionInfo[] | undefined { synchronizeHostData(); - return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly); + return GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position, searchOtherFilesOnly, stopAtAlias); } function getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined { diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 61f90c9817d..604a8337426 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -377,12 +377,12 @@ namespace ts.Completions.StringCompletions { function isEmitResolutionKindUsingNodeModules(compilerOptions: CompilerOptions): boolean { return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || + getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; } function isEmitModuleResolutionRespectingExportMaps(compilerOptions: CompilerOptions) { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; } diff --git a/src/services/types.ts b/src/services/types.ts index 886546f5f06..82ed0b94124 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -267,7 +267,7 @@ namespace ts { /* * Unlike `realpath and `readDirectory`, `readFile` and `fileExists` are now _required_ - * to properly acquire and setup source files under module: node12+ modes. + * to properly acquire and setup source files under module: node16+ modes. */ readFile(path: string, encoding?: string): string | undefined; fileExists(path: string): boolean; @@ -474,7 +474,10 @@ namespace ts { /*@internal*/ // eslint-disable-next-line @typescript-eslint/unified-signatures - getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: boolean): readonly DefinitionInfo[] | undefined; + getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: false, stopAtAlias: boolean): readonly DefinitionInfo[] | undefined; + /*@internal*/ + // eslint-disable-next-line @typescript-eslint/unified-signatures + getDefinitionAtPosition(fileName: string, position: number, searchOtherFilesOnly: boolean, stopAtAlias: false): readonly DefinitionInfo[] | undefined; getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a2f5846b82e..18f85ceb264 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1929,11 +1929,11 @@ namespace ts { } export function moduleResolutionRespectsExports(moduleResolution: ModuleResolutionKind): boolean { - return moduleResolution >= ModuleResolutionKind.Node12 && moduleResolution <= ModuleResolutionKind.NodeNext; + return moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; } export function moduleResolutionUsesNodeModules(moduleResolution: ModuleResolutionKind): boolean { - return moduleResolution === ModuleResolutionKind.NodeJs || moduleResolution >= ModuleResolutionKind.Node12 && moduleResolution <= ModuleResolutionKind.NodeNext; + return moduleResolution === ModuleResolutionKind.NodeJs || moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; } export function makeImportIfNecessary(defaultImport: Identifier | undefined, namedImports: readonly ImportSpecifier[] | undefined, moduleSpecifier: string, quotePreference: QuotePreference): ImportDeclaration | undefined { diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 401c5aeb68a..b3457e3f031 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -154,6 +154,7 @@ "unittests/tsc/incremental.ts", "unittests/tsc/listFilesOnly.ts", "unittests/tsc/projectReferences.ts", + "unittests/tsc/redirect.ts", "unittests/tsc/runWithoutArgs.ts", "unittests/tscWatch/consoleClearing.ts", "unittests/tscWatch/emit.ts", diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 0c9a9fd954b..e2b48977106 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -159,7 +159,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'.", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -237,7 +237,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node12', 'nodenext'.", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts index 9c560a1bd6f..d8caa8997e7 100644 --- a/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts +++ b/src/testRunner/unittests/tsbuild/moduleSpecifiers.ts @@ -89,7 +89,7 @@ namespace ts { }); }); - // https://github.com/microsoft/TypeScript/issues/44434 but with `module: node12`, some `exports` maps blocking direct access, and no `baseUrl` + // https://github.com/microsoft/TypeScript/issues/44434 but with `module: node16`, some `exports` maps blocking direct access, and no `baseUrl` describe("unittests:: tsbuild:: moduleSpecifiers:: synthesized module specifiers across referenced projects resolve correctly", () => { verifyTsc({ scenario: "moduleSpecifiers", @@ -140,7 +140,7 @@ namespace ts { { "compilerOptions": { "declaration": true, - "module": "node12" + "module": "node16" } }`, "/src/src-types/package.json": Utils.dedent` @@ -178,7 +178,7 @@ namespace ts { }`, }, ""), modifyFs: fs => { - fs.writeFileSync("/lib/lib.es2020.full.d.ts", tscWatch.libFile.content); + fs.writeFileSync("/lib/lib.es2022.full.d.ts", tscWatch.libFile.content); fs.symlinkSync("/src", "/src/src-types/node_modules"); fs.symlinkSync("/src", "/src/src-dogs/node_modules"); }, diff --git a/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts b/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts index 17398988cc6..597ae19dcf4 100644 --- a/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts @@ -77,7 +77,7 @@ namespace ts.tscWatch { content: JSON.stringify({ compilerOptions: { outDir: "build", - module: "node12", + module: "node16", }, references: [{ path: "../pkg2" }] }) @@ -96,7 +96,7 @@ namespace ts.tscWatch { compilerOptions: { composite: true, outDir: "build", - module: "node12", + module: "node16", } }) }, @@ -113,7 +113,7 @@ namespace ts.tscWatch { path: `${projectRoot}/node_modules/pkg2`, symLink: `${projectRoot}/packages/pkg2`, }, - { ...libFile, path: `/a/lib/lib.es2020.full.d.ts` } + { ...libFile, path: `/a/lib/lib.es2022.full.d.ts` } ], { currentDirectory: projectRoot }), commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"], changes: [ diff --git a/src/testRunner/unittests/tsc/redirect.ts b/src/testRunner/unittests/tsc/redirect.ts new file mode 100644 index 00000000000..e131ba821af --- /dev/null +++ b/src/testRunner/unittests/tsc/redirect.ts @@ -0,0 +1,34 @@ +namespace ts { + describe("unittests:: tsc:: redirect::", () => { + verifyTsc({ + scenario: "redirect", + subScenario: "when redirecting ts file", + fs: () => loadProjectFromFiles({ + "/src/project/tsconfig.json": JSON.stringify({ + compilerOptions: { + outDir: "out" + }, + include: [ + "copy1/node_modules/target/*", + "copy2/node_modules/target/*", + ] + }), + "/src/project/copy1/node_modules/target/index.ts": "export const a = 1;", + "/src/project/copy1/node_modules/target/import.ts": `import {} from "./";`, + "/src/project/copy1/node_modules/target/package.json": JSON.stringify({ + name: "target", + version: "1.0.0", + main: "index.js", + }), + "/src/project/copy2/node_modules/target/index.ts": "export const a = 1;", + "/src/project/copy2/node_modules/target/import.ts": `import {} from "./";`, + "/src/project/copy2/node_modules/target/package.json": JSON.stringify({ + name: "target", + version: "1.0.0", + main: "index.js", + }), + }), + commandLineArgs: ["-p", "src/project"], + }); + }); +} diff --git a/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt index b64781a4873..4d680b362ac 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck13.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19): error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck13.ts(4,19 strSet.add('World') for (const str of strSet) { } ~~~~~~ -!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file +!!! error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt index 1fde67722db..e815c53e2f3 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck14.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts(2,17): error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck14.ts (1 errors) ==== var union: string | Set for (const e of union) { } ~~~~~ -!!! error TS2569: Type 'Set' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators. \ No newline at end of file +!!! error TS2802: Type 'Set' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 1e389228866..f7e45674ac0 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2893,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2902,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3074,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4818,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6822,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6841,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c1fc7000c4b..fb0a5a0c1e7 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2063,7 +2063,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls whether the + * When `module` is `Node16` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -2893,7 +2893,7 @@ declare namespace ts { export enum ModuleResolutionKind { Classic = 1, NodeJs = 2, - Node12 = 3, + Node16 = 3, NodeNext = 99 } export enum ModuleDetectionKind { @@ -2902,7 +2902,7 @@ declare namespace ts { */ Legacy = 1, /** - * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+ + * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ */ Auto = 2, /** @@ -3074,7 +3074,7 @@ declare namespace ts { ES2020 = 6, ES2022 = 7, ESNext = 99, - Node12 = 100, + Node16 = 100, NodeNext = 199 } export enum JsxEmit { @@ -4818,7 +4818,7 @@ declare namespace ts { /** * Controls the format the file is detected as - this can be derived from only the path * and files on disk, but needs to be done with a module resolution cache in scope to be performant. - * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`. + * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node16` or `nodenext`. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; /** @@ -6822,7 +6822,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. Only used if the file was not found * in the registry and a new one was created. @@ -6841,7 +6841,7 @@ declare namespace ts { * shape of a the resulting SourceFile. This allows the DocumentRegistry to store * multiple copies of the same file for different compilation settings. A minimal * resolution cache is needed to fully define a source file's shape when - * the compilation settings include `module: node12`+, so providing a cache host + * the compilation settings include `module: node16`+, so providing a cache host * object should be preferred. A common host is a language service `ConfiguredProject`. * @param scriptSnapshot Text of the file. * @param version Current version of the file. diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt index 0c8ac2b8ec9..f97a066c8c8 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -12,8 +12,8 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' tests/cases/compiler/awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/compiler/awaitInNonAsyncFunction.ts (16 errors) ==== @@ -97,7 +97,7 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level ' for await (const _ of []); ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. await null; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/completionsCommentsClass.baseline b/tests/baselines/reference/completionsCommentsClass.baseline index f7144af7e12..5dce64b756e 100644 --- a/tests/baselines/reference/completionsCommentsClass.baseline +++ b/tests/baselines/reference/completionsCommentsClass.baseline @@ -1340,7 +1340,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1453,7 +1453,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsClassMembers.baseline b/tests/baselines/reference/completionsCommentsClassMembers.baseline index 9a068cdbf28..6180976aaba 100644 --- a/tests/baselines/reference/completionsCommentsClassMembers.baseline +++ b/tests/baselines/reference/completionsCommentsClassMembers.baseline @@ -2369,7 +2369,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -2482,7 +2482,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -9430,7 +9430,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -9543,7 +9543,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -14244,7 +14244,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -14357,7 +14357,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -21305,7 +21305,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -21418,7 +21418,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -25370,7 +25370,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -25483,7 +25483,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -30591,7 +30591,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -30704,7 +30704,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -34610,7 +34610,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -34723,7 +34723,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -39785,7 +39785,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -39898,7 +39898,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -45006,7 +45006,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -45119,7 +45119,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -50227,7 +50227,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -50340,7 +50340,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -55448,7 +55448,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -55561,7 +55561,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -59508,7 +59508,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -59621,7 +59621,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -63568,7 +63568,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -63681,7 +63681,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -67628,7 +67628,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -67741,7 +67741,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -71688,7 +71688,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -71801,7 +71801,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -75748,7 +75748,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -75861,7 +75861,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -79808,7 +79808,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -79921,7 +79921,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -84209,7 +84209,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -84322,7 +84322,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -89567,7 +89567,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -89680,7 +89680,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -94181,7 +94181,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -94294,7 +94294,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsCommentParsing.baseline b/tests/baselines/reference/completionsCommentsCommentParsing.baseline index f03678262a7..d4a9a88a0a1 100644 --- a/tests/baselines/reference/completionsCommentsCommentParsing.baseline +++ b/tests/baselines/reference/completionsCommentsCommentParsing.baseline @@ -3203,7 +3203,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -3316,7 +3316,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -8852,7 +8852,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -8965,7 +8965,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -15271,7 +15271,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -15384,7 +15384,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -20816,7 +20816,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -20929,7 +20929,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -26715,7 +26715,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -26828,7 +26828,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -32364,7 +32364,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -32477,7 +32477,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -38704,7 +38704,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -38817,7 +38817,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline index 68e1b3d6ce0..3c056e5f263 100644 --- a/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionDeclaration.baseline @@ -1071,7 +1071,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1184,7 +1184,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -5343,7 +5343,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -5456,7 +5456,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -8859,7 +8859,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -8972,7 +8972,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline index 5be58374a3f..e153a2ecdaf 100644 --- a/tests/baselines/reference/completionsCommentsFunctionExpression.baseline +++ b/tests/baselines/reference/completionsCommentsFunctionExpression.baseline @@ -1247,7 +1247,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -1360,7 +1360,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -5175,7 +5175,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -5288,7 +5288,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -9793,7 +9793,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -9906,7 +9906,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] @@ -13493,7 +13493,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI.", + "text": "A value representing an unencoded URI.", "kind": "text" } ] @@ -13606,7 +13606,7 @@ "kind": "space" }, { - "text": "A value representing an encoded URI component.", + "text": "A value representing an unencoded URI component.", "kind": "text" } ] diff --git a/tests/baselines/reference/dependentDestructuredVariables.errors.txt b/tests/baselines/reference/dependentDestructuredVariables.errors.txt new file mode 100644 index 00000000000..fbddf80744c --- /dev/null +++ b/tests/baselines/reference/dependentDestructuredVariables.errors.txt @@ -0,0 +1,334 @@ +tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts(314,5): error TS7022: 'value1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts(314,5): error TS7031: Binding element 'value1' implicitly has an 'any' type. + + +==== tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts (2 errors) ==== + type Action = + | { kind: 'A', payload: number } + | { kind: 'B', payload: string }; + + function f10({ kind, payload }: Action) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + + function f11(action: Action) { + const { kind, payload } = action; + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + + function f12({ kind, payload }: Action) { + switch (kind) { + case 'A': + payload.toFixed(); + break; + case 'B': + payload.toUpperCase(); + break; + default: + payload; // never + } + } + + type Action2 = + | { kind: 'A', payload: number | undefined } + | { kind: 'B', payload: string | undefined }; + + function f20({ kind, payload }: Action2) { + if (payload) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f21(action: Action2) { + const { kind, payload } = action; + if (payload) { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f22(action: Action2) { + if (action.payload) { + const { kind, payload } = action; + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + } + } + + function f23({ kind, payload }: Action2) { + if (payload) { + switch (kind) { + case 'A': + payload.toFixed(); + break; + case 'B': + payload.toUpperCase(); + break; + default: + payload; // never + } + } + } + + type Foo = + | { kind: 'A', isA: true } + | { kind: 'B', isA: false } + | { kind: 'C', isA: false }; + + function f30({ kind, isA }: Foo) { + if (kind === 'A') { + isA; // true + } + if (kind === 'B') { + isA; // false + } + if (kind === 'C') { + isA; // false + } + if (isA) { + kind; // 'A' + } + else { + kind; // 'B' | 'C' + } + } + + type Args = ['A', number] | ['B', string] + + function f40(...[kind, data]: Args) { + if (kind === 'A') { + data.toFixed(); + } + if (kind === 'B') { + data.toUpperCase(); + } + } + + // Repro from #35283 + + interface A { variant: 'a', value: T } + + interface B { variant: 'b', value: Array } + + type AB = A | B; + + declare function printValue(t: T): void; + + declare function printValueList(t: Array): void; + + function unrefined1(ab: AB): void { + const { variant, value } = ab; + if (variant === 'a') { + printValue(value); + } + else { + printValueList(value); + } + } + + // Repro from #38020 + + type Action3 = + | {type: 'add', payload: { toAdd: number } } + | {type: 'remove', payload: { toRemove: number } }; + + const reducerBroken = (state: number, { type, payload }: Action3) => { + switch (type) { + case 'add': + return state + payload.toAdd; + case 'remove': + return state - payload.toRemove; + } + } + + // Repro from #46143 + + declare var it: Iterator; + const { value, done } = it.next(); + if (!done) { + value; // number + } + + // Repro from #46658 + + declare function f50(cb: (...args: Args) => void): void + + f50((kind, data) => { + if (kind === 'A') { + data.toFixed(); + } + if (kind === 'B') { + data.toUpperCase(); + } + }); + + const f51: (...args: ['A', number] | ['B', string]) => void = (kind, payload) => { + if (kind === 'A') { + payload.toFixed(); + } + if (kind === 'B') { + payload.toUpperCase(); + } + }; + + const f52: (...args: ['A', number] | ['B']) => void = (kind, payload?) => { + if (kind === 'A') { + payload.toFixed(); + } + else { + payload; // undefined + } + }; + + declare function readFile(path: string, callback: (...args: [err: null, data: unknown[]] | [err: Error, data: undefined]) => void): void; + + readFile('hello', (err, data) => { + if (err === null) { + data.length; + } + else { + err.message; + } + }); + + type ReducerArgs = ["add", { a: number, b: number }] | ["concat", { firstArr: any[], secondArr: any[] }]; + + const reducer: (...args: ReducerArgs) => void = (op, args) => { + switch (op) { + case "add": + console.log(args.a + args.b); + break; + case "concat": + console.log(args.firstArr.concat(args.secondArr)); + break; + } + } + + reducer("add", { a: 1, b: 3 }); + reducer("concat", { firstArr: [1, 2], secondArr: [3, 4] }); + + // repro from https://github.com/microsoft/TypeScript/pull/47190#issuecomment-1057603588 + + type FooMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): void; + } + + let fooM: FooMethod = { + method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooAsyncMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): Promise; + } + + let fooAsyncM: FooAsyncMethod = { + async method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooGenMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): Generator; + } + + let fooGenM: FooGenMethod = { + *method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + type FooAsyncGenMethod = { + method(...args: + [type: "str", cb: (e: string) => void] | + [type: "num", cb: (e: number) => void] + ): AsyncGenerator; + } + + let fooAsyncGenM: FooAsyncGenMethod = { + async *method(type, cb) { + if (type == 'num') { + cb(123) + } else { + cb("abc") + } + } + }; + + // Repro from #48345 + + type Func = (...args: T) => void; + + const f60: Func = (kind, payload) => { + if (kind === "a") { + payload.toFixed(); // error + } + if (kind === "b") { + payload.toUpperCase(); // error + } + }; + + // Repro from #48902 + + function foo({ + value1, + ~~~~~~ +!!! error TS7022: 'value1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + ~~~~~~ +!!! error TS7031: Binding element 'value1' implicitly has an 'any' type. + test1 = value1.test1, + test2 = value1.test2, + test3 = value1.test3, + test4 = value1.test4, + test5 = value1.test5, + test6 = value1.test6, + test7 = value1.test7, + test8 = value1.test8, + test9 = value1.test9 + }) {} + \ No newline at end of file diff --git a/tests/baselines/reference/dependentDestructuredVariables.js b/tests/baselines/reference/dependentDestructuredVariables.js index a9f2006ec1e..eab12767faf 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.js +++ b/tests/baselines/reference/dependentDestructuredVariables.js @@ -308,6 +308,21 @@ const f60: Func = (kind, payload) => { payload.toUpperCase(); // error } }; + +// Repro from #48902 + +function foo({ + value1, + test1 = value1.test1, + test2 = value1.test2, + test3 = value1.test3, + test4 = value1.test4, + test5 = value1.test5, + test6 = value1.test6, + test7 = value1.test7, + test8 = value1.test8, + test9 = value1.test9 +}) {} //// [dependentDestructuredVariables.js] @@ -550,6 +565,8 @@ const f60 = (kind, payload) => { payload.toUpperCase(); // error } }; +// Repro from #48902 +function foo({ value1, test1 = value1.test1, test2 = value1.test2, test3 = value1.test3, test4 = value1.test4, test5 = value1.test5, test6 = value1.test6, test7 = value1.test7, test8 = value1.test8, test9 = value1.test9 }) { } //// [dependentDestructuredVariables.d.ts] @@ -667,3 +684,15 @@ declare type FooAsyncGenMethod = { declare let fooAsyncGenM: FooAsyncGenMethod; declare type Func = (...args: T) => void; declare const f60: Func; +declare function foo({ value1, test1, test2, test3, test4, test5, test6, test7, test8, test9 }: { + value1: any; + test1?: any; + test2?: any; + test3?: any; + test4?: any; + test5?: any; + test6?: any; + test7?: any; + test8?: any; + test9?: any; +}): void; diff --git a/tests/baselines/reference/dependentDestructuredVariables.symbols b/tests/baselines/reference/dependentDestructuredVariables.symbols index f859b5ee756..ccaaaa72fe9 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.symbols +++ b/tests/baselines/reference/dependentDestructuredVariables.symbols @@ -784,3 +784,49 @@ const f60: Func = (kind, payload) => { } }; +// Repro from #48902 + +function foo({ +>foo : Symbol(foo, Decl(dependentDestructuredVariables.ts, 308, 2)) + + value1, +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test1 = value1.test1, +>test1 : Symbol(test1, Decl(dependentDestructuredVariables.ts, 313, 11)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test2 = value1.test2, +>test2 : Symbol(test2, Decl(dependentDestructuredVariables.ts, 314, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test3 = value1.test3, +>test3 : Symbol(test3, Decl(dependentDestructuredVariables.ts, 315, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test4 = value1.test4, +>test4 : Symbol(test4, Decl(dependentDestructuredVariables.ts, 316, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test5 = value1.test5, +>test5 : Symbol(test5, Decl(dependentDestructuredVariables.ts, 317, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test6 = value1.test6, +>test6 : Symbol(test6, Decl(dependentDestructuredVariables.ts, 318, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test7 = value1.test7, +>test7 : Symbol(test7, Decl(dependentDestructuredVariables.ts, 319, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test8 = value1.test8, +>test8 : Symbol(test8, Decl(dependentDestructuredVariables.ts, 320, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + + test9 = value1.test9 +>test9 : Symbol(test9, Decl(dependentDestructuredVariables.ts, 321, 25)) +>value1 : Symbol(value1, Decl(dependentDestructuredVariables.ts, 312, 14)) + +}) {} + diff --git a/tests/baselines/reference/dependentDestructuredVariables.types b/tests/baselines/reference/dependentDestructuredVariables.types index 440c42a3827..f3f90242313 100644 --- a/tests/baselines/reference/dependentDestructuredVariables.types +++ b/tests/baselines/reference/dependentDestructuredVariables.types @@ -891,3 +891,67 @@ const f60: Func = (kind, payload) => { } }; +// Repro from #48902 + +function foo({ +>foo : ({ value1, test1, test2, test3, test4, test5, test6, test7, test8, test9 }: { value1: any; test1?: any; test2?: any; test3?: any; test4?: any; test5?: any; test6?: any; test7?: any; test8?: any; test9?: any; }) => void + + value1, +>value1 : any + + test1 = value1.test1, +>test1 : any +>value1.test1 : any +>value1 : any +>test1 : any + + test2 = value1.test2, +>test2 : any +>value1.test2 : any +>value1 : any +>test2 : any + + test3 = value1.test3, +>test3 : any +>value1.test3 : any +>value1 : any +>test3 : any + + test4 = value1.test4, +>test4 : any +>value1.test4 : any +>value1 : any +>test4 : any + + test5 = value1.test5, +>test5 : any +>value1.test5 : any +>value1 : any +>test5 : any + + test6 = value1.test6, +>test6 : any +>value1.test6 : any +>value1 : any +>test6 : any + + test7 = value1.test7, +>test7 : any +>value1.test7 : any +>value1 : any +>test7 : any + + test8 = value1.test8, +>test8 : any +>value1.test8 : any +>value1 : any +>test8 : any + + test9 = value1.test9 +>test9 : any +>value1.test9 : any +>value1 : any +>test9 : any + +}) {} + diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js new file mode 100644 index 00000000000..8aed6c9347a --- /dev/null +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js @@ -0,0 +1,27 @@ +//// [a.ts] +declare var dec: any, __decorate: any; +@dec export class A { +} + +const o = { a: 1 }; +const y = { ...o }; + + +//// [a.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.A = void 0; +let A = class A { +}; +A = __decorate([ + dec +], A); +exports.A = A; +const o = { a: 1 }; +const y = Object.assign({}, o); diff --git a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt index 6d7b87ebd33..b00dfc3c328 100644 --- a/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt +++ b/tests/baselines/reference/genericUnboundedTypeParamAssignability.errors.txt @@ -1,10 +1,8 @@ tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(2,5): error TS2339: Property 'toString' does not exist on type 'T'. -tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(15,6): error TS2345: Argument of type 'T' is not assignable to parameter of type '{}'. -tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(16,6): error TS2345: Argument of type 'T' is not assignable to parameter of type 'Record'. tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(17,5): error TS2339: Property 'toString' does not exist on type 'T'. -==== tests/cases/compiler/genericUnboundedTypeParamAssignability.ts (4 errors) ==== +==== tests/cases/compiler/genericUnboundedTypeParamAssignability.ts (2 errors) ==== function f1(o: T) { o.toString(); // error ~~~~~~~~ @@ -22,13 +20,7 @@ tests/cases/compiler/genericUnboundedTypeParamAssignability.ts(17,5): error TS23 function user(t: T) { f1(t); f2(t); // error in strict, unbounded T doesn't satisfy the constraint - ~ -!!! error TS2345: Argument of type 'T' is not assignable to parameter of type '{}'. -!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint. f3(t); // error in strict, unbounded T doesn't satisfy the constraint - ~ -!!! error TS2345: Argument of type 'T' is not assignable to parameter of type 'Record'. -!!! related TS2208 tests/cases/compiler/genericUnboundedTypeParamAssignability.ts:13:15: This type parameter probably needs an `extends object` constraint. t.toString(); // error, for the same reason as f1() ~~~~~~~~ !!! error TS2339: Property 'toString' does not exist on type 'T'. diff --git a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt index fa365df88cd..b7a88e8ce62 100644 --- a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt @@ -3,14 +3,14 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(8,11): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments -tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comma not allowed. @@ -49,29 +49,29 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm const a = import('./0') const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const dd = import('./0', {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const f = import() ~~~~~~~~ !!! message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments const g = import('./0', {}, {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. ~ !!! error TS1009: Trailing comma not allowed. diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt index fb959409350..266938cb7cd 100644 --- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt @@ -3,15 +3,15 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -48,31 +48,31 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor ==== tests/cases/conformance/importAssertion/3.ts (9 errors) ==== const a = import('./0') ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const dd = import('./0', {}) ~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const f = import() ~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const g = import('./0', {}, {}) ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt index 43821679002..5fbfb92fa50 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,10 +9,10 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports ==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ==== import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. var p1 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. p1.then(zero => { return zero.foo(); }) @@ -20,5 +20,5 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports function foo() { const p2 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt index 063b200b672..ee698678c3c 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt +++ b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Argument of dynamic import cannot be spread element. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. -tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. @@ -25,6 +25,6 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): ~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~ !!! error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt index 5e37388bc02..de342b78047 100644 --- a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt index 5e37388bc02..de342b78047 100644 --- a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt index 65b8a2d631e..53920e46540 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1326: Dynamic import cannot have type arguments. -tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: Dynamic import cannot have type arguments. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. +tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/1.ts(3,10): error TS1326: Dynamic import c "use strict" var p1 = import>("./0"); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1326: Dynamic import cannot have type arguments. +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. var p2 = import<>("./0"); // error ~~~~~~~~~~~~~~~ -!!! error TS1326: Dynamic import cannot have type arguments. \ No newline at end of file +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt index 9c82043ec74..2f65f3fc12c 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt index 9c82043ec74..2f65f3fc12c 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importWithTypeArguments.errors.txt b/tests/baselines/reference/importWithTypeArguments.errors.txt new file mode 100644 index 00000000000..2981a63bec7 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/import/importWithTypeArguments.ts(1,1): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. +tests/cases/conformance/types/import/importWithTypeArguments.ts(2,11): error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + + +==== tests/cases/conformance/types/import/importWithTypeArguments.ts (2 errors) ==== + import + ~~~~~~~~~ +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + const a = import + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1326: This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments. + \ No newline at end of file diff --git a/tests/baselines/reference/importWithTypeArguments.js b/tests/baselines/reference/importWithTypeArguments.js new file mode 100644 index 00000000000..9a54a823050 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.js @@ -0,0 +1,8 @@ +//// [importWithTypeArguments.ts] +import +const a = import + + +//// [importWithTypeArguments.js] +import; +var a = (import); diff --git a/tests/baselines/reference/importWithTypeArguments.symbols b/tests/baselines/reference/importWithTypeArguments.symbols new file mode 100644 index 00000000000..5f769bb1978 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/types/import/importWithTypeArguments.ts === +import +>T : Symbol(T) + +const a = import +>a : Symbol(a, Decl(importWithTypeArguments.ts, 1, 5)) + diff --git a/tests/baselines/reference/importWithTypeArguments.types b/tests/baselines/reference/importWithTypeArguments.types new file mode 100644 index 00000000000..442b3cc9ed9 --- /dev/null +++ b/tests/baselines/reference/importWithTypeArguments.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/types/import/importWithTypeArguments.ts === +import +const a = import +>a : any + diff --git a/tests/baselines/reference/jsdocLink3.baseline b/tests/baselines/reference/jsdocLink3.baseline index da1a6fa0cfb..039d48a13af 100644 --- a/tests/baselines/reference/jsdocLink3.baseline +++ b/tests/baselines/reference/jsdocLink3.baseline @@ -59,10 +59,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -87,10 +87,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -110,10 +110,10 @@ "text": "C()", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -133,10 +133,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, @@ -181,10 +181,10 @@ "text": "C", "kind": "linkName", "target": { - "fileName": "/jsdocLink3.ts", + "fileName": "/module1.ts", "textSpan": { - "start": 0, - "length": 18 + "start": 9, + "length": 1 } } }, diff --git a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess.errors.txt deleted file mode 100644 index f5c436bbf1d..00000000000 --- a/tests/baselines/reference/keyofAndIndexedAccess.errors.txt +++ /dev/null @@ -1,709 +0,0 @@ -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(316,5): error TS2322: Type 'T' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(317,5): error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'. - Type 'T[string]' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(318,5): error TS2322: Type 'T[K]' is not assignable to type '{}'. - Type 'T[keyof T]' is not assignable to type '{}'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(323,5): error TS2322: Type 'T' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(324,5): error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(325,5): error TS2322: Type 'T[K]' is not assignable to type '{} | null | undefined'. - Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(611,33): error TS2345: Argument of type 'T[K]' is not assignable to parameter of type '{} | null | undefined'. - Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. -tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts(619,13): error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. - Type 'T[string]' is not assignable to type '{} | null | undefined'. - - -==== tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts (8 errors) ==== - class Shape { - name: string; - width: number; - height: number; - visible: boolean; - } - - class TaggedShape extends Shape { - tag: string; - } - - class Item { - name: string; - price: number; - } - - class Options { - visible: "yes" | "no"; - } - - type Dictionary = { [x: string]: T }; - type NumericallyIndexed = { [x: number]: T }; - - const enum E { A, B, C } - - type K00 = keyof any; // string - type K01 = keyof string; // "toString" | "charAt" | ... - type K02 = keyof number; // "toString" | "toFixed" | "toExponential" | ... - type K03 = keyof boolean; // "valueOf" - type K04 = keyof void; // never - type K05 = keyof undefined; // never - type K06 = keyof null; // never - type K07 = keyof never; // string | number | symbol - type K08 = keyof unknown; // never - - type K10 = keyof Shape; // "name" | "width" | "height" | "visible" - type K11 = keyof Shape[]; // "length" | "toString" | ... - type K12 = keyof Dictionary; // string - type K13 = keyof {}; // never - type K14 = keyof Object; // "constructor" | "toString" | ... - type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... - type K16 = keyof [string, number]; // "0" | "1" | "length" | "toString" | ... - type K17 = keyof (Shape | Item); // "name" - type K18 = keyof (Shape & Item); // "name" | "width" | "height" | "visible" | "price" - type K19 = keyof NumericallyIndexed // never - - type KeyOf = keyof T; - - type K20 = KeyOf; // "name" | "width" | "height" | "visible" - type K21 = KeyOf>; // string - - type NAME = "name"; - type WIDTH_OR_HEIGHT = "width" | "height"; - - type Q10 = Shape["name"]; // string - type Q11 = Shape["width" | "height"]; // number - type Q12 = Shape["name" | "visible"]; // string | boolean - - type Q20 = Shape[NAME]; // string - type Q21 = Shape[WIDTH_OR_HEIGHT]; // number - - type Q30 = [string, number][0]; // string - type Q31 = [string, number][1]; // number - type Q32 = [string, number][number]; // string | number - type Q33 = [string, number][E.A]; // string - type Q34 = [string, number][E.B]; // number - type Q35 = [string, number]["0"]; // string - type Q36 = [string, number]["1"]; // string - - type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no" - type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no" - - type Q50 = Dictionary["howdy"]; // Shape - type Q51 = Dictionary[123]; // Shape - type Q52 = Dictionary[E.B]; // Shape - - declare let cond: boolean; - - function getProperty(obj: T, key: K) { - return obj[key]; - } - - function setProperty(obj: T, key: K, value: T[K]) { - obj[key] = value; - } - - function f10(shape: Shape) { - let name = getProperty(shape, "name"); // string - let widthOrHeight = getProperty(shape, cond ? "width" : "height"); // number - let nameOrVisible = getProperty(shape, cond ? "name" : "visible"); // string | boolean - setProperty(shape, "name", "rectangle"); - setProperty(shape, cond ? "width" : "height", 10); - setProperty(shape, cond ? "name" : "visible", true); // Technically not safe - } - - function f11(a: Shape[]) { - let len = getProperty(a, "length"); // number - setProperty(a, "length", len); - } - - function f12(t: [Shape, boolean]) { - let len = getProperty(t, "length"); - let s2 = getProperty(t, "0"); // Shape - let b2 = getProperty(t, "1"); // boolean - } - - function f13(foo: any, bar: any) { - let x = getProperty(foo, "x"); // any - let y = getProperty(foo, "100"); // any - let z = getProperty(foo, bar); // any - } - - class Component { - props: PropType; - getProperty(key: K) { - return this.props[key]; - } - setProperty(key: K, value: PropType[K]) { - this.props[key] = value; - } - } - - function f20(component: Component) { - let name = component.getProperty("name"); // string - let widthOrHeight = component.getProperty(cond ? "width" : "height"); // number - let nameOrVisible = component.getProperty(cond ? "name" : "visible"); // string | boolean - component.setProperty("name", "rectangle"); - component.setProperty(cond ? "width" : "height", 10) - component.setProperty(cond ? "name" : "visible", true); // Technically not safe - } - - function pluck(array: T[], key: K) { - return array.map(x => x[key]); - } - - function f30(shapes: Shape[]) { - let names = pluck(shapes, "name"); // string[] - let widths = pluck(shapes, "width"); // number[] - let nameOrVisibles = pluck(shapes, cond ? "name" : "visible"); // (string | boolean)[] - } - - function f31(key: K) { - const shape: Shape = { name: "foo", width: 5, height: 10, visible: true }; - return shape[key]; // Shape[K] - } - - function f32(key: K) { - const shape: Shape = { name: "foo", width: 5, height: 10, visible: true }; - return shape[key]; // Shape[K] - } - - function f33(shape: S, key: K) { - let name = getProperty(shape, "name"); - let prop = getProperty(shape, key); - return prop; - } - - function f34(ts: TaggedShape) { - let tag1 = f33(ts, "tag"); - let tag2 = getProperty(ts, "tag"); - } - - class C { - public x: string; - protected y: string; - private z: string; - } - - // Indexed access expressions have always permitted access to private and protected members. - // For consistency we also permit such access in indexed access types. - function f40(c: C) { - type X = C["x"]; - type Y = C["y"]; - type Z = C["z"]; - let x: X = c["x"]; - let y: Y = c["y"]; - let z: Z = c["z"]; - } - - function f50(k: keyof T, s: string) { - const x1 = s as keyof T; - const x2 = k as string; - } - - function f51(k: K, s: string) { - const x1 = s as keyof T; - const x2 = k as string; - } - - function f52(obj: { [x: string]: boolean }, k: Exclude, s: string, n: number) { - const x1 = obj[s]; - const x2 = obj[n]; - const x3 = obj[k]; - } - - function f53>(obj: { [x: string]: boolean }, k: K, s: string, n: number) { - const x1 = obj[s]; - const x2 = obj[n]; - const x3 = obj[k]; - } - - function f54(obj: T, key: keyof T) { - for (let s in obj[key]) { - } - const b = "foo" in obj[key]; - } - - function f55(obj: T, key: K) { - for (let s in obj[key]) { - } - const b = "foo" in obj[key]; - } - - function f60(source: T, target: T) { - for (let k in source) { - target[k] = source[k]; - } - } - - function f70(func: (k1: keyof (T | U), k2: keyof (T & U)) => void) { - func<{ a: any, b: any }, { a: any, c: any }>('a', 'a'); - func<{ a: any, b: any }, { a: any, c: any }>('a', 'b'); - func<{ a: any, b: any }, { a: any, c: any }>('a', 'c'); - } - - function f71(func: (x: T, y: U) => Partial) { - let x = func({ a: 1, b: "hello" }, { c: true }); - x.a; // number | undefined - x.b; // string | undefined - x.c; // boolean | undefined - } - - function f72(func: (x: T, y: U, k: K) => (T & U)[K]) { - let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string - let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean - } - - function f73(func: (x: T, y: U, k: K) => (T & U)[K]) { - let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string - let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean - } - - function f74(func: (x: T, y: U, k: K) => (T | U)[K]) { - let a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number - let b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean - } - - function f80(obj: T) { - let a1 = obj.a; // { x: any } - let a2 = obj['a']; // { x: any } - let a3 = obj['a'] as T['a']; // T["a"] - let x1 = obj.a.x; // any - let x2 = obj['a']['x']; // any - let x3 = obj['a']['x'] as T['a']['x']; // T["a"]["x"] - } - - function f81(obj: T) { - return obj['a']['x'] as T['a']['x']; - } - - function f82() { - let x1 = f81({ a: { x: "hello" } }); // string - let x2 = f81({ a: { x: 42 } }); // number - } - - function f83(obj: T, key: K) { - return obj[key]['x'] as T[K]['x']; - } - - function f84() { - let x1 = f83({ foo: { x: "hello" } }, "foo"); // string - let x2 = f83({ bar: { x: 42 } }, "bar"); // number - } - - class C1 { - x: number; - get(key: K) { - return this[key]; - } - set(key: K, value: this[K]) { - this[key] = value; - } - foo() { - let x1 = this.x; // number - let x2 = this["x"]; // number - let x3 = this.get("x"); // this["x"] - let x4 = getProperty(this, "x"); // this["x"] - this.x = 42; - this["x"] = 42; - this.set("x", 42); - setProperty(this, "x", 42); - } - } - - type S2 = { - a: string; - b: string; - }; - - function f90(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) { - x1 = x2; - x1 = x3; - x2 = x1; - x2 = x3; - x3 = x1; - x3 = x2; - x1.length; - x2.length; - x3.length; - } - - function f91(x: T, y: T[keyof T], z: T[K]) { - let a: {}; - a = x; - ~ -!!! error TS2322: Type 'T' is not assignable to type '{}'. -!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:314:14: This type parameter probably needs an `extends object` constraint. - a = y; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{}'. - a = z; - ~ -!!! error TS2322: Type 'T[K]' is not assignable to type '{}'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{}'. - } - - function f92(x: T, y: T[keyof T], z: T[K]) { - let a: {} | null | undefined; - a = x; - ~ -!!! error TS2322: Type 'T' is not assignable to type '{} | null | undefined'. -!!! related TS2208 tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts:321:14: This type parameter probably needs an `extends object` constraint. - a = y; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{} | null | undefined'. - a = z; - ~ -!!! error TS2322: Type 'T[K]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. - } - - // Repros from #12011 - - class Base { - get(prop: K) { - return this[prop]; - } - set(prop: K, value: this[K]) { - this[prop] = value; - } - } - - class Person extends Base { - parts: number; - constructor(parts: number) { - super(); - this.set("parts", parts); - } - getParts() { - return this.get("parts") - } - } - - class OtherPerson { - parts: number; - constructor(parts: number) { - setProperty(this, "parts", parts); - } - getParts() { - return getProperty(this, "parts") - } - } - - // Modified repro from #12544 - - function path(obj: T, key1: K1): T[K1]; - function path(obj: T, key1: K1, key2: K2): T[K1][K2]; - function path(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3]; - function path(obj: any, ...keys: (string | number)[]): any; - function path(obj: any, ...keys: (string | number)[]): any { - let result = obj; - for (let k of keys) { - result = result[k]; - } - return result; - } - - type Thing = { - a: { x: number, y: string }, - b: boolean - }; - - - function f1(thing: Thing) { - let x1 = path(thing, 'a'); // { x: number, y: string } - let x2 = path(thing, 'a', 'y'); // string - let x3 = path(thing, 'b'); // boolean - let x4 = path(thing, ...['a', 'x']); // any - } - - // Repro from comment in #12114 - - const assignTo2 = (object: T, key1: K1, key2: K2) => - (value: T[K1][K2]) => object[key1][key2] = value; - - // Modified repro from #12573 - - declare function one(handler: (t: T) => void): T - var empty = one(() => {}) // inferred as {}, expected - - type Handlers = { [K in keyof T]: (t: T[K]) => void } - declare function on(handlerHash: Handlers): T - var hashOfEmpty1 = on({ test: () => {} }); // {} - var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean } - - // Repro from #12624 - - interface Options1 { - data?: Data - computed?: Computed; - } - - declare class Component1 { - constructor(options: Options1); - get(key: K): (Data & Computed)[K]; - } - - let c1 = new Component1({ - data: { - hello: "" - } - }); - - c1.get("hello"); - - // Repro from #12625 - - interface Options2 { - data?: Data - computed?: Computed; - } - - declare class Component2 { - constructor(options: Options2); - get(key: K): (Data & Computed)[K]; - } - - // Repro from #12641 - - interface R { - p: number; - } - - function f(p: K) { - let a: any; - a[p].add; // any - } - - // Repro from #12651 - - type MethodDescriptor = { - name: string; - args: any[]; - returnValue: any; - } - - declare function dispatchMethod(name: M['name'], args: M['args']): M['returnValue']; - - type SomeMethodDescriptor = { - name: "someMethod"; - args: [string, number]; - returnValue: string[]; - } - - let result = dispatchMethod("someMethod", ["hello", 35]); - - // Repro from #13073 - - type KeyTypes = "a" | "b" - let MyThingy: { [key in KeyTypes]: string[] }; - - function addToMyThingy(key: S) { - MyThingy[key].push("a"); - } - - // Repro from #13102 - - type Handler = { - onChange: (name: keyof T) => void; - }; - - function onChangeGenericFunction(handler: Handler) { - handler.onChange('preset') - } - - // Repro from #13285 - - function updateIds, K extends string>( - obj: T, - idFields: K[], - idMapping: Partial> - ): Record { - for (const idField of idFields) { - const newId: T[K] | undefined = idMapping[obj[idField]]; - if (newId) { - obj[idField] = newId; - } - } - return obj; - } - - // Repro from #13285 - - function updateIds2( - obj: T, - key: K, - stringMap: { [oldId: string]: string } - ) { - var x = obj[key]; - stringMap[x]; // Should be OK. - } - - // Repro from #13514 - - declare function head>(list: T): T[0]; - - // Repro from #13604 - - class A { - props: T & { foo: string }; - } - - class B extends A<{ x: number}> { - f(p: this["props"]) { - p.x; - } - } - - // Repro from #13749 - - class Form { - private childFormFactories: {[K in keyof T]: (v: T[K]) => Form} - - public set(prop: K, value: T[K]) { - this.childFormFactories[prop](value) - } - } - - // Repro from #13787 - - class SampleClass

{ - public props: Readonly

; - constructor(props: P) { - this.props = Object.freeze(props); - } - } - - interface Foo { - foo: string; - } - - declare function merge(obj1: T, obj2: U): T & U; - - class AnotherSampleClass extends SampleClass { - constructor(props: T) { - const foo: Foo = { foo: "bar" }; - super(merge(props, foo)); - } - - public brokenMethod() { - this.props.foo.concat; - } - } - new AnotherSampleClass({}); - - // Positive repro from #17166 - function f3>(t: T, k: K, tk: T[K]): void { - for (let key in t) { - key = k // ok, K ==> keyof T - t[key] = tk; // ok, T[K] ==> T[keyof T] - } - } - - // # 21185 - type Predicates = { - [T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T] - } - - // Repros from #23592 - - type Example = { [K in keyof T]: T[K]["prop"] }; - type Result = Example<{ a: { prop: string }; b: { prop: number } }>; - - type Helper2 = { [K in keyof T]: Extract }; - type Example2 = { [K in keyof Helper2]: Helper2[K]["prop"] }; - type Result2 = Example2<{ 1: { prop: string }; 2: { prop: number } }>; - - // Repro from #23618 - - type DBBoolTable = { [k in K]: 0 | 1 } - enum Flag { - FLAG_1 = "flag_1", - FLAG_2 = "flag_2" - } - - type SimpleDBRecord = { staticField: number } & DBBoolTable - function getFlagsFromSimpleRecord(record: SimpleDBRecord, flags: Flag[]) { - return record[flags[0]]; - } - - type DynamicDBRecord = ({ dynamicField: number } | { dynamicField: string }) & DBBoolTable - function getFlagsFromDynamicRecord(record: DynamicDBRecord, flags: Flag[]) { - return record[flags[0]]; - } - - // Repro from #21368 - - interface I { - foo: string; - } - - declare function take(p: T): void; - - function fn(o: T, k: K) { - take<{} | null | undefined>(o[k]); - ~~~~ -!!! error TS2345: Argument of type 'T[K]' is not assignable to parameter of type '{} | null | undefined'. -!!! error TS2345: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2345: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2345: Type 'T[string]' is not assignable to type '{} | null | undefined'. - take(o[k]); - } - - // Repro from #23133 - - class Unbounded { - foo(x: T[keyof T]) { - let y: {} | undefined | null = x; - ~ -!!! error TS2322: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{} | null | undefined'. -!!! error TS2322: Type 'T[string]' is not assignable to type '{} | null | undefined'. - } - } - - // Repro from #23940 - - interface I7 { - x: any; - } - type Foo7 = T; - declare function f7(type: K): Foo7; - - // Repro from #21770 - - type Dict = { [key in T]: number }; - type DictDict = { [key in V]: Dict }; - - function ff1(dd: DictDict, k1: V, k2: T): number { - return dd[k1][k2]; - } - - function ff2(dd: DictDict, k1: V, k2: T): number { - const d: Dict = dd[k1]; - return d[k2]; - } - - // Repro from #26409 - - const cf1 = (t: T, k: K) => - { - const s: string = t[k]; - t.cool; - }; - - const cf2 = (t: T, k: K) => - { - const s: string = t[k]; - t.cool; - }; - \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypesAndObjects.errors.txt b/tests/baselines/reference/mappedTypesAndObjects.errors.txt deleted file mode 100644 index c32fc58b370..00000000000 --- a/tests/baselines/reference/mappedTypesAndObjects.errors.txt +++ /dev/null @@ -1,54 +0,0 @@ -tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts(25,11): error TS2430: Interface 'E1' incorrectly extends interface 'Base'. - Types of property 'foo' are incompatible. - Type 'T' is not assignable to type '{ [key: string]: any; }'. - - -==== tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts (1 errors) ==== - function f1(x: Partial, y: Readonly) { - let obj: {}; - obj = x; - obj = y; - } - - function f2(x: Partial, y: Readonly) { - let obj: { [x: string]: any }; - obj = x; - obj = y; - } - - function f3(x: Partial) { - x = {}; - } - - // Repro from #12900 - - interface Base { - foo: { [key: string]: any }; - bar: any; - baz: any; - } - - interface E1 extends Base { - ~~ -!!! error TS2430: Interface 'E1' incorrectly extends interface 'Base'. -!!! error TS2430: Types of property 'foo' are incompatible. -!!! error TS2430: Type 'T' is not assignable to type '{ [key: string]: any; }'. -!!! related TS2208 tests/cases/conformance/types/mapped/mappedTypesAndObjects.ts:25:14: This type parameter probably needs an `extends object` constraint. - foo: T; - } - - interface Something { name: string, value: string }; - interface E2 extends Base { - foo: Partial; // or other mapped type - } - - interface E3 extends Base { - foo: Partial; // or other mapped type - } - - // Repro from #13747 - - class Form { - private values: {[P in keyof T]?: T[P]} = {} - } - \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).js b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).js new file mode 100644 index 00000000000..843190b26d3 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/moduleResolutionWithModule.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" +} +//// [entrypoint.d.ts] +export declare function thing(): void; +//// [index.ts] +import * as p from "pkg"; +p.thing(); + +//// [index.js] +"use strict"; +exports.__esModule = true; +var p = require("pkg"); +p.thing(); diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).symbols new file mode 100644 index 00000000000..8ab99790e5f --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : Symbol(p, Decl(index.ts, 0, 6)) + +p.thing(); +>p.thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) +>p : Symbol(p, Decl(index.ts, 0, 6)) +>thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).types b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).types new file mode 100644 index 00000000000..c49641fe551 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=commonjs,moduleresolution=node16).types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : () => void + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : typeof p + +p.thing(); +>p.thing() : void +>p.thing : () => void +>p : typeof p +>thing : () => void + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).errors.txt b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).errors.txt new file mode 100644 index 00000000000..dc0e81b0259 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/index.ts(1,20): error TS2307: Cannot find module 'pkg' or its corresponding type declarations. + + +==== tests/cases/compiler/node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" + } +==== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts (0 errors) ==== + export declare function thing(): void; +==== tests/cases/compiler/index.ts (1 errors) ==== + import * as p from "pkg"; + ~~~~~ +!!! error TS2307: Cannot find module 'pkg' or its corresponding type declarations. + p.thing(); \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).js new file mode 100644 index 00000000000..23844cf6bab --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/moduleResolutionWithModule.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" +} +//// [entrypoint.d.ts] +export declare function thing(): void; +//// [index.ts] +import * as p from "pkg"; +p.thing(); + +//// [index.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const p = __importStar(require("pkg")); +p.thing(); diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).symbols new file mode 100644 index 00000000000..40ac39fdf75 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : Symbol(p, Decl(index.ts, 0, 6)) + +p.thing(); +>p : Symbol(p, Decl(index.ts, 0, 6)) + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).types new file mode 100644 index 00000000000..45eed8eb127 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node).types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : () => void + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : any + +p.thing(); +>p.thing() : any +>p.thing : any +>p : any +>thing : any + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).js new file mode 100644 index 00000000000..23844cf6bab --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/moduleResolutionWithModule.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" +} +//// [entrypoint.d.ts] +export declare function thing(): void; +//// [index.ts] +import * as p from "pkg"; +p.thing(); + +//// [index.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const p = __importStar(require("pkg")); +p.thing(); diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).symbols new file mode 100644 index 00000000000..8ab99790e5f --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : Symbol(p, Decl(index.ts, 0, 6)) + +p.thing(); +>p.thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) +>p : Symbol(p, Decl(index.ts, 0, 6)) +>thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).types new file mode 100644 index 00000000000..c49641fe551 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=node16).types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : () => void + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : typeof p + +p.thing(); +>p.thing() : void +>p.thing : () => void +>p : typeof p +>thing : () => void + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).js b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).js new file mode 100644 index 00000000000..23844cf6bab --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/moduleResolutionWithModule.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" +} +//// [entrypoint.d.ts] +export declare function thing(): void; +//// [index.ts] +import * as p from "pkg"; +p.thing(); + +//// [index.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const p = __importStar(require("pkg")); +p.thing(); diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).symbols new file mode 100644 index 00000000000..8ab99790e5f --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : Symbol(p, Decl(index.ts, 0, 6)) + +p.thing(); +>p.thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) +>p : Symbol(p, Decl(index.ts, 0, 6)) +>thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).types b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).types new file mode 100644 index 00000000000..c49641fe551 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=node16,moduleresolution=nodenext).types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : () => void + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : typeof p + +p.thing(); +>p.thing() : void +>p.thing : () => void +>p : typeof p +>thing : () => void + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).js b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).js new file mode 100644 index 00000000000..23844cf6bab --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/moduleResolutionWithModule.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": "./entrypoint.js" +} +//// [entrypoint.d.ts] +export declare function thing(): void; +//// [index.ts] +import * as p from "pkg"; +p.thing(); + +//// [index.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const p = __importStar(require("pkg")); +p.thing(); diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).symbols b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).symbols new file mode 100644 index 00000000000..8ab99790e5f --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : Symbol(thing, Decl(entrypoint.d.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : Symbol(p, Decl(index.ts, 0, 6)) + +p.thing(); +>p.thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) +>p : Symbol(p, Decl(index.ts, 0, 6)) +>thing : Symbol(p.thing, Decl(entrypoint.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).types b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).types new file mode 100644 index 00000000000..c49641fe551 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithModule(module=nodenext,moduleresolution=node16).types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/node_modules/pkg/entrypoint.d.ts === +export declare function thing(): void; +>thing : () => void + +=== tests/cases/compiler/index.ts === +import * as p from "pkg"; +>p : typeof p + +p.thing(); +>p.thing() : void +>p.thing : () => void +>p : typeof p +>thing : () => void + diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt index 5f3cbbc121c..30a2033c2b1 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension1.errors.txt @@ -1,5 +1,5 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.mjs'? -/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'? +/src/bar.mts(3,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/foo.mts (0 errors) ==== @@ -11,8 +11,8 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".mjs" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.mjs'? import { baz } from "./baz"; // should error, ask for extension, no extension suggestion ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt index 0c753a10299..356bbda92dd 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension3.errors.txt @@ -1,4 +1,4 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.jsx'? +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'? ==== /src/foo.tsx (0 errors) ==== @@ -10,5 +10,5 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".jsx" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.jsx'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.jsx'? \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt index afd24269d69..917ae242e7a 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension4.errors.txt @@ -1,4 +1,4 @@ -/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.js'? +/src/bar.mts(2,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'? ==== /src/foo.tsx (0 errors) ==== @@ -10,5 +10,5 @@ // Extensionless relative path ES import in an ES module import { foo } from "./foo"; // should error, suggest adding ".js" ~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './foo.js'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './foo.js'? \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt index b4b0a89ae97..2660f052ec9 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension5.errors.txt @@ -1,8 +1,8 @@ -/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/buzz.mts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/buzz.mts (1 errors) ==== // Extensionless relative path dynamic import in an ES module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt index c990522c6c7..b857c4d7fbc 100644 --- a/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithoutExtension8.errors.txt @@ -1,8 +1,8 @@ -/src/bar.cts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +/src/bar.cts(2,8): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== /src/bar.cts (1 errors) ==== // Extensionless relative path dynamic import in a cjs module import("./foo").then(x => x); // should error, ask for extension ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt new file mode 100644 index 00000000000..bdf6aba250c --- /dev/null +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ==== + // esm format file + import * as self from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + self; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).js b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).js new file mode 100644 index 00000000000..aeafa06e281 --- /dev/null +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts] //// + +//// [index.js] +// esm format file +import * as self from "package"; +self; +//// [index.mjs] +// esm format file +import * as self from "package"; +self; +//// [index.cjs] +// esm format file +import * as self from "package"; +self; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} + +//// [index.js] +// esm format file +import * as self from "package"; +self; +//// [index.mjs] +// esm format file +import * as self from "package"; +self; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const self = __importStar(require("package")); +self; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).symbols b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).symbols new file mode 100644 index 00000000000..eb9fab3a89a --- /dev/null +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.js, 1, 6)) + +self; +>self : Symbol(self, Decl(index.js, 1, 6)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.mjs, 1, 6)) + +self; +>self : Symbol(self, Decl(index.mjs, 1, 6)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.cjs, 1, 6)) + +self; +>self : Symbol(self, Decl(index.cjs, 1, 6)) + diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).types b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).types new file mode 100644 index 00000000000..894b0d65103 --- /dev/null +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/allowJs/index.cjs === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + diff --git a/tests/baselines/reference/nodeModules1(module=node16).errors.txt b/tests/baselines/reference/nodeModules1(module=node16).errors.txt new file mode 100644 index 00000000000..e8bcd1c06a7 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node16).errors.txt @@ -0,0 +1,564 @@ +tests/cases/conformance/node/index.cts(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/index.cts(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.cts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.cts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.cts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.mts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/index.mts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.mts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.mts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.mts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/index.mts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.mts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.mts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.mts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.ts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/index.ts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.ts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.ts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.ts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/index.ts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.ts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.ts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.ts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.mts (27 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones should all fail - esm format files have no index resolution or extension resolution + import * as m13 from "./"; + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + import * as m15 from "./subfolder"; + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m16 from "./subfolder/"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m17 from "./subfolder/index"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + import * as m18 from "./subfolder2"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m19 from "./subfolder2/"; + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m20 from "./subfolder2/index"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + import m27 = require("./subfolder/"); + import m28 = require("./subfolder/index"); + import m29 = require("./subfolder2"); + import m30 = require("./subfolder2/"); + import m31 = require("./subfolder2/index"); + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.cts (27 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) + import * as m13 from "./"; + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m15 from "./subfolder"; + import * as m16 from "./subfolder/"; + import * as m17 from "./subfolder/index"; + import * as m18 from "./subfolder2"; + import * as m19 from "./subfolder2/"; + import * as m20 from "./subfolder2/index"; + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + import m27 = require("./subfolder/"); + import m28 = require("./subfolder/index"); + import m29 = require("./subfolder2"); + import m30 = require("./subfolder2/"); + import m31 = require("./subfolder2/index"); + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.ts (27 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones shouldn't all work - esm format files have no index resolution or extension resolution + import * as m13 from "./"; + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + import * as m15 from "./subfolder"; + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m16 from "./subfolder/"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m17 from "./subfolder/index"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + import * as m18 from "./subfolder2"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m19 from "./subfolder2/"; + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m20 from "./subfolder2/index"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + import m27 = require("./subfolder/"); + import m28 = require("./subfolder/index"); + import m29 = require("./subfolder2"); + import m30 = require("./subfolder2/"); + import m31 = require("./subfolder2/index"); + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModules1(module=node16).js b/tests/baselines/reference/nodeModules1(module=node16).js new file mode 100644 index 00000000000..5b6840498ef --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node16).js @@ -0,0 +1,700 @@ +//// [tests/cases/conformance/node/nodeModules1.ts] //// + +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; +//// [index.ts] +// esm format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); + +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// cjs format file +const x = 1; +export {x}; +//// [index.ts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM-format imports below should issue errors +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +const m13 = __importStar(require("./")); +const m14 = __importStar(require("./index")); +const m15 = __importStar(require("./subfolder")); +const m16 = __importStar(require("./subfolder/")); +const m17 = __importStar(require("./subfolder/index")); +const m18 = __importStar(require("./subfolder2")); +const m19 = __importStar(require("./subfolder2/")); +const m20 = __importStar(require("./subfolder2/index")); +const m21 = __importStar(require("./subfolder2/another")); +const m22 = __importStar(require("./subfolder2/another/")); +const m23 = __importStar(require("./subfolder2/another/index")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = require("./"); +const m25 = require("./index"); +const m26 = require("./subfolder"); +const m27 = require("./subfolder/"); +const m28 = require("./subfolder/index"); +const m29 = require("./subfolder2"); +const m30 = require("./subfolder2/"); +const m31 = require("./subfolder2/index"); +const m32 = require("./subfolder2/another"); +const m33 = require("./subfolder2/another/"); +const m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = __require("./"); +const m25 = __require("./index"); +const m26 = __require("./subfolder"); +const m27 = __require("./subfolder/"); +const m28 = __require("./subfolder/index"); +const m29 = __require("./subfolder2"); +const m30 = __require("./subfolder2/"); +const m31 = __require("./subfolder2/index"); +const m32 = __require("./subfolder2/another"); +const m33 = __require("./subfolder2/another/"); +const m34 = __require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export { x }; +//// [index.mjs] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = __require("./"); +const m25 = __require("./index"); +const m26 = __require("./subfolder"); +const m27 = __require("./subfolder/"); +const m28 = __require("./subfolder/index"); +const m29 = __require("./subfolder2"); +const m30 = __require("./subfolder2/"); +const m31 = __require("./subfolder2/index"); +const m32 = __require("./subfolder2/another"); +const m33 = __require("./subfolder2/another/"); +const m34 = __require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export { x }; + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=node16).symbols b/tests/baselines/reference/nodeModules1(module=node16).symbols new file mode 100644 index 00000000000..287b1e895d1 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node16).symbols @@ -0,0 +1,817 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.mts, 13, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.mts, 14, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.mts, 15, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.mts, 16, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.mts, 17, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.mts, 18, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.mts, 19, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.mts, 20, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.mts, 21, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.mts, 22, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.mts, 23, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.mts, 13, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.mts, 14, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.mts, 15, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.mts, 16, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.mts, 17, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.mts, 18, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.mts, 19, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.mts, 20, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.mts, 21, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.mts, 22, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.mts, 23, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.mts, 46, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.mts, 49, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.mts, 50, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.mts, 51, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.mts, 52, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.mts, 53, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.mts, 54, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.mts, 55, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.mts, 56, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.mts, 57, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.mts, 58, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.mts, 46, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.mts, 49, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.mts, 50, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.mts, 51, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.mts, 52, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.mts, 53, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.mts, 54, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.mts, 55, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.mts, 56, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.mts, 57, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.mts, 58, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.mts, 73, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.mts, 74, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.mts, 75, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.mts, 76, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.mts, 77, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.mts, 78, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.mts, 79, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.mts, 80, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.mts, 81, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.mts, 82, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.mts, 83, 5)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 86, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mts, 87, 8)) + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.cts, 14, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.cts, 15, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.cts, 16, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.cts, 17, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.cts, 18, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.cts, 19, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.cts, 20, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.cts, 21, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.cts, 22, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.cts, 23, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.cts, 24, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.cts, 14, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.cts, 15, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.cts, 16, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.cts, 17, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.cts, 18, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.cts, 19, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.cts, 20, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.cts, 21, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.cts, 22, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.cts, 23, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.cts, 24, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.cts, 47, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.cts, 50, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.cts, 51, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.cts, 52, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.cts, 53, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.cts, 54, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.cts, 55, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.cts, 56, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.cts, 57, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.cts, 58, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.cts, 59, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.cts, 47, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.cts, 50, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.cts, 51, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.cts, 52, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.cts, 53, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.cts, 54, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.cts, 55, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.cts, 56, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.cts, 57, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.cts, 58, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.cts, 59, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.cts, 74, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.cts, 75, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.cts, 76, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.cts, 77, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.cts, 78, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.cts, 79, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.cts, 80, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.cts, 81, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.cts, 82, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.cts, 83, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.cts, 84, 5)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 86, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cts, 87, 8)) + +=== tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.ts, 13, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.ts, 14, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.ts, 15, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.ts, 16, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.ts, 17, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.ts, 18, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.ts, 19, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.ts, 20, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.ts, 21, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.ts, 22, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.ts, 23, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.ts, 13, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.ts, 14, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.ts, 15, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.ts, 16, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.ts, 17, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.ts, 18, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.ts, 19, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.ts, 20, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.ts, 21, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.ts, 22, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.ts, 23, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.ts, 46, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.ts, 49, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.ts, 50, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.ts, 51, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.ts, 52, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.ts, 53, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.ts, 54, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.ts, 55, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.ts, 56, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.ts, 57, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.ts, 58, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.ts, 46, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.ts, 49, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.ts, 50, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.ts, 51, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.ts, 52, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.ts, 53, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.ts, 54, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.ts, 55, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.ts, 56, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.ts, 57, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.ts, 58, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.ts, 73, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.ts, 74, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.ts, 75, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.ts, 76, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.ts, 77, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.ts, 78, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.ts, 79, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.ts, 80, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.ts, 81, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.ts, 82, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.ts, 83, 5)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 85, 5)) + +export {x}; +>x : Symbol(m1.x, Decl(index.ts, 86, 8)) + diff --git a/tests/baselines/reference/nodeModules1(module=node16).types b/tests/baselines/reference/nodeModules1(module=node16).types new file mode 100644 index 00000000000..9f52683c7d7 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node16).types @@ -0,0 +1,997 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : any + +import * as m14 from "./index"; +>m14 : any + +import * as m15 from "./subfolder"; +>m15 : any + +import * as m16 from "./subfolder/"; +>m16 : any + +import * as m17 from "./subfolder/index"; +>m17 : any + +import * as m18 from "./subfolder2"; +>m18 : any + +import * as m19 from "./subfolder2/"; +>m19 : any + +import * as m20 from "./subfolder2/index"; +>m20 : any + +import * as m21 from "./subfolder2/another"; +>m21 : any + +import * as m22 from "./subfolder2/another/"; +>m22 : any + +import * as m23 from "./subfolder2/another/index"; +>m23 : any + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : any + +void m14; +>void m14 : undefined +>m14 : any + +void m15; +>void m15 : undefined +>m15 : any + +void m16; +>void m16 : undefined +>m16 : any + +void m17; +>void m17 : undefined +>m17 : any + +void m18; +>void m18 : undefined +>m18 : any + +void m19; +>void m19 : undefined +>m19 : any + +void m20; +>void m20 : undefined +>m20 : any + +void m21; +>void m21 : undefined +>m21 : any + +void m22; +>void m22 : undefined +>m22 : any + +void m23; +>void m23 : undefined +>m23 : any + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m26 + +import m27 = require("./subfolder/"); +>m27 : typeof m26 + +import m28 = require("./subfolder/index"); +>m28 : typeof m26 + +import m29 = require("./subfolder2"); +>m29 : typeof m29 + +import m30 = require("./subfolder2/"); +>m30 : typeof m29 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m29 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m26 + +void m27; +>void m27 : undefined +>m27 : typeof m26 + +void m28; +>void m28 : undefined +>m28 : typeof m26 + +void m29; +>void m29 : undefined +>m29 : typeof m29 + +void m30; +>void m30 : undefined +>m30 : typeof m29 + +void m31; +>void m31 : undefined +>m31 : typeof m29 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +>m13 : typeof m1 + +import * as m14 from "./index"; +>m14 : typeof m1 + +import * as m15 from "./subfolder"; +>m15 : typeof m4 + +import * as m16 from "./subfolder/"; +>m16 : typeof m4 + +import * as m17 from "./subfolder/index"; +>m17 : typeof m4 + +import * as m18 from "./subfolder2"; +>m18 : typeof m7 + +import * as m19 from "./subfolder2/"; +>m19 : typeof m7 + +import * as m20 from "./subfolder2/index"; +>m20 : typeof m7 + +import * as m21 from "./subfolder2/another"; +>m21 : typeof m10 + +import * as m22 from "./subfolder2/another/"; +>m22 : typeof m10 + +import * as m23 from "./subfolder2/another/index"; +>m23 : typeof m10 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : typeof m1 + +void m14; +>void m14 : undefined +>m14 : typeof m1 + +void m15; +>void m15 : undefined +>m15 : typeof m4 + +void m16; +>void m16 : undefined +>m16 : typeof m4 + +void m17; +>void m17 : undefined +>m17 : typeof m4 + +void m18; +>void m18 : undefined +>m18 : typeof m7 + +void m19; +>void m19 : undefined +>m19 : typeof m7 + +void m20; +>void m20 : undefined +>m20 : typeof m7 + +void m21; +>void m21 : undefined +>m21 : typeof m10 + +void m22; +>void m22 : undefined +>m22 : typeof m10 + +void m23; +>void m23 : undefined +>m23 : typeof m10 + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m4 + +import m27 = require("./subfolder/"); +>m27 : typeof m4 + +import m28 = require("./subfolder/index"); +>m28 : typeof m4 + +import m29 = require("./subfolder2"); +>m29 : typeof m7 + +import m30 = require("./subfolder2/"); +>m30 : typeof m7 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m7 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m4 + +void m27; +>void m27 : undefined +>m27 : typeof m4 + +void m28; +>void m28 : undefined +>m28 : typeof m4 + +void m29; +>void m29 : undefined +>m29 : typeof m7 + +void m30; +>void m30 : undefined +>m30 : typeof m7 + +void m31; +>void m31 : undefined +>m31 : typeof m7 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : any + +import * as m14 from "./index"; +>m14 : any + +import * as m15 from "./subfolder"; +>m15 : any + +import * as m16 from "./subfolder/"; +>m16 : any + +import * as m17 from "./subfolder/index"; +>m17 : any + +import * as m18 from "./subfolder2"; +>m18 : any + +import * as m19 from "./subfolder2/"; +>m19 : any + +import * as m20 from "./subfolder2/index"; +>m20 : any + +import * as m21 from "./subfolder2/another"; +>m21 : any + +import * as m22 from "./subfolder2/another/"; +>m22 : any + +import * as m23 from "./subfolder2/another/index"; +>m23 : any + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : any + +void m14; +>void m14 : undefined +>m14 : any + +void m15; +>void m15 : undefined +>m15 : any + +void m16; +>void m16 : undefined +>m16 : any + +void m17; +>void m17 : undefined +>m17 : any + +void m18; +>void m18 : undefined +>m18 : any + +void m19; +>void m19 : undefined +>m19 : any + +void m20; +>void m20 : undefined +>m20 : any + +void m21; +>void m21 : undefined +>m21 : any + +void m22; +>void m22 : undefined +>m22 : any + +void m23; +>void m23 : undefined +>m23 : any + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m26 + +import m27 = require("./subfolder/"); +>m27 : typeof m26 + +import m28 = require("./subfolder/index"); +>m28 : typeof m26 + +import m29 = require("./subfolder2"); +>m29 : typeof m29 + +import m30 = require("./subfolder2/"); +>m30 : typeof m29 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m29 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m26 + +void m27; +>void m27 : undefined +>m27 : typeof m26 + +void m28; +>void m28 : undefined +>m28 : typeof m26 + +void m29; +>void m29 : undefined +>m29 : typeof m29 + +void m30; +>void m30 : undefined +>m30 : typeof m29 + +void m31; +>void m31 : undefined +>m31 : typeof m29 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt index 724e3b73ed7..e8bcd1c06a7 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -15,70 +15,70 @@ tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/index.cts(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/index.cts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/index.cts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/index.cts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.cts(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.cts(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.cts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.cts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.cts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.cts(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/index.mts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/index.mts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/index.mts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/index.mts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/index.mts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.mts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.mts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.mts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.mts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/index.mts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/index.mts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/index.mts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/index.mts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.mts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.mts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.mts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.mts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.mts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.mts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/index.ts(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/index.ts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/index.ts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/index.ts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/index.ts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.ts(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.ts(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.ts(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.ts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/index.ts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/index.ts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/index.ts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/index.ts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/index.ts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/index.ts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/index.ts(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/index.ts(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? ==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== @@ -136,34 +136,34 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path !!! error TS2307: Cannot find module './' or its corresponding type declarations. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? import * as m15 from "./subfolder"; ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m16 from "./subfolder/"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m17 from "./subfolder/index"; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? import * as m18 from "./subfolder2"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m19 from "./subfolder2/"; ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m20 from "./subfolder2/index"; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? void m1; void m2; void m3; @@ -228,34 +228,34 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // esm format file const x = 1; @@ -372,34 +372,34 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // cjs format file const x = 1; export {x}; @@ -422,34 +422,34 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path !!! error TS2307: Cannot find module './' or its corresponding type declarations. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? import * as m15 from "./subfolder"; ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m16 from "./subfolder/"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m17 from "./subfolder/index"; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? import * as m18 from "./subfolder2"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m19 from "./subfolder2/"; ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m20 from "./subfolder2/index"; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? void m1; void m2; void m3; @@ -514,34 +514,34 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // esm format file const x = 1; export {x}; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt new file mode 100644 index 00000000000..83c4abe3350 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt @@ -0,0 +1,663 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/allowJs/index.js(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.js(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/allowJs/index.js(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.js(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/allowJs/index.mjs(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. +tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.js (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (38 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones shouldn't all work - esm format files have no index resolution or extension resolution + import * as m13 from "./"; + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + import * as m15 from "./subfolder"; + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m16 from "./subfolder/"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m17 from "./subfolder/index"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + import * as m18 from "./subfolder2"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m19 from "./subfolder2/"; + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m20 from "./subfolder2/index"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.cjs (38 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) + import * as m13 from "./"; + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m15 from "./subfolder"; + import * as m16 from "./subfolder/"; + import * as m17 from "./subfolder/index"; + import * as m18 from "./subfolder2"; + import * as m19 from "./subfolder2/"; + import * as m20 from "./subfolder2/index"; + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.mjs (38 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + // The next ones should all fail - esm format files have no index resolution or extension resolution + import * as m13 from "./"; + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + import * as m14 from "./index"; + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + import * as m15 from "./subfolder"; + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m16 from "./subfolder/"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m17 from "./subfolder/index"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + import * as m18 from "./subfolder2"; + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m19 from "./subfolder2/"; + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m20 from "./subfolder2/index"; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + import * as m21 from "./subfolder2/another"; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m22 from "./subfolder2/another/"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + import * as m23 from "./subfolder2/another/index"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + void m13; + void m14; + void m15; + void m16; + void m17; + void m18; + void m19; + void m20; + void m21; + void m22; + void m23; + + // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) + import m24 = require("./"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~ +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m25 = require("./index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~ +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m26 = require("./subfolder"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m27 = require("./subfolder/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m28 = require("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m29 = require("./subfolder2"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m30 = require("./subfolder2/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m31 = require("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + import m32 = require("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m33 = require("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import m34 = require("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + void m24; + void m25; + void m26; + void m27; + void m28; + void m29; + void m30; + void m31; + void m32; + void m33; + void m34; + + // These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution + const _m35 = import("./"); + ~~~~ +!!! error TS2307: Cannot find module './' or its corresponding type declarations. + const _m36 = import("./index"); + ~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? + const _m37 = import("./subfolder"); + ~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m38 = import("./subfolder/"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m39 = import("./subfolder/index"); + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? + const _m40 = import("./subfolder2"); + ~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m41 = import("./subfolder2/"); + ~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m42 = import("./subfolder2/index"); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? + const _m43 = import("./subfolder2/another"); + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m44 = import("./subfolder2/another/"); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. + const _m45 = import("./subfolder2/another/index"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? + + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/allowJs/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).js b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).js new file mode 100644 index 00000000000..1376e7c5aea --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).js @@ -0,0 +1,688 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts] //// + +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; +//// [index.js] +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; +//// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +import m25 = require("./index"); +import m26 = require("./subfolder"); +import m27 = require("./subfolder/"); +import m28 = require("./subfolder/index"); +import m29 = require("./subfolder2"); +import m30 = require("./subfolder2/"); +import m31 = require("./subfolder2/index"); +import m32 = require("./subfolder2/another"); +import m33 = require("./subfolder2/another/"); +import m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); + +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM-format imports below should issue errors +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +const m13 = __importStar(require("./")); +const m14 = __importStar(require("./index")); +const m15 = __importStar(require("./subfolder")); +const m16 = __importStar(require("./subfolder/")); +const m17 = __importStar(require("./subfolder/index")); +const m18 = __importStar(require("./subfolder2")); +const m19 = __importStar(require("./subfolder2/")); +const m20 = __importStar(require("./subfolder2/index")); +const m21 = __importStar(require("./subfolder2/another")); +const m22 = __importStar(require("./subfolder2/another/")); +const m23 = __importStar(require("./subfolder2/another/index")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = require("./"); +const m25 = require("./index"); +const m26 = require("./subfolder"); +const m27 = require("./subfolder/"); +const m28 = require("./subfolder/index"); +const m29 = require("./subfolder2"); +const m30 = require("./subfolder2/"); +const m31 = require("./subfolder2/index"); +const m32 = require("./subfolder2/another"); +const m33 = require("./subfolder2/another/"); +const m34 = require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = __require("./"); +const m25 = __require("./index"); +const m26 = __require("./subfolder"); +const m27 = __require("./subfolder/"); +const m28 = __require("./subfolder/index"); +const m29 = __require("./subfolder2"); +const m30 = __require("./subfolder2/"); +const m31 = __require("./subfolder2/index"); +const m32 = __require("./subfolder2/another"); +const m33 = __require("./subfolder2/another/"); +const m34 = __require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export { x }; +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +import * as m14 from "./index"; +import * as m15 from "./subfolder"; +import * as m16 from "./subfolder/"; +import * as m17 from "./subfolder/index"; +import * as m18 from "./subfolder2"; +import * as m19 from "./subfolder2/"; +import * as m20 from "./subfolder2/index"; +import * as m21 from "./subfolder2/another"; +import * as m22 from "./subfolder2/another/"; +import * as m23 from "./subfolder2/another/index"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +void m13; +void m14; +void m15; +void m16; +void m17; +void m18; +void m19; +void m20; +void m21; +void m22; +void m23; +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +const m24 = __require("./"); +const m25 = __require("./index"); +const m26 = __require("./subfolder"); +const m27 = __require("./subfolder/"); +const m28 = __require("./subfolder/index"); +const m29 = __require("./subfolder2"); +const m30 = __require("./subfolder2/"); +const m31 = __require("./subfolder2/index"); +const m32 = __require("./subfolder2/another"); +const m33 = __require("./subfolder2/another/"); +const m34 = __require("./subfolder2/another/index"); +void m24; +void m25; +void m26; +void m27; +void m28; +void m29; +void m30; +void m31; +void m32; +void m33; +void m34; +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +const _m36 = import("./index"); +const _m37 = import("./subfolder"); +const _m38 = import("./subfolder/"); +const _m39 = import("./subfolder/index"); +const _m40 = import("./subfolder2"); +const _m41 = import("./subfolder2/"); +const _m42 = import("./subfolder2/index"); +const _m43 = import("./subfolder2/another"); +const _m44 = import("./subfolder2/another/"); +const _m45 = import("./subfolder2/another/index"); +// esm format file +const x = 1; +export { x }; + + +//// [index.d.ts] +export const x: 1; +//// [index.d.cts] +export const x: 1; +//// [index.d.mts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.cts] +export const x: 1; +//// [index.d.mts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.cts] +export const x: 1; +//// [index.d.mts] +export const x: 1; +//// [index.d.cts] +export const x: 1; +//// [index.d.mts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).symbols new file mode 100644 index 00000000000..d874ab0c830 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).symbols @@ -0,0 +1,817 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.js, 13, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.js, 14, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.js, 15, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.js, 16, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.js, 17, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.js, 18, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.js, 19, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.js, 20, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.js, 21, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.js, 22, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.js, 23, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.js, 13, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.js, 14, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.js, 15, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.js, 16, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.js, 17, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.js, 18, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.js, 19, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.js, 20, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.js, 21, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.js, 22, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.js, 23, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.js, 46, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.js, 49, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.js, 50, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.js, 51, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.js, 52, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.js, 53, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.js, 54, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.js, 55, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.js, 56, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.js, 57, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.js, 58, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.js, 46, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.js, 49, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.js, 50, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.js, 51, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.js, 52, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.js, 53, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.js, 54, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.js, 55, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.js, 56, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.js, 57, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.js, 58, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.js, 73, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.js, 74, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.js, 75, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.js, 76, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.js, 77, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.js, 78, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.js, 79, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.js, 80, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.js, 81, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.js, 82, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.js, 83, 5)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 85, 5)) + +export {x}; +>x : Symbol(m1.x, Decl(index.js, 86, 8)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.cjs, 14, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.cjs, 15, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.cjs, 16, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.cjs, 17, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.cjs, 18, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.cjs, 19, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.cjs, 20, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.cjs, 21, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.cjs, 22, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.cjs, 23, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.cjs, 24, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.cjs, 14, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.cjs, 15, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.cjs, 16, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.cjs, 17, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.cjs, 18, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.cjs, 19, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.cjs, 20, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.cjs, 21, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.cjs, 22, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.cjs, 23, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.cjs, 24, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.cjs, 47, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.cjs, 50, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.cjs, 51, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.cjs, 52, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.cjs, 53, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.cjs, 54, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.cjs, 55, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.cjs, 56, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.cjs, 57, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.cjs, 58, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.cjs, 59, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.cjs, 47, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.cjs, 50, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.cjs, 51, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.cjs, 52, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.cjs, 53, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.cjs, 54, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.cjs, 55, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.cjs, 56, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.cjs, 57, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.cjs, 58, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.cjs, 59, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.cjs, 74, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.cjs, 75, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.cjs, 76, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.cjs, 77, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.cjs, 78, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.cjs, 79, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.cjs, 80, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.cjs, 81, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.cjs, 82, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.cjs, 83, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.cjs, 84, 5)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 86, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cjs, 87, 8)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : Symbol(m13, Decl(index.mjs, 13, 6)) + +import * as m14 from "./index"; +>m14 : Symbol(m14, Decl(index.mjs, 14, 6)) + +import * as m15 from "./subfolder"; +>m15 : Symbol(m15, Decl(index.mjs, 15, 6)) + +import * as m16 from "./subfolder/"; +>m16 : Symbol(m16, Decl(index.mjs, 16, 6)) + +import * as m17 from "./subfolder/index"; +>m17 : Symbol(m17, Decl(index.mjs, 17, 6)) + +import * as m18 from "./subfolder2"; +>m18 : Symbol(m18, Decl(index.mjs, 18, 6)) + +import * as m19 from "./subfolder2/"; +>m19 : Symbol(m19, Decl(index.mjs, 19, 6)) + +import * as m20 from "./subfolder2/index"; +>m20 : Symbol(m20, Decl(index.mjs, 20, 6)) + +import * as m21 from "./subfolder2/another"; +>m21 : Symbol(m21, Decl(index.mjs, 21, 6)) + +import * as m22 from "./subfolder2/another/"; +>m22 : Symbol(m22, Decl(index.mjs, 22, 6)) + +import * as m23 from "./subfolder2/another/index"; +>m23 : Symbol(m23, Decl(index.mjs, 23, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +void m13; +>m13 : Symbol(m13, Decl(index.mjs, 13, 6)) + +void m14; +>m14 : Symbol(m14, Decl(index.mjs, 14, 6)) + +void m15; +>m15 : Symbol(m15, Decl(index.mjs, 15, 6)) + +void m16; +>m16 : Symbol(m16, Decl(index.mjs, 16, 6)) + +void m17; +>m17 : Symbol(m17, Decl(index.mjs, 17, 6)) + +void m18; +>m18 : Symbol(m18, Decl(index.mjs, 18, 6)) + +void m19; +>m19 : Symbol(m19, Decl(index.mjs, 19, 6)) + +void m20; +>m20 : Symbol(m20, Decl(index.mjs, 20, 6)) + +void m21; +>m21 : Symbol(m21, Decl(index.mjs, 21, 6)) + +void m22; +>m22 : Symbol(m22, Decl(index.mjs, 22, 6)) + +void m23; +>m23 : Symbol(m23, Decl(index.mjs, 23, 6)) + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : Symbol(m24, Decl(index.mjs, 46, 9)) + +import m25 = require("./index"); +>m25 : Symbol(m25, Decl(index.mjs, 49, 27)) + +import m26 = require("./subfolder"); +>m26 : Symbol(m26, Decl(index.mjs, 50, 32)) + +import m27 = require("./subfolder/"); +>m27 : Symbol(m27, Decl(index.mjs, 51, 36)) + +import m28 = require("./subfolder/index"); +>m28 : Symbol(m28, Decl(index.mjs, 52, 37)) + +import m29 = require("./subfolder2"); +>m29 : Symbol(m29, Decl(index.mjs, 53, 42)) + +import m30 = require("./subfolder2/"); +>m30 : Symbol(m30, Decl(index.mjs, 54, 37)) + +import m31 = require("./subfolder2/index"); +>m31 : Symbol(m31, Decl(index.mjs, 55, 38)) + +import m32 = require("./subfolder2/another"); +>m32 : Symbol(m32, Decl(index.mjs, 56, 43)) + +import m33 = require("./subfolder2/another/"); +>m33 : Symbol(m33, Decl(index.mjs, 57, 45)) + +import m34 = require("./subfolder2/another/index"); +>m34 : Symbol(m34, Decl(index.mjs, 58, 46)) + +void m24; +>m24 : Symbol(m24, Decl(index.mjs, 46, 9)) + +void m25; +>m25 : Symbol(m25, Decl(index.mjs, 49, 27)) + +void m26; +>m26 : Symbol(m26, Decl(index.mjs, 50, 32)) + +void m27; +>m27 : Symbol(m27, Decl(index.mjs, 51, 36)) + +void m28; +>m28 : Symbol(m28, Decl(index.mjs, 52, 37)) + +void m29; +>m29 : Symbol(m29, Decl(index.mjs, 53, 42)) + +void m30; +>m30 : Symbol(m30, Decl(index.mjs, 54, 37)) + +void m31; +>m31 : Symbol(m31, Decl(index.mjs, 55, 38)) + +void m32; +>m32 : Symbol(m32, Decl(index.mjs, 56, 43)) + +void m33; +>m33 : Symbol(m33, Decl(index.mjs, 57, 45)) + +void m34; +>m34 : Symbol(m34, Decl(index.mjs, 58, 46)) + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Symbol(_m35, Decl(index.mjs, 73, 5)) + +const _m36 = import("./index"); +>_m36 : Symbol(_m36, Decl(index.mjs, 74, 5)) + +const _m37 = import("./subfolder"); +>_m37 : Symbol(_m37, Decl(index.mjs, 75, 5)) + +const _m38 = import("./subfolder/"); +>_m38 : Symbol(_m38, Decl(index.mjs, 76, 5)) + +const _m39 = import("./subfolder/index"); +>_m39 : Symbol(_m39, Decl(index.mjs, 77, 5)) + +const _m40 = import("./subfolder2"); +>_m40 : Symbol(_m40, Decl(index.mjs, 78, 5)) + +const _m41 = import("./subfolder2/"); +>_m41 : Symbol(_m41, Decl(index.mjs, 79, 5)) + +const _m42 = import("./subfolder2/index"); +>_m42 : Symbol(_m42, Decl(index.mjs, 80, 5)) + +const _m43 = import("./subfolder2/another"); +>_m43 : Symbol(_m43, Decl(index.mjs, 81, 5)) + +const _m44 = import("./subfolder2/another/"); +>_m44 : Symbol(_m44, Decl(index.mjs, 82, 5)) + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Symbol(_m45, Decl(index.mjs, 83, 5)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 86, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mjs, 87, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).types b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).types new file mode 100644 index 00000000000..bc08d749cf8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).types @@ -0,0 +1,997 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones shouldn't all work - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : any + +import * as m14 from "./index"; +>m14 : any + +import * as m15 from "./subfolder"; +>m15 : any + +import * as m16 from "./subfolder/"; +>m16 : any + +import * as m17 from "./subfolder/index"; +>m17 : any + +import * as m18 from "./subfolder2"; +>m18 : any + +import * as m19 from "./subfolder2/"; +>m19 : any + +import * as m20 from "./subfolder2/index"; +>m20 : any + +import * as m21 from "./subfolder2/another"; +>m21 : any + +import * as m22 from "./subfolder2/another/"; +>m22 : any + +import * as m23 from "./subfolder2/another/index"; +>m23 : any + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : any + +void m14; +>void m14 : undefined +>m14 : any + +void m15; +>void m15 : undefined +>m15 : any + +void m16; +>void m16 : undefined +>m16 : any + +void m17; +>void m17 : undefined +>m17 : any + +void m18; +>void m18 : undefined +>m18 : any + +void m19; +>void m19 : undefined +>m19 : any + +void m20; +>void m20 : undefined +>m20 : any + +void m21; +>void m21 : undefined +>m21 : any + +void m22; +>void m22 : undefined +>m22 : any + +void m23; +>void m23 : undefined +>m23 : any + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m26 + +import m27 = require("./subfolder/"); +>m27 : typeof m26 + +import m28 = require("./subfolder/index"); +>m28 : typeof m26 + +import m29 = require("./subfolder2"); +>m29 : typeof m29 + +import m30 = require("./subfolder2/"); +>m30 : typeof m29 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m29 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m26 + +void m27; +>void m27 : undefined +>m27 : typeof m26 + +void m28; +>void m28 : undefined +>m28 : typeof m26 + +void m29; +>void m29 : undefined +>m29 : typeof m29 + +void m30; +>void m30 : undefined +>m30 : typeof m29 + +void m31; +>void m31 : undefined +>m31 : typeof m29 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) +import * as m13 from "./"; +>m13 : typeof m1 + +import * as m14 from "./index"; +>m14 : typeof m1 + +import * as m15 from "./subfolder"; +>m15 : typeof m4 + +import * as m16 from "./subfolder/"; +>m16 : typeof m4 + +import * as m17 from "./subfolder/index"; +>m17 : typeof m4 + +import * as m18 from "./subfolder2"; +>m18 : typeof m7 + +import * as m19 from "./subfolder2/"; +>m19 : typeof m7 + +import * as m20 from "./subfolder2/index"; +>m20 : typeof m7 + +import * as m21 from "./subfolder2/another"; +>m21 : typeof m10 + +import * as m22 from "./subfolder2/another/"; +>m22 : typeof m10 + +import * as m23 from "./subfolder2/another/index"; +>m23 : typeof m10 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : typeof m1 + +void m14; +>void m14 : undefined +>m14 : typeof m1 + +void m15; +>void m15 : undefined +>m15 : typeof m4 + +void m16; +>void m16 : undefined +>m16 : typeof m4 + +void m17; +>void m17 : undefined +>m17 : typeof m4 + +void m18; +>void m18 : undefined +>m18 : typeof m7 + +void m19; +>void m19 : undefined +>m19 : typeof m7 + +void m20; +>void m20 : undefined +>m20 : typeof m7 + +void m21; +>void m21 : undefined +>m21 : typeof m10 + +void m22; +>void m22 : undefined +>m22 : typeof m10 + +void m23; +>void m23 : undefined +>m23 : typeof m10 + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m4 + +import m27 = require("./subfolder/"); +>m27 : typeof m4 + +import m28 = require("./subfolder/index"); +>m28 : typeof m4 + +import m29 = require("./subfolder2"); +>m29 : typeof m7 + +import m30 = require("./subfolder2/"); +>m30 : typeof m7 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m7 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m4 + +void m27; +>void m27 : undefined +>m27 : typeof m4 + +void m28; +>void m28 : undefined +>m28 : typeof m4 + +void m29; +>void m29 : undefined +>m29 : typeof m7 + +void m30; +>void m30 : undefined +>m30 : typeof m7 + +void m31; +>void m31 : undefined +>m31 : typeof m7 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +// The next ones should all fail - esm format files have no index resolution or extension resolution +import * as m13 from "./"; +>m13 : any + +import * as m14 from "./index"; +>m14 : any + +import * as m15 from "./subfolder"; +>m15 : any + +import * as m16 from "./subfolder/"; +>m16 : any + +import * as m17 from "./subfolder/index"; +>m17 : any + +import * as m18 from "./subfolder2"; +>m18 : any + +import * as m19 from "./subfolder2/"; +>m19 : any + +import * as m20 from "./subfolder2/index"; +>m20 : any + +import * as m21 from "./subfolder2/another"; +>m21 : any + +import * as m22 from "./subfolder2/another/"; +>m22 : any + +import * as m23 from "./subfolder2/another/index"; +>m23 : any + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +void m13; +>void m13 : undefined +>m13 : any + +void m14; +>void m14 : undefined +>m14 : any + +void m15; +>void m15 : undefined +>m15 : any + +void m16; +>void m16 : undefined +>m16 : any + +void m17; +>void m17 : undefined +>m17 : any + +void m18; +>void m18 : undefined +>m18 : any + +void m19; +>void m19 : undefined +>m19 : any + +void m20; +>void m20 : undefined +>m20 : any + +void m21; +>void m21 : undefined +>m21 : any + +void m22; +>void m22 : undefined +>m22 : any + +void m23; +>void m23 : undefined +>m23 : any + +// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) +import m24 = require("./"); +>m24 : typeof m1 + +import m25 = require("./index"); +>m25 : typeof m1 + +import m26 = require("./subfolder"); +>m26 : typeof m26 + +import m27 = require("./subfolder/"); +>m27 : typeof m26 + +import m28 = require("./subfolder/index"); +>m28 : typeof m26 + +import m29 = require("./subfolder2"); +>m29 : typeof m29 + +import m30 = require("./subfolder2/"); +>m30 : typeof m29 + +import m31 = require("./subfolder2/index"); +>m31 : typeof m29 + +import m32 = require("./subfolder2/another"); +>m32 : typeof m10 + +import m33 = require("./subfolder2/another/"); +>m33 : typeof m10 + +import m34 = require("./subfolder2/another/index"); +>m34 : typeof m10 + +void m24; +>void m24 : undefined +>m24 : typeof m1 + +void m25; +>void m25 : undefined +>m25 : typeof m1 + +void m26; +>void m26 : undefined +>m26 : typeof m26 + +void m27; +>void m27 : undefined +>m27 : typeof m26 + +void m28; +>void m28 : undefined +>m28 : typeof m26 + +void m29; +>void m29 : undefined +>m29 : typeof m29 + +void m30; +>void m30 : undefined +>m30 : typeof m29 + +void m31; +>void m31 : undefined +>m31 : typeof m29 + +void m32; +>void m32 : undefined +>m32 : typeof m10 + +void m33; +>void m33 : undefined +>m33 : typeof m10 + +void m34; +>void m34 : undefined +>m34 : typeof m10 + +// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution +const _m35 = import("./"); +>_m35 : Promise +>import("./") : Promise +>"./" : "./" + +const _m36 = import("./index"); +>_m36 : Promise +>import("./index") : Promise +>"./index" : "./index" + +const _m37 = import("./subfolder"); +>_m37 : Promise +>import("./subfolder") : Promise +>"./subfolder" : "./subfolder" + +const _m38 = import("./subfolder/"); +>_m38 : Promise +>import("./subfolder/") : Promise +>"./subfolder/" : "./subfolder/" + +const _m39 = import("./subfolder/index"); +>_m39 : Promise +>import("./subfolder/index") : Promise +>"./subfolder/index" : "./subfolder/index" + +const _m40 = import("./subfolder2"); +>_m40 : Promise +>import("./subfolder2") : Promise +>"./subfolder2" : "./subfolder2" + +const _m41 = import("./subfolder2/"); +>_m41 : Promise +>import("./subfolder2/") : Promise +>"./subfolder2/" : "./subfolder2/" + +const _m42 = import("./subfolder2/index"); +>_m42 : Promise +>import("./subfolder2/index") : Promise +>"./subfolder2/index" : "./subfolder2/index" + +const _m43 = import("./subfolder2/another"); +>_m43 : Promise +>import("./subfolder2/another") : Promise +>"./subfolder2/another" : "./subfolder2/another" + +const _m44 = import("./subfolder2/another/"); +>_m44 : Promise +>import("./subfolder2/another/") : Promise +>"./subfolder2/another/" : "./subfolder2/another/" + +const _m45 = import("./subfolder2/another/index"); +>_m45 : Promise +>import("./subfolder2/another/index") : Promise +>"./subfolder2/another/index" : "./subfolder2/another/index" + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt index 178c28ed460..83c4abe3350 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -26,27 +26,27 @@ tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './s tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/allowJs/index.cjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/allowJs/index.cjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.cjs(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(78,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(79,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(81,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(82,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.cjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(84,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.cjs(85,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.js(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/allowJs/index.js(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/allowJs/index.js(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/allowJs/index.js(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/allowJs/index.js(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.js(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -64,27 +64,27 @@ tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './su tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/allowJs/index.js(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/allowJs/index.js(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/allowJs/index.js(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/allowJs/index.js(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.js(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.js(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.js(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.js(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(14,22): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/allowJs/index.mjs(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(15,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(16,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(17,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(18,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(19,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(20,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -102,16 +102,16 @@ tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './s tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. -tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? -tests/cases/conformance/node/allowJs/index.mjs(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(78,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(79,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(80,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(81,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +tests/cases/conformance/node/allowJs/index.mjs(82,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(83,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? ==== tests/cases/conformance/node/allowJs/subfolder/index.js (0 errors) ==== @@ -169,34 +169,34 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im !!! error TS2307: Cannot find module './' or its corresponding type declarations. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? import * as m15 from "./subfolder"; ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m16 from "./subfolder/"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m17 from "./subfolder/index"; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? import * as m18 from "./subfolder2"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m19 from "./subfolder2/"; ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m20 from "./subfolder2/index"; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? void m1; void m2; void m3; @@ -283,34 +283,34 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // esm format file const x = 1; export {x}; @@ -448,34 +448,34 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // cjs format file const x = 1; export {x}; @@ -498,34 +498,34 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im !!! error TS2307: Cannot find module './' or its corresponding type declarations. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? import * as m15 from "./subfolder"; ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m16 from "./subfolder/"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m17 from "./subfolder/index"; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? import * as m18 from "./subfolder2"; ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m19 from "./subfolder2/"; ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m20 from "./subfolder2/index"; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? void m1; void m2; void m3; @@ -612,34 +612,34 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im !!! error TS2307: Cannot find module './' or its corresponding type declarations. const _m36 = import("./index"); ~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? const _m37 = import("./subfolder"); ~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m38 = import("./subfolder/"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m39 = import("./subfolder/index"); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder/index.mjs'? const _m40 = import("./subfolder2"); ~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m41 = import("./subfolder2/"); ~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m42 = import("./subfolder2/index"); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/index.mjs'? const _m43 = import("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m44 = import("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. const _m45 = import("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? +!!! error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? // esm format file const x = 1; diff --git a/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).symbols new file mode 100644 index 00000000000..8ec82fe7e05 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/node/allowJs/foo.cjs === +exports.foo = "foo" +>exports.foo : Symbol(foo, Decl(foo.cjs, 0, 0)) +>exports : Symbol(foo, Decl(foo.cjs, 0, 0)) +>foo : Symbol(foo, Decl(foo.cjs, 0, 0)) + +=== tests/cases/conformance/node/allowJs/bar.ts === +import foo from "./foo.cjs" +>foo : Symbol(foo, Decl(bar.ts, 0, 6)) + +foo.foo; +>foo.foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0)) +>foo : Symbol(foo, Decl(bar.ts, 0, 6)) +>foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).types new file mode 100644 index 00000000000..7559910259c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsCjsFromJs(module=node16).types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/node/allowJs/foo.cjs === +exports.foo = "foo" +>exports.foo = "foo" : "foo" +>exports.foo : "foo" +>exports : typeof import("tests/cases/conformance/node/allowJs/foo") +>foo : "foo" +>"foo" : "foo" + +=== tests/cases/conformance/node/allowJs/bar.ts === +import foo from "./foo.cjs" +>foo : typeof foo + +foo.foo; +>foo.foo : "foo" +>foo : typeof foo +>foo : "foo" + diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt new file mode 100644 index 00000000000..83e50c001e7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@ -0,0 +1,135 @@ +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.cjsSource; + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (1 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const implicitCjsSource = true; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (1 errors) ==== + // esm format file + import * as cjs from "inner/a"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const mjsSource = true; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const cjsSource = true; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts", + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).js new file mode 100644 index 00000000000..bd0f2a77807 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).js @@ -0,0 +1,205 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts] //// + +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.cjs] +// cjs format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.cjsSource; +mjsi.cjsSource; +typei.implicitCjsSource; +ts.cjsSource; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const implicitCjsSource = true; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const mjsSource = true; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const cjsSource = true; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts", + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } +} + +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjs = __importStar(require("package/cjs")); +const mjs = __importStar(require("package/mjs")); +const type = __importStar(require("package")); +cjs; +mjs; +type; +const cjsi = __importStar(require("inner/a")); +const mjsi = __importStar(require("inner/b")); +const typei = __importStar(require("inner")); +const ts = __importStar(require("inner/types")); +cjsi.cjsSource; +mjsi.cjsSource; +typei.implicitCjsSource; +ts.cjsSource; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).symbols new file mode 100644 index 00000000000..ce8944196c0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).symbols @@ -0,0 +1,243 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.js, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +type; +>type : Symbol(type, Decl(index.js, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.js, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.js, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.js, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.js, 10, 6)) + +cjsi.mjsSource; +>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.js, 7, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +mjsi.mjsSource; +>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.js, 8, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +typei.mjsSource; +>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>typei : Symbol(typei, Decl(index.js, 9, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +ts.mjsSource; +>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>ts : Symbol(ts, Decl(index.js, 10, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.mjs, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.mjs, 10, 6)) + +cjsi.mjsSource; +>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +mjsi.mjsSource; +>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +typei.mjsSource; +>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>typei : Symbol(typei, Decl(index.mjs, 9, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +ts.mjsSource; +>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>ts : Symbol(ts, Decl(index.mjs, 10, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.cjs, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.cjs, 10, 6)) + +cjsi.cjsSource; +>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +mjsi.cjsSource; +>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +typei.implicitCjsSource; +>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) +>typei : Symbol(typei, Decl(index.cjs, 9, 6)) +>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) + +ts.cjsSource; +>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>ts : Symbol(ts, Decl(index.cjs, 10, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.ts, 4, 6)) + +export { cjs }; +>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8)) + +export { mjs }; +>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8)) + +export { type }; +>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8)) + +export { ts }; +>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8)) + +export const implicitCjsSource = true; +>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.mts, 4, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8)) + +export { mjs }; +>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8)) + +export { type }; +>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8)) + +export { ts }; +>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8)) + +export const mjsSource = true; +>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.cts, 4, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8)) + +export { ts }; +>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8)) + +export const cjsSource = true; +>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).types new file mode 100644 index 00000000000..7b1fe309bb0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).types @@ -0,0 +1,246 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.mjsSource; +>cjsi.mjsSource : true +>cjsi : typeof cjsi +>mjsSource : true + +mjsi.mjsSource; +>mjsi.mjsSource : true +>mjsi : typeof cjsi +>mjsSource : true + +typei.mjsSource; +>typei.mjsSource : true +>typei : typeof cjsi +>mjsSource : true + +ts.mjsSource; +>ts.mjsSource : true +>ts : typeof cjsi +>mjsSource : true + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.mjsSource; +>cjsi.mjsSource : true +>cjsi : typeof cjsi +>mjsSource : true + +mjsi.mjsSource; +>mjsi.mjsSource : true +>mjsi : typeof cjsi +>mjsSource : true + +typei.mjsSource; +>typei.mjsSource : true +>typei : typeof cjsi +>mjsSource : true + +ts.mjsSource; +>ts.mjsSource : true +>ts : typeof cjsi +>mjsSource : true + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi.type + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.cjsSource; +>cjsi.cjsSource : true +>cjsi : typeof cjsi +>cjsSource : true + +mjsi.cjsSource; +>mjsi.cjsSource : true +>mjsi : typeof cjsi +>cjsSource : true + +typei.implicitCjsSource; +>typei.implicitCjsSource : true +>typei : typeof cjsi.type +>implicitCjsSource : true + +ts.cjsSource; +>ts.cjsSource : true +>ts : typeof cjsi +>cjsSource : true + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : any + +import * as mjs from "inner/b"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs.type + +import * as ts from "inner/types"; +>ts : typeof mjs + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.type + +export { ts }; +>ts : typeof mjs + +export const implicitCjsSource = true; +>implicitCjsSource : true +>true : true + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/a"; +>cjs : any + +import * as mjs from "inner/b"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs + +import * as ts from "inner/types"; +>ts : typeof mjs + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs + +export { ts }; +>ts : typeof mjs + +export const mjsSource = true; +>mjsSource : true +>true : true + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : typeof cjs + +import * as mjs from "inner/b"; +>mjs : typeof cjs + +import * as type from "inner"; +>type : typeof cjs.type + +import * as ts from "inner/types"; +>ts : typeof cjs + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs + +export { type }; +>type : typeof cjs.type + +export { ts }; +>ts : typeof cjs + +export const cjsSource = true; +>cjsSource : true +>true : true + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).js new file mode 100644 index 00000000000..471912e1192 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts] //// + +//// [index.js] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} + + +//// [index.d.ts] +export function main(): Promise; +//// [index.d.ts] +export function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).symbols new file mode 100644 index 00000000000..0b0c85a01f1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).types new file mode 100644 index 00000000000..650fcf3a637 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).errors.txt new file mode 100644 index 00000000000..a0a3d489f44 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/subfolder/file.js (0 errors) ==== + // cjs format file + const a = {}; + module.exports = a; +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (1 errors) ==== + // esm format file + import "fs"; + const a = {}; + module.exports = a; + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).js new file mode 100644 index 00000000000..10d6da622e9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).js @@ -0,0 +1,61 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts] //// + +//// [index.js] +// cjs format file +const a = {}; +export = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export = a; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; + + +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export = a; +declare const a: {}; +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).symbols new file mode 100644 index 00000000000..4e0e3aed1a9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(file.js, 1, 5)) + +module.exports = a; +>module.exports : Symbol(module.exports, Decl(file.js, 0, 0)) +>module : Symbol(export=, Decl(file.js, 1, 13)) +>exports : Symbol(export=, Decl(file.js, 1, 13)) +>a : Symbol(a, Decl(file.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : Symbol(a, Decl(file.js, 2, 5)) + +module.exports = a; +>a : Symbol(a, Decl(file.js, 2, 5)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).types new file mode 100644 index 00000000000..e6543212f66 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node16).types @@ -0,0 +1,45 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : {} +>module.exports : {} +>module : { exports: {}; } +>exports : {} +>a : {} + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : any +>module.exports : any +>module : any +>exports : any +>a : {} + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).errors.txt new file mode 100644 index 00000000000..ed3dc20285b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node16. +tests/cases/conformance/node/allowJs/subfolder/index.js(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node16. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).js new file mode 100644 index 00000000000..3900870c747 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts] //// + +//// [index.js] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.js] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; + + +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).symbols new file mode 100644 index 00000000000..8565d39212c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).types new file mode 100644 index 00000000000..a290eb3ca58 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node16).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).errors.txt new file mode 100644 index 00000000000..bbc352d7a78 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).js new file mode 100644 index 00000000000..1e97293cca8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts] //// + +//// [index.js] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.js] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.js] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; + + +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [file.d.ts] +/// +import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).symbols new file mode 100644 index 00000000000..11b3047ebcd --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.js, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.js, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.js, 4, 12)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).types new file mode 100644 index 00000000000..2720b1f1b7d --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node16).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).errors.txt new file mode 100644 index 00000000000..b75c1c1e6f5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).js new file mode 100644 index 00000000000..a30d220227f --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts] //// + +//// [index.js] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.js] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = tslib_1.__importDefault(require("fs")); +fs_1.default.readFile; +const fs = tslib_1.__importStar(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).symbols new file mode 100644 index 00000000000..3822c3fa16d --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).types new file mode 100644 index 00000000000..0b27106eae0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node16).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).errors.txt new file mode 100644 index 00000000000..e07871859db --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/allowJs/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).js new file mode 100644 index 00000000000..f689312eb37 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +tslib_1.__exportStar(require("fs"), exports); +exports.fs = tslib_1.__importStar(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +/// +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).symbols new file mode 100644 index 00000000000..46c533db2dc --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 2, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).types new file mode 100644 index 00000000000..bbcb3d29931 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node16).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).errors.txt new file mode 100644 index 00000000000..cd8457101bb --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export {default} from "fs"; + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).js new file mode 100644 index 00000000000..8e07883b727 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts] //// + +//// [index.js] +// cjs format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [index.js] +// esm format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.baz = exports.foo = exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +var fs_2 = require("fs"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } }); +var fs_3 = require("fs"); +Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } }); +//// [index.js] +// esm format file +export { default } from "fs"; +export { default as foo } from "fs"; +export { bar as baz } from "fs"; + + +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).symbols new file mode 100644 index 00000000000..767be993d64 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).types new file mode 100644 index 00000000000..b07207ec08d --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node16).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).errors.txt new file mode 100644 index 00000000000..7f8ce469152 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).js new file mode 100644 index 00000000000..7e6d01b7daf --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts] //// + +//// [index.js] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.js] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; + + +//// [index.d.ts] +export const x: string; +//// [index.d.ts] +export const x: string; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).symbols new file mode 100644 index 00000000000..89649ba7b33 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>meta : Symbol(ImportMetaExpression.meta) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>meta : Symbol(ImportMetaExpression.meta) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).types new file mode 100644 index 00000000000..de6d0c96059 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt new file mode 100644 index 00000000000..e6f4b3ce2eb --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt @@ -0,0 +1,107 @@ +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).js new file mode 100644 index 00000000000..cce457e2d41 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).js @@ -0,0 +1,165 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts] //// + +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.cjs] +// cjs format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} + +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjs = __importStar(require("package/cjs")); +const mjs = __importStar(require("package/mjs")); +const type = __importStar(require("package")); +cjs; +mjs; +type; +const cjsi = __importStar(require("inner/cjs")); +const mjsi = __importStar(require("inner/mjs")); +const typei = __importStar(require("inner")); +cjsi; +mjsi; +typei; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).symbols new file mode 100644 index 00000000000..44c1af02648 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).symbols @@ -0,0 +1,174 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.js, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +type; +>type : Symbol(type, Decl(index.js, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.js, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.js, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.js, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.js, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.js, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.js, 9, 6)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.mjs, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mjs, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mjs, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mjs, 9, 6)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.cjs, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cjs, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cjs, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cjs, 9, 6)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).types new file mode 100644 index 00000000000..f610f5095dd --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).types @@ -0,0 +1,174 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : any + +import * as mjs from "inner/mjs"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof cjs.mjs + +import * as type from "inner"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt new file mode 100644 index 00000000000..261be58f1a2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== tests/cases/conformance/node/allowJs/index.cjs (2 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "#type"; + ~~~~~~~ +!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js", + "imports": { + "#cjs": "./index.cjs", + "#mjs": "./index.mjs", + "#type": "./index.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).js new file mode 100644 index 00000000000..634e532de49 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).js @@ -0,0 +1,96 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts] //// + +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.mjs] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.cjs] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js", + "imports": { + "#cjs": "./index.cjs", + "#mjs": "./index.mjs", + "#type": "./index.js" + } +} + +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.mjs] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const cjs = __importStar(require("#cjs")); +const mjs = __importStar(require("#mjs")); +const type = __importStar(require("#type")); +cjs; +mjs; +type; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).symbols new file mode 100644 index 00000000000..196837bc0bc --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.js, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.js, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.js, 2, 6)) + +type; +>type : Symbol(type, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mjs, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cjs, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cjs, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cjs, 3, 6)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).types new file mode 100644 index 00000000000..6387f04fcb6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).types @@ -0,0 +1,60 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +=== tests/cases/conformance/node/allowJs/index.cjs === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt new file mode 100644 index 00000000000..0f199947722 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ==== + // cjs format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs/index"; + import * as mjs from "inner/mjs/index"; + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index"; + import * as mjs from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + } +==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs/*": "./*.cjs", + "./mjs/*": "./*.mjs", + "./js/*": "./*.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).js new file mode 100644 index 00000000000..db1bb37d36a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).js @@ -0,0 +1,124 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts] //// + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.cjs] +// cjs format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs/*": "./*.cjs", + "./mjs/*": "./*.mjs", + "./js/*": "./*.js" + } +} + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjsi = __importStar(require("inner/cjs/index")); +const mjsi = __importStar(require("inner/mjs/index")); +const typei = __importStar(require("inner/js/index")); +cjsi; +mjsi; +typei; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).symbols new file mode 100644 index 00000000000..714bff6bd6b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.js, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.js, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.js, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.js, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.js, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.mjs, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mjs, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.cjs, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cjs, 3, 6)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).types new file mode 100644 index 00000000000..2103a12734a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner/js/index"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : any + +import * as mjs from "inner/mjs/index"; +>mjs : typeof mjs + +import * as type from "inner/js/index"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner/js/index"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index"; +>mjs : typeof cjs.mjs + +import * as type from "inner/js/index"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt new file mode 100644 index 00000000000..b989016f16a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/index.cjs (1 errors) ==== + // cjs format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index.cjs"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs/index.cjs"; + import * as mjs from "inner/mjs/index.mjs"; + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index.cjs"; + import * as mjs from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + } +==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs/*.cjs": "./*.cjs", + "./mjs/*.mjs": "./*.mjs", + "./js/*.js": "./*.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).js new file mode 100644 index 00000000000..e10a987a399 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).js @@ -0,0 +1,124 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts] //// + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.cjs] +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs/*.cjs": "./*.cjs", + "./mjs/*.mjs": "./*.mjs", + "./js/*.js": "./*.js" + } +} + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjsi = __importStar(require("inner/cjs/index.cjs")); +const mjsi = __importStar(require("inner/mjs/index.mjs")); +const typei = __importStar(require("inner/js/index.js")); +cjsi; +mjsi; +typei; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).symbols new file mode 100644 index 00000000000..2e24aeb1a83 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.js, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.js, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.js, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.js, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.js, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.mjs, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mjs, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.cjs, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cjs, 3, 6)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).types new file mode 100644 index 00000000000..556b7c15a3d --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.mjs === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/allowJs/index.cjs === +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : any + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof mjs + +import * as type from "inner/js/index.js"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner/js/index.js"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof cjs.mjs + +import * as type from "inner/js/index.js"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt new file mode 100644 index 00000000000..c722192e670 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~ +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/allowJs/index.js (3 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~ +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).js new file mode 100644 index 00000000000..a02ef88f1e5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts] //// + +//// [index.js] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.js] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; + + +//// [index.d.ts] +export function h(): Promise; +//// [index.d.ts] +export function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).symbols new file mode 100644 index 00000000000..8cbba01b82f --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.js, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.js, 4, 36)) +>_f : Symbol(_f, Decl(index.js, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.js, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.js, 1, 8)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.js, 4, 46)) +>_h : Symbol(_h, Decl(index.js, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.js, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.js, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.js, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).types new file mode 100644 index 00000000000..dde67707808 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : { default: typeof mod2; f(): Promise; } +>await import ("./index.js") : { default: typeof mod2; f(): Promise; } +>import ("./index.js") : Promise<{ default: typeof mod2; f(): Promise; }> +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : { default: typeof mod2; f(): Promise; } +>await import ("./subfolder/index.js") : { default: typeof mod2; f(): Promise; } +>import ("./subfolder/index.js") : Promise<{ default: typeof mod2; f(): Promise; }> +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt new file mode 100644 index 00000000000..00d2aa600be --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + const x = await 1; + export {x}; + for await (const y of []) {} +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).js b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).js new file mode 100644 index 00000000000..354fe725f09 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts] //// + +//// [index.js] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.js] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } + + +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).symbols b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).symbols new file mode 100644 index 00000000000..09ad69c019c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).types b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).types new file mode 100644 index 00000000000..b50bdd2c107 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt index 50ff19655e9..00d2aa600be 100644 --- a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. ==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== // cjs format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. ==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== // esm format file const x = await 1; diff --git a/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).js b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).js new file mode 100644 index 00000000000..f0c9198a513 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts] //// + +//// [index.ts] +// cjs format file +export const a = 1; +//// [index.ts] +// esm format file +import mod from "./subfolder/index.js"; +mod; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +// cjs format file +exports.a = 1; +//// [index.js] +// esm format file +import mod from "./subfolder/index.js"; +mod; + + +//// [index.d.ts] +export declare const a = 1; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).symbols b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).symbols new file mode 100644 index 00000000000..0d676181e27 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export const a = 1; +>a : Symbol(a, Decl(index.ts, 1, 12)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import mod from "./subfolder/index.js"; +>mod : Symbol(mod, Decl(index.ts, 1, 6)) + +mod; +>mod : Symbol(mod, Decl(index.ts, 1, 6)) + diff --git a/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).types b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).types new file mode 100644 index 00000000000..abbc4f1b40e --- /dev/null +++ b/tests/baselines/reference/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export const a = 1; +>a : 1 +>1 : 1 + +=== tests/cases/conformance/node/index.ts === +// esm format file +import mod from "./subfolder/index.js"; +>mod : typeof mod + +mod; +>mod : typeof mod + diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt new file mode 100644 index 00000000000..7397e1e1dbd --- /dev/null +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt @@ -0,0 +1,135 @@ +tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== tests/cases/conformance/node/index.cts (2 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.cjsSource; + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (1 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const implicitCjsSource = true; +==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ==== + // esm format file + import * as cjs from "inner/a"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const mjsSource = true; +==== tests/cases/conformance/node/node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const cjsSource = true; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts", + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).js new file mode 100644 index 00000000000..a67f7fdfdd4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).js @@ -0,0 +1,205 @@ +//// [tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts] //// + +//// [index.ts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.mts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.cts] +// cjs format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.cjsSource; +mjsi.cjsSource; +typei.implicitCjsSource; +ts.cjsSource; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const implicitCjsSource = true; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const mjsSource = true; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/a"; +import * as mjs from "inner/b"; +import * as type from "inner"; +import * as ts from "inner/types"; +export { cjs }; +export { mjs }; +export { type }; +export { ts }; +export const cjsSource = true; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts", + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } +} + +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjs = __importStar(require("package/cjs")); +const mjs = __importStar(require("package/mjs")); +const type = __importStar(require("package")); +cjs; +mjs; +type; +const cjsi = __importStar(require("inner/a")); +const mjsi = __importStar(require("inner/b")); +const typei = __importStar(require("inner")); +const ts = __importStar(require("inner/types")); +cjsi.cjsSource; +mjsi.cjsSource; +typei.implicitCjsSource; +ts.cjsSource; +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; + + +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).symbols new file mode 100644 index 00000000000..88fdfed4eaa --- /dev/null +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).symbols @@ -0,0 +1,243 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.ts, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.ts, 10, 6)) + +cjsi.mjsSource; +>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +mjsi.mjsSource; +>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +typei.mjsSource; +>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>typei : Symbol(typei, Decl(index.ts, 9, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +ts.mjsSource; +>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>ts : Symbol(ts, Decl(index.ts, 10, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.mts, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.mts, 10, 6)) + +cjsi.mjsSource; +>cjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +mjsi.mjsSource; +>mjsi.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +typei.mjsSource; +>typei.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>typei : Symbol(typei, Decl(index.mts, 9, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +ts.mjsSource; +>ts.mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) +>ts : Symbol(ts, Decl(index.mts, 10, 6)) +>mjsSource : Symbol(cjsi.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +import * as cjsi from "inner/a"; +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) + +import * as mjsi from "inner/b"; +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.cts, 9, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.cts, 10, 6)) + +cjsi.cjsSource; +>cjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +mjsi.cjsSource; +>mjsi.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +typei.implicitCjsSource; +>typei.implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) +>typei : Symbol(typei, Decl(index.cts, 9, 6)) +>implicitCjsSource : Symbol(cjsi.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) + +ts.cjsSource; +>ts.cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) +>ts : Symbol(ts, Decl(index.cts, 10, 6)) +>cjsSource : Symbol(cjsi.cjsSource, Decl(index.d.cts, 9, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.ts, 4, 6)) + +export { cjs }; +>cjs : Symbol(mjs.type.cjs, Decl(index.d.ts, 5, 8)) + +export { mjs }; +>mjs : Symbol(mjs.type.mjs, Decl(index.d.ts, 6, 8)) + +export { type }; +>type : Symbol(mjs.type.type, Decl(index.d.ts, 7, 8)) + +export { ts }; +>ts : Symbol(mjs.type.ts, Decl(index.d.ts, 8, 8)) + +export const implicitCjsSource = true; +>implicitCjsSource : Symbol(mjs.type.implicitCjsSource, Decl(index.d.ts, 9, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.mts, 4, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs, Decl(index.d.mts, 5, 8)) + +export { mjs }; +>mjs : Symbol(mjs.mjs, Decl(index.d.mts, 6, 8)) + +export { type }; +>type : Symbol(mjs.type, Decl(index.d.mts, 7, 8)) + +export { ts }; +>ts : Symbol(mjs.ts, Decl(index.d.mts, 8, 8)) + +export const mjsSource = true; +>mjsSource : Symbol(mjs.mjsSource, Decl(index.d.mts, 9, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/b"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +import * as ts from "inner/types"; +>ts : Symbol(ts, Decl(index.d.cts, 4, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 5, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 6, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 7, 8)) + +export { ts }; +>ts : Symbol(cjs.ts, Decl(index.d.cts, 8, 8)) + +export const cjsSource = true; +>cjsSource : Symbol(cjs.cjsSource, Decl(index.d.cts, 9, 12)) + diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).types new file mode 100644 index 00000000000..d46ce7ffa46 --- /dev/null +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).types @@ -0,0 +1,246 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.mjsSource; +>cjsi.mjsSource : true +>cjsi : typeof cjsi +>mjsSource : true + +mjsi.mjsSource; +>mjsi.mjsSource : true +>mjsi : typeof cjsi +>mjsSource : true + +typei.mjsSource; +>typei.mjsSource : true +>typei : typeof cjsi +>mjsSource : true + +ts.mjsSource; +>ts.mjsSource : true +>ts : typeof cjsi +>mjsSource : true + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.mjsSource; +>cjsi.mjsSource : true +>cjsi : typeof cjsi +>mjsSource : true + +mjsi.mjsSource; +>mjsi.mjsSource : true +>mjsi : typeof cjsi +>mjsSource : true + +typei.mjsSource; +>typei.mjsSource : true +>typei : typeof cjsi +>mjsSource : true + +ts.mjsSource; +>ts.mjsSource : true +>ts : typeof cjsi +>mjsSource : true + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/a"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/b"; +>mjsi : typeof cjsi + +import * as typei from "inner"; +>typei : typeof cjsi.type + +import * as ts from "inner/types"; +>ts : typeof cjsi + +cjsi.cjsSource; +>cjsi.cjsSource : true +>cjsi : typeof cjsi +>cjsSource : true + +mjsi.cjsSource; +>mjsi.cjsSource : true +>mjsi : typeof cjsi +>cjsSource : true + +typei.implicitCjsSource; +>typei.implicitCjsSource : true +>typei : typeof cjsi.type +>implicitCjsSource : true + +ts.cjsSource; +>ts.cjsSource : true +>ts : typeof cjsi +>cjsSource : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : any + +import * as mjs from "inner/b"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs.type + +import * as ts from "inner/types"; +>ts : typeof mjs + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.type + +export { ts }; +>ts : typeof mjs + +export const implicitCjsSource = true; +>implicitCjsSource : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/a"; +>cjs : any + +import * as mjs from "inner/b"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs + +import * as ts from "inner/types"; +>ts : typeof mjs + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs + +export { ts }; +>ts : typeof mjs + +export const mjsSource = true; +>mjsSource : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/a"; +>cjs : typeof cjs + +import * as mjs from "inner/b"; +>mjs : typeof cjs + +import * as type from "inner"; +>type : typeof cjs.type + +import * as ts from "inner/types"; +>ts : typeof cjs + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs + +export { type }; +>type : typeof cjs.type + +export { ts }; +>ts : typeof cjs + +export const cjsSource = true; +>cjsSource : true +>true : true + diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt new file mode 100644 index 00000000000..11f39b9dd93 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt @@ -0,0 +1,116 @@ +tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/node/node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + export const a = cjs; + export const b = mjs; + export const c = type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + export const d = cjsi; + export const e = mjsi; + export const f = typei; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + export const a = cjs; + export const b = mjs; + export const c = type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + export const d = cjsi; + export const e = mjsi; + export const f = typei; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + export const a = cjs; + export const b = mjs; + export const c = type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner"; + export const d = cjsi; + export const e = mjsi; + export const f = typei; +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + cjs; + ~~~ +!!! error TS1036: Statements are not allowed in ambient contexts. + mjs; + type; + export const cjsMain = true; +==== tests/cases/conformance/node/node_modules/inner/index.d.mts (1 errors) ==== + // esm format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + cjs; + ~~~ +!!! error TS1036: Statements are not allowed in ambient contexts. + mjs; + type; + export const esm = true; +==== tests/cases/conformance/node/node_modules/inner/index.d.cts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + cjs; + ~~~ +!!! error TS1036: Statements are not allowed in ambient contexts. + mjs; + type; + export const cjsNonmain = true; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).js new file mode 100644 index 00000000000..7500542fd8d --- /dev/null +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).js @@ -0,0 +1,202 @@ +//// [tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts] //// + +//// [index.ts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; +//// [index.mts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; +//// [index.cts] +// cjs format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +cjs; +mjs; +type; +export const cjsMain = true; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +cjs; +mjs; +type; +export const esm = true; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +cjs; +mjs; +type; +export const cjsNonmain = true; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} + +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = exports.e = exports.d = exports.c = exports.b = exports.a = void 0; +// cjs format file +const cjs = __importStar(require("package/cjs")); +const mjs = __importStar(require("package/mjs")); +const type = __importStar(require("package")); +exports.a = cjs; +exports.b = mjs; +exports.c = type; +const cjsi = __importStar(require("inner/cjs")); +const mjsi = __importStar(require("inner/mjs")); +const typei = __importStar(require("inner")); +exports.d = cjsi; +exports.e = mjsi; +exports.f = typei; +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; + + +//// [index.d.mts] +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export declare const a: typeof cjs; +export declare const b: typeof mjs; +export declare const c: typeof type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export declare const d: typeof cjsi; +export declare const e: typeof mjsi; +export declare const f: typeof typei; +//// [index.d.cts] +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export declare const a: typeof cjs; +export declare const b: typeof mjs; +export declare const c: typeof type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export declare const d: typeof cjsi; +export declare const e: typeof mjsi; +export declare const f: typeof typei; +//// [index.d.ts] +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export declare const a: typeof cjs; +export declare const b: typeof mjs; +export declare const c: typeof type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export declare const d: typeof cjsi; +export declare const e: typeof mjsi; +export declare const f: typeof typei; diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).symbols new file mode 100644 index 00000000000..3af13052d29 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).symbols @@ -0,0 +1,201 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +export const a = cjs; +>a : Symbol(type.a, Decl(index.ts, 4, 12)) +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +export const b = mjs; +>b : Symbol(type.b, Decl(index.ts, 5, 12)) +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +export const c = type; +>c : Symbol(type.c, Decl(index.ts, 6, 12)) +>type : Symbol(type, Decl(index.ts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.ts, 9, 6)) + +export const d = cjsi; +>d : Symbol(type.d, Decl(index.ts, 10, 12)) +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) + +export const e = mjsi; +>e : Symbol(type.e, Decl(index.ts, 11, 12)) +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) + +export const f = typei; +>f : Symbol(type.f, Decl(index.ts, 12, 12)) +>typei : Symbol(typei, Decl(index.ts, 9, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +export const a = cjs; +>a : Symbol(mjs.a, Decl(index.mts, 4, 12)) +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +export const b = mjs; +>b : Symbol(mjs.b, Decl(index.mts, 5, 12)) +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +export const c = type; +>c : Symbol(mjs.c, Decl(index.mts, 6, 12)) +>type : Symbol(type, Decl(index.mts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.mts, 9, 6)) + +export const d = cjsi; +>d : Symbol(mjs.d, Decl(index.mts, 10, 12)) +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) + +export const e = mjsi; +>e : Symbol(mjs.e, Decl(index.mts, 11, 12)) +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) + +export const f = typei; +>f : Symbol(mjs.f, Decl(index.mts, 12, 12)) +>typei : Symbol(typei, Decl(index.mts, 9, 6)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +export const a = cjs; +>a : Symbol(cjs.a, Decl(index.cts, 4, 12)) +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +export const b = mjs; +>b : Symbol(cjs.b, Decl(index.cts, 5, 12)) +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +export const c = type; +>c : Symbol(cjs.c, Decl(index.cts, 6, 12)) +>type : Symbol(type, Decl(index.cts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.cts, 9, 6)) + +export const d = cjsi; +>d : Symbol(cjs.d, Decl(index.cts, 10, 12)) +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) + +export const e = mjsi; +>e : Symbol(cjs.e, Decl(index.cts, 11, 12)) +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) + +export const f = typei; +>f : Symbol(cjs.f, Decl(index.cts, 12, 12)) +>typei : Symbol(typei, Decl(index.cts, 9, 6)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export const cjsMain = true; +>cjsMain : Symbol(type.cjsMain, Decl(index.d.ts, 7, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export const esm = true; +>esm : Symbol(mjs.esm, Decl(index.d.mts, 7, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export const cjsNonmain = true; +>cjsNonmain : Symbol(cjs.cjsNonmain, Decl(index.d.cts, 7, 12)) + diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).types new file mode 100644 index 00000000000..5db63226d08 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).types @@ -0,0 +1,204 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +export const a = cjs; +>a : typeof cjs +>cjs : typeof cjs + +export const b = mjs; +>b : typeof mjs +>mjs : typeof mjs + +export const c = type; +>c : typeof type +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof mjsi + +import * as typei from "inner"; +>typei : typeof typei + +export const d = cjsi; +>d : typeof cjsi +>cjsi : typeof cjsi + +export const e = mjsi; +>e : typeof mjsi +>mjsi : typeof mjsi + +export const f = typei; +>f : typeof typei +>typei : typeof typei + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +export const a = cjs; +>a : typeof cjs +>cjs : typeof cjs + +export const b = mjs; +>b : typeof mjs +>mjs : typeof mjs + +export const c = type; +>c : typeof type +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof mjsi + +import * as typei from "inner"; +>typei : typeof typei + +export const d = cjsi; +>d : typeof cjsi +>cjsi : typeof cjsi + +export const e = mjsi; +>e : typeof mjsi +>mjsi : typeof mjsi + +export const f = typei; +>f : typeof typei +>typei : typeof typei + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +export const a = cjs; +>a : typeof cjs +>cjs : typeof cjs + +export const b = mjs; +>b : typeof mjs +>mjs : typeof mjs + +export const c = type; +>c : typeof type +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof mjsi + +import * as typei from "inner"; +>typei : typeof typei + +export const d = cjsi; +>d : typeof cjsi +>cjsi : typeof cjsi + +export const e = mjsi; +>e : typeof mjsi +>mjsi : typeof mjsi + +export const f = typei; +>f : typeof typei +>typei : typeof typei + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +export const cjsMain = true; +>cjsMain : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +export const esm = true; +>esm : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +export const cjsNonmain = true; +>cjsNonmain : true +>true : true + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node16).js b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).js new file mode 100644 index 00000000000..aceeafb8c59 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/node/nodeModulesDynamicImport.ts] //// + +//// [index.ts] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.ts] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} + + +//// [index.d.ts] +export declare function main(): Promise; +//// [index.d.ts] +export declare function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node16).symbols b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).symbols new file mode 100644 index 00000000000..69296bc3fa9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node16).types b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).types new file mode 100644 index 00000000000..879fb7ca71b --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).errors.txt new file mode 100644 index 00000000000..cef29663806 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/index.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const a = {}; + export = a; +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node16).js b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).js new file mode 100644 index 00000000000..2d09438ae7c --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/nodeModulesExportAssignments.ts] //// + +//// [index.ts] +// cjs format file +const a = {}; +export = a; +//// [index.ts] +// esm format file +const a = {}; +export = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; + + +//// [index.d.ts] +declare const a: {}; +export = a; +//// [index.d.ts] +declare const a: {}; +export = a; diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node16).symbols b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).symbols new file mode 100644 index 00000000000..4552dd34157 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node16).types b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).types new file mode 100644 index 00000000000..73f7e0869eb --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node16).types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt new file mode 100644 index 00000000000..53ab414e38b --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. +tests/cases/conformance/node/index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. + + +==== tests/cases/conformance/node/index.ts (2 errors) ==== + // esm format file + import { Thing } from "inner/other"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner")).x(); + ~ +!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; +==== tests/cases/conformance/node/node_modules/inner/other.d.ts (0 errors) ==== + // esm format file + export interface Thing {} + export const x: () => Thing; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).js b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).js new file mode 100644 index 00000000000..da6fe0fc800 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).js @@ -0,0 +1,30 @@ +//// [tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts] //// + +//// [index.ts] +// esm format file +import { Thing } from "inner/other"; +export const a = (await import("inner")).x(); +//// [index.d.ts] +// esm format file +export { x } from "./other.js"; +//// [other.d.ts] +// esm format file +export interface Thing {} +export const x: () => Thing; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} +//// [package.json] +{ + "name": "inner", + "private": true, + "type": "module", + "exports": "./index.js" +} + +//// [index.js] +export const a = (await import("inner")).x(); diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).symbols b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).symbols new file mode 100644 index 00000000000..07abee8390f --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : Symbol(Thing, Decl(index.ts, 1, 8)) + +export const a = (await import("inner")).x(); +>a : Symbol(a, Decl(index.ts, 2, 12)) +>(await import("inner")).x : Symbol(x, Decl(index.d.ts, 1, 8)) +>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0)) +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + +export const x: () => Thing; +>x : Symbol(x, Decl(other.d.ts, 2, 12)) +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).types b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).types new file mode 100644 index 00000000000..f7806a6a255 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : any + +export const a = (await import("inner")).x(); +>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")) : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>await import("inner") : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>import("inner") : Promise +>"inner" : "inner" +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +export const x: () => Thing; +>x : () => Thing + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt new file mode 100644 index 00000000000..b25fc090f8b --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import { Thing } from "inner/other.js"; // should fail + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. + export const a = (await import("inner")).x(); +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; +==== tests/cases/conformance/node/node_modules/inner/other.d.ts (0 errors) ==== + // esm format file + export interface Thing {} + export const x: () => Thing; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "type": "module", + "exports": { + ".": { + "default": "./index.js" + }, + "./other": { + "default": "./other.js" + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).js b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).js new file mode 100644 index 00000000000..5db58ae2f7b --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts] //// + +//// [index.ts] +// esm format file +import { Thing } from "inner/other.js"; // should fail +export const a = (await import("inner")).x(); +//// [index.d.ts] +// esm format file +export { x } from "./other.js"; +//// [other.d.ts] +// esm format file +export interface Thing {} +export const x: () => Thing; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} +//// [package.json] +{ + "name": "inner", + "private": true, + "type": "module", + "exports": { + ".": { + "default": "./index.js" + }, + "./other": { + "default": "./other.js" + } + } +} + +//// [index.js] +export const a = (await import("inner")).x(); + + +//// [index.d.ts] +export declare const a: import("inner/other").Thing; diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).symbols b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).symbols new file mode 100644 index 00000000000..1abea377c5f --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other.js"; // should fail +>Thing : Symbol(Thing, Decl(index.ts, 1, 8)) + +export const a = (await import("inner")).x(); +>a : Symbol(a, Decl(index.ts, 2, 12)) +>(await import("inner")).x : Symbol(x, Decl(index.d.ts, 1, 8)) +>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0)) +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + +export const x: () => Thing; +>x : Symbol(x, Decl(other.d.ts, 2, 12)) +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).types b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).types new file mode 100644 index 00000000000..6020ebf5b21 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other.js"; // should fail +>Thing : any + +export const a = (await import("inner")).x(); +>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner")) : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>await import("inner") : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>import("inner") : Promise +>"inner" : "inner" +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +export const x: () => Thing; +>x : () => Thing + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt new file mode 100644 index 00000000000..b2d874ee38b --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import { Thing } from "inner/other"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner/index.js")).x(); +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; +==== tests/cases/conformance/node/node_modules/inner/other.d.ts (0 errors) ==== + // esm format file + export interface Thing {} + export const x: () => Thing; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "type": "module", + "exports": { + "./": "./" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).js b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).js new file mode 100644 index 00000000000..c0d6b006b33 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts] //// + +//// [index.ts] +// esm format file +import { Thing } from "inner/other"; +export const a = (await import("inner/index.js")).x(); +//// [index.d.ts] +// esm format file +export { x } from "./other.js"; +//// [other.d.ts] +// esm format file +export interface Thing {} +export const x: () => Thing; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} +//// [package.json] +{ + "name": "inner", + "private": true, + "type": "module", + "exports": { + "./": "./" + } +} + +//// [index.js] +export const a = (await import("inner/index.js")).x(); + + +//// [index.d.ts] +export declare const a: import("inner/other.js").Thing; diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).symbols b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).symbols new file mode 100644 index 00000000000..a12a7b1c026 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : Symbol(Thing, Decl(index.ts, 1, 8)) + +export const a = (await import("inner/index.js")).x(); +>a : Symbol(a, Decl(index.ts, 2, 12)) +>(await import("inner/index.js")).x : Symbol(x, Decl(index.d.ts, 1, 8)) +>"inner/index.js" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0)) +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + +export const x: () => Thing; +>x : Symbol(x, Decl(other.d.ts, 2, 12)) +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).types b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).types new file mode 100644 index 00000000000..a75c2359eb0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : any + +export const a = (await import("inner/index.js")).x(); +>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")) : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>await import("inner/index.js") : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>import("inner/index.js") : Promise +>"inner/index.js" : "inner/index.js" +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +export const x: () => Thing; +>x : () => Thing + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt new file mode 100644 index 00000000000..c315a2a5232 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import { Thing } from "inner/other"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. + export const a = (await import("inner/index.js")).x(); +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (0 errors) ==== + // esm format file + export { x } from "./other.js"; +==== tests/cases/conformance/node/node_modules/inner/other.d.ts (0 errors) ==== + // esm format file + export interface Thing {} + export const x: () => Thing; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "type": "module", + "exports": { + "./*.js": "./*.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).js b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).js new file mode 100644 index 00000000000..dcdd62bed69 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts] //// + +//// [index.ts] +// esm format file +import { Thing } from "inner/other"; +export const a = (await import("inner/index.js")).x(); +//// [index.d.ts] +// esm format file +export { x } from "./other.js"; +//// [other.d.ts] +// esm format file +export interface Thing {} +export const x: () => Thing; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} +//// [package.json] +{ + "name": "inner", + "private": true, + "type": "module", + "exports": { + "./*.js": "./*.js" + } +} + +//// [index.js] +export const a = (await import("inner/index.js")).x(); + + +//// [index.d.ts] +export declare const a: import("inner/other.js").Thing; diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).symbols b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).symbols new file mode 100644 index 00000000000..a12a7b1c026 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : Symbol(Thing, Decl(index.ts, 1, 8)) + +export const a = (await import("inner/index.js")).x(); +>a : Symbol(a, Decl(index.ts, 2, 12)) +>(await import("inner/index.js")).x : Symbol(x, Decl(index.d.ts, 1, 8)) +>"inner/index.js" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.d.ts, 0, 0)) +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : Symbol(x, Decl(index.d.ts, 1, 8)) + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + +export const x: () => Thing; +>x : Symbol(x, Decl(other.d.ts, 2, 12)) +>Thing : Symbol(Thing, Decl(other.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).types b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).types new file mode 100644 index 00000000000..a75c2359eb0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import { Thing } from "inner/other"; +>Thing : any + +export const a = (await import("inner/index.js")).x(); +>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing +>(await import("inner/index.js")) : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>await import("inner/index.js") : typeof import("tests/cases/conformance/node/node_modules/inner/index") +>import("inner/index.js") : Promise +>"inner/index.js" : "inner/index.js" +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// esm format file +export { x } from "./other.js"; +>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing + +=== tests/cases/conformance/node/node_modules/inner/other.d.ts === +// esm format file +export interface Thing {} +export const x: () => Thing; +>x : () => Thing + diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).errors.txt new file mode 100644 index 00000000000..984483a332e --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).errors.txt @@ -0,0 +1,139 @@ +tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).js new file mode 100644 index 00000000000..4cca6af5a58 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).js @@ -0,0 +1,172 @@ +//// [tests/cases/conformance/node/nodeModulesForbidenSyntax.ts] //// + +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; + + +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).symbols new file mode 100644 index 00000000000..1ca35d0d3e3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).types new file mode 100644 index 00000000000..016af4314d1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node16).types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).errors.txt new file mode 100644 index 00000000000..e268184c7ff --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/subfolder/index.ts(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node16. +tests/cases/conformance/node/subfolder/index.ts(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/subfolder/index.ts (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node16. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).js new file mode 100644 index 00000000000..064128d216e --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts] //// + +//// [index.ts] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.ts] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; + + +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).symbols b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).symbols new file mode 100644 index 00000000000..9e967fe93b7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).types b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).types new file mode 100644 index 00000000000..094de6c8692 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node16).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt new file mode 100644 index 00000000000..5730914f867 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/node/index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/node/otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/node/otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + import json from "./package.json" assert { type: "json" }; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +==== tests/cases/conformance/node/otherc.cts (2 errors) ==== + import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "pkg", + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).js b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).js new file mode 100644 index 00000000000..091166d523c --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssertions.ts] //// + +//// [index.ts] +import json from "./package.json" assert { type: "json" }; +//// [otherc.cts] +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +//// [package.json] +{ + "name": "pkg", + "private": true, + "type": "module" +} + +//// [index.js] +export {}; +//// [otherc.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).symbols b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).symbols new file mode 100644 index 00000000000..3bacb3cfabe --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : Symbol(json, Decl(index.ts, 0, 6)) + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : Symbol(json, Decl(otherc.cts, 0, 6)) + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Symbol(json2, Decl(otherc.cts, 1, 5)) +>"./package.json" : Symbol("tests/cases/conformance/node/package", Decl(package.json, 0, 0)) +>assert : Symbol(assert, Decl(otherc.cts, 1, 40)) +>type : Symbol(type, Decl(otherc.cts, 1, 50)) + +=== tests/cases/conformance/node/package.json === +{ + "name": "pkg", +>"name" : Symbol("name", Decl(package.json, 0, 1)) + + "private": true, +>"private" : Symbol("private", Decl(package.json, 1, 18)) + + "type": "module" +>"type" : Symbol("type", Decl(package.json, 2, 20)) +} diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).types b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).types new file mode 100644 index 00000000000..36c03c4d926 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : { name: string; private: boolean; type: string; } +>type : any + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : { name: string; private: boolean; type: string; } +>type : any + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>import("./package.json", { assert: { type: "json" } }) : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>"./package.json" : "./package.json" +>{ assert: { type: "json" } } : { assert: { type: string; }; } +>assert : { type: string; } +>{ type: "json" } : { type: string; } +>type : string +>"json" : "json" + +=== tests/cases/conformance/node/package.json === +{ +>{ "name": "pkg", "private": true, "type": "module"} : { name: string; private: boolean; type: string; } + + "name": "pkg", +>"name" : string +>"pkg" : "pkg" + + "private": true, +>"private" : boolean +>true : true + + "type": "module" +>"type" : string +>"module" : "module" +} diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt index 29dbcb839f5..1a3369a277e 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt @@ -1,19 +1,13 @@ -tests/cases/conformance/node/index.ts(1,18): error TS7062: JSON imports are experimental in ES module mode imports. tests/cases/conformance/node/otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls. -tests/cases/conformance/node/otherc.cts(2,22): error TS7062: JSON imports are experimental in ES module mode imports. -==== tests/cases/conformance/node/index.ts (1 errors) ==== +==== tests/cases/conformance/node/index.ts (0 errors) ==== import json from "./package.json" assert { type: "json" }; - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. -==== tests/cases/conformance/node/otherc.cts (2 errors) ==== +==== tests/cases/conformance/node/otherc.cts (1 errors) ==== import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls. const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. ==== tests/cases/conformance/node/package.json (0 errors) ==== { "name": "pkg", diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node16).js b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).js new file mode 100644 index 00000000000..c73ff1177a5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).js @@ -0,0 +1,65 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssignments.ts] //// + +//// [index.ts] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.ts] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.ts] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; + + +//// [index.d.ts] +export import fs2 = require("fs"); +//// [index.d.ts] +export import fs2 = require("fs"); +//// [file.d.ts] +export import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node16).symbols b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).symbols new file mode 100644 index 00000000000..ae7fbc666da --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.ts, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.ts, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.ts, 4, 12)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node16).types b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).types new file mode 100644 index 00000000000..21af2cd798f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node16).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).errors.txt new file mode 100644 index 00000000000..b4ae0ff6fb0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).js new file mode 100644 index 00000000000..4712d65a099 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts] //// + +//// [index.ts] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.ts] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = tslib_1.__importDefault(require("fs")); +fs_1.default.readFile; +const fs = tslib_1.__importStar(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).symbols new file mode 100644 index 00000000000..996840abd4e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).types new file mode 100644 index 00000000000..e08e9456be9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node16).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).errors.txt new file mode 100644 index 00000000000..d2f62391af2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).js new file mode 100644 index 00000000000..c058d00e216 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.ts] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +tslib_1.__exportStar(require("fs"), exports); +exports.fs = tslib_1.__importStar(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).symbols new file mode 100644 index 00000000000..367ba59adf0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).types new file mode 100644 index 00000000000..6a468baefa7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node16).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).errors.txt new file mode 100644 index 00000000000..d511944f393 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export {default} from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).js new file mode 100644 index 00000000000..8abf8ba9ada --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts] //// + +//// [index.ts] +// cjs format file +export {default} from "fs"; +//// [index.ts] +// esm format file +export {default} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +//// [index.js] +// esm format file +export { default } from "fs"; + + +//// [index.d.ts] +export { default } from "fs"; +//// [index.d.ts] +export { default } from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).symbols new file mode 100644 index 00000000000..aec1d32dab1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).types new file mode 100644 index 00000000000..eef93356ac7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node16).types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportMeta(module=node16).errors.txt new file mode 100644 index 00000000000..27f6e3c9e28 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node16).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node16).js b/tests/baselines/reference/nodeModulesImportMeta(module=node16).js new file mode 100644 index 00000000000..aa962a90bd3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node16).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/node/nodeModulesImportMeta.ts] //// + +//// [index.ts] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.ts] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; + + +//// [index.d.ts] +declare const x: string; +export { x }; +//// [index.d.ts] +declare const x: string; +export { x }; diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node16).symbols b/tests/baselines/reference/nodeModulesImportMeta(module=node16).symbols new file mode 100644 index 00000000000..4a9cda0f125 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>meta : Symbol(ImportMetaExpression.meta) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>meta : Symbol(ImportMetaExpression.meta) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node16).types b/tests/baselines/reference/nodeModulesImportMeta(module=node16).types new file mode 100644 index 00000000000..6f64dc2b5fa --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt new file mode 100644 index 00000000000..a8a76a05152 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt @@ -0,0 +1,37 @@ +/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. +/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + + +==== /index.ts (3 errors) ==== + import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; + import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + + export interface LocalInterface extends RequireInterface, ImportInterface {} + + import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; + ~~~~~~~~~~~~~~~ +!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + export interface Loc extends Req, Imp {} + + export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; + export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export interface ImportInterface {} +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export interface RequireInterface {} \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).js b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).js new file mode 100644 index 00000000000..1b8bc65976e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export interface ImportInterface {} +//// [require.d.ts] +export interface RequireInterface {} +//// [index.ts] +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + +export interface LocalInterface extends RequireInterface, ImportInterface {} + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +export interface Loc extends Req, Imp {} + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [index.d.ts] +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +export interface LocalInterface extends RequireInterface, ImportInterface { +} +import { type RequireInterface as Req } from "pkg" assert { "resolution-mode": "require" }; +import { type ImportInterface as Imp } from "pkg" assert { "resolution-mode": "import" }; +export interface Loc extends Req, Imp { +} +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).symbols new file mode 100644 index 00000000000..e9a80972b95 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).symbols @@ -0,0 +1,38 @@ +=== /index.ts === +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 0, 13)) + +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 1, 13)) + +export interface LocalInterface extends RequireInterface, ImportInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 1, 82)) +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 0, 13)) +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 1, 13)) + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) +>Req : Symbol(Req, Decl(index.ts, 5, 8)) + +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +>Imp : Symbol(Imp, Decl(index.ts, 6, 8)) + +export interface Loc extends Req, Imp {} +>Loc : Symbol(Loc, Decl(index.ts, 6, 87)) +>Req : Symbol(Req, Decl(index.ts, 5, 8)) +>Imp : Symbol(Imp, Decl(index.ts, 6, 8)) + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 9, 13)) + +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 10, 13)) + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).types b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).types new file mode 100644 index 00000000000..61190a772be --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).types @@ -0,0 +1,30 @@ +=== /index.ts === +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : RequireInterface + +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : ImportInterface + +export interface LocalInterface extends RequireInterface, ImportInterface {} + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : any +>Req : any + +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : any +>Imp : any + +export interface Loc extends Req, Imp {} + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : RequireInterface + +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : ImportInterface + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt new file mode 100644 index 00000000000..0403a6e026f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt @@ -0,0 +1,42 @@ +/index.ts(6,14): error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. +/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + + +==== /index.ts (3 errors) ==== + import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; + import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + + export interface LocalInterface extends RequireInterface, ImportInterface {} + + import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; + ~~~~~~~~~~~~~~~~ +!!! error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + export interface Loc extends Req, Imp {} + + export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; + export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export interface ImportInterface {} +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export interface RequireInterface {} +==== /package.json (0 errors) ==== + { + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).js b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).js new file mode 100644 index 00000000000..fad19d466a6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit2.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export interface ImportInterface {} +//// [require.d.ts] +export interface RequireInterface {} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + +export interface LocalInterface extends RequireInterface, ImportInterface {} + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +export interface Loc extends Req, Imp {} + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + + +//// [index.js] +export {}; + + +//// [index.d.ts] +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +export interface LocalInterface extends RequireInterface, ImportInterface { +} +import { type RequireInterface as Req } from "pkg" assert { "resolution-mode": "require" }; +import { type ImportInterface as Imp } from "pkg" assert { "resolution-mode": "import" }; +export interface Loc extends Req, Imp { +} +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).symbols b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).symbols new file mode 100644 index 00000000000..fe172a1586e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).symbols @@ -0,0 +1,38 @@ +=== /index.ts === +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 0, 13)) + +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 1, 13)) + +export interface LocalInterface extends RequireInterface, ImportInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 1, 82)) +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 0, 13)) +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 1, 13)) + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +>Req : Symbol(Req, Decl(index.ts, 5, 8)) + +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) +>Imp : Symbol(Imp, Decl(index.ts, 6, 8)) + +export interface Loc extends Req, Imp {} +>Loc : Symbol(Loc, Decl(index.ts, 6, 87)) +>Req : Symbol(Req, Decl(index.ts, 5, 8)) +>Imp : Symbol(Imp, Decl(index.ts, 6, 8)) + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 9, 13)) + +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 10, 13)) + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).types b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).types new file mode 100644 index 00000000000..61190a772be --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).types @@ -0,0 +1,30 @@ +=== /index.ts === +import type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : RequireInterface + +import type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : ImportInterface + +export interface LocalInterface extends RequireInterface, ImportInterface {} + +import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : any +>Req : any + +import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : any +>Imp : any + +export interface Loc extends Req, Imp {} + +export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : RequireInterface + +export type { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : ImportInterface + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt new file mode 100644 index 00000000000..bc3eb30565c --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt @@ -0,0 +1,43 @@ +/index.ts(2,45): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. +/index.ts(4,39): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(6,76): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + + +==== /index.ts (5 errors) ==== + // incorrect mode + import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + ~~~~~~~~ +!!! error TS1453: `resolution-mode` should be either `require` or `import`. + // not type-only + import { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; + ~~~~~~~~~~~~~~~ +!!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + // not exclusively type-only + import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + + export interface LocalInterface extends RequireInterface, ImportInterface {} + + + + +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export interface ImportInterface {} +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export interface RequireInterface {} \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).js b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).js new file mode 100644 index 00000000000..3b2af2656d0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesImportModeDeclarationEmitErrors1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export interface ImportInterface {} +//// [require.d.ts] +export interface RequireInterface {} +//// [index.ts] +// incorrect mode +import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; +// not type-only +import { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +// not exclusively type-only +import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; + +export interface LocalInterface extends RequireInterface, ImportInterface {} + + + + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [index.d.ts] +import type { RequireInterface } from "pkg"; +import { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +export interface LocalInterface extends RequireInterface, ImportInterface { +} diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).symbols new file mode 100644 index 00000000000..fd145783183 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).symbols @@ -0,0 +1,28 @@ +=== /index.ts === +// incorrect mode +import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 1, 13)) + +// not type-only +import { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 3, 8)) + +// not exclusively type-only +import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) +>Req : Symbol(Req, Decl(index.ts, 5, 8)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) +>Req2 : Symbol(Req2, Decl(index.ts, 5, 37)) + +export interface LocalInterface extends RequireInterface, ImportInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 5, 115)) +>RequireInterface : Symbol(RequireInterface, Decl(index.ts, 1, 13)) +>ImportInterface : Symbol(ImportInterface, Decl(index.ts, 3, 8)) + + + + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).types b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).types new file mode 100644 index 00000000000..07bda5323db --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).types @@ -0,0 +1,24 @@ +=== /index.ts === +// incorrect mode +import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; +>RequireInterface : RequireInterface + +// not type-only +import { ImportInterface } from "pkg" assert { "resolution-mode": "import" }; +>ImportInterface : any + +// not exclusively type-only +import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; +>RequireInterface : any +>Req : any +>RequireInterface : any +>Req2 : any + +export interface LocalInterface extends RequireInterface, ImportInterface {} + + + + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).js b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).js new file mode 100644 index 00000000000..d9c0ba1a429 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts] //// + +//// [index.ts] +// esm format file +import * as type from "#type"; +type; +//// [index.mts] +// esm format file +import * as type from "#type"; +type; +//// [index.cts] +// esm format file +import * as type from "#type"; +type; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.cjs", + "imports": { + "#type": "package" + } +} + +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const type = __importStar(require("#type")); +type; +//// [index.js] +// esm format file +import * as type from "#type"; +type; +//// [index.mjs] +// esm format file +import * as type from "#type"; +type; + + +//// [index.d.cts] +export {}; +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).symbols b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).symbols new file mode 100644 index 00000000000..1a0ad59fc81 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.ts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.ts, 1, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.mts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.mts, 1, 6)) + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.cts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.cts, 1, 6)) + diff --git a/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).types b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).types new file mode 100644 index 00000000000..cb05ede987e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionIntoExport(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as type from "#type"; +>type : typeof type + +type; +>type : typeof type + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as type from "#type"; +>type : typeof type + +type; +>type : typeof type + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as type from "#type"; +>type : typeof type + +type; +>type : typeof type + diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).errors.txt new file mode 100644 index 00000000000..c73a7a7885f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + type; +==== tests/cases/conformance/node/index.mts (1 errors) ==== + // esm format file + import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + type; +==== tests/cases/conformance/node/index.cts (1 errors) ==== + // esm format file + import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + type; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "package", + "imports": { + "#type": "package" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).js b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).js new file mode 100644 index 00000000000..a5ed511f6f5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts] //// + +//// [index.ts] +// esm format file +import * as type from "#type"; +type; +//// [index.mts] +// esm format file +import * as type from "#type"; +type; +//// [index.cts] +// esm format file +import * as type from "#type"; +type; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "package", + "imports": { + "#type": "package" + } +} + +//// [index.js] +// esm format file +import * as type from "#type"; +type; +//// [index.mjs] +// esm format file +import * as type from "#type"; +type; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const type = __importStar(require("#type")); +type; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).symbols b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).symbols new file mode 100644 index 00000000000..1a0ad59fc81 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.ts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.ts, 1, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.mts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.mts, 1, 6)) + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as type from "#type"; +>type : Symbol(type, Decl(index.cts, 1, 6)) + +type; +>type : Symbol(type, Decl(index.cts, 1, 6)) + diff --git a/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).types b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).types new file mode 100644 index 00000000000..8bfd3afd06e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportResolutionNoCycle(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as type from "#type"; +>type : any + +type; +>type : any + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as type from "#type"; +>type : any + +type; +>type : any + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as type from "#type"; +>type : any + +type; +>type : any + diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js new file mode 100644 index 00000000000..4a65e05cdd9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export interface ImportInterface {} +//// [require.d.ts] +export interface RequireInterface {} +//// [index.ts] +export type LocalInterface = + & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +exports.a = null; +exports.b = null; + + +//// [index.d.ts] +export declare type LocalInterface = import("pkg", { assert: { "resolution-mode": "require" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg").RequireInterface; +export declare const b: import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols new file mode 100644 index 00000000000..dd5d4527772 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).symbols @@ -0,0 +1,26 @@ +=== /index.ts === +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) + + & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +>a : Symbol(a, Decl(index.ts, 4, 12)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +>b : Symbol(b, Decl(index.ts, 5, 12)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types new file mode 100644 index 00000000000..520761d1b0a --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmit1(module=node16).types @@ -0,0 +1,26 @@ +=== /index.ts === +export type LocalInterface = +>LocalInterface : import("/node_modules/pkg/require").RequireInterface & import("/node_modules/pkg/import").ImportInterface + + & import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface); +>a : import("/node_modules/pkg/require").RequireInterface +>(null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface) : import("/node_modules/pkg/require").RequireInterface +>null as any as import("pkg", { assert: {"resolution-mode": "require"} }).RequireInterface : import("/node_modules/pkg/require").RequireInterface +>null as any : any +>null : null + +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +>b : import("/node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("/node_modules/pkg/import").ImportInterface +>null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("/node_modules/pkg/import").ImportInterface +>null as any : any +>null : null + +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt new file mode 100644 index 00000000000..b8b88af5ded --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt @@ -0,0 +1,304 @@ +/index.ts(2,51): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(5,78): error TS1453: `resolution-mode` should be either `require` or `import`. +/other.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other.ts(3,22): error TS1005: 'assert' expected. +/other.ts(3,39): error TS1005: ';' expected. +/other.ts(3,50): error TS1128: Declaration or statement expected. +/other.ts(3,51): error TS1128: Declaration or statement expected. +/other.ts(3,52): error TS1128: Declaration or statement expected. +/other.ts(3,53): error TS2304: Cannot find name 'RequireInterface'. +/other.ts(4,22): error TS2322: Type '{ "resolution-mode": string; }' is not assignable to type 'ImportCallOptions'. + Object literal may only specify known properties, and '"resolution-mode"' does not exist in type 'ImportCallOptions'. +/other.ts(4,52): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. +/other.ts(6,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other.ts(6,49): error TS1005: 'assert' expected. +/other.ts(6,66): error TS1005: ';' expected. +/other.ts(6,77): error TS1128: Declaration or statement expected. +/other.ts(6,78): error TS1128: Declaration or statement expected. +/other.ts(6,79): error TS1128: Declaration or statement expected. +/other.ts(6,80): error TS1434: Unexpected keyword or identifier. +/other.ts(6,80): error TS2304: Cannot find name 'RequireInterface'. +/other.ts(6,96): error TS1128: Declaration or statement expected. +/other.ts(7,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other.ts(7,49): error TS1005: 'assert' expected. +/other.ts(7,66): error TS1005: ';' expected. +/other.ts(7,76): error TS1128: Declaration or statement expected. +/other.ts(7,77): error TS1128: Declaration or statement expected. +/other.ts(7,78): error TS1128: Declaration or statement expected. +/other.ts(7,79): error TS1434: Unexpected keyword or identifier. +/other.ts(7,79): error TS2304: Cannot find name 'ImportInterface'. +/other.ts(7,94): error TS1128: Declaration or statement expected. +/other2.ts(3,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,32): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(4,52): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other2.ts(6,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,59): error TS1455: `resolution-mode` is the only valid key for type import assertions. +/other2.ts(7,79): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other3.ts(3,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other3.ts(3,21): error TS1005: '{' expected. +/other3.ts(3,23): error TS2538: Type '{ "resolution-mode": "require"; }' cannot be used as an index type. +/other3.ts(3,55): error TS1005: ';' expected. +/other3.ts(3,56): error TS1128: Declaration or statement expected. +/other3.ts(3,57): error TS2304: Cannot find name 'RequireInterface'. +/other3.ts(4,21): error TS2559: Type '{ "resolution-mode": string; }[]' has no properties in common with type 'ImportCallOptions'. +/other3.ts(4,56): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. +/other3.ts(6,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other3.ts(6,48): error TS1005: '{' expected. +/other3.ts(6,50): error TS2538: Type '{ "resolution-mode": "require"; }' cannot be used as an index type. +/other3.ts(6,100): error TS1005: ',' expected. +/other3.ts(7,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other3.ts(7,48): error TS1005: '{' expected. +/other3.ts(7,50): error TS2538: Type '{ "resolution-mode": "import"; }' cannot be used as an index type. +/other3.ts(7,98): error TS1005: ',' expected. +/other4.ts(6,7): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other4.ts(6,21): error TS1005: '{' expected. +/other4.ts(6,21): error TS2448: Block-scoped variable 'Asserts1' used before its declaration. +/other4.ts(6,29): error TS1128: Declaration or statement expected. +/other4.ts(6,30): error TS1128: Declaration or statement expected. +/other4.ts(6,31): error TS2448: Block-scoped variable 'RequireInterface' used before its declaration. +/other4.ts(7,21): error TS2448: Block-scoped variable 'Asserts2' used before its declaration. +/other4.ts(7,31): error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. +/other4.ts(9,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other4.ts(9,48): error TS1005: '{' expected. +/other4.ts(9,56): error TS1005: ',' expected. +/other4.ts(9,57): error TS1134: Variable declaration expected. +/other4.ts(9,74): error TS1005: ',' expected. +/other4.ts(10,34): error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? +/other4.ts(10,48): error TS1005: '{' expected. +/other4.ts(10,56): error TS1005: ',' expected. +/other4.ts(10,57): error TS1134: Variable declaration expected. +/other4.ts(10,73): error TS1005: ',' expected. +/other5.ts(2,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,31): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(3,37): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +/other5.ts(5,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,58): error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. +/other5.ts(6,64): error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. + + +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export interface ImportInterface {} +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export interface RequireInterface {} +==== /index.ts (2 errors) ==== + export type LocalInterface = + & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + ~~~~~~~~ +!!! error TS1453: `resolution-mode` should be either `require` or `import`. + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + + export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); + ~~~~~~~~ +!!! error TS1453: `resolution-mode` should be either `require` or `import`. + export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +==== /other.ts (27 errors) ==== + // missing assert: + export type LocalInterface = + & import("pkg", {"resolution-mode": "require"}).RequireInterface + ~~~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~~~~~~~~~~ +!!! error TS1005: 'assert' expected. +!!! related TS1007 /other.ts:3:21: The parser expected to find a '}' to match the '{' token here. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'RequireInterface'. + & import("pkg", {"resolution-mode": "import"}).ImportInterface; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type '{ "resolution-mode": string; }' is not assignable to type 'ImportCallOptions'. +!!! error TS2322: Object literal may only specify known properties, and '"resolution-mode"' does not exist in type 'ImportCallOptions'. + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. + + export const a = (null as any as import("pkg", {"resolution-mode": "require"}).RequireInterface); + ~~~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~~~~~~~~~~ +!!! error TS1005: 'assert' expected. +!!! related TS1007 /other.ts:6:48: The parser expected to find a '}' to match the '{' token here. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~~~~~~~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'RequireInterface'. + ~ +!!! error TS1128: Declaration or statement expected. + export const b = (null as any as import("pkg", {"resolution-mode": "import"}).ImportInterface); + ~~~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~~~~~~~~~~ +!!! error TS1005: 'assert' expected. +!!! related TS1007 /other.ts:7:48: The parser expected to find a '}' to match the '{' token here. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~~~~~~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'ImportInterface'. + ~ +!!! error TS1128: Declaration or statement expected. +==== /other2.ts (6 errors) ==== + // wrong assertion key + export type LocalInterface = + & import("pkg", { assert: {"bad": "require"} }).RequireInterface + ~~~~~ +!!! error TS1455: `resolution-mode` is the only valid key for type import assertions. + & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + ~~~~~ +!!! error TS1455: `resolution-mode` is the only valid key for type import assertions. + ~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. + + export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); + ~~~~~ +!!! error TS1455: `resolution-mode` is the only valid key for type import assertions. + export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); + ~~~~~ +!!! error TS1455: `resolution-mode` is the only valid key for type import assertions. + ~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. +==== /other3.ts (16 errors) ==== + // Array instead of object-y thing + export type LocalInterface = + & import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other3.ts:3:21: The parser expected to find a '}' to match the '{' token here. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2538: Type '{ "resolution-mode": "require"; }' cannot be used as an index type. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'RequireInterface'. + & import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2559: Type '{ "resolution-mode": string; }[]' has no properties in common with type 'ImportCallOptions'. + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. + + export const a = (null as any as import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface); + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other3.ts:6:48: The parser expected to find a '}' to match the '{' token here. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2538: Type '{ "resolution-mode": "require"; }' cannot be used as an index type. + ~ +!!! error TS1005: ',' expected. + export const b = (null as any as import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface); + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other3.ts:7:48: The parser expected to find a '}' to match the '{' token here. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2538: Type '{ "resolution-mode": "import"; }' cannot be used as an index type. + ~ +!!! error TS1005: ',' expected. +==== /other4.ts (18 errors) ==== + // Indirected assertion objecty-thing - not allowed + type Asserts1 = { assert: {"resolution-mode": "require"} }; + type Asserts2 = { assert: {"resolution-mode": "import"} }; + + export type LocalInterface = + & import("pkg", Asserts1).RequireInterface + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other4.ts:6:21: The parser expected to find a '}' to match the '{' token here. + ~~~~~~~~ +!!! error TS2448: Block-scoped variable 'Asserts1' used before its declaration. +!!! related TS2728 /other4.ts:9:48: 'Asserts1' is declared here. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~~~~~~~~~~~ +!!! error TS2448: Block-scoped variable 'RequireInterface' used before its declaration. +!!! related TS2728 /other4.ts:9:58: 'RequireInterface' is declared here. + & import("pkg", Asserts2).ImportInterface; + ~~~~~~~~ +!!! error TS2448: Block-scoped variable 'Asserts2' used before its declaration. +!!! related TS2728 /other4.ts:10:48: 'Asserts2' is declared here. + ~~~~~~~~~~~~~~~ +!!! error TS2339: Property 'ImportInterface' does not exist on type 'Promise<{ default: typeof import("/node_modules/pkg/import"); }>'. + + export const a = (null as any as import("pkg", Asserts1).RequireInterface); + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other4.ts:9:48: The parser expected to find a '}' to match the '{' token here. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1134: Variable declaration expected. + ~ +!!! error TS1005: ',' expected. + export const b = (null as any as import("pkg", Asserts2).ImportInterface); + ~~~~~~~~~~~~~ +!!! error TS1340: Module 'pkg' does not refer to a type, but is used as a type here. Did you mean 'typeof import('pkg')'? + ~~~~~~~~ +!!! error TS1005: '{' expected. +!!! related TS1007 /other4.ts:10:48: The parser expected to find a '}' to match the '{' token here. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1134: Variable declaration expected. + ~ +!!! error TS1005: ',' expected. +==== /other5.ts (6 errors) ==== + export type LocalInterface = + & import("pkg", { assert: {} }).RequireInterface + ~~ +!!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. + & import("pkg", { assert: {} }).ImportInterface; + ~~ +!!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. + ~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. + + export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); + ~~ +!!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. + export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + ~~ +!!! error TS1456: Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`. + ~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace '"/node_modules/pkg/require"' has no exported member 'ImportInterface'. + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js new file mode 100644 index 00000000000..7fd0aff8e8f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).js @@ -0,0 +1,147 @@ +//// [tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export interface ImportInterface {} +//// [require.d.ts] +export interface RequireInterface {} +//// [index.ts] +export type LocalInterface = + & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +//// [other.ts] +// missing assert: +export type LocalInterface = + & import("pkg", {"resolution-mode": "require"}).RequireInterface + & import("pkg", {"resolution-mode": "import"}).ImportInterface; + +export const a = (null as any as import("pkg", {"resolution-mode": "require"}).RequireInterface); +export const b = (null as any as import("pkg", {"resolution-mode": "import"}).ImportInterface); +//// [other2.ts] +// wrong assertion key +export type LocalInterface = + & import("pkg", { assert: {"bad": "require"} }).RequireInterface + & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); +export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); +//// [other3.ts] +// Array instead of object-y thing +export type LocalInterface = + & import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface + & import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface; + +export const a = (null as any as import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface); +export const b = (null as any as import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface); +//// [other4.ts] +// Indirected assertion objecty-thing - not allowed +type Asserts1 = { assert: {"resolution-mode": "require"} }; +type Asserts2 = { assert: {"resolution-mode": "import"} }; + +export type LocalInterface = + & import("pkg", Asserts1).RequireInterface + & import("pkg", Asserts2).ImportInterface; + +export const a = (null as any as import("pkg", Asserts1).RequireInterface); +export const b = (null as any as import("pkg", Asserts2).ImportInterface); +//// [other5.ts] +export type LocalInterface = + & import("pkg", { assert: {} }).RequireInterface + & import("pkg", { assert: {} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); +export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +exports.a = null; +exports.b = null; +//// [other.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +"resolution-mode"; +"require"; +RequireInterface + & import("pkg", { "resolution-mode": "import" }).ImportInterface; +exports.a = null; +"resolution-mode"; +"require"; +RequireInterface; +; +exports.b = null; +"resolution-mode"; +"import"; +ImportInterface; +; +//// [other2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +exports.a = null; +exports.b = null; +//// [other3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +RequireInterface + & import("pkg", [{ "resolution-mode": "import" }]).ImportInterface; +exports.a = null.RequireInterface; +exports.b = null.ImportInterface; +//// [other4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ImportInterface = exports.Asserts2 = exports.b = exports.RequireInterface = exports.Asserts1 = exports.a = void 0; +exports.Asserts1; +exports.RequireInterface + & import("pkg", exports.Asserts2).ImportInterface; +exports.a = null; +exports.b = null; +//// [other5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.b = exports.a = void 0; +exports.a = null; +exports.b = null; + + +//// [index.d.ts] +export declare type LocalInterface = import("pkg", { assert: { "resolution-mode": "foobar" } }).RequireInterface & import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; +export declare const a: import("pkg").RequireInterface; +export declare const b: import("pkg", { assert: { "resolution-mode": "import" } }).ImportInterface; +//// [other.d.ts] +export declare type LocalInterface = import("pkg", { assert: {} }); +export declare const a: any; +export declare const b: any; +//// [other2.d.ts] +export declare type LocalInterface = import("pkg", { assert: { "bad": "require" } }).RequireInterface & import("pkg", { assert: { "bad": "import" } }).ImportInterface; +export declare const a: import("pkg").RequireInterface; +export declare const b: any; +//// [other3.d.ts] +export declare type LocalInterface = import("pkg", { assert: {} })[{ + "resolution-mode": "require"; +}]; +export declare const a: any; +export declare const b: any; +//// [other4.d.ts] +export declare type LocalInterface = import("pkg", { assert: {} }); +export declare const a: any, Asserts1: any, RequireInterface: any; +export declare const b: any, Asserts2: any, ImportInterface: any; +//// [other5.d.ts] +export declare type LocalInterface = import("pkg", { assert: {} }).RequireInterface & import("pkg", { assert: {} }).ImportInterface; +export declare const a: import("pkg").RequireInterface; +export declare const b: any; diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols new file mode 100644 index 00000000000..71b67ec81d6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).symbols @@ -0,0 +1,128 @@ +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + +=== /index.ts === +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) + + & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +>a : Symbol(a, Decl(index.ts, 4, 12)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +>b : Symbol(b, Decl(index.ts, 5, 12)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 0, 0)) + +=== /other.ts === +// missing assert: +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(other.ts, 0, 0)) + + & import("pkg", {"resolution-mode": "require"}).RequireInterface + & import("pkg", {"resolution-mode": "import"}).ImportInterface; +>"pkg" : Symbol("/node_modules/pkg/import", Decl(import.d.ts, 0, 0)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other.ts, 3, 21)) + +export const a = (null as any as import("pkg", {"resolution-mode": "require"}).RequireInterface); +>a : Symbol(a, Decl(other.ts, 5, 12)) + +export const b = (null as any as import("pkg", {"resolution-mode": "import"}).ImportInterface); +>b : Symbol(b, Decl(other.ts, 6, 12)) + +=== /other2.ts === +// wrong assertion key +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(other2.ts, 0, 0)) + + & import("pkg", { assert: {"bad": "require"} }).RequireInterface +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + + & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); +>a : Symbol(a, Decl(other2.ts, 5, 12)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + +export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); +>b : Symbol(b, Decl(other2.ts, 6, 12)) + +=== /other3.ts === +// Array instead of object-y thing +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(other3.ts, 0, 0)) + + & import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface +>"resolution-mode" : Symbol("resolution-mode", Decl(other3.ts, 2, 23)) + + & import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface; +>"pkg" : Symbol("/node_modules/pkg/import", Decl(import.d.ts, 0, 0)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other3.ts, 3, 23)) + +export const a = (null as any as import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface); +>a : Symbol(a, Decl(other3.ts, 5, 12)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other3.ts, 5, 50)) + +export const b = (null as any as import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface); +>b : Symbol(b, Decl(other3.ts, 6, 12)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other3.ts, 6, 50)) + +=== /other4.ts === +// Indirected assertion objecty-thing - not allowed +type Asserts1 = { assert: {"resolution-mode": "require"} }; +>Asserts1 : Symbol(Asserts1, Decl(other4.ts, 0, 0), Decl(other4.ts, 8, 46)) +>assert : Symbol(assert, Decl(other4.ts, 1, 17)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other4.ts, 1, 27)) + +type Asserts2 = { assert: {"resolution-mode": "import"} }; +>Asserts2 : Symbol(Asserts2, Decl(other4.ts, 1, 59), Decl(other4.ts, 9, 46)) +>assert : Symbol(assert, Decl(other4.ts, 2, 17)) +>"resolution-mode" : Symbol("resolution-mode", Decl(other4.ts, 2, 27)) + +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(other4.ts, 2, 58)) + + & import("pkg", Asserts1).RequireInterface +>Asserts1 : Symbol(Asserts1, Decl(other4.ts, 8, 46)) +>RequireInterface : Symbol(RequireInterface, Decl(other4.ts, 8, 57)) + + & import("pkg", Asserts2).ImportInterface; +>"pkg" : Symbol("/node_modules/pkg/import", Decl(import.d.ts, 0, 0)) +>Asserts2 : Symbol(Asserts2, Decl(other4.ts, 9, 46)) + +export const a = (null as any as import("pkg", Asserts1).RequireInterface); +>a : Symbol(a, Decl(other4.ts, 8, 12)) +>Asserts1 : Symbol(Asserts1, Decl(other4.ts, 8, 46)) +>RequireInterface : Symbol(RequireInterface, Decl(other4.ts, 8, 57)) + +export const b = (null as any as import("pkg", Asserts2).ImportInterface); +>b : Symbol(b, Decl(other4.ts, 9, 12)) +>Asserts2 : Symbol(Asserts2, Decl(other4.ts, 9, 46)) +>ImportInterface : Symbol(ImportInterface, Decl(other4.ts, 9, 57)) + +=== /other5.ts === +export type LocalInterface = +>LocalInterface : Symbol(LocalInterface, Decl(other5.ts, 0, 0)) + + & import("pkg", { assert: {} }).RequireInterface +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + + & import("pkg", { assert: {} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); +>a : Symbol(a, Decl(other5.ts, 4, 12)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 0, 0)) + +export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); +>b : Symbol(b, Decl(other5.ts, 5, 12)) + diff --git a/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types new file mode 100644 index 00000000000..1b75c0fff24 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).types @@ -0,0 +1,193 @@ +=== /node_modules/pkg/import.d.ts === +export interface ImportInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export interface RequireInterface {} +No type information for this code.=== /index.ts === +export type LocalInterface = +>LocalInterface : import("/node_modules/pkg/require").RequireInterface & import("/node_modules/pkg/import").ImportInterface + + & import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface + & import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface); +>a : import("/node_modules/pkg/require").RequireInterface +>(null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface) : import("/node_modules/pkg/require").RequireInterface +>null as any as import("pkg", { assert: {"resolution-mode": "foobar"} }).RequireInterface : import("/node_modules/pkg/require").RequireInterface +>null as any : any +>null : null + +export const b = (null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface); +>b : import("/node_modules/pkg/import").ImportInterface +>(null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface) : import("/node_modules/pkg/import").ImportInterface +>null as any as import("pkg", { assert: {"resolution-mode": "import"} }).ImportInterface : import("/node_modules/pkg/import").ImportInterface +>null as any : any +>null : null + +=== /other.ts === +// missing assert: +export type LocalInterface = +>LocalInterface : any + + & import("pkg", {"resolution-mode": "require"}).RequireInterface +>"resolution-mode" : "resolution-mode" +>"require" : "require" +>RequireInterface & import("pkg", {"resolution-mode": "import"}).ImportInterface : number +>RequireInterface : any + + & import("pkg", {"resolution-mode": "import"}).ImportInterface; +>import("pkg", {"resolution-mode": "import"}).ImportInterface : any +>import("pkg", {"resolution-mode": "import"}) : Promise<{ default: typeof import("/node_modules/pkg/import"); }> +>"pkg" : "pkg" +>{"resolution-mode": "import"} : { "resolution-mode": string; } +>"resolution-mode" : string +>"import" : "import" +>ImportInterface : any + +export const a = (null as any as import("pkg", {"resolution-mode": "require"}).RequireInterface); +>a : any +>(null as any as import("pkg", { : any +>null as any as import("pkg", { : any +>null as any : any +>null : null +>"resolution-mode" : "resolution-mode" +>"require" : "require" +>RequireInterface : any + +export const b = (null as any as import("pkg", {"resolution-mode": "import"}).ImportInterface); +>b : any +>(null as any as import("pkg", { : any +>null as any as import("pkg", { : any +>null as any : any +>null : null +>"resolution-mode" : "resolution-mode" +>"import" : "import" +>ImportInterface : any + +=== /other2.ts === +// wrong assertion key +export type LocalInterface = +>LocalInterface : any + + & import("pkg", { assert: {"bad": "require"} }).RequireInterface + & import("pkg", { assert: {"bad": "import"} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface); +>a : import("/node_modules/pkg/require").RequireInterface +>(null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface) : import("/node_modules/pkg/require").RequireInterface +>null as any as import("pkg", { assert: {"bad": "require"} }).RequireInterface : import("/node_modules/pkg/require").RequireInterface +>null as any : any +>null : null + +export const b = (null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface); +>b : any +>(null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface) : any +>null as any as import("pkg", { assert: {"bad": "import"} }).ImportInterface : any +>null as any : any +>null : null + +=== /other3.ts === +// Array instead of object-y thing +export type LocalInterface = +>LocalInterface : any + + & import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface +>"resolution-mode" : "require" +>RequireInterface & import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface : number +>RequireInterface : any + + & import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface; +>import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface : any +>import("pkg", [ {"resolution-mode": "import"} ]) : Promise<{ default: typeof import("/node_modules/pkg/import"); }> +>"pkg" : "pkg" +>[ {"resolution-mode": "import"} ] : { "resolution-mode": string; }[] +>{"resolution-mode": "import"} : { "resolution-mode": string; } +>"resolution-mode" : string +>"import" : "import" +>ImportInterface : any + +export const a = (null as any as import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface); +>a : any +>(null as any as import("pkg", [ {"resolution-mode": "require"} ]).RequireInterface : any +>(null as any as import("pkg", [ {"resolution-mode": "require"} ]) : any +>null as any as import("pkg", [ {"resolution-mode": "require"} ] : any +>null as any : any +>null : null +>"resolution-mode" : "require" +>RequireInterface : any + +export const b = (null as any as import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface); +>b : any +>(null as any as import("pkg", [ {"resolution-mode": "import"} ]).ImportInterface : any +>(null as any as import("pkg", [ {"resolution-mode": "import"} ]) : any +>null as any as import("pkg", [ {"resolution-mode": "import"} ] : any +>null as any : any +>null : null +>"resolution-mode" : "import" +>ImportInterface : any + +=== /other4.ts === +// Indirected assertion objecty-thing - not allowed +type Asserts1 = { assert: {"resolution-mode": "require"} }; +>Asserts1 : { assert: { "resolution-mode": "require";}; } +>assert : { "resolution-mode": "require"; } +>"resolution-mode" : "require" + +type Asserts2 = { assert: {"resolution-mode": "import"} }; +>Asserts2 : { assert: { "resolution-mode": "import";}; } +>assert : { "resolution-mode": "import"; } +>"resolution-mode" : "import" + +export type LocalInterface = +>LocalInterface : any + + & import("pkg", Asserts1).RequireInterface +>Asserts1 : any +>RequireInterface & import("pkg", Asserts2).ImportInterface : number +>RequireInterface : any + + & import("pkg", Asserts2).ImportInterface; +>import("pkg", Asserts2).ImportInterface : any +>import("pkg", Asserts2) : Promise<{ default: typeof import("/node_modules/pkg/import"); }> +>"pkg" : "pkg" +>Asserts2 : any +>ImportInterface : any + +export const a = (null as any as import("pkg", Asserts1).RequireInterface); +>a : any +>(null as any as import("pkg", : any +>null as any as import("pkg", : any +>null as any : any +>null : null +>Asserts1 : any +>RequireInterface : any + +export const b = (null as any as import("pkg", Asserts2).ImportInterface); +>b : any +>(null as any as import("pkg", : any +>null as any as import("pkg", : any +>null as any : any +>null : null +>Asserts2 : any +>ImportInterface : any + +=== /other5.ts === +export type LocalInterface = +>LocalInterface : any + + & import("pkg", { assert: {} }).RequireInterface + & import("pkg", { assert: {} }).ImportInterface; + +export const a = (null as any as import("pkg", { assert: {} }).RequireInterface); +>a : import("/node_modules/pkg/require").RequireInterface +>(null as any as import("pkg", { assert: {} }).RequireInterface) : import("/node_modules/pkg/require").RequireInterface +>null as any as import("pkg", { assert: {} }).RequireInterface : import("/node_modules/pkg/require").RequireInterface +>null as any : any +>null : null + +export const b = (null as any as import("pkg", { assert: {} }).ImportInterface); +>b : any +>(null as any as import("pkg", { assert: {} }).ImportInterface) : any +>null as any as import("pkg", { assert: {} }).ImportInterface : any +>null as any : any +>null : null + diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt new file mode 100644 index 00000000000..464db33f319 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt @@ -0,0 +1,107 @@ +tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + ~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesPackageExports(module=node16).js new file mode 100644 index 00000000000..d974207d7b4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageExports(module=node16).js @@ -0,0 +1,165 @@ +//// [tests/cases/conformance/node/nodeModulesPackageExports.ts] //// + +//// [index.ts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.mts] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.cts] +// cjs format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs"; +import * as mjs from "inner/mjs"; +import * as type from "inner"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } +} + +//// [index.mjs] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjs = __importStar(require("package/cjs")); +const mjs = __importStar(require("package/mjs")); +const type = __importStar(require("package")); +cjs; +mjs; +type; +const cjsi = __importStar(require("inner/cjs")); +const mjsi = __importStar(require("inner/mjs")); +const typei = __importStar(require("inner")); +cjsi; +mjsi; +typei; +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; + + +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesPackageExports(module=node16).symbols new file mode 100644 index 00000000000..0a2a74496f4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageExports(module=node16).symbols @@ -0,0 +1,174 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.ts, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.ts, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.ts, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.ts, 9, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.mts, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mts, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mts, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mts, 9, 6)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +import * as mjs from "package/mjs"; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +import * as type from "package"; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +import * as cjsi from "inner/cjs"; +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) + +import * as mjsi from "inner/mjs"; +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) + +import * as typei from "inner"; +>typei : Symbol(typei, Decl(index.cts, 9, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cts, 7, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cts, 8, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cts, 9, 6)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesPackageExports(module=node16).types new file mode 100644 index 00000000000..8d3dcec7235 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageExports(module=node16).types @@ -0,0 +1,174 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjs from "package/cjs"; +>cjs : typeof cjs + +import * as mjs from "package/mjs"; +>mjs : typeof mjs + +import * as type from "package"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +import * as cjsi from "inner/cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : any + +import * as mjs from "inner/mjs"; +>mjs : typeof mjs + +import * as type from "inner"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs"; +>mjs : typeof cjs.mjs + +import * as type from "inner"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt new file mode 100644 index 00000000000..cc174f1eb7e --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt @@ -0,0 +1,44 @@ +tests/cases/conformance/node/index.cts(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== tests/cases/conformance/node/index.cts (2 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "#type"; + ~~~~~~~ +!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + cjs; + mjs; + type; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js", + "imports": { + "#cjs": "./index.cjs", + "#mjs": "./index.mjs", + "#type": "./index.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).js b/tests/baselines/reference/nodeModulesPackageImports(module=node16).js new file mode 100644 index 00000000000..fb612b6c2fd --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).js @@ -0,0 +1,96 @@ +//// [tests/cases/conformance/node/nodeModulesPackageImports.ts] //// + +//// [index.ts] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.mts] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.cts] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js", + "imports": { + "#cjs": "./index.cjs", + "#mjs": "./index.mjs", + "#type": "./index.js" + } +} + +//// [index.mjs] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const cjs = __importStar(require("#cjs")); +const mjs = __importStar(require("#mjs")); +const type = __importStar(require("#type")); +cjs; +mjs; +type; +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; + + +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).symbols b/tests/baselines/reference/nodeModulesPackageImports(module=node16).symbols new file mode 100644 index 00000000000..2a0fece7237 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).symbols @@ -0,0 +1,60 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.ts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.ts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.mts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.mts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.mts, 3, 6)) + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as cjs from "#cjs"; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +import * as mjs from "#mjs"; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +import * as type from "#type"; +>type : Symbol(type, Decl(index.cts, 3, 6)) + +cjs; +>cjs : Symbol(cjs, Decl(index.cts, 1, 6)) + +mjs; +>mjs : Symbol(mjs, Decl(index.cts, 2, 6)) + +type; +>type : Symbol(type, Decl(index.cts, 3, 6)) + diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).types b/tests/baselines/reference/nodeModulesPackageImports(module=node16).types new file mode 100644 index 00000000000..b4ade055923 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).types @@ -0,0 +1,60 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as cjs from "#cjs"; +>cjs : typeof cjs + +import * as mjs from "#mjs"; +>mjs : typeof mjs + +import * as type from "#type"; +>type : typeof type + +cjs; +>cjs : typeof cjs + +mjs; +>mjs : typeof mjs + +type; +>type : typeof type + diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt new file mode 100644 index 00000000000..0dc3774d5ef --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.cts (1 errors) ==== + // cjs format file + import * as cjsi from "inner/cjs/index"; + import * as mjsi from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner/js/index"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs/index"; + import * as mjs from "inner/mjs/index"; + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index"; + import * as mjs from "inner/mjs/index"; + ~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs/*": "./*.cjs", + "./mjs/*": "./*.mjs", + "./js/*": "./*.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).js b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).js new file mode 100644 index 00000000000..cef593a4246 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).js @@ -0,0 +1,124 @@ +//// [tests/cases/conformance/node/nodeModulesPackagePatternExports.ts] //// + +//// [index.ts] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.mts] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.cts] +// cjs format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs/index"; +import * as mjs from "inner/mjs/index"; +import * as type from "inner/js/index"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs/*": "./*.cjs", + "./mjs/*": "./*.mjs", + "./js/*": "./*.js" + } +} + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index"; +import * as mjsi from "inner/mjs/index"; +import * as typei from "inner/js/index"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjsi = __importStar(require("inner/cjs/index")); +const mjsi = __importStar(require("inner/mjs/index")); +const typei = __importStar(require("inner/js/index")); +cjsi; +mjsi; +typei; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).symbols b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).symbols new file mode 100644 index 00000000000..c9823ad5c6c --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.ts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.mts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mts, 3, 6)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjsi from "inner/cjs/index"; +>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6)) + +import * as mjsi from "inner/mjs/index"; +>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6)) + +import * as typei from "inner/js/index"; +>typei : Symbol(typei, Decl(index.cts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cts, 3, 6)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs/index"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner/js/index"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).types b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).types new file mode 100644 index 00000000000..3ebdb118fd9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjsi from "inner/cjs/index"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner/js/index"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : any + +import * as mjs from "inner/mjs/index"; +>mjs : typeof mjs + +import * as type from "inner/js/index"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner/js/index"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index"; +>mjs : typeof cjs.mjs + +import * as type from "inner/js/index"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt new file mode 100644 index 00000000000..9aa041ab418 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt @@ -0,0 +1,78 @@ +tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/index.cts (1 errors) ==== + // cjs format file + import * as cjsi from "inner/cjs/index.cjs"; + import * as mjsi from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as typei from "inner/js/index.js"; + cjsi; + mjsi; + typei; +==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index.cjs"; + ~~~ +!!! error TS2303: Circular definition of import alias 'cjs'. + import * as mjs from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs/index.cjs"; + import * as mjs from "inner/mjs/index.mjs"; + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ==== + // cjs format file + import * as cjs from "inner/cjs/index.cjs"; + import * as mjs from "inner/mjs/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import * as type from "inner/js/index.js"; + export { cjs }; + export { mjs }; + export { type }; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + } +==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs/*.cjs": "./*.cjs", + "./mjs/*.mjs": "./*.mjs", + "./js/*.js": "./*.js" + } + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).js b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).js new file mode 100644 index 00000000000..62c5b115698 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).js @@ -0,0 +1,124 @@ +//// [tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts] //// + +//// [index.ts] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.mts] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.cts] +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.d.ts] +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.mts] +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [index.d.cts] +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +import * as mjs from "inner/mjs/index.mjs"; +import * as type from "inner/js/index.js"; +export { cjs }; +export { mjs }; +export { type }; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + "./cjs/*.cjs": "./*.cjs", + "./mjs/*.mjs": "./*.mjs", + "./js/*.js": "./*.js" + } +} + +//// [index.js] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.mjs] +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +import * as mjsi from "inner/mjs/index.mjs"; +import * as typei from "inner/js/index.js"; +cjsi; +mjsi; +typei; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const cjsi = __importStar(require("inner/cjs/index.cjs")); +const mjsi = __importStar(require("inner/mjs/index.mjs")); +const typei = __importStar(require("inner/js/index.js")); +cjsi; +mjsi; +typei; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).symbols b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).symbols new file mode 100644 index 00000000000..59394e7d56d --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.ts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.mts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.mts, 3, 6)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6)) + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6)) + +import * as typei from "inner/js/index.js"; +>typei : Symbol(typei, Decl(index.cts, 3, 6)) + +cjsi; +>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6)) + +mjsi; +>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6)) + +typei; +>typei : Symbol(typei, Decl(index.cts, 3, 6)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.ts, 3, 6)) + +export { cjs }; +>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8)) + +export { mjs }; +>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8)) + +export { type }; +>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.mts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8)) + +export { type }; +>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6)) + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6)) + +import * as type from "inner/js/index.js"; +>type : Symbol(type, Decl(index.d.cts, 3, 6)) + +export { cjs }; +>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8)) + +export { mjs }; +>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8)) + +export { type }; +>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8)) + diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).types b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).types new file mode 100644 index 00000000000..f72f1247699 --- /dev/null +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.cjs.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof typei + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.cjs.mjs + +typei; +>typei : typeof typei + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as cjsi from "inner/cjs/index.cjs"; +>cjsi : typeof cjsi + +import * as mjsi from "inner/mjs/index.mjs"; +>mjsi : typeof cjsi.mjs + +import * as typei from "inner/js/index.js"; +>typei : typeof cjsi.mjs.cjs.type + +cjsi; +>cjsi : typeof cjsi + +mjsi; +>mjsi : typeof cjsi.mjs + +typei; +>typei : typeof cjsi.mjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : any + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof mjs + +import * as type from "inner/js/index.js"; +>type : typeof mjs.cjs.cjs.type + +export { cjs }; +>cjs : any + +export { mjs }; +>mjs : typeof mjs + +export { type }; +>type : typeof mjs.cjs.cjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof cjs.cjs.mjs + +import * as type from "inner/js/index.js"; +>type : typeof cjs.cjs.mjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.cjs.mjs + +export { type }; +>type : typeof cjs.cjs.mjs.type + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +import * as cjs from "inner/cjs/index.cjs"; +>cjs : typeof cjs + +import * as mjs from "inner/mjs/index.mjs"; +>mjs : typeof cjs.mjs + +import * as type from "inner/js/index.js"; +>type : typeof cjs.mjs.cjs.type + +export { cjs }; +>cjs : typeof cjs + +export { mjs }; +>mjs : typeof cjs.mjs + +export { type }; +>type : typeof cjs.mjs.cjs.type + diff --git a/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).js b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).js new file mode 100644 index 00000000000..c349cb78a0f --- /dev/null +++ b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).js @@ -0,0 +1,120 @@ +//// [tests/cases/conformance/node/nodeModulesResolveJsonModule.ts] //// + +//// [index.ts] +import pkg from "./package.json" +export const name = pkg.name; +import * as ns from "./package.json"; +export const thing = ns; +export const name2 = ns.default.name; +//// [index.cts] +import pkg from "./package.json" +export const name = pkg.name; +import * as ns from "./package.json"; +export const thing = ns; +export const name2 = ns.default.name; +//// [index.mts] +import pkg from "./package.json" +export const name = pkg.name; +import * as ns from "./package.json"; +export const thing = ns; +export const name2 = ns.default.name; +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "type": "module", + "default": "misedirection" +} + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "type": "module", + "default": "misedirection" +} +//// [index.js] +import pkg from "./package.json"; +export const name = pkg.name; +import * as ns from "./package.json"; +export const thing = ns; +export const name2 = ns.default.name; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.name2 = exports.thing = exports.name = void 0; +const package_json_1 = __importDefault(require("./package.json")); +exports.name = package_json_1.default.name; +const ns = __importStar(require("./package.json")); +exports.thing = ns; +exports.name2 = ns.default.name; +//// [index.mjs] +import pkg from "./package.json"; +export const name = pkg.name; +import * as ns from "./package.json"; +export const thing = ns; +export const name2 = ns.default.name; + + +//// [index.d.ts] +export declare const name: string; +export declare const thing: { + default: { + name: string; + version: string; + type: string; + default: string; + }; +}; +export declare const name2: string; +//// [index.d.cts] +export declare const name: string; +export declare const thing: { + default: { + name: string; + version: string; + type: string; + default: string; + }; + name: string; + version: string; + type: string; +}; +export declare const name2: string; +//// [index.d.mts] +export declare const name: string; +export declare const thing: { + default: { + name: string; + version: string; + type: string; + default: string; + }; +}; +export declare const name2: string; diff --git a/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).symbols b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).symbols new file mode 100644 index 00000000000..f1927c68996 --- /dev/null +++ b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).symbols @@ -0,0 +1,89 @@ +=== tests/cases/conformance/node/index.ts === +import pkg from "./package.json" +>pkg : Symbol(pkg, Decl(index.ts, 0, 6)) + +export const name = pkg.name; +>name : Symbol(name, Decl(index.ts, 1, 12)) +>pkg.name : Symbol("name", Decl(package.json, 0, 1)) +>pkg : Symbol(pkg, Decl(index.ts, 0, 6)) +>name : Symbol("name", Decl(package.json, 0, 1)) + +import * as ns from "./package.json"; +>ns : Symbol(ns, Decl(index.ts, 2, 6)) + +export const thing = ns; +>thing : Symbol(thing, Decl(index.ts, 3, 12)) +>ns : Symbol(ns, Decl(index.ts, 2, 6)) + +export const name2 = ns.default.name; +>name2 : Symbol(name2, Decl(index.ts, 4, 12)) +>ns.default.name : Symbol("name", Decl(package.json, 0, 1)) +>ns.default : Symbol("tests/cases/conformance/node/package") +>ns : Symbol(ns, Decl(index.ts, 2, 6)) +>default : Symbol("tests/cases/conformance/node/package") +>name : Symbol("name", Decl(package.json, 0, 1)) + +=== tests/cases/conformance/node/index.cts === +import pkg from "./package.json" +>pkg : Symbol(pkg, Decl(index.cts, 0, 6)) + +export const name = pkg.name; +>name : Symbol(name, Decl(index.cts, 1, 12)) +>pkg.name : Symbol("name", Decl(package.json, 0, 1)) +>pkg : Symbol(pkg, Decl(index.cts, 0, 6)) +>name : Symbol("name", Decl(package.json, 0, 1)) + +import * as ns from "./package.json"; +>ns : Symbol(ns, Decl(index.cts, 2, 6)) + +export const thing = ns; +>thing : Symbol(thing, Decl(index.cts, 3, 12)) +>ns : Symbol(ns, Decl(index.cts, 2, 6)) + +export const name2 = ns.default.name; +>name2 : Symbol(name2, Decl(index.cts, 4, 12)) +>ns.default.name : Symbol("name", Decl(package.json, 0, 1)) +>ns.default : Symbol("tests/cases/conformance/node/package") +>ns : Symbol(ns, Decl(index.cts, 2, 6)) +>default : Symbol("tests/cases/conformance/node/package") +>name : Symbol("name", Decl(package.json, 0, 1)) + +=== tests/cases/conformance/node/index.mts === +import pkg from "./package.json" +>pkg : Symbol(pkg, Decl(index.mts, 0, 6)) + +export const name = pkg.name; +>name : Symbol(name, Decl(index.mts, 1, 12)) +>pkg.name : Symbol("name", Decl(package.json, 0, 1)) +>pkg : Symbol(pkg, Decl(index.mts, 0, 6)) +>name : Symbol("name", Decl(package.json, 0, 1)) + +import * as ns from "./package.json"; +>ns : Symbol(ns, Decl(index.mts, 2, 6)) + +export const thing = ns; +>thing : Symbol(thing, Decl(index.mts, 3, 12)) +>ns : Symbol(ns, Decl(index.mts, 2, 6)) + +export const name2 = ns.default.name; +>name2 : Symbol(name2, Decl(index.mts, 4, 12)) +>ns.default.name : Symbol("name", Decl(package.json, 0, 1)) +>ns.default : Symbol("tests/cases/conformance/node/package") +>ns : Symbol(ns, Decl(index.mts, 2, 6)) +>default : Symbol("tests/cases/conformance/node/package") +>name : Symbol("name", Decl(package.json, 0, 1)) + +=== tests/cases/conformance/node/package.json === +{ + "name": "pkg", +>"name" : Symbol("name", Decl(package.json, 0, 1)) + + "version": "0.0.1", +>"version" : Symbol("version", Decl(package.json, 1, 18)) + + "type": "module", +>"type" : Symbol("type", Decl(package.json, 2, 23)) + + "default": "misedirection" +>"default" : Symbol("default", Decl(package.json, 3, 21)) +} diff --git a/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).types b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).types new file mode 100644 index 00000000000..f6ad83e1754 --- /dev/null +++ b/tests/baselines/reference/nodeModulesResolveJsonModule(module=node16).types @@ -0,0 +1,95 @@ +=== tests/cases/conformance/node/index.ts === +import pkg from "./package.json" +>pkg : { name: string; version: string; type: string; default: string; } + +export const name = pkg.name; +>name : string +>pkg.name : string +>pkg : { name: string; version: string; type: string; default: string; } +>name : string + +import * as ns from "./package.json"; +>ns : { default: { name: string; version: string; type: string; default: string; }; } + +export const thing = ns; +>thing : { default: { name: string; version: string; type: string; default: string; }; } +>ns : { default: { name: string; version: string; type: string; default: string; }; } + +export const name2 = ns.default.name; +>name2 : string +>ns.default.name : string +>ns.default : { name: string; version: string; type: string; default: string; } +>ns : { default: { name: string; version: string; type: string; default: string; }; } +>default : { name: string; version: string; type: string; default: string; } +>name : string + +=== tests/cases/conformance/node/index.cts === +import pkg from "./package.json" +>pkg : { name: string; version: string; type: string; default: string; } + +export const name = pkg.name; +>name : string +>pkg.name : string +>pkg : { name: string; version: string; type: string; default: string; } +>name : string + +import * as ns from "./package.json"; +>ns : { default: { name: string; version: string; type: string; default: string; }; name: string; version: string; type: string; } + +export const thing = ns; +>thing : { default: { name: string; version: string; type: string; default: string; }; name: string; version: string; type: string; } +>ns : { default: { name: string; version: string; type: string; default: string; }; name: string; version: string; type: string; } + +export const name2 = ns.default.name; +>name2 : string +>ns.default.name : string +>ns.default : { name: string; version: string; type: string; default: string; } +>ns : { default: { name: string; version: string; type: string; default: string; }; name: string; version: string; type: string; } +>default : { name: string; version: string; type: string; default: string; } +>name : string + +=== tests/cases/conformance/node/index.mts === +import pkg from "./package.json" +>pkg : { name: string; version: string; type: string; default: string; } + +export const name = pkg.name; +>name : string +>pkg.name : string +>pkg : { name: string; version: string; type: string; default: string; } +>name : string + +import * as ns from "./package.json"; +>ns : { default: { name: string; version: string; type: string; default: string; }; } + +export const thing = ns; +>thing : { default: { name: string; version: string; type: string; default: string; }; } +>ns : { default: { name: string; version: string; type: string; default: string; }; } + +export const name2 = ns.default.name; +>name2 : string +>ns.default.name : string +>ns.default : { name: string; version: string; type: string; default: string; } +>ns : { default: { name: string; version: string; type: string; default: string; }; } +>default : { name: string; version: string; type: string; default: string; } +>name : string + +=== tests/cases/conformance/node/package.json === +{ +>{ "name": "pkg", "version": "0.0.1", "type": "module", "default": "misedirection"} : { name: string; version: string; type: string; default: string; } + + "name": "pkg", +>"name" : string +>"pkg" : "pkg" + + "version": "0.0.1", +>"version" : string +>"0.0.1" : "0.0.1" + + "type": "module", +>"type" : string +>"module" : "module" + + "default": "misedirection" +>"default" : string +>"misedirection" : "misedirection" +} diff --git a/tests/baselines/reference/nodeModulesResolveJsonModule(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesResolveJsonModule(module=nodenext).errors.txt deleted file mode 100644 index 4200a11e7ba..00000000000 --- a/tests/baselines/reference/nodeModulesResolveJsonModule(module=nodenext).errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -tests/cases/conformance/node/index.mts(1,17): error TS7062: JSON imports are experimental in ES module mode imports. -tests/cases/conformance/node/index.mts(3,21): error TS7062: JSON imports are experimental in ES module mode imports. -tests/cases/conformance/node/index.ts(1,17): error TS7062: JSON imports are experimental in ES module mode imports. -tests/cases/conformance/node/index.ts(3,21): error TS7062: JSON imports are experimental in ES module mode imports. - - -==== tests/cases/conformance/node/index.ts (2 errors) ==== - import pkg from "./package.json" - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. - export const name = pkg.name; - import * as ns from "./package.json"; - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. - export const thing = ns; - export const name2 = ns.default.name; -==== tests/cases/conformance/node/index.cts (0 errors) ==== - import pkg from "./package.json" - export const name = pkg.name; - import * as ns from "./package.json"; - export const thing = ns; - export const name2 = ns.default.name; -==== tests/cases/conformance/node/index.mts (2 errors) ==== - import pkg from "./package.json" - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. - export const name = pkg.name; - import * as ns from "./package.json"; - ~~~~~~~~~~~~~~~~ -!!! error TS7062: JSON imports are experimental in ES module mode imports. - export const thing = ns; - export const name2 = ns.default.name; -==== tests/cases/conformance/node/package.json (0 errors) ==== - { - "name": "pkg", - "version": "0.0.1", - "type": "module", - "default": "misedirection" - } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt new file mode 100644 index 00000000000..012ef390621 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~ +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~ +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).js new file mode 100644 index 00000000000..7ac63da5914 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts] //// + +//// [index.ts] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.ts] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; + + +//// [index.d.ts] +export declare function h(): Promise; +//// [index.d.ts] +export declare function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).symbols b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).symbols new file mode 100644 index 00000000000..8b03ab0af9f --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.ts, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.ts, 4, 36)) +>_f : Symbol(_f, Decl(index.ts, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.ts, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.ts, 1, 8)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.ts, 4, 46)) +>_h : Symbol(_h, Decl(index.ts, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.ts, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.ts, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.ts, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).types b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).types new file mode 100644 index 00000000000..0ded6fc1b88 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : { default: typeof mod2; f(): Promise; } +>await import ("./index.js") : { default: typeof mod2; f(): Promise; } +>import ("./index.js") : Promise<{ default: typeof mod2; f(): Promise; }> +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : { default: typeof mod2; f(): Promise; } +>await import ("./subfolder/index.js") : { default: typeof mod2; f(): Promise; } +>import ("./subfolder/index.js") : Promise<{ default: typeof mod2; f(): Promise; }> +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt new file mode 100644 index 00000000000..00001d997b4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = await 1; + export {x}; + for await (const y of []) {} +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).js new file mode 100644 index 00000000000..8d33777f0c4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/node/nodeModulesTopLevelAwait.ts] //// + +//// [index.ts] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.ts] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).symbols b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).symbols new file mode 100644 index 00000000000..624f09cb773 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).types b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).types new file mode 100644 index 00000000000..ae8108f4020 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt index 140c9f2c32c..00001d997b4 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. +tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. ==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== // cjs format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. ==== tests/cases/conformance/node/index.ts (0 errors) ==== // esm format file const x = await 1; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).js new file mode 100644 index 00000000000..422ed137b0f --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} +} +//// [index.ts] +/// +export interface LocalInterface extends RequireInterface {} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// + + +//// [index.d.ts] +/// +export interface LocalInterface extends RequireInterface { +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).symbols new file mode 100644 index 00000000000..b3bd9d822f3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).symbols @@ -0,0 +1,14 @@ +=== /index.ts === +/// +export interface LocalInterface extends RequireInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) + +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).types new file mode 100644 index 00000000000..5309ca6f8bc --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit1(module=node16).types @@ -0,0 +1,10 @@ +=== /index.ts === +/// +No type information for this code.export interface LocalInterface extends RequireInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : any + + interface RequireInterface {} +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).js new file mode 100644 index 00000000000..19f87244dba --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit2.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} +} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +/// +export interface LocalInterface extends ImportInterface {} + +//// [index.js] +/// +export {}; + + +//// [index.d.ts] +/// +export interface LocalInterface extends ImportInterface { +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).symbols new file mode 100644 index 00000000000..e21bf153066 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).symbols @@ -0,0 +1,14 @@ +=== /index.ts === +/// +export interface LocalInterface extends ImportInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) + +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).types new file mode 100644 index 00000000000..e6e97a84b46 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit2(module=node16).types @@ -0,0 +1,10 @@ +=== /index.ts === +/// +No type information for this code.export interface LocalInterface extends ImportInterface {} +No type information for this code.=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : any + + interface ImportInterface {} +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).js new file mode 100644 index 00000000000..78d1f72c4b1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit3.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} +} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +/// +export interface LocalInterface extends RequireInterface {} + +//// [index.js] +/// +export {}; + + +//// [index.d.ts] +/// +export interface LocalInterface extends RequireInterface { +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).symbols new file mode 100644 index 00000000000..da1b6a81fbb --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).symbols @@ -0,0 +1,14 @@ +=== /index.ts === +/// +export interface LocalInterface extends RequireInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) + +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).types new file mode 100644 index 00000000000..abc205f8742 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit3(module=node16).types @@ -0,0 +1,10 @@ +=== /index.ts === +/// +No type information for this code.export interface LocalInterface extends RequireInterface {} +No type information for this code.=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : any + + interface RequireInterface {} +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).js new file mode 100644 index 00000000000..9f2493f030a --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit4.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} +} +//// [index.ts] +/// +export interface LocalInterface extends ImportInterface {} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// + + +//// [index.d.ts] +/// +export interface LocalInterface extends ImportInterface { +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).symbols new file mode 100644 index 00000000000..dcaf8d70169 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).symbols @@ -0,0 +1,14 @@ +=== /index.ts === +/// +export interface LocalInterface extends ImportInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) + +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).types new file mode 100644 index 00000000000..62e354e99b1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit4(module=node16).types @@ -0,0 +1,10 @@ +=== /index.ts === +/// +No type information for this code.export interface LocalInterface extends ImportInterface {} +No type information for this code.=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : any + + interface ImportInterface {} +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).js new file mode 100644 index 00000000000..63ad10a1141 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit5.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} +} +//// [index.ts] +/// +/// +export interface LocalInterface extends ImportInterface, RequireInterface {} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +/// + + +//// [index.d.ts] +/// +/// +export interface LocalInterface extends ImportInterface, RequireInterface { +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).symbols new file mode 100644 index 00000000000..6602737d542 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).symbols @@ -0,0 +1,24 @@ +=== /index.ts === +/// +/// +export interface LocalInterface extends ImportInterface, RequireInterface {} +>LocalInterface : Symbol(LocalInterface, Decl(index.ts, 0, 0)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) + +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + interface ImportInterface {} +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).types new file mode 100644 index 00000000000..1e3690c89f0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit5(module=node16).types @@ -0,0 +1,18 @@ +=== /index.ts === +/// +No type information for this code./// +No type information for this code.export interface LocalInterface extends ImportInterface, RequireInterface {} +No type information for this code.=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : any + + interface ImportInterface {} +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : any + + interface RequireInterface {} +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).js new file mode 100644 index 00000000000..34117c328c5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit6.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface {} + function getInterI(): ImportInterface; +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface {} + function getInterR(): RequireInterface; +} +//// [uses.ts] +/// +export default getInterR(); +//// [index.ts] +import obj from "./uses.js" +export default (obj as typeof obj); + +//// [uses.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +exports.default = getInterR(); +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const uses_js_1 = __importDefault(require("./uses.js")); +exports.default = uses_js_1.default; + + +//// [uses.d.ts] +/// +declare const _default: RequireInterface; +export default _default; +//// [index.d.ts] +/// +declare const _default: RequireInterface; +export default _default; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).symbols new file mode 100644 index 00000000000..5aa8fccc15d --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).symbols @@ -0,0 +1,25 @@ +=== /index.ts === +import obj from "./uses.js" +>obj : Symbol(obj, Decl(index.ts, 0, 6)) + +export default (obj as typeof obj); +>obj : Symbol(obj, Decl(index.ts, 0, 6)) +>obj : Symbol(obj, Decl(index.ts, 0, 6)) + +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + interface RequireInterface {} +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) + + function getInterR(): RequireInterface; +>getInterR : Symbol(getInterR, Decl(require.d.ts, 2, 33)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +} +=== /uses.ts === +/// +export default getInterR(); +>getInterR : Symbol(getInterR, Decl(require.d.ts, 2, 33)) + diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).types new file mode 100644 index 00000000000..8b46fbb9f54 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit6(module=node16).types @@ -0,0 +1,25 @@ +=== /index.ts === +import obj from "./uses.js" +>obj : RequireInterface + +export default (obj as typeof obj); +>(obj as typeof obj) : RequireInterface +>obj as typeof obj : RequireInterface +>obj : RequireInterface +>obj : RequireInterface + +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + interface RequireInterface {} + function getInterR(): RequireInterface; +>getInterR : () => RequireInterface +} +=== /uses.ts === +/// +export default getInterR(); +>getInterR() : RequireInterface +>getInterR : () => RequireInterface + diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).js new file mode 100644 index 00000000000..2426cb28b25 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).js @@ -0,0 +1,78 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit7.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + interface ImportInterface { _i: any; } + function getInterI(): ImportInterface; +} +//// [require.d.ts] +export {}; +declare global { + interface RequireInterface { _r: any; } + function getInterR(): RequireInterface; +} +//// [uses.ts] +/// +export default getInterI(); +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [uses.ts] +/// +export default getInterR(); +//// [package.json] +{ + "private": true, + "type": "commonjs" +} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +// only an esm file can `import` both kinds of files +import obj1 from "./sub1/uses.js" +import obj2 from "./sub2/uses.js" +export default [obj1, obj2.default] as const; + +//// [uses.js] +/// +export default getInterI(); +//// [uses.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +exports.default = getInterR(); +//// [index.js] +// only an esm file can `import` both kinds of files +import obj1 from "./sub1/uses.js"; +import obj2 from "./sub2/uses.js"; +export default [obj1, obj2.default]; + + +//// [uses.d.ts] +/// +declare const _default: ImportInterface; +export default _default; +//// [uses.d.ts] +/// +declare const _default: RequireInterface; +export default _default; +//// [index.d.ts] +/// +/// +declare const _default: readonly [ImportInterface, RequireInterface]; +export default _default; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).symbols new file mode 100644 index 00000000000..8f29793a362 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).symbols @@ -0,0 +1,51 @@ +=== /index.ts === +// only an esm file can `import` both kinds of files +import obj1 from "./sub1/uses.js" +>obj1 : Symbol(obj1, Decl(index.ts, 1, 6)) + +import obj2 from "./sub2/uses.js" +>obj2 : Symbol(obj2, Decl(index.ts, 2, 6)) + +export default [obj1, obj2.default] as const; +>obj1 : Symbol(obj1, Decl(index.ts, 1, 6)) +>obj2.default : Symbol(obj2.default, Decl(uses.ts, 0, 0)) +>obj2 : Symbol(obj2, Decl(index.ts, 2, 6)) +>default : Symbol(obj2.default, Decl(uses.ts, 0, 0)) +>const : Symbol(const) + +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + interface ImportInterface { _i: any; } +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +>_i : Symbol(ImportInterface._i, Decl(import.d.ts, 2, 31)) + + function getInterI(): ImportInterface; +>getInterI : Symbol(getInterI, Decl(import.d.ts, 2, 42)) +>ImportInterface : Symbol(ImportInterface, Decl(import.d.ts, 1, 16)) +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + interface RequireInterface { _r: any; } +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +>_r : Symbol(RequireInterface._r, Decl(require.d.ts, 2, 32)) + + function getInterR(): RequireInterface; +>getInterR : Symbol(getInterR, Decl(require.d.ts, 2, 43)) +>RequireInterface : Symbol(RequireInterface, Decl(require.d.ts, 1, 16)) +} +=== /sub1/uses.ts === +/// +export default getInterI(); +>getInterI : Symbol(getInterI, Decl(import.d.ts, 2, 42)) + +=== /sub2/uses.ts === +/// +export default getInterR(); +>getInterR : Symbol(getInterR, Decl(require.d.ts, 2, 43)) + diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).types new file mode 100644 index 00000000000..20edd715aea --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeDeclarationEmit7(module=node16).types @@ -0,0 +1,50 @@ +=== /index.ts === +// only an esm file can `import` both kinds of files +import obj1 from "./sub1/uses.js" +>obj1 : ImportInterface + +import obj2 from "./sub2/uses.js" +>obj2 : typeof obj2 + +export default [obj1, obj2.default] as const; +>[obj1, obj2.default] as const : readonly [ImportInterface, RequireInterface] +>[obj1, obj2.default] : readonly [ImportInterface, RequireInterface] +>obj1 : ImportInterface +>obj2.default : RequireInterface +>obj2 : typeof obj2 +>default : RequireInterface + +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : typeof global + + interface ImportInterface { _i: any; } +>_i : any + + function getInterI(): ImportInterface; +>getInterI : () => ImportInterface +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + interface RequireInterface { _r: any; } +>_r : any + + function getInterR(): RequireInterface; +>getInterR : () => RequireInterface +} +=== /sub1/uses.ts === +/// +export default getInterI(); +>getInterI() : ImportInterface +>getInterI : () => ImportInterface + +=== /sub2/uses.ts === +/// +export default getInterR(); +>getInterR() : RequireInterface +>getInterR : () => RequireInterface + diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).errors.txt new file mode 100644 index 00000000000..c9a6ac79317 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).errors.txt @@ -0,0 +1,29 @@ +/index.ts(2,1): error TS2304: Cannot find name 'foo'. + + +==== /index.ts (1 errors) ==== + /// + foo; + ~~~ +!!! error TS2304: Cannot find name 'foo'. + bar; // bar should resolve while foo should not, since index.js is cjs + export {}; +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export {}; + declare global { + var foo: number; + } +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export {}; + declare global { + var bar: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).js new file mode 100644 index 00000000000..df6436da900 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride1.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [index.ts] +/// +foo; +bar; // bar should resolve while foo should not, since index.js is cjs +export {}; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +foo; +bar; // bar should resolve while foo should not, since index.js is cjs diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).symbols new file mode 100644 index 00000000000..734168a97f3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).symbols @@ -0,0 +1,15 @@ +=== /index.ts === +/// +foo; +bar; // bar should resolve while foo should not, since index.js is cjs +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + var bar: number; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).types new file mode 100644 index 00000000000..992f05b1805 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride1(module=node16).types @@ -0,0 +1,17 @@ +=== /index.ts === +/// +foo; +>foo : any + +bar; // bar should resolve while foo should not, since index.js is cjs +>bar : number + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + var bar: number; +>bar : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).errors.txt new file mode 100644 index 00000000000..13991aa1353 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).errors.txt @@ -0,0 +1,34 @@ +/index.ts(3,1): error TS2304: Cannot find name 'bar'. + + +==== /index.ts (1 errors) ==== + /// + foo; // foo should resolve while bar should not, since index.js is esm + bar; + ~~~ +!!! error TS2304: Cannot find name 'bar'. + export {}; +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export {}; + declare global { + var foo: number; + } +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export {}; + declare global { + var bar: number; + } +==== /package.json (0 errors) ==== + { + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).js new file mode 100644 index 00000000000..aee176689b2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride2.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +/// +foo; // foo should resolve while bar should not, since index.js is esm +bar; +export {}; + +//// [index.js] +/// +foo; // foo should resolve while bar should not, since index.js is esm +bar; +export {}; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).symbols new file mode 100644 index 00000000000..babba09bdf8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).symbols @@ -0,0 +1,15 @@ +=== /index.ts === +/// +foo; // foo should resolve while bar should not, since index.js is esm +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) + +bar; +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + var foo: number; +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).types new file mode 100644 index 00000000000..baabb036278 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride2(module=node16).types @@ -0,0 +1,17 @@ +=== /index.ts === +/// +foo; // foo should resolve while bar should not, since index.js is esm +>foo : number + +bar; +>bar : any + +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : typeof global + + var foo: number; +>foo : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).errors.txt new file mode 100644 index 00000000000..477d247984d --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).errors.txt @@ -0,0 +1,34 @@ +/index.ts(2,1): error TS2304: Cannot find name 'foo'. + + +==== /index.ts (1 errors) ==== + /// + foo; + ~~~ +!!! error TS2304: Cannot find name 'foo'. + bar; // bar should resolve while foo should not, since even though index.js is esm, the reference is cjs + export {}; +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export {}; + declare global { + var foo: number; + } +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export {}; + declare global { + var bar: number; + } +==== /package.json (0 errors) ==== + { + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).js new file mode 100644 index 00000000000..c6806f897de --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [package.json] +{ + "private": true, + "type": "module" +} +//// [index.ts] +/// +foo; +bar; // bar should resolve while foo should not, since even though index.js is esm, the reference is cjs +export {}; + +//// [index.js] +/// +foo; +bar; // bar should resolve while foo should not, since even though index.js is esm, the reference is cjs +export {}; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).symbols new file mode 100644 index 00000000000..dd4f1ee4370 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).symbols @@ -0,0 +1,15 @@ +=== /index.ts === +/// +foo; +bar; // bar should resolve while foo should not, since even though index.js is esm, the reference is cjs +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + var bar: number; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).types new file mode 100644 index 00000000000..296d29ee050 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride3(module=node16).types @@ -0,0 +1,17 @@ +=== /index.ts === +/// +foo; +>foo : any + +bar; // bar should resolve while foo should not, since even though index.js is esm, the reference is cjs +>bar : number + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + var bar: number; +>bar : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).errors.txt new file mode 100644 index 00000000000..3d7f07f2775 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).errors.txt @@ -0,0 +1,29 @@ +/index.ts(3,1): error TS2304: Cannot find name 'bar'. + + +==== /index.ts (1 errors) ==== + /// + foo; // foo should resolve while bar should not, since even though index.js is cjs, the refernce is esm + bar; + ~~~ +!!! error TS2304: Cannot find name 'bar'. + export {}; +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export {}; + declare global { + var foo: number; + } +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export {}; + declare global { + var bar: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).js new file mode 100644 index 00000000000..74346916b26 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride4.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [index.ts] +/// +foo; // foo should resolve while bar should not, since even though index.js is cjs, the refernce is esm +bar; +export {}; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +foo; // foo should resolve while bar should not, since even though index.js is cjs, the refernce is esm +bar; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).symbols new file mode 100644 index 00000000000..c6420dbbea7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).symbols @@ -0,0 +1,15 @@ +=== /index.ts === +/// +foo; // foo should resolve while bar should not, since even though index.js is cjs, the refernce is esm +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) + +bar; +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + var foo: number; +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).types new file mode 100644 index 00000000000..eb9b906744a --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride4(module=node16).types @@ -0,0 +1,17 @@ +=== /index.ts === +/// +foo; // foo should resolve while bar should not, since even though index.js is cjs, the refernce is esm +>foo : number + +bar; +>bar : any + +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : typeof global + + var foo: number; +>foo : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).js new file mode 100644 index 00000000000..0c37dc00e4d --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride5.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [index.ts] +/// +/// +// Both `foo` and `bar` should resolve, as _both_ entrypoints are included by the two +// references above. +foo; +bar; +export {}; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +/// +// Both `foo` and `bar` should resolve, as _both_ entrypoints are included by the two +// references above. +foo; +bar; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).symbols new file mode 100644 index 00000000000..0dc4119ca97 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).symbols @@ -0,0 +1,28 @@ +=== /index.ts === +/// +/// +// Both `foo` and `bar` should resolve, as _both_ entrypoints are included by the two +// references above. +foo; +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) + +bar; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) + +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(import.d.ts, 0, 10)) + + var foo: number; +>foo : Symbol(foo, Decl(import.d.ts, 2, 7)) +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + var bar: number; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).types new file mode 100644 index 00000000000..047cef77a49 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverride5(module=node16).types @@ -0,0 +1,28 @@ +=== /index.ts === +/// +/// +// Both `foo` and `bar` should resolve, as _both_ entrypoints are included by the two +// references above. +foo; +>foo : number + +bar; +>bar : number + +export {}; +=== /node_modules/pkg/import.d.ts === +export {}; +declare global { +>global : typeof global + + var foo: number; +>foo : number +} +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + var bar: number; +>bar : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).errors.txt new file mode 100644 index 00000000000..68be0baf515 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).errors.txt @@ -0,0 +1,32 @@ +/index.ts(1,23): error TS1453: `resolution-mode` should be either `require` or `import`. +/index.ts(2,1): error TS2304: Cannot find name 'foo'. + + +==== /index.ts (2 errors) ==== + /// + ~~~ +!!! error TS1453: `resolution-mode` should be either `require` or `import`. + foo; // bad resolution mode, which resolves is arbitrary + ~~~ +!!! error TS2304: Cannot find name 'foo'. + bar; + export {}; +==== /node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } + } +==== /node_modules/pkg/import.d.ts (0 errors) ==== + export {}; + declare global { + var foo: number; + } +==== /node_modules/pkg/require.d.ts (0 errors) ==== + export {}; + declare global { + var bar: number; + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).js b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).js new file mode 100644 index 00000000000..09540ae8aba --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideModeError.ts] //// + +//// [package.json] +{ + "name": "pkg", + "version": "0.0.1", + "exports": { + "import": "./import.js", + "require": "./require.js" + } +} +//// [import.d.ts] +export {}; +declare global { + var foo: number; +} +//// [require.d.ts] +export {}; +declare global { + var bar: number; +} +//// [index.ts] +/// +foo; // bad resolution mode, which resolves is arbitrary +bar; +export {}; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/// +foo; // bad resolution mode, which resolves is arbitrary +bar; diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).symbols b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).symbols new file mode 100644 index 00000000000..0b19a6c5440 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).symbols @@ -0,0 +1,15 @@ +=== /index.ts === +/// +foo; // bad resolution mode, which resolves is arbitrary +bar; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : Symbol(global, Decl(require.d.ts, 0, 10)) + + var bar: number; +>bar : Symbol(bar, Decl(require.d.ts, 2, 7)) +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).types b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).types new file mode 100644 index 00000000000..4f97b44ffc8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideModeError(module=node16).types @@ -0,0 +1,17 @@ +=== /index.ts === +/// +foo; // bad resolution mode, which resolves is arbitrary +>foo : any + +bar; +>bar : number + +export {}; +=== /node_modules/pkg/require.d.ts === +export {}; +declare global { +>global : typeof global + + var bar: number; +>bar : number +} diff --git a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.errors.txt b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.errors.txt index ee262510ffd..05f937c37ad 100644 --- a/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.errors.txt +++ b/tests/baselines/reference/nodeModulesTripleSlashReferenceModeOverrideOldResolutionError.errors.txt @@ -1,6 +1,6 @@ -/index.ts(1,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`. +/index.ts(1,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`. /index.ts(1,23): error TS2688: Cannot find type definition file for 'pkg'. -/index.ts(2,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`. +/index.ts(2,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`. /index.ts(2,23): error TS2688: Cannot find type definition file for 'pkg'. /index.ts(3,1): error TS2304: Cannot find name 'foo'. /index.ts(4,1): error TS2304: Cannot find name 'bar'. @@ -9,12 +9,12 @@ ==== /index.ts (6 errors) ==== /// ~~~ -!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`. +!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`. ~~~ !!! error TS2688: Cannot find type definition file for 'pkg'. /// ~~~ -!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`. +!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`. ~~~ !!! error TS2688: Cannot find type definition file for 'pkg'. foo; // `resolution-mode` is an error in old resolution settings, which resolves is arbitrary diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).js b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).js new file mode 100644 index 00000000000..1553828a6ae --- /dev/null +++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).js @@ -0,0 +1,98 @@ +//// [tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts] //// + +//// [index.ts] +// esm format file +import * as mod from "inner"; +mod.correctVersionApplied; + +//// [index.mts] +// esm format file +import * as mod from "inner"; +mod.correctVersionApplied; + +//// [index.cts] +// cjs format file +import * as mod from "inner"; +mod.correctVersionApplied; + +//// [index.d.ts] +// cjs format file +export const noConditionsApplied = true; +//// [index.d.mts] +// esm format file +export const importConditionApplied = true; +//// [index.d.cts] +// cjs format file +export const wrongConditionApplied = true; +//// [old-types.d.ts] +export const noVersionApplied = true; +//// [new-types.d.ts] +export const correctVersionApplied = true; +//// [future-types.d.ts] +export const futureVersionApplied = true; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", +} +//// [package.json] +{ + "name": "inner", + "private": true, + "exports": { + ".": { + "types@>=10000": "./future-types.d.ts", + "types@>=1": "./new-types.d.ts", + "types": "./old-types.d.ts", + "import": "./index.mjs", + "node": "./index.js" + }, + } +} + +//// [index.js] +// esm format file +import * as mod from "inner"; +mod.correctVersionApplied; +//// [index.mjs] +// esm format file +import * as mod from "inner"; +mod.correctVersionApplied; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const mod = __importStar(require("inner")); +mod.correctVersionApplied; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).symbols b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).symbols new file mode 100644 index 00000000000..19b9d0e40d9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).symbols @@ -0,0 +1,57 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as mod from "inner"; +>mod : Symbol(mod, Decl(index.ts, 1, 6)) + +mod.correctVersionApplied; +>mod.correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12)) +>mod : Symbol(mod, Decl(index.ts, 1, 6)) +>correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as mod from "inner"; +>mod : Symbol(mod, Decl(index.mts, 1, 6)) + +mod.correctVersionApplied; +>mod.correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12)) +>mod : Symbol(mod, Decl(index.mts, 1, 6)) +>correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as mod from "inner"; +>mod : Symbol(mod, Decl(index.cts, 1, 6)) + +mod.correctVersionApplied; +>mod.correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12)) +>mod : Symbol(mod, Decl(index.cts, 1, 6)) +>correctVersionApplied : Symbol(mod.correctVersionApplied, Decl(new-types.d.ts, 0, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +export const noConditionsApplied = true; +>noConditionsApplied : Symbol(noConditionsApplied, Decl(index.d.ts, 1, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +export const importConditionApplied = true; +>importConditionApplied : Symbol(importConditionApplied, Decl(index.d.mts, 1, 12)) + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +export const wrongConditionApplied = true; +>wrongConditionApplied : Symbol(wrongConditionApplied, Decl(index.d.cts, 1, 12)) + +=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts === +export const noVersionApplied = true; +>noVersionApplied : Symbol(noVersionApplied, Decl(old-types.d.ts, 0, 12)) + +=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts === +export const correctVersionApplied = true; +>correctVersionApplied : Symbol(correctVersionApplied, Decl(new-types.d.ts, 0, 12)) + +=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts === +export const futureVersionApplied = true; +>futureVersionApplied : Symbol(futureVersionApplied, Decl(future-types.d.ts, 0, 12)) + diff --git a/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).types b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).types new file mode 100644 index 00000000000..fe286fd6674 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTypesVersionPackageExports(module=node16).types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as mod from "inner"; +>mod : typeof mod + +mod.correctVersionApplied; +>mod.correctVersionApplied : true +>mod : typeof mod +>correctVersionApplied : true + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as mod from "inner"; +>mod : typeof mod + +mod.correctVersionApplied; +>mod.correctVersionApplied : true +>mod : typeof mod +>correctVersionApplied : true + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as mod from "inner"; +>mod : typeof mod + +mod.correctVersionApplied; +>mod.correctVersionApplied : true +>mod : typeof mod +>correctVersionApplied : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.ts === +// cjs format file +export const noConditionsApplied = true; +>noConditionsApplied : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.mts === +// esm format file +export const importConditionApplied = true; +>importConditionApplied : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/index.d.cts === +// cjs format file +export const wrongConditionApplied = true; +>wrongConditionApplied : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/old-types.d.ts === +export const noVersionApplied = true; +>noVersionApplied : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/new-types.d.ts === +export const correctVersionApplied = true; +>correctVersionApplied : true +>true : true + +=== tests/cases/conformance/node/node_modules/inner/future-types.d.ts === +export const futureVersionApplied = true; +>futureVersionApplied : true +>true : true + diff --git a/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution.errors.txt b/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution.errors.txt index cf759f6040d..20f2430229a 100644 --- a/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution.errors.txt +++ b/tests/baselines/reference/nodeNextImportModeImplicitIndexResolution.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/index.ts(2,31): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. -tests/cases/compiler/index.ts(3,31): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/compiler/index.ts(2,31): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. +tests/cases/compiler/index.ts(3,31): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. ==== tests/cases/compiler/node_modules/pkg/package.json (0 errors) ==== @@ -24,8 +24,8 @@ tests/cases/compiler/index.ts(3,31): error TS2834: Relative import paths need ex import { item } from "pkg"; // should work (`index.js` is assumed to be the entrypoint for packages found via nonrelative import) import { item as item2 } from "./pkg"; // shouldn't work (`index.js` is _not_ assumed to be the entrypoint for packages found via relative import) ~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. import { item as item3 } from "./node_modules/pkg" // _even if they're in a node_modules folder_ ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path. +!!! error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. \ No newline at end of file diff --git a/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt b/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt new file mode 100644 index 00000000000..c1573b8f51d --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== tests/cases/conformance/node/index.cts (1 errors) ==== + // esm format file + import * as self from "package"; + ~~~~~~~~~ +!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + self; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodePackageSelfName(module=node16).js b/tests/baselines/reference/nodePackageSelfName(module=node16).js new file mode 100644 index 00000000000..7061f58c6bb --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfName(module=node16).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/node/nodePackageSelfName.ts] //// + +//// [index.ts] +// esm format file +import * as self from "package"; +self; +//// [index.mts] +// esm format file +import * as self from "package"; +self; +//// [index.cts] +// esm format file +import * as self from "package"; +self; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" +} + +//// [index.js] +// esm format file +import * as self from "package"; +self; +//// [index.mjs] +// esm format file +import * as self from "package"; +self; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// esm format file +const self = __importStar(require("package")); +self; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodePackageSelfName(module=node16).symbols b/tests/baselines/reference/nodePackageSelfName(module=node16).symbols new file mode 100644 index 00000000000..44b9566b90c --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfName(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.ts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.ts, 1, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.mts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.mts, 1, 6)) + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as self from "package"; +>self : Symbol(self, Decl(index.cts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.cts, 1, 6)) + diff --git a/tests/baselines/reference/nodePackageSelfName(module=node16).types b/tests/baselines/reference/nodePackageSelfName(module=node16).types new file mode 100644 index 00000000000..b41eef255ab --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfName(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/index.cts === +// esm format file +import * as self from "package"; +>self : typeof self + +self; +>self : typeof self + diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt new file mode 100644 index 00000000000..b2a9f313de7 --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/node/index.cts(2,23): error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + + +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import * as self from "@scope/package"; + self; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + // esm format file + import * as self from "@scope/package"; + self; +==== tests/cases/conformance/node/index.cts (1 errors) ==== + // cjs format file + import * as self from "@scope/package"; + ~~~~~~~~~~~~~~~~ +!!! error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. + self; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "@scope/package", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).js b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).js new file mode 100644 index 00000000000..8738c8041a9 --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).js @@ -0,0 +1,67 @@ +//// [tests/cases/conformance/node/nodePackageSelfNameScoped.ts] //// + +//// [index.ts] +// esm format file +import * as self from "@scope/package"; +self; +//// [index.mts] +// esm format file +import * as self from "@scope/package"; +self; +//// [index.cts] +// cjs format file +import * as self from "@scope/package"; +self; +//// [package.json] +{ + "name": "@scope/package", + "private": true, + "type": "module", + "exports": "./index.js" +} + +//// [index.js] +// esm format file +import * as self from "@scope/package"; +self; +//// [index.mjs] +// esm format file +import * as self from "@scope/package"; +self; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const self = __importStar(require("@scope/package")); +self; + + +//// [index.d.ts] +export {}; +//// [index.d.mts] +export {}; +//// [index.d.cts] +export {}; diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).symbols b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).symbols new file mode 100644 index 00000000000..e54b0cb667a --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as self from "@scope/package"; +>self : Symbol(self, Decl(index.ts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.ts, 1, 6)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as self from "@scope/package"; +>self : Symbol(self, Decl(index.mts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.mts, 1, 6)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as self from "@scope/package"; +>self : Symbol(self, Decl(index.cts, 1, 6)) + +self; +>self : Symbol(self, Decl(index.cts, 1, 6)) + diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).types b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).types new file mode 100644 index 00000000000..3e5c141f63f --- /dev/null +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/index.ts === +// esm format file +import * as self from "@scope/package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/index.mts === +// esm format file +import * as self from "@scope/package"; +>self : typeof self + +self; +>self : typeof self + +=== tests/cases/conformance/node/index.cts === +// cjs format file +import * as self from "@scope/package"; +>self : typeof self + +self; +>self : typeof self + diff --git a/tests/baselines/reference/parser.forAwait.es2018.errors.txt b/tests/baselines/reference/parser.forAwait.es2018.errors.txt index 1f1f9de0973..4627a2b674a 100644 --- a/tests/baselines/reference/parser.forAwait.es2018.errors.txt +++ b/tests/baselines/reference/parser.forAwait.es2018.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/inFunctionDeclWithExprIsE tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithDeclIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithExprIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'y'. } @@ -30,7 +30,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'x'. ~ diff --git a/tests/baselines/reference/renameNamedImport.baseline b/tests/baselines/reference/renameNamedImport.baseline new file mode 100644 index 00000000000..02abd21a3c7 --- /dev/null +++ b/tests/baselines/reference/renameNamedImport.baseline @@ -0,0 +1,4 @@ +/*====== /src/index.ts ======*/ + +import { [|RENAME|] } from '../lib/index'; +RENAME; diff --git a/tests/baselines/reference/renameNamespaceImport.baseline b/tests/baselines/reference/renameNamespaceImport.baseline new file mode 100644 index 00000000000..7ebef850ab5 --- /dev/null +++ b/tests/baselines/reference/renameNamespaceImport.baseline @@ -0,0 +1,4 @@ +/*====== /src/index.ts ======*/ + +import * as [|RENAME|] from '../lib/index'; +RENAME.someExportedVariable; diff --git a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt index 1c56871bbd5..b272ba8a8c6 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/conformance/externalModules/index.ts (2 errors) ==== export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. class C { } @@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt index 1c56871bbd5..b272ba8a8c6 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/conformance/externalModules/index.ts (2 errors) ==== export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. class C { } @@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt index 1c56871bbd5..b272ba8a8c6 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/conformance/externalModules/index.ts (2 errors) ==== export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. class C { } @@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt index 0fecbd4a916..d00a14233de 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt index 0fecbd4a916..d00a14233de 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt index 0fecbd4a916..d00a14233de 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt index 0fecbd4a916..d00a14233de 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node12', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).errors.txt b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).errors.txt new file mode 100644 index 00000000000..179a40218dc --- /dev/null +++ b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/usage.ts(1,23): error TS2688: Cannot find type definition file for 'pkg'. + + +==== tests/cases/compiler/node_modules/pkg/index.d.ts (0 errors) ==== + interface GlobalThing { a: number } +==== tests/cases/compiler/node_modules/pkg/package.json (0 errors) ==== + { + "name": "pkg", + "types": "index.d.ts", + "exports": "some-other-thing.js" + } +==== tests/cases/compiler/usage.ts (1 errors) ==== + /// + ~~~ +!!! error TS2688: Cannot find type definition file for 'pkg'. + + const a: GlobalThing = { a: 0 }; \ No newline at end of file diff --git a/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).js b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).js new file mode 100644 index 00000000000..89dd2c7541a --- /dev/null +++ b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts] //// + +//// [index.d.ts] +interface GlobalThing { a: number } +//// [package.json] +{ + "name": "pkg", + "types": "index.d.ts", + "exports": "some-other-thing.js" +} +//// [usage.ts] +/// + +const a: GlobalThing = { a: 0 }; + +//// [usage.js] +/// +const a = { a: 0 }; diff --git a/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).symbols b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).symbols new file mode 100644 index 00000000000..b97c41025fe --- /dev/null +++ b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/index.d.ts === +interface GlobalThing { a: number } +>GlobalThing : Symbol(GlobalThing, Decl(index.d.ts, 0, 0)) +>a : Symbol(GlobalThing.a, Decl(index.d.ts, 0, 23)) + +=== tests/cases/compiler/usage.ts === +/// + +const a: GlobalThing = { a: 0 }; +>a : Symbol(a, Decl(usage.ts, 2, 5)) +>GlobalThing : Symbol(GlobalThing, Decl(index.d.ts, 0, 0)) +>a : Symbol(a, Decl(usage.ts, 2, 24)) + diff --git a/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).types b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).types new file mode 100644 index 00000000000..b107f91dcb2 --- /dev/null +++ b/tests/baselines/reference/tripleSlashTypesReferenceWithMissingExports(module=node16).types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/node_modules/pkg/index.d.ts === +interface GlobalThing { a: number } +>a : number + +=== tests/cases/compiler/usage.ts === +/// + +const a: GlobalThing = { a: 0 }; +>a : GlobalThing +>{ a: 0 } : { a: number; } +>a : number +>0 : 0 + diff --git a/tests/baselines/reference/tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js b/tests/baselines/reference/tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js index c8c48ac9ca7..0f60bb939b0 100644 --- a/tests/baselines/reference/tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js +++ b/tests/baselines/reference/tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js @@ -14,7 +14,7 @@ interface Array { length: number; [n: number]: T; } interface ReadonlyArray {} declare const console: { log(msg: any): void; }; -//// [/lib/lib.es2020.full.d.ts] +//// [/lib/lib.es2022.full.d.ts] /// interface Boolean {} interface Function {} @@ -118,7 +118,7 @@ export * from './dogconfig.js'; { "compilerOptions": { "declaration": true, - "module": "node12" + "module": "node16" } } @@ -198,18 +198,18 @@ export declare class LassieDog extends Dog { import { Dog } from '../dog.js'; import { LASSIE_CONFIG } from './lassieconfig.js'; export class LassieDog extends Dog { + static getDogConfig = () => LASSIE_CONFIG; } -LassieDog.getDogConfig = () => LASSIE_CONFIG; //// [/src/src-dogs/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","../src-types/dogconfig.d.ts","../src-types/index.d.ts","./dogconfig.ts","./dog.ts","./lassie/lassieconfig.ts","./lassie/lassiedog.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","impliedFormat":99},{"version":"-5608794531-export * from './dogconfig.js';\r\n","impliedFormat":99},{"version":"1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n","signature":"17588480778-import { DogConfig } from 'src-types';\r\nexport declare const DOG_CONFIG: DogConfig;\r\n","impliedFormat":99},{"version":"6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n","signature":"22128633249-import { DogConfig } from 'src-types';\r\nexport declare abstract class Dog {\r\n static getCapabilities(): DogConfig;\r\n}\r\n","impliedFormat":99},{"version":"4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n","signature":"8131483665-import { DogConfig } from 'src-types';\r\nexport declare const LASSIE_CONFIG: DogConfig;\r\n","impliedFormat":99},{"version":"-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n","signature":"-20244062422-import { Dog } from '../dog.js';\r\nexport declare class LassieDog extends Dog {\r\n protected static getDogConfig: () => import(\"../index.js\").DogConfig;\r\n}\r\n","impliedFormat":99},{"version":"-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n","signature":"-16783836862-export * from 'src-types';\r\nexport * from './lassie/lassiedog.js';\r\n","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[3,4],[3],[3,7],[5,6],[2],[5,8]],"referencedMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"exportedModulesMap":[[5,2],[4,2],[8,3],[6,2],[7,6],[3,5]],"semanticDiagnosticsPerFile":[1,5,4,8,6,7,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.es2022.full.d.ts","../src-types/dogconfig.d.ts","../src-types/index.d.ts","./dogconfig.ts","./dog.ts","./lassie/lassieconfig.ts","./lassie/lassiedog.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","impliedFormat":99},{"version":"-5608794531-export * from './dogconfig.js';\r\n","impliedFormat":99},{"version":"1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n","signature":"17588480778-import { DogConfig } from 'src-types';\r\nexport declare const DOG_CONFIG: DogConfig;\r\n","impliedFormat":99},{"version":"6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n","signature":"22128633249-import { DogConfig } from 'src-types';\r\nexport declare abstract class Dog {\r\n static getCapabilities(): DogConfig;\r\n}\r\n","impliedFormat":99},{"version":"4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n","signature":"8131483665-import { DogConfig } from 'src-types';\r\nexport declare const LASSIE_CONFIG: DogConfig;\r\n","impliedFormat":99},{"version":"-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n","signature":"-20244062422-import { Dog } from '../dog.js';\r\nexport declare class LassieDog extends Dog {\r\n protected static getDogConfig: () => import(\"../index.js\").DogConfig;\r\n}\r\n","impliedFormat":99},{"version":"-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n","signature":"-16783836862-export * from 'src-types';\r\nexport * from './lassie/lassiedog.js';\r\n","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[3,4],[3],[3,7],[5,6],[2],[5,8]],"referencedMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"exportedModulesMap":[[5,2],[4,2],[8,3],[6,2],[7,6],[3,5]],"semanticDiagnosticsPerFile":[1,5,4,8,6,7,2,3]},"version":"FakeTSVersion"} //// [/src/src-dogs/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ - "../../lib/lib.es2020.full.d.ts", + "../../lib/lib.es2022.full.d.ts", "../src-types/dogconfig.d.ts", "../src-types/index.d.ts", "./dogconfig.ts", @@ -243,7 +243,7 @@ LassieDog.getDogConfig = () => LASSIE_CONFIG; ] ], "fileInfos": { - "../../lib/lib.es2020.full.d.ts": { + "../../lib/lib.es2022.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "affectsGlobalScope": true, @@ -336,7 +336,7 @@ LassieDog.getDogConfig = () => LASSIE_CONFIG; ] }, "semanticDiagnosticsPerFile": [ - "../../lib/lib.es2020.full.d.ts", + "../../lib/lib.es2022.full.d.ts", "./dog.ts", "./dogconfig.ts", "./index.ts", @@ -369,13 +369,13 @@ export * from './dogconfig.js'; //// [/src/src-types/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","./dogconfig.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-5575793279-export interface DogConfig {\n name: string;\n}","signature":"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","impliedFormat":99},{"version":"-6189272282-export * from './dogconfig.js';","signature":"-5608794531-export * from './dogconfig.js';\r\n","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.es2022.full.d.ts","./dogconfig.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-5575793279-export interface DogConfig {\n name: string;\n}","signature":"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","impliedFormat":99},{"version":"-6189272282-export * from './dogconfig.js';","signature":"-5608794531-export * from './dogconfig.js';\r\n","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/src/src-types/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ - "../../lib/lib.es2020.full.d.ts", + "../../lib/lib.es2022.full.d.ts", "./dogconfig.ts", "./index.ts" ], @@ -385,7 +385,7 @@ export * from './dogconfig.js'; ] ], "fileInfos": { - "../../lib/lib.es2020.full.d.ts": { + "../../lib/lib.es2022.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "affectsGlobalScope": true, @@ -418,7 +418,7 @@ export * from './dogconfig.js'; ] }, "semanticDiagnosticsPerFile": [ - "../../lib/lib.es2020.full.d.ts", + "../../lib/lib.es2022.full.d.ts", "./dogconfig.ts", "./index.ts" ] diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index c5373d62745..7c1a0027558 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -7,7 +7,7 @@ import type { TheNum } from 'pkg2' export const theNum: TheNum = 42; //// [/user/username/projects/myproject/packages/pkg1/tsconfig.json] -{"compilerOptions":{"outDir":"build","module":"node12"},"references":[{"path":"../pkg2"}]} +{"compilerOptions":{"outDir":"build","module":"node16"},"references":[{"path":"../pkg2"}]} //// [/user/username/projects/myproject/packages/pkg2/const.cts] export type TheNum = 42; @@ -16,13 +16,13 @@ export type TheNum = 42; export type { TheNum } from './const.cjs'; //// [/user/username/projects/myproject/packages/pkg2/tsconfig.json] -{"compilerOptions":{"composite":true,"outDir":"build","module":"node12"}} +{"compilerOptions":{"composite":true,"outDir":"build","module":"node16"}} //// [/user/username/projects/myproject/packages/pkg2/package.json] {"name":"pkg2","version":"1.0.0","main":"build/index.js","type":"module"} //// [/user/username/projects/myproject/node_modules/pkg2] symlink(/user/username/projects/myproject/packages/pkg2) -//// [/a/lib/lib.es2020.full.d.ts] +//// [/a/lib/lib.es2022.full.d.ts] /// interface Boolean {} interface Function {} @@ -52,7 +52,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'. File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it as a name resolution result. @@ -67,7 +67,7 @@ File '/package.json' does not exist. Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -90,7 +90,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/package.json' does n File '/user/username/projects/myproject/packages/pkg2/package.json' exists according to earlier cached lookups. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -107,17 +107,17 @@ Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts" Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/const.cts /user/username/projects/myproject/packages/pkg2/index.ts Semantic diagnostics in builder refreshed for:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/const.cts /user/username/projects/myproject/packages/pkg2/index.ts Shape signatures in builder refreshed for:: -/a/lib/lib.es2020.full.d.ts (used version) +/a/lib/lib.es2022.full.d.ts (used version) /user/username/projects/myproject/packages/pkg2/const.cts (computed .d.ts during emit) /user/username/projects/myproject/packages/pkg2/index.ts (computed .d.ts during emit) @@ -125,19 +125,19 @@ Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.ts /user/username/projects/myproject/packages/pkg1/index.ts Semantic diagnostics in builder refreshed for:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.ts /user/username/projects/myproject/packages/pkg1/index.ts Shape signatures in builder refreshed for:: -/a/lib/lib.es2020.full.d.ts (used version) +/a/lib/lib.es2022.full.d.ts (used version) /user/username/projects/myproject/packages/pkg2/build/const.d.cts (used version) /user/username/projects/myproject/packages/pkg2/build/index.d.ts (used version) /user/username/projects/myproject/packages/pkg1/index.ts (used version) @@ -186,13 +186,13 @@ export type { TheNum } from './const.cjs'; //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","signature":"-9649133742-export declare type TheNum = 42;\n","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":99}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2022.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","signature":"-9649133742-export declare type TheNum = 42;\n","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":99}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ - "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../../../../../../../a/lib/lib.es2022.full.d.ts", "../const.cts", "../index.ts" ], @@ -202,7 +202,7 @@ export type { TheNum } from './const.cjs'; ] ], "fileInfos": { - "../../../../../../../a/lib/lib.es2020.full.d.ts": { + "../../../../../../../a/lib/lib.es2022.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "affectsGlobalScope": true, @@ -235,7 +235,7 @@ export type { TheNum } from './const.cjs'; ] }, "semanticDiagnosticsPerFile": [ - "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../../../../../../../a/lib/lib.es2022.full.d.ts", "../const.cts", "../index.ts" ] @@ -267,7 +267,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -297,7 +297,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package 'package.json' does not have a 'typesVersions' field. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -319,7 +319,7 @@ Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.ts /user/username/projects/myproject/packages/pkg1/index.ts @@ -375,7 +375,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -399,7 +399,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package 'package.json' does not have a 'typesVersions' field. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -416,7 +416,7 @@ Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.ts /user/username/projects/myproject/packages/pkg1/index.ts @@ -473,7 +473,7 @@ Output:: Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -503,7 +503,7 @@ Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package 'package.json' does not have a 'typesVersions' field. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. @@ -525,7 +525,7 @@ Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.ts /user/username/projects/myproject/packages/pkg1/index.ts @@ -583,7 +583,7 @@ Output:: [12:01:40 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'. File '/user/username/projects/myproject/packages/pkg2/const.cjs.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/const.cjs.tsx' does not exist. @@ -603,7 +603,7 @@ File '/package.json' does not exist. Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. 'package.json' does not have a 'typesVersions' field. ======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. @@ -629,7 +629,7 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui ======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.cts' with Package ID 'pkg2/build/index.d.cts@1.0.0'. ======== ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.cts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. -Module resolution kind is not specified, using 'Node12'. +Module resolution kind is not specified, using 'Node16'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. @@ -649,7 +649,7 @@ Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts" Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/const.cts /user/username/projects/myproject/packages/pkg2/index.cts @@ -663,7 +663,7 @@ Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} Program structureReused: Not Program files:: -/a/lib/lib.es2020.full.d.ts +/a/lib/lib.es2022.full.d.ts /user/username/projects/myproject/packages/pkg2/build/const.d.cts /user/username/projects/myproject/packages/pkg2/build/index.d.cts /user/username/projects/myproject/packages/pkg1/index.ts @@ -705,13 +705,13 @@ exitCode:: ExitStatus.undefined //// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] file changed its modified time //// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] file changed its modified time //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","signature":"-9649133742-export declare type TheNum = 42;\n","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2022.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","signature":"-9649133742-export declare type TheNum = 42;\n","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ - "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../../../../../../../a/lib/lib.es2022.full.d.ts", "../const.cts", "../index.cts" ], @@ -721,7 +721,7 @@ exitCode:: ExitStatus.undefined ] ], "fileInfos": { - "../../../../../../../a/lib/lib.es2020.full.d.ts": { + "../../../../../../../a/lib/lib.es2022.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "affectsGlobalScope": true, @@ -754,7 +754,7 @@ exitCode:: ExitStatus.undefined ] }, "semanticDiagnosticsPerFile": [ - "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../../../../../../../a/lib/lib.es2022.full.d.ts", "../const.cts", "../index.cts" ] diff --git a/tests/baselines/reference/tsc/redirect/when-redirecting-ts-file.js b/tests/baselines/reference/tsc/redirect/when-redirecting-ts-file.js new file mode 100644 index 00000000000..b50062956ca --- /dev/null +++ b/tests/baselines/reference/tsc/redirect/when-redirecting-ts-file.js @@ -0,0 +1,68 @@ +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/project/copy1/node_modules/target/import.ts] +import {} from "./"; + +//// [/src/project/copy1/node_modules/target/index.ts] +export const a = 1; + +//// [/src/project/copy1/node_modules/target/package.json] +{"name":"target","version":"1.0.0","main":"index.js"} + +//// [/src/project/copy2/node_modules/target/import.ts] +import {} from "./"; + +//// [/src/project/copy2/node_modules/target/index.ts] +export const a = 1; + +//// [/src/project/copy2/node_modules/target/package.json] +{"name":"target","version":"1.0.0","main":"index.js"} + +//// [/src/project/tsconfig.json] +{"compilerOptions":{"outDir":"out"},"include":["copy1/node_modules/target/*","copy2/node_modules/target/*"]} + + + +Output:: +/lib/tsc -p src/project +exitCode:: ExitStatus.Success + + +//// [/src/project/out/copy1/node_modules/target/import.js] +"use strict"; +exports.__esModule = true; + + +//// [/src/project/out/copy1/node_modules/target/index.js] +"use strict"; +exports.__esModule = true; +exports.a = void 0; +exports.a = 1; + + +//// [/src/project/out/copy2/node_modules/target/import.js] +"use strict"; +exports.__esModule = true; + + +//// [/src/project/out/copy2/node_modules/target/index.js] +"use strict"; +exports.__esModule = true; +exports.a = void 0; +exports.a = 1; + + diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index e9634479566..5e7ba543d34 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -85,7 +85,7 @@ default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext default: undefined --lib diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index 50b1c2f7ed7..eb384f25ae3 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -85,7 +85,7 @@ default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext default: undefined --lib diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 50b1c2f7ed7..eb384f25ae3 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -85,7 +85,7 @@ default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext default: undefined --lib diff --git a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt index a967c92e555..81231a34562 100644 --- a/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt +++ b/tests/baselines/reference/tsxNotUsingApparentTypeOfSFC.errors.txt @@ -5,17 +5,9 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(15,14): error TS2769: No o Type '{}' is not assignable to type 'Readonly

'. Overload 2 of 2, '(props: P, context?: any): MyComponent', gave the following error. Type '{}' is not assignable to type 'Readonly

'. -tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(17,14): error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes & P'. - Type 'P' is not assignable to type 'IntrinsicAttributes'. -tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(18,14): error TS2769: No overload matches this call. - Overload 1 of 2, '(props: Readonly

): MyComponent', gave the following error. - Type 'P' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Readonly

'. - Type 'P' is not assignable to type 'IntrinsicAttributes'. - Overload 2 of 2, '(props: P, context?: any): MyComponent', gave the following error. - Type 'P' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Readonly

'. -==== tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx (4 errors) ==== +==== tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx (2 errors) ==== /// import React from 'react'; @@ -42,17 +34,5 @@ tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(18,14): error TS2769: No o !!! error TS2769: Type '{}' is not assignable to type 'Readonly

'. let z = // should work - ~~~~~ -!!! error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes & P'. -!!! error TS2322: Type 'P' is not assignable to type 'IntrinsicAttributes'. -!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter probably needs an `extends object` constraint. let q = // should work - ~~~~~~~~~~~ -!!! error TS2769: No overload matches this call. -!!! error TS2769: Overload 1 of 2, '(props: Readonly

): MyComponent', gave the following error. -!!! error TS2769: Type 'P' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Readonly

'. -!!! error TS2769: Type 'P' is not assignable to type 'IntrinsicAttributes'. -!!! error TS2769: Overload 2 of 2, '(props: P, context?: any): MyComponent', gave the following error. -!!! error TS2769: Type 'P' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Readonly

'. -!!! related TS2208 tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx:5:15: This type parameter probably needs an `extends object` constraint. } \ No newline at end of file diff --git a/tests/baselines/reference/unknownType1.errors.txt b/tests/baselines/reference/unknownType1.errors.txt index 39d7a1feb52..138fff847cc 100644 --- a/tests/baselines/reference/unknownType1.errors.txt +++ b/tests/baselines/reference/unknownType1.errors.txt @@ -25,14 +25,13 @@ tests/cases/conformance/types/unknown/unknownType1.ts(144,29): error TS2698: Spr tests/cases/conformance/types/unknown/unknownType1.ts(150,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/types/unknown/unknownType1.ts(156,14): error TS2700: Rest types may only be created from object types. tests/cases/conformance/types/unknown/unknownType1.ts(162,5): error TS2564: Property 'a' has no initializer and is not definitely assigned in the constructor. -tests/cases/conformance/types/unknown/unknownType1.ts(170,9): error TS2322: Type 'T' is not assignable to type '{}'. tests/cases/conformance/types/unknown/unknownType1.ts(171,9): error TS2322: Type 'U' is not assignable to type '{}'. Type 'unknown' is not assignable to type '{}'. tests/cases/conformance/types/unknown/unknownType1.ts(181,5): error TS2322: Type 'T' is not assignable to type '{}'. Type 'unknown' is not assignable to type '{}'. -==== tests/cases/conformance/types/unknown/unknownType1.ts (28 errors) ==== +==== tests/cases/conformance/types/unknown/unknownType1.ts (27 errors) ==== // In an intersection everything absorbs unknown type T00 = unknown & null; // null @@ -255,9 +254,6 @@ tests/cases/conformance/types/unknown/unknownType1.ts(181,5): error TS2322: Type function f30(t: T, u: U) { let x: {} = t; - ~ -!!! error TS2322: Type 'T' is not assignable to type '{}'. -!!! related TS2208 tests/cases/conformance/types/unknown/unknownType1.ts:169:14: This type parameter probably needs an `extends object` constraint. let y: {} = u; ~ !!! error TS2322: Type 'U' is not assignable to type '{}'. diff --git a/tests/cases/compiler/moduleResolutionWithModule.ts b/tests/cases/compiler/moduleResolutionWithModule.ts index de0c873cdd0..74601d43da2 100644 --- a/tests/cases/compiler/moduleResolutionWithModule.ts +++ b/tests/cases/compiler/moduleResolutionWithModule.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node,node12,nodenext -// @module: commonjs,node12,nodenext +// @moduleResolution: node16,nodenext +// @module: commonjs,node16,nodenext // @filename: node_modules/pkg/package.json { "name": "pkg", diff --git a/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts b/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts index d5b58f5077f..fe80146389c 100644 --- a/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts +++ b/tests/cases/compiler/tripleSlashTypesReferenceWithMissingExports.ts @@ -1,4 +1,4 @@ -// @module: commonjs,node12,nodenext +// @module: commonjs,node16,nodenext // @filename: node_modules/pkg/index.d.ts interface GlobalThing { a: number } // @filename: node_modules/pkg/package.json diff --git a/tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts b/tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts index b56045e7ec0..ae11c010fad 100644 --- a/tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts +++ b/tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts @@ -312,3 +312,18 @@ const f60: Func = (kind, payload) => { payload.toUpperCase(); // error } }; + +// Repro from #48902 + +function foo({ + value1, + test1 = value1.test1, + test2 = value1.test2, + test3 = value1.test3, + test4 = value1.test4, + test5 = value1.test5, + test6 = value1.test6, + test7 = value1.test7, + test8 = value1.test8, + test9 = value1.test9 +}) {} diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension1.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension1.ts index 83e86fc6c60..0b740390a8a 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension1.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension1.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/foo.mts export function foo() { diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension2.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension2.ts index 0051e17401c..a7adfbcac57 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension2.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension2.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/buzz.mts // Extensionless relative path cjs import in an ES module diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension5.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension5.ts index 5053a242cd5..08011b2be63 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension5.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension5.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/buzz.mts // Extensionless relative path dynamic import in an ES module diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension6.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension6.ts index 2a6ef2645dd..c846e6fd260 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension6.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension6.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/bar.cts // Extensionless relative path import statement in a cjs module diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension7.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension7.ts index 3b10dd6e48a..f5e27470a02 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension7.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension7.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/bar.cts // Extensionless relative path cjs import in a cjs module diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension8.ts b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension8.ts index fef17b3aa1e..d862ba69de1 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension8.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithoutExtension8.ts @@ -1,5 +1,5 @@ -// @moduleResolution: node12 -// @module: node12 +// @moduleResolution: node16 +// @module: node16 // @filename: /src/bar.cts // Extensionless relative path dynamic import in a cjs module diff --git a/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts b/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts index a19a7104ae1..bf4718d847a 100644 --- a/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts +++ b/tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts index 113c1fdeb8a..f790752053f 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsCjsFromJs.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsCjsFromJs.ts index ea0821742f8..74143dcefaa 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsCjsFromJs.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsCjsFromJs.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @allowJs: true // @noEmit: true // @filename: foo.cjs diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts index 1020812d5ae..f6f62444a61 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts index d7032c648b4..5da3c3e5425 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts index f7d5aaf822a..0457ce4cb62 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts index 14783731bf9..7cb94da8f60 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts index 53e6b944500..2688b07fb99 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts index d5727a3dc78..26874896143 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @allowJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts index 032290f78ba..af20a16ba76 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @allowJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts index 9452e2003a6..a6b91898853 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @allowJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts index a8708434b93..43fdf016c43 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts index 65e5721b0bb..23de392ed7e 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts index b9d6027f5d7..84d0f650abc 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts index 2691885690b..eab5792b8fb 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts index 6b96f347583..b8ea4f9cbd8 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts index 15892edbe32..78025e25074 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts index 872cad71c91..e18c50fef7a 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts index 698a6efec1e..32c83b4525b 100644 --- a/tests/cases/conformance/node/nodeModules1.ts +++ b/tests/cases/conformance/node/nodeModules1.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts b/tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts index 06c6320d779..31051b3a18b 100644 --- a/tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts +++ b/tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts b/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts index 07bf9d9724c..a0240cdef4e 100644 --- a/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts +++ b/tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts b/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts index 2599ff429ff..9b4eb3ec9f8 100644 --- a/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts +++ b/tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodeModulesDynamicImport.ts b/tests/cases/conformance/node/nodeModulesDynamicImport.ts index 46b317ca52d..0864b42bbaf 100644 --- a/tests/cases/conformance/node/nodeModulesDynamicImport.ts +++ b/tests/cases/conformance/node/nodeModulesDynamicImport.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesExportAssignments.ts b/tests/cases/conformance/node/nodeModulesExportAssignments.ts index 7cbcd200d96..efc867fa1c6 100644 --- a/tests/cases/conformance/node/nodeModulesExportAssignments.ts +++ b/tests/cases/conformance/node/nodeModulesExportAssignments.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts b/tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts index ffc5adf8e07..ee6587b5ea0 100644 --- a/tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts +++ b/tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts index 2562c7a4a11..92c686f1c23 100644 --- a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts +++ b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts index 2eb8ac58e66..684cb5588fc 100644 --- a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts +++ b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts index 97812da5b57..a325a2dfe6c 100644 --- a/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts +++ b/tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts index d441627d7d0..ca9ff3cf413 100644 --- a/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts +++ b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts index e9a9b9d9edd..6f6fa8acb07 100644 --- a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts +++ b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportAssertions.ts b/tests/cases/conformance/node/nodeModulesImportAssertions.ts index 0fe1ccdf820..ae941bd003b 100644 --- a/tests/cases/conformance/node/nodeModulesImportAssertions.ts +++ b/tests/cases/conformance/node/nodeModulesImportAssertions.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @resolveJsonModule: true // @filename: index.ts import json from "./package.json" assert { type: "json" }; diff --git a/tests/cases/conformance/node/nodeModulesImportAssignments.ts b/tests/cases/conformance/node/nodeModulesImportAssignments.ts index 6c22fe83e00..cce29eb0d75 100644 --- a/tests/cases/conformance/node/nodeModulesImportAssignments.ts +++ b/tests/cases/conformance/node/nodeModulesImportAssignments.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts index 103b5837124..0a4698a95fb 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @filename: subfolder/index.ts diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts index 7f90947a5fb..58e65723cbc 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @filename: subfolder/index.ts diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts index 5f6984ad1fb..3145df76cd5 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @importHelpers: true // @filename: subfolder/index.ts diff --git a/tests/cases/conformance/node/nodeModulesImportMeta.ts b/tests/cases/conformance/node/nodeModulesImportMeta.ts index d684c7b5cb2..cc8bdcce9da 100644 --- a/tests/cases/conformance/node/nodeModulesImportMeta.ts +++ b/tests/cases/conformance/node/nodeModulesImportMeta.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit1.ts b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit1.ts index 5a9a0ef8cee..c1c0c57cf9d 100644 --- a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit1.ts +++ b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit1.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit2.ts b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit2.ts index 7b819fddf49..06a9b226b21 100644 --- a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit2.ts +++ b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmit2.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmitErrors1.ts b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmitErrors1.ts index 1e475dfc63a..01907185636 100644 --- a/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmitErrors1.ts +++ b/tests/cases/conformance/node/nodeModulesImportModeDeclarationEmitErrors1.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts b/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts index 2a407b2bc68..58a8adbf9b0 100644 --- a/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts +++ b/tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts b/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts index c0482c86ec2..b3a4139a00c 100644 --- a/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts +++ b/tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts index 41d64844e09..c6ca4e2f13f 100644 --- a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts +++ b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts index d6f35e46385..d118bc6da29 100644 --- a/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts +++ b/tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesPackageExports.ts b/tests/cases/conformance/node/nodeModulesPackageExports.ts index 897d01b07d7..6433e49270f 100644 --- a/tests/cases/conformance/node/nodeModulesPackageExports.ts +++ b/tests/cases/conformance/node/nodeModulesPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodeModulesPackageImports.ts b/tests/cases/conformance/node/nodeModulesPackageImports.ts index cccf930098e..55122ed464f 100644 --- a/tests/cases/conformance/node/nodeModulesPackageImports.ts +++ b/tests/cases/conformance/node/nodeModulesPackageImports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts b/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts index e22e497a942..4a4af53809a 100644 --- a/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts +++ b/tests/cases/conformance/node/nodeModulesPackagePatternExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts b/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts index 3abe36e0d69..ad842bcdb4a 100644 --- a/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts +++ b/tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodeModulesResolveJsonModule.ts b/tests/cases/conformance/node/nodeModulesResolveJsonModule.ts index c298685c228..33bc45a2a07 100644 --- a/tests/cases/conformance/node/nodeModulesResolveJsonModule.ts +++ b/tests/cases/conformance/node/nodeModulesResolveJsonModule.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @resolveJsonModule: true // @outDir: ./out // @declaration: true diff --git a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts index 78aa93ee17c..203760b4e5d 100644 --- a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts +++ b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts index 2fbd5d3b0cd..0e532ced3ba 100644 --- a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts +++ b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit1.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit1.ts index 8e99536aa8c..b1e4156f7fe 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit1.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit1.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit2.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit2.ts index 9349d1c2767..501d62d8db4 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit2.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit2.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit3.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit3.ts index 8c16d1bd455..5ccdd5f1f9f 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit3.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit3.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit4.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit4.ts index 6d778bb754c..2efe66d7462 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit4.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit4.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit5.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit5.ts index 6694ad03d8d..849f1ee97cd 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit5.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit5.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit6.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit6.ts index 8a38a967170..4ceec4badef 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit6.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit6.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit7.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit7.ts index 317728fbaa8..5260cc2ae77 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit7.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeDeclarationEmit7.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: /node_modules/pkg/package.json diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride1.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride1.ts index 061d16a7560..c488964766d 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride1.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride1.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride2.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride2.ts index 105e52cf2d8..79eeba94abf 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride2.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride2.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts index d183196f176..74a9d2fffe5 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride4.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride4.ts index 466d47fba20..26bc3c8f393 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride4.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride4.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride5.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride5.ts index e9198bd5107..2174f959237 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride5.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride5.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideModeError.ts b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideModeError.ts index 197b2db20ba..84828c5dabb 100644 --- a/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideModeError.ts +++ b/tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverrideModeError.ts @@ -1,5 +1,5 @@ // @noImplicitReferences: true -// @module: node12,nodenext +// @module: node16,nodenext // @outDir: out // @filename: /node_modules/pkg/package.json { diff --git a/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts b/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts index 52cda091b32..1cdaef53f24 100644 --- a/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts +++ b/tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @outDir: out // @filename: index.ts diff --git a/tests/cases/conformance/node/nodePackageSelfName.ts b/tests/cases/conformance/node/nodePackageSelfName.ts index 099d9c424e1..ec9dd150591 100644 --- a/tests/cases/conformance/node/nodePackageSelfName.ts +++ b/tests/cases/conformance/node/nodePackageSelfName.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/node/nodePackageSelfNameScoped.ts b/tests/cases/conformance/node/nodePackageSelfNameScoped.ts index f4ef1e3798c..9e9eef38496 100644 --- a/tests/cases/conformance/node/nodePackageSelfNameScoped.ts +++ b/tests/cases/conformance/node/nodePackageSelfNameScoped.ts @@ -1,4 +1,4 @@ -// @module: node12,nodenext +// @module: node16,nodenext // @declaration: true // @filename: index.ts // esm format file diff --git a/tests/cases/conformance/types/import/importWithTypeArguments.ts b/tests/cases/conformance/types/import/importWithTypeArguments.ts new file mode 100644 index 00000000000..684260429c2 --- /dev/null +++ b/tests/cases/conformance/types/import/importWithTypeArguments.ts @@ -0,0 +1,2 @@ +import +const a = import diff --git a/tests/cases/fourslash/autoImport_node12_node_modules1.ts b/tests/cases/fourslash/autoImport_node12_node_modules1.ts index 5020f5809b4..80a9e157311 100644 --- a/tests/cases/fourslash/autoImport_node12_node_modules1.ts +++ b/tests/cases/fourslash/autoImport_node12_node_modules1.ts @@ -1,6 +1,6 @@ /// -// @module: node12 +// @module: node16 // @Filename: /node_modules/undici/index.d.ts //// export function request(): any; diff --git a/tests/cases/fourslash/completionListInObjectLiteral8.ts b/tests/cases/fourslash/completionListInObjectLiteral8.ts new file mode 100644 index 00000000000..11b8a1844d4 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectLiteral8.ts @@ -0,0 +1,18 @@ +/// + +////declare function test< +//// Variants extends Partial>, +////>(v: Variants): void +//// +////test({ +//// hover: "", +//// /**/ +////}); + +verify.completions({ + marker: '', + exact: [{ + name: 'pressed', + sortText: completion.SortText.OptionalMember + }] +}); diff --git a/tests/cases/fourslash/formatAfterPasteInString.ts b/tests/cases/fourslash/formatAfterPasteInString.ts new file mode 100644 index 00000000000..716af9183bb --- /dev/null +++ b/tests/cases/fourslash/formatAfterPasteInString.ts @@ -0,0 +1,9 @@ +/// + +//// /*2*/const x = f('aa/*1*/a').x() + +goTo.marker('1'); +edit.paste("bb"); +format.document(); +goTo.marker('2'); +verify.currentLineContentIs("const x = f('aabba').x()"); diff --git a/tests/cases/fourslash/moduleNodeNextImportFix.ts b/tests/cases/fourslash/moduleNodeNextImportFix.ts index 74edf7daff3..19b2aa291e1 100644 --- a/tests/cases/fourslash/moduleNodeNextImportFix.ts +++ b/tests/cases/fourslash/moduleNodeNextImportFix.ts @@ -8,7 +8,7 @@ ////{ //// "compilerOptions": { //// "outDir": "./dist", -//// "module": "node12", +//// "module": "node16", //// "target": "esnext" //// }, //// "include": ["./src"] diff --git a/tests/cases/fourslash/organizeImports10.ts b/tests/cases/fourslash/organizeImports10.ts new file mode 100644 index 00000000000..de1acf551ee --- /dev/null +++ b/tests/cases/fourslash/organizeImports10.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: /module.ts +////import type { ZodType } from './declaration'; +//// +/////** Intended to be used in combination with {@link ZodType} */ +////export function fun() { /* ... */ } + +// @Filename: /declaration.ts +//// type ZodType = {}; +//// export type { ZodType } + + +verify.organizeImports(`import type { ZodType } from './declaration'; + +/** Intended to be used in combination with {@link ZodType} */ +export function fun() { /* ... */ }` +); diff --git a/tests/cases/fourslash/organizeImports11.ts b/tests/cases/fourslash/organizeImports11.ts new file mode 100644 index 00000000000..d2ba946ef82 --- /dev/null +++ b/tests/cases/fourslash/organizeImports11.ts @@ -0,0 +1,62 @@ +/// + +// @Filename: /test.ts +////import { TypeA, TypeB, TypeC, UnreferencedType } from './my-types'; +//// +/////** +//// * MyClass {@link TypeA} +//// */ +////export class MyClass { +//// +//// /** +//// * Some Property {@link TypeB} +//// */ +//// public something; +//// +//// /** +//// * Some function {@link TypeC} +//// */ +//// public myMethod() { +//// +//// /** +//// * Some lambda function {@link TypeC} +//// */ +//// const someFunction = () => { +//// return ''; +//// } +//// someFunction(); +//// } +////} + +// @Filename: /my-types.ts +//// export type TypeA = string; +//// export class TypeB { } +//// export type TypeC = () => string; + +verify.organizeImports(`import { TypeA, TypeB, TypeC } from './my-types'; + +/** + * MyClass {@link TypeA} + */ +export class MyClass { + + /** + * Some Property {@link TypeB} + */ + public something; + + /** + * Some function {@link TypeC} + */ + public myMethod() { + + /** + * Some lambda function {@link TypeC} + */ + const someFunction = () => { + return ''; + } + someFunction(); + } +}` +); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoFunctionCheckType.ts b/tests/cases/fourslash/quickInfoFunctionCheckType.ts new file mode 100644 index 00000000000..813b920db3b --- /dev/null +++ b/tests/cases/fourslash/quickInfoFunctionCheckType.ts @@ -0,0 +1,6 @@ +/// + +////export type /**/Tail = ((...t: T) => void) extends (h: any, ...rest: infer R) => void ? R : never; + +verify.quickInfoAt("", "type Tail = ((...t: T) => void) extends (h: any, ...rest: infer R) => void ? R : never"); + diff --git a/tests/cases/fourslash/refactorConvertToEsModule_module_node12.ts b/tests/cases/fourslash/refactorConvertToEsModule_module_node12.ts index a7be99ba157..475fc0f5c53 100644 --- a/tests/cases/fourslash/refactorConvertToEsModule_module_node12.ts +++ b/tests/cases/fourslash/refactorConvertToEsModule_module_node12.ts @@ -2,7 +2,7 @@ // @allowJs: true // @target: esnext -// @module: node12 +// @module: node16 // @Filename: /a.js ////module.exports = 0; diff --git a/tests/cases/fourslash/server/autoImportProvider_namespaceSameNameAsIntrinsic.ts b/tests/cases/fourslash/server/autoImportProvider_namespaceSameNameAsIntrinsic.ts new file mode 100644 index 00000000000..f4c6342f44e --- /dev/null +++ b/tests/cases/fourslash/server/autoImportProvider_namespaceSameNameAsIntrinsic.ts @@ -0,0 +1,39 @@ +/// + +// @Filename: /node_modules/fp-ts/package.json +//// { "name": "fp-ts", "version": "0.10.4" } + +// @Filename: /node_modules/fp-ts/index.d.ts +//// export * as string from "./lib/string"; + +// @Filename: /node_modules/fp-ts/lib/string.d.ts +//// export declare const fromString: (s: string) => string; +//// export type SafeString = string; + +// @Filename: /package.json +//// { "dependencies": { "fp-ts": "^0.10.4" } } + +// @Filename: /tsconfig.json +//// { "compilerOptions": { "module": "commonjs" } } + +// @Filename: /index.ts +//// type A = { name: string/**/ } + +goTo.marker(""); +verify.completions({ + marker: "", + includes: [{ + name: "string", + sortText: completion.SortText.GlobalsOrKeywords, + }, { + name: "string", + sortText: completion.SortText.AutoImportSuggestions, + source: "fp-ts", + sourceDisplay: "fp-ts", + hasAction: true, + }], + preferences: { + includeCompletionsForModuleExports: true, + allowIncompleteCompletions: true, + }, +}); diff --git a/tests/cases/fourslash/server/renameNamedImport.ts b/tests/cases/fourslash/server/renameNamedImport.ts new file mode 100644 index 00000000000..07ae2b93c8b --- /dev/null +++ b/tests/cases/fourslash/server/renameNamedImport.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /lib/tsconfig.json +//// {} + +// @Filename: /lib/index.ts +//// const unrelatedLocalVariable = 123; +//// export const someExportedVariable = unrelatedLocalVariable; + +// @Filename: /src/tsconfig.json +//// {} + +// @Filename: /src/index.ts +//// import { /*i*/someExportedVariable } from '../lib/index'; +//// someExportedVariable; + +// @Filename: /tsconfig.json +//// {} + +goTo.file("/lib/index.ts"); +goTo.file("/src/index.ts"); +verify.baselineRename("i", { providePrefixAndSuffixTextForRename: true }); diff --git a/tests/cases/fourslash/server/renameNamespaceImport.ts b/tests/cases/fourslash/server/renameNamespaceImport.ts new file mode 100644 index 00000000000..a4b98baa01c --- /dev/null +++ b/tests/cases/fourslash/server/renameNamespaceImport.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /lib/tsconfig.json +//// {} + +// @Filename: /lib/index.ts +//// const unrelatedLocalVariable = 123; +//// export const someExportedVariable = unrelatedLocalVariable; + +// @Filename: /src/tsconfig.json +//// {} + +// @Filename: /src/index.ts +//// import * as /*i*/lib from '../lib/index'; +//// lib.someExportedVariable; + +// @Filename: /tsconfig.json +//// {} + +goTo.file("/lib/index.ts"); +goTo.file("/src/index.ts"); +verify.baselineRename("i", {});