From 9b83a2ef040f8cdc538011273248bc6bb31e715c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 6 Jul 2021 12:11:22 -0700 Subject: [PATCH 1/5] cts, mts, cjs, mjs, etc extension support --- src/compiler/builderState.ts | 2 +- src/compiler/checker.ts | 12 + src/compiler/commandLineParser.ts | 45 +- src/compiler/diagnosticMessages.json | 8 + src/compiler/emitter.ts | 34 +- src/compiler/moduleNameResolver.ts | 57 +- src/compiler/moduleSpecifiers.ts | 2 +- src/compiler/program.ts | 11 +- src/compiler/utilities.ts | 107 ++-- src/compiler/watch.ts | 2 + src/compiler/watchUtilities.ts | 2 +- src/executeCommandLine/executeCommandLine.ts | 4 +- src/harness/compilerImpl.ts | 6 +- src/harness/fourslashImpl.ts | 3 +- src/harness/vpathUtil.ts | 2 +- src/server/watchType.ts | 2 - src/services/stringCompletions.ts | 8 +- src/testRunner/unittests/moduleResolution.ts | 10 +- src/testRunner/unittests/programApi.ts | 2 +- .../unittests/tsbuild/moduleResolution.ts | 90 ++++ ...tionEmitInvalidReferenceAllowJs.errors.txt | 4 +- ...sFileCompilationWithMapFileAsJs.errors.txt | 4 +- ...hMapFileAsJsWithInlineSourceMap.errors.txt | 4 +- ...lationWithMapFileAsJsWithOutDir.errors.txt | 4 +- .../nodeModules1(module=node12).errors.txt | 158 ++++++ .../reference/nodeModules1(module=node12).js | 265 ++++++++++ .../nodeModules1(module=node12).symbols | 285 +++++++++- .../nodeModules1(module=node12).types | 325 ++++++++++++ .../nodeModules1(module=nodenext).errors.txt | 158 ++++++ .../nodeModules1(module=nodenext).js | 265 ++++++++++ .../nodeModules1(module=nodenext).symbols | 285 +++++++++- .../nodeModules1(module=nodenext).types | 325 ++++++++++++ ...eModulesAllowJs1(module=node12).errors.txt | 158 ++++++ .../nodeModulesAllowJs1(module=node12).js | 265 ++++++++++ ...nodeModulesAllowJs1(module=node12).symbols | 285 +++++++++- .../nodeModulesAllowJs1(module=node12).types | 325 ++++++++++++ ...odulesAllowJs1(module=nodenext).errors.txt | 158 ++++++ .../nodeModulesAllowJs1(module=nodenext).js | 265 ++++++++++ ...deModulesAllowJs1(module=nodenext).symbols | 285 +++++++++- ...nodeModulesAllowJs1(module=nodenext).types | 325 ++++++++++++ ...esForbidenSyntax(module=node12).errors.txt | 139 +++++ ...odeModulesForbidenSyntax(module=node12).js | 172 +++++++ ...dulesForbidenSyntax(module=node12).symbols | 120 +++++ ...ModulesForbidenSyntax(module=node12).types | 168 ++++++ ...ForbidenSyntax(module=nodenext).errors.txt | 139 +++++ ...eModulesForbidenSyntax(module=nodenext).js | 172 +++++++ ...lesForbidenSyntax(module=nodenext).symbols | 120 +++++ ...dulesForbidenSyntax(module=nodenext).types | 168 ++++++ .../amd/invalidRootFile.errors.txt | 8 +- .../node/invalidRootFile.errors.txt | 8 +- ...t-correctly-with-cts-and-mts-extensions.js | 485 ++++++++++++++++++ .../node/allowJs/nodeModulesAllowJs1.ts | 105 ++++ tests/cases/conformance/node/nodeModules1.ts | 105 ++++ .../node/nodeModulesForbidenSyntax.ts | 67 +++ 54 files changed, 6364 insertions(+), 169 deletions(-) create mode 100644 tests/baselines/reference/nodeModules1(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModules1(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types create mode 100644 tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js create mode 100644 tests/cases/conformance/node/nodeModulesForbidenSyntax.ts diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 779924a4c9d3a..f94c2086733a2 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -423,7 +423,7 @@ namespace ts { ); const firstDts = firstOrUndefined(emitOutput.outputFiles); if (firstDts) { - Debug.assert(fileExtensionIs(firstDts.name, Extension.Dts), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); + Debug.assert(fileExtensionIsOneOf(firstDts.name, [Extension.Dts, Extension.Dmts, Extension.Dcts]), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); latestSignature = (computeHash || generateDjb2Hash)(firstDts.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70196b6da2add..9345eb730f71a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30386,6 +30386,12 @@ namespace ts { } function checkAssertion(node: AssertionExpression) { + if (node.kind === SyntaxKind.TypeAssertionExpression) { + const file = getSourceFileOfNode(node); + if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { + grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Use_an_as_expression_instead); + } + } return checkAssertionWorker(node, node.type, node.expression); } @@ -41549,6 +41555,12 @@ namespace ts { return false; } + if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { + if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) { + grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Add_a_trailing_comma_or_explicit_constraint); + } + } + const { equalsGreaterThanToken } = node; const startLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line; const endLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 49a0b71fdbe99..9d13f1db0cbb3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -3214,7 +3214,7 @@ namespace ts { let jsonOnlyIncludeRegexes: readonly RegExp[] | undefined; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { - for (const file of host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) { + for (const file of host.readDirectory(basePath, flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) { if (fileExtensionIs(file, Extension.Json)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { @@ -3439,16 +3439,24 @@ namespace ts { * extension priority. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ - function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { - const extensionPriority = getExtensionPriority(file, extensions); - const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions); - for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { - const higherPriorityExtension = extensions[i]; - const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); + function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap, wildcardFiles: ESMap, extensions: readonly string[][], keyMapper: (value: string) => string) { + const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined); + if (!extensionGroup) { + return false; + } + for (const ext of extensionGroup) { + if (fileExtensionIs(file, ext)) { + break; + } + const higherPriorityPath = keyMapper(changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { + if (ext === Extension.Dts && (fileExtensionIs(file, Extension.Js) || fileExtensionIs(file, Extension.Jsx))) { + // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration + // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to + // prevent breakage. + continue; + } return true; } } @@ -3461,15 +3469,18 @@ namespace ts { * already been included. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ - function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { - const extensionPriority = getExtensionPriority(file, extensions); - const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions); - for (let i = nextExtensionPriority; i < extensions.length; i++) { - const lowerPriorityExtension = extensions[i]; - const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension)); + function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap, extensions: readonly string[][], keyMapper: (value: string) => string) { + const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined); + if (!extensionGroup) { + return; + } + for (let i = extensionGroup.length - 1; i >= 0; i--) { + const ext = extensionGroup[i]; + if (fileExtensionIs(file, ext)) { + break; + } + const lowerPriorityPath = keyMapper(changeExtension(file, ext)); wildcardFiles.delete(lowerPriorityPath); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a199dab5bb579..2c16ea3f137a6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5975,6 +5975,14 @@ "category": "Error", "code": 7057 }, + "This syntax is reserved in files with this extension. Use an `as` expression instead.": { + "category": "Error", + "code": 7058 + }, + "This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.": { + "category": "Error", + "code": 7059 + }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5667e792b4606..943dd14836e78 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -89,7 +89,7 @@ namespace ts { return getOutputPathsForBundle(options, forceDtsPaths); } else { - const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options)); const isJsonFile = isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it const isJsonEmittedToSameLocation = isJsonFile && @@ -106,26 +106,23 @@ namespace ts { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve /* @internal */ - export function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): Extension { - if (isJsonSourceFile(sourceFile)) { + export function getOutputExtension(fileName: string, options: CompilerOptions): Extension { + if (fileExtensionIs(fileName, Extension.Json)) { return Extension.Json; } if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJS(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, Extension.Jsx)) { - return Extension.Jsx; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax + if (fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx])) { return Extension.Jsx; } } + if (fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs])) { + return Extension.Mjs; + } + if (fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs])) { + return Extension.Cjs; + } return Extension.Js; } @@ -140,10 +137,9 @@ namespace ts { /* @internal */ export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, getCommonSourceDirectory?: () => string) { - Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && !fileExtensionIs(inputFileName, Extension.Json)); return changeExtension( getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), - Extension.Dts + getDeclarationEmitExtensionForPath(inputFileName) ); } @@ -152,11 +148,7 @@ namespace ts { const isJsonFile = fileExtensionIs(inputFileName, Extension.Json); const outputFileName = changeExtension( getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), - isJsonFile ? - Extension.Json : - configFile.options.jsx === JsxEmit.Preserve && (fileExtensionIs(inputFileName, Extension.Tsx) || fileExtensionIs(inputFileName, Extension.Jsx)) ? - Extension.Jsx : - Extension.Js + getOutputExtension(inputFileName, configFile.options) ); return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== Comparison.EqualTo ? outputFileName : @@ -238,7 +230,7 @@ namespace ts { export function getCommonSourceDirectoryOfConfig({ options, fileNames }: ParsedCommandLine, ignoreCase: boolean): string { return getCommonSourceDirectory( options, - () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensions)) && !fileExtensionIs(file, Extension.Dts)), + () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensionsFlat)) && !fileExtensionIs(file, Extension.Dts)), getDirectoryPath(normalizeSlashes(Debug.checkDefined(options.configFilePath))), createGetCanonicalFileName(!ignoreCase) ); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ab5f754e9eeb3..acd31c36b391c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1244,11 +1244,12 @@ namespace ts { function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { const extensionLess = tryRemoveExtension(candidate, Extension.Json); - return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); + const extension = extensionLess ? candidate.substring(extensionLess.length) : ""; + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); + const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -1257,16 +1258,16 @@ namespace ts { // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJSFileExtension(candidate)) { const extensionless = removeFileExtension(candidate); + const extension = candidate.substring(extensionless.length); if (state.traceEnabled) { - const extension = candidate.substring(extensionless.length); trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state); } } /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate: string, extensions: Extensions, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { + function tryAddingExtensions(candidate: string, extensions: Extensions, originalExtension: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing const directory = getDirectoryPath(candidate); @@ -1277,11 +1278,51 @@ namespace ts { switch (extensions) { case Extensions.DtsOnly: - return tryExtension(Extension.Dts); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Dmts); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Dcts); + case Extension.Json: + candidate += Extension.Json; + return tryExtension(Extension.Dts); + default: return tryExtension(Extension.Dts); + } case Extensions.TypeScript: - return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Mts) || tryExtension(Extension.Dmts); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Cts) || tryExtension(Extension.Dcts); + case Extension.Json: + candidate += Extension.Json; + return tryExtension(Extension.Dts); + default: + return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + } case Extensions.JavaScript: - return tryExtension(Extension.Js) || tryExtension(Extension.Jsx); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Mjs); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Cjs); + case Extension.Json: + return tryExtension(Extension.Json); + default: + return tryExtension(Extension.Js) || tryExtension(Extension.Jsx); + } case Extensions.TSConfig: case Extensions.Json: return tryExtension(Extension.Json); diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index de42460d54aeb..8bfffcffb82ef 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -652,7 +652,7 @@ namespace ts.moduleSpecifiers { function tryGetAnyFileFromPath(host: ModuleSpecifierResolutionHost, path: string) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - const extensions = getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }]); + const extensions = flatten(getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }])); for (const e of extensions) { const fullPath = path + e; if (host.fileExists(fullPath)) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d529b73ffacb5..f3c3452fee9dd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2466,13 +2466,13 @@ namespace ts { if (hasExtension(fileName)) { const canonicalFileName = host.getCanonicalFileName(fileName); - if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule, extension => fileExtensionIs(canonicalFileName, extension))) { + if (!options.allowNonTsExtensions && !forEach(flatten(supportedExtensionsWithJsonIfResolveJsonModule), extension => fileExtensionIs(canonicalFileName, extension))) { if (fail) { if (hasJSFileExtension(canonicalFileName)) { fail(Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName); } else { - fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'"); } } return undefined; @@ -2504,8 +2504,9 @@ namespace ts { return undefined; } - const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension)); - if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + // Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts) + const sourceFileWithAddedExtension = forEach(supportedExtensions[0], extension => getSourceFile(fileName + extension)); + if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'"); return sourceFileWithAddedExtension; } } @@ -3704,7 +3705,7 @@ namespace ts { return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (fileExtensionIsOneOf(filePath, supportedJSExtensions) || fileExtensionIs(filePath, Extension.Dts)) { + if (fileExtensionIsOneOf(filePath, supportedJSExtensionsFlat) || fileExtensionIs(filePath, Extension.Dts)) { // Otherwise just check if sourceFile with the name exists const filePathWithoutExtension = removeFileExtension(filePath); return !!getSourceFileByPath((filePathWithoutExtension + Extension.Ts) as Path) || diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index df03bfa8d743d..477fbba6fd016 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4234,7 +4234,15 @@ namespace ts { const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName; - return removeFileExtension(path) + Extension.Dts; + const declarationExtension = getDeclarationEmitExtensionForPath(path); + return removeFileExtension(path) + declarationExtension; + } + + export function getDeclarationEmitExtensionForPath(path: string) { + return fileExtensionIsOneOf(path, [Extension.Mjs, Extension.Mts]) ? Extension.Dmts : + fileExtensionIsOneOf(path, [Extension.Cjs, Extension.Cts]) ? Extension.Dcts : + fileExtensionIsOneOf(path, [Extension.Json]) ? `.json.d.ts` : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + Extension.Dts; } export function outFile(options: CompilerOptions) { @@ -6702,37 +6710,42 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedTSExtensions: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts]; - export const supportedTSExtensionsWithJson: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Json]; + export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]]; + export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions); + const supportedTSExtensionsWithJson: readonly Extension[][] = [...supportedTSExtensions, [Extension.Json]]; /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - export const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Ts, Extension.Tsx]; - export const supportedJSExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx]; - export const supportedJSAndJsonExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx, Extension.Json]; - const allSupportedExtensions: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions]; - const allSupportedExtensionsWithJson: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions, Extension.Json]; - - export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[]; - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[]; - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[] { + const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts, Extension.Cts, Extension.Mts, Extension.Ts, Extension.Tsx, Extension.Cts, Extension.Mts]; + export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]]; + export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions); + const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]]; + const allSupportedExtensionsWithJson: readonly Extension[][] = [...allSupportedExtensions, [Extension.Json]]; + + export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[][]; + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][]; + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][] { const needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : supportedTSExtensions; } + const builtins = needJsExtensions ? allSupportedExtensions : supportedTSExtensions; + const flatBuiltins = flatten(builtins); const extensions = [ - ...needJsExtensions ? allSupportedExtensions : supportedTSExtensions, - ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined) + ...builtins, + ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension as Extension) === -1 ? [x.extension] : undefined) ]; - return deduplicate(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive); + return extensions; } - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[]): readonly string[] { + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { if (!options || !options.resolveJsonModule) { return supportedExtensions; } if (supportedExtensions === allSupportedExtensions) { return allSupportedExtensionsWithJson; } if (supportedExtensions === supportedTSExtensions) { return supportedTSExtensionsWithJson; } - return [...supportedExtensions, Extension.Json]; + return [...supportedExtensions, [Extension.Json]]; } function isJSLike(scriptKind: ScriptKind | undefined): boolean { @@ -6740,18 +6753,18 @@ namespace ts { } export function hasJSFileExtension(fileName: string): boolean { - return some(supportedJSExtensions, extension => fileExtensionIs(fileName, extension)); + return some(supportedJSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); } export function hasTSFileExtension(fileName: string): boolean { - return some(supportedTSExtensions, extension => fileExtensionIs(fileName, extension)); + return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); } export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]) { if (!fileName) { return false; } const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions); - for (const extension of getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)) { + for (const extension of flatten(getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { if (fileExtensionIs(fileName, extension)) { return true; } @@ -6771,59 +6784,7 @@ namespace ts { ); } - /** - * Extension boundaries by priority. Lower numbers indicate higher priorities, and are - * aligned to the offset of the highest priority extension in the - * allSupportedExtensions array. - */ - export const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - - Highest = TypeScriptFiles, - Lowest = DeclarationAndJavaScriptFiles, - } - - export function getExtensionPriority(path: string, supportedExtensions: readonly string[]): ExtensionPriority { - for (let i = supportedExtensions.length - 1; i >= 0; i--) { - if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i as ExtensionPriority, supportedExtensions); - } - } - - // If its not in the list of supported extensions, this is likely a - // TypeScript file with a non-ts extension - return ExtensionPriority.Highest; - } - - /** - * Adjusts an extension priority to be the highest priority within the same range. - */ - export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority { - if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { - return ExtensionPriority.TypeScriptFiles; - } - else if (extensionPriority < supportedExtensions.length) { - return ExtensionPriority.DeclarationAndJavaScriptFiles; - } - else { - return supportedExtensions.length; - } - } - - /** - * Gets the next lowest extension priority for a given priority. - */ - export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority { - if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { - return ExtensionPriority.DeclarationAndJavaScriptFiles; - } - else { - return supportedExtensions.length; - } - } - - const extensionsToRemove = [Extension.Dts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; + const extensionsToRemove = [Extension.Dts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Mts, Extension.Cjs, Extension.Cts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; export function removeFileExtension(path: string): string { for (const ext of extensionsToRemove) { const extensionless = tryRemoveExtension(path, ext); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index d444e63c800c9..d3a44d9231a83 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -418,6 +418,7 @@ namespace ts { ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", + PackageJsonFile: "package.json file for import suggestions", }; export interface WatchTypeRegistry { @@ -431,6 +432,7 @@ namespace ts { ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", + PackageJsonFile: "package.json file for import suggestions", } interface WatchFactory extends ts.WatchFactory { diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 39256b39acb68..7e13212596323 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -480,7 +480,7 @@ namespace ts { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; } - else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensions)) { + else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensionsFlat)) { return false; } diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 888172b87325e..a6979376e3a6f 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -43,10 +43,10 @@ namespace ts { } const path = file.path; - if (fileExtensionIsOneOf(path, supportedTSExtensions)) { + if (fileExtensionIsOneOf(path, supportedTSExtensionsFlat)) { return "TypeScript"; } - else if (fileExtensionIsOneOf(path, supportedJSExtensions)) { + else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) { return "JavaScript"; } else if (fileExtensionIs(path, Extension.Json)) { diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 7d42ccea2c0bd..9f7c1503ae8fb 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -118,11 +118,11 @@ namespace compiler { const input = new documents.TextDocument(sourceFile.fileName, sourceFile.text); this._inputs.push(input); if (!vpath.isDeclaration(sourceFile.fileName)) { - const extname = ts.getOutputExtension(sourceFile, this.options); + const extname = ts.getOutputExtension(sourceFile.fileName, this.options); const outputs: CompilationOutput = { inputs: [input], js: js.get(this.getOutputPath(sourceFile.fileName, extname)), - dts: dts.get(this.getOutputPath(sourceFile.fileName, ".d.ts")), + dts: dts.get(this.getOutputPath(sourceFile.fileName, ts.getDeclarationEmitExtensionForPath(sourceFile.fileName))), map: maps.get(this.getOutputPath(sourceFile.fileName, extname + ".map")) }; @@ -205,7 +205,7 @@ namespace compiler { } else { path = vpath.resolve(this.vfs.cwd(), path); - const outDir = ext === ".d.ts" ? this.options.declarationDir || this.options.outDir : this.options.outDir; + const outDir = ext === ".d.ts" || ext === ".json.d.ts" || ext === ".d.mts" || ext === ".d.cts" ? this.options.declarationDir || this.options.outDir : this.options.outDir; if (outDir) { const common = this.commonSourceDirectory; if (common) { diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index af75c48f0bae0..d2953bcd1ad2c 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -313,12 +313,13 @@ namespace FourSlash { this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined); }); + const exts = ts.flatten(ts.getSupportedExtensions(compilationOptions)); // Add import files into language-service host ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison const importedFilePath = this.basePath + "/" + importedFile.fileName; - this.addMatchedInputFile(importedFilePath, ts.getSupportedExtensions(compilationOptions)); + this.addMatchedInputFile(importedFilePath, exts); }); // Check if no-default-lib flag is false and if so add default library diff --git a/src/harness/vpathUtil.ts b/src/harness/vpathUtil.ts index 31419e976fffb..44ef5b0f6af3f 100644 --- a/src/harness/vpathUtil.ts +++ b/src/harness/vpathUtil.ts @@ -108,7 +108,7 @@ namespace vpath { } export function isDeclaration(path: string) { - return extname(path, ".d.ts", /*ignoreCase*/ false).length > 0; + return ts.fileExtensionIsOneOf(path, [ts.Extension.Dmts, ts.Extension.Dcts, ts.Extension.Dts]); } export function isSourceMap(path: string) { diff --git a/src/server/watchType.ts b/src/server/watchType.ts index 2b9edafb09870..7893de0e26bc1 100644 --- a/src/server/watchType.ts +++ b/src/server/watchType.ts @@ -8,7 +8,6 @@ namespace ts { MissingSourceMapFile: "Missing source map file", NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root", MissingGeneratedFile: "Missing generated file", - PackageJsonFile: "package.json file for import suggestions", NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation", } WatchType.ClosedScriptInfo = "Closed Script info"; @@ -17,5 +16,4 @@ namespace ts { WatchType.MissingSourceMapFile = "Missing source map file"; WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root"; WatchType.MissingGeneratedFile = "Missing generated file"; - WatchType.PackageJsonFile = "package.json file for import suggestions"; } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 9255898ca7289..944b61b885ebd 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -330,7 +330,7 @@ namespace ts.Completions.StringCompletions { readonly includeExtensionsOption: IncludeExtensionsOption; } function getExtensionOptions(compilerOptions: CompilerOptions, includeExtensionsOption = IncludeExtensionsOption.Exclude): ExtensionOptions { - return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption }; + return { extensions: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, preferences: UserPreferences) { const includeExtensions = preferences.importModuleSpecifierEnding === "js" ? IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude; @@ -344,10 +344,10 @@ namespace ts.Completions.StringCompletions { } } - function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[] { + function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] { const extensions = getSupportedExtensions(compilerOptions); - return compilerOptions.resolveJsonModule && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? - extensions.concat(Extension.Json) : + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? + getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index e9f44a9e6bb77..37de920604105 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -81,9 +81,11 @@ namespace ts { } describe("unittests:: moduleResolution:: Node module resolution - relative paths", () => { - + // node module resolution does _not_ implicitly append these extensions to an extensionless path (though will still attempt to load them if explicitly) + const nonImplicitExtensions = [Extension.Mts, Extension.Dmts, Extension.Mjs, Extension.Cts, Extension.Dcts, Extension.Cjs]; + const autoExtensions = filter(supportedTSExtensionsFlat, e => nonImplicitExtensions.indexOf(e) === -1); function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { - for (const ext of supportedTSExtensions) { + for (const ext of autoExtensions) { test(ext, /*hasDirectoryExists*/ false); test(ext, /*hasDirectoryExists*/ true); } @@ -96,7 +98,7 @@ namespace ts { const failedLookupLocations: string[] = []; const dir = getDirectoryPath(containingFileName); - for (const e of supportedTSExtensions) { + for (const e of autoExtensions) { if (e === ext) { break; } @@ -137,7 +139,7 @@ namespace ts { const resolution = nodeModuleNameResolver(moduleName, containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, packageJson, moduleFile)); checkResolvedModule(resolution.resolvedModule, createResolvedModule(moduleFile.name)); // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions.length); + assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions[0].length); } } diff --git a/src/testRunner/unittests/programApi.ts b/src/testRunner/unittests/programApi.ts index b71d13e54cd7e..359dff1c03434 100644 --- a/src/testRunner/unittests/programApi.ts +++ b/src/testRunner/unittests/programApi.ts @@ -11,7 +11,7 @@ namespace ts { assert.equal(notFound.length, 0, `Not found ${notFound} in actual: ${missingPaths} expected: ${expected}`); } - describe("unittests:: Program.getMissingFilePaths", () => { + describe("unittests:: programApi:: Program.getMissingFilePaths", () => { const options: CompilerOptions = { noLib: true, diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 487f83196c36e..29c14a8552019 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -66,6 +66,96 @@ namespace ts.tscWatch { changes: emptyArray }); + verifyTscWatch({ + scenario: "moduleResolution", + subScenario: `resolves specifier in output declaration file from referenced project correctly with cts and mts extensions`, + sys: () => createWatchedSystem([ + { + path: `${projectRoot}/packages/pkg1/package.json`, + content: JSON.stringify({ + name: "pkg1", + version: "1.0.0", + main: "build/index.js", + type: "module" + }) + }, + { + path: `${projectRoot}/packages/pkg1/index.ts`, + content: Utils.dedent` + import type { TheNum } from 'pkg2' + export const theNum: TheNum = 42;` + }, + { + path: `${projectRoot}/packages/pkg1/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + outDir: "build", + module: "node12", + }, + references: [{ path: "../pkg2" }] + }) + }, + { + path: `${projectRoot}/packages/pkg2/const.cts`, + content: `export type TheNum = 42;` + }, + { + path: `${projectRoot}/packages/pkg2/index.ts`, + content: `export type { TheNum } from './const.cjs';` + }, + { + path: `${projectRoot}/packages/pkg2/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + composite: true, + outDir: "build", + module: "node12", + } + }) + }, + { + path: `${projectRoot}/packages/pkg2/package.json`, + content: JSON.stringify({ + name: "pkg2", + version: "1.0.0", + main: "build/index.js", + type: "module" + }) + }, + { + path: `${projectRoot}/node_modules/pkg2`, + symLink: `${projectRoot}/packages/pkg2`, + }, + { ...libFile, path: `/a/lib/lib.es2020.full.d.ts` } + ], { currentDirectory: projectRoot }), + commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"], + changes: [ + { + caption: "reports import errors after change to package file", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "removes those errors when a package file is changed back", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"commonjs"`, `"module"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "reports import errors after change to package file", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "removes those errors when a package file is changed to cjs extensions", + change: sys => { + replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"main": "build/index.js"`, `"main": "build/index.cjs"`); + sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`) + }, + timeouts: runQueuedTimeoutCallbacks, + }, + ] + }); + verifyTsc({ scenario: "moduleResolution", subScenario: `type reference resolution uses correct options for different resolution options referenced project`, diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt index 79f9afa5f34cb..c035c443cf289 100644 --- a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt +++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. ==== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts (1 errors) ==== /// ~~~~~~~ -!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. var x = 0; \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt index 1f078b80a0002..2520eedbc7f64 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt @@ -1,13 +1,13 @@ error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation ==== tests/cases/compiler/a.ts (0 errors) ==== diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt index 1f078b80a0002..2520eedbc7f64 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt @@ -1,13 +1,13 @@ error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation ==== tests/cases/compiler/a.ts (0 errors) ==== diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt index 5b421bbfc8642..321ab08822506 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt @@ -1,4 +1,4 @@ -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? @@ -6,7 +6,7 @@ error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mea Root file specified for compilation -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation !!! error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? diff --git a/tests/baselines/reference/nodeModules1(module=node12).errors.txt b/tests/baselines/reference/nodeModules1(module=node12).errors.txt new file mode 100644 index 0000000000000..8ee0d921d50d2 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node12).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/index.cts(2,21): error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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/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 (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.cts (6 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.ts (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // 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=node12).js b/tests/baselines/reference/nodeModules1(module=node12).js index 1acae5c9aab3b..fba5f41f193e3 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).js +++ b/tests/baselines/reference/nodeModules1(module=node12).js @@ -4,15 +4,120 @@ // 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ 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 }); @@ -48,25 +164,174 @@ 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.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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (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")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = 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.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 }; diff --git a/tests/baselines/reference/nodeModules1(module=node12).symbols b/tests/baselines/reference/nodeModules1(module=node12).symbols index e1653429c87db..b8caa52c8cfa0 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).symbols +++ b/tests/baselines/reference/nodeModules1(module=node12).symbols @@ -6,6 +6,22 @@ const x = 1; 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; @@ -14,6 +30,22 @@ const x = 1; 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; @@ -22,11 +54,260 @@ const x = 1; 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)) + +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)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mts, 26, 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)) + +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)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cts, 27, 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)) + +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)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.ts, 1, 5)) +>x : Symbol(x, Decl(index.ts, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.ts, 2, 8)) +>x : Symbol(m1.x, Decl(index.ts, 26, 8)) diff --git a/tests/baselines/reference/nodeModules1(module=node12).types b/tests/baselines/reference/nodeModules1(module=node12).types index 1c479a5e7bd48..cf878a592d2e9 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).types +++ b/tests/baselines/reference/nodeModules1(module=node12).types @@ -7,6 +7,24 @@ const x = 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; @@ -16,6 +34,24 @@ const x = 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; @@ -25,7 +61,296 @@ const x = 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 + +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 + +// 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 + +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 + +// 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 + +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 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt new file mode 100644 index 0000000000000..8ee0d921d50d2 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/index.cts(2,21): error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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/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 (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.cts (6 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.ts (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // 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=nodenext).js b/tests/baselines/reference/nodeModules1(module=nodenext).js index 1acae5c9aab3b..fba5f41f193e3 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).js +++ b/tests/baselines/reference/nodeModules1(module=nodenext).js @@ -4,15 +4,120 @@ // 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ 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 }); @@ -48,25 +164,174 @@ 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.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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (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")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = 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.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 }; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).symbols b/tests/baselines/reference/nodeModules1(module=nodenext).symbols index e1653429c87db..b8caa52c8cfa0 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModules1(module=nodenext).symbols @@ -6,6 +6,22 @@ const x = 1; 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; @@ -14,6 +30,22 @@ const x = 1; 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; @@ -22,11 +54,260 @@ const x = 1; 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)) + +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)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mts, 26, 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)) + +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)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cts, 27, 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)) + +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)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.ts, 1, 5)) +>x : Symbol(x, Decl(index.ts, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.ts, 2, 8)) +>x : Symbol(m1.x, Decl(index.ts, 26, 8)) diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).types b/tests/baselines/reference/nodeModules1(module=nodenext).types index 1c479a5e7bd48..cf878a592d2e9 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).types +++ b/tests/baselines/reference/nodeModules1(module=nodenext).types @@ -7,6 +7,24 @@ const x = 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; @@ -16,6 +34,24 @@ const x = 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; @@ -25,7 +61,296 @@ const x = 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 + +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 + +// 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 + +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 + +// 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 + +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 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt new file mode 100644 index 0000000000000..d2d1c33f60189 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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/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 (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.cjs (6 errors) ==== + // ESM format imports below should error + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.mjs (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // 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=node12).js b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js index 358104e5f6a62..0ec674cdd18b3 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js @@ -4,15 +4,120 @@ // 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// ESM format imports below should error +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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ 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 }); @@ -48,11 +164,136 @@ 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; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (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 error +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")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; @@ -60,9 +301,33 @@ export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +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.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols index 99bfb2a40ff73..90c86e3a1be64 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols @@ -6,6 +6,22 @@ const x = 1; 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; @@ -14,6 +30,22 @@ const x = 1; 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; @@ -22,11 +54,260 @@ const x = 1; 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)) + +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)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.js, 1, 5)) +>x : Symbol(x, Decl(index.js, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.js, 2, 8)) +>x : Symbol(m1.x, Decl(index.js, 26, 8)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +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)) + +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)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cjs, 27, 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)) + +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)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mjs, 26, 8)) diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types index bb0713313ec99..d0acce4132567 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types @@ -7,6 +7,24 @@ const x = 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; @@ -16,6 +34,24 @@ const x = 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; @@ -25,7 +61,296 @@ const x = 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 + +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 + +// 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 error +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 + +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 + +// 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 + +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 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt new file mode 100644 index 0000000000000..d2d1c33f60189 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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/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 (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.cjs (6 errors) ==== + // ESM format imports below should error + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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 TS1435: 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.mjs (0 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"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // 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=nodenext).js b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js index 358104e5f6a62..0ec674cdd18b3 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js @@ -4,15 +4,120 @@ // 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// ESM format imports below should error +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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ 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 }); @@ -48,11 +164,136 @@ 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; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (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 error +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")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; @@ -60,9 +301,33 @@ export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +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.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols index 99bfb2a40ff73..90c86e3a1be64 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols @@ -6,6 +6,22 @@ const x = 1; 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; @@ -14,6 +30,22 @@ const x = 1; 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; @@ -22,11 +54,260 @@ const x = 1; 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)) + +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)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.js, 1, 5)) +>x : Symbol(x, Decl(index.js, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.js, 2, 8)) +>x : Symbol(m1.x, Decl(index.js, 26, 8)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +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)) + +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)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cjs, 27, 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)) + +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)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mjs, 26, 8)) diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types index bb0713313ec99..d0acce4132567 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types @@ -7,6 +7,24 @@ const x = 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; @@ -16,6 +34,24 @@ const x = 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; @@ -25,7 +61,296 @@ const x = 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 + +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 + +// 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 error +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 + +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 + +// 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 + +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 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt new file mode 100644 index 0000000000000..233fb07a30e11 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt @@ -0,0 +1,139 @@ +tests/cases/conformance/node/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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=node12).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js new file mode 100644 index 0000000000000..4cca6af5a58d7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).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=node12).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols new file mode 100644 index 0000000000000..1ca35d0d3e32e --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).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=node12).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types new file mode 100644 index 0000000000000..016af4314d16b --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).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/nodeModulesForbidenSyntax(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt new file mode 100644 index 0000000000000..233fb07a30e11 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt @@ -0,0 +1,139 @@ +tests/cases/conformance/node/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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 TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this 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=nodenext).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js new file mode 100644 index 0000000000000..4cca6af5a58d7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).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=nodenext).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols new file mode 100644 index 0000000000000..1ca35d0d3e32e --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).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=nodenext).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types new file mode 100644 index 0000000000000..016af4314d16b --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).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/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 071a8c6b528bc..ce9c2a81f90ee 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,10 +1,10 @@ error TS6053: File 'a.ts' not found. The file is in the program because: Root file specified for compilation -error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation -error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation @@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', !!! error TS6053: File 'a.ts' not found. !!! error TS6053: The file is in the program because: !!! error TS6053: Root file specified for compilation -!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation -!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6231: The file is in the program because: !!! error TS6231: Root file specified for compilation \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 071a8c6b528bc..ce9c2a81f90ee 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,10 +1,10 @@ error TS6053: File 'a.ts' not found. The file is in the program because: Root file specified for compilation -error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation -error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation @@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', !!! error TS6053: File 'a.ts' not found. !!! error TS6053: The file is in the program because: !!! error TS6053: Root file specified for compilation -!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation -!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6231: The file is in the program because: !!! error TS6231: Root file specified for compilation \ No newline at end of file diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js new file mode 100644 index 0000000000000..03cd75fe0268e --- /dev/null +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -0,0 +1,485 @@ +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"} + +//// [/user/username/projects/myproject/packages/pkg1/index.ts] +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"}]} + +//// [/user/username/projects/myproject/packages/pkg2/const.cts] +export type TheNum = 42; + +//// [/user/username/projects/myproject/packages/pkg2/index.ts] +export type { TheNum } from './const.cjs'; + +//// [/user/username/projects/myproject/packages/pkg2/tsconfig.json] +{"compilerOptions":{"composite":true,"outDir":"build","module":"node12"}} + +//// [/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] +/// +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; } + + +/a/lib/tsc.js -b packages/pkg1 -w --verbose --traceResolution +Output:: +>> Screen clear +[12:00:41 AM] Starting compilation in watch mode... + +[12:00:42 AM] Projects in this build: + * packages/pkg2/tsconfig.json + * packages/pkg1/tsconfig.json + +[12:00:43 AM] Project 'packages/pkg2/tsconfig.json' is out of date because output file 'packages/pkg2/build/const.cjs' does not exist + +[12:00:44 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... + +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'. +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. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist. +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. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:00 AM] Project 'packages/pkg1/tsconfig.json' is out of date because output file 'packages/pkg1/build/index.js' does not exist + +[12:01:01 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +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'. +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. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +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/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'. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:07 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.ts"] +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 +/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 +/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) +/user/username/projects/myproject/packages/pkg2/const.cts (used version) +/user/username/projects/myproject/packages/pkg2/index.ts (used version) + +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 +/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 +/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) +/user/username/projects/myproject/packages/pkg2/build/index.d.ts (used version) +/user/username/projects/myproject/packages/pkg1/index.ts (used version) + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] +export declare type TheNum = 42; + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.js] +export {}; + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.d.ts] +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},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"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", + "../const.cts", + "../index.ts" + ], + "fileNamesList": [ + [ + "../const.cts" + ] + ], + "fileInfos": { + "../../../../../../../a/lib/lib.es2020.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 + }, + "../const.cts": { + "version": "-11202312776-export type TheNum = 42;", + "signature": "-11202312776-export type TheNum = 42;" + }, + "../index.ts": { + "version": "-9668872159-export type { TheNum } from './const.cjs';", + "signature": "-9668872159-export type { TheNum } from './const.cjs';" + } + }, + "options": { + "composite": true, + "module": 100, + "outDir": "./" + }, + "referencedMap": { + "../index.ts": [ + "../const.cts" + ] + }, + "exportedModulesMap": { + "../index.ts": [ + "../const.cts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.ts" + ] + }, + "version": "FakeTSVersion", + "size": 808 +} + +//// [/user/username/projects/myproject/packages/pkg1/build/index.js] +export const theNum = 42; + + + +Change:: reports import errors after change to package file + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: removes those errors when a package file is changed back + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: reports import errors after change to package file + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: removes those errors when a package file is changed to cjs extensions + +Input:: +//// [/user/username/projects/myproject/packages/pkg2/package.json] file written with same contents +//// [/user/username/projects/myproject/packages/pkg2/index.cts] +export type { TheNum } from './const.cjs'; + +//// [/user/username/projects/myproject/packages/pkg2/index.ts] deleted + +Output:: +>> Screen clear +[12:01:23 AM] File change detected. Starting incremental compilation... + +[12:01:24 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' + +[12:01:25 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'. +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. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist. +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. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:34 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... + + + +Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.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 +/user/username/projects/myproject/packages/pkg2/const.cts +/user/username/projects/myproject/packages/pkg2/index.cts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg2/index.cts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg2/index.cts (computed .d.ts) + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.cts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +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},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n"}],"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", + "../const.cts", + "../index.cts" + ], + "fileNamesList": [ + [ + "../const.cts" + ] + ], + "fileInfos": { + "../../../../../../../a/lib/lib.es2020.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 + }, + "../const.cts": { + "version": "-11202312776-export type TheNum = 42;", + "signature": "-11202312776-export type TheNum = 42;" + }, + "../index.cts": { + "version": "-9668872159-export type { TheNum } from './const.cjs';", + "signature": "-9835135925-export type { TheNum } from './const.cjs';\n" + } + }, + "options": { + "composite": true, + "module": 100, + "outDir": "./" + }, + "referencedMap": { + "../index.cts": [ + "../const.cts" + ] + }, + "exportedModulesMap": { + "../index.cts": [ + "../const.cts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.cts" + ] + }, + "version": "FakeTSVersion", + "size": 892 +} + +//// [/user/username/projects/myproject/packages/pkg2/build/index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.d.cts] +export type { TheNum } from './const.cjs'; + + diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts index 9b27ee95c1789..174300a96b045 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts @@ -7,15 +7,120 @@ // cjs format file const x = 1; export {x}; +// @filename: subfolder/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/index.js // cjs format file const x = 1; export {x}; +// @filename: subfolder2/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/another/index.js // esm format file const x = 1; export {x}; +// @filename: subfolder2/another/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +// @filename: index.cjs +// ESM format imports below should error +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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; +// @filename: 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts index 349d103b0efcf..b0ba13a1e346e 100644 --- a/tests/cases/conformance/node/nodeModules1.ts +++ b/tests/cases/conformance/node/nodeModules1.ts @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +// @filename: subfolder/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder/index.mts +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/index.ts // cjs format file const x = 1; export {x}; +// @filename: subfolder2/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.mts +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/another/index.ts // esm format file const x = 1; export {x}; +// @filename: subfolder2/another/index.mts +// esm format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +// @filename: 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; // @filename: 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"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; diff --git a/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts new file mode 100644 index 0000000000000..d441627d7d0c4 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts @@ -0,0 +1,67 @@ +// @module: node12,nodenext +// @declaration: true +// @filename: subfolder/index.ts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.ts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.ts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: index.ts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: subfolder2/package.json +{ +} +// @filename: subfolder2/another/package.json +{ + "type": "module" +} \ No newline at end of file From e6a386c9b4de959af044ce50f8764b2ca6704add Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Aug 2021 14:41:55 -0700 Subject: [PATCH 2/5] Fix watch of files whose intepretation changes due to a package.json update --- src/compiler/builder.ts | 18 +- src/compiler/builderState.ts | 3 +- src/compiler/program.ts | 1 + src/compiler/tsbuildPublic.ts | 1 + src/compiler/types.ts | 4 + .../unittests/tsbuild/moduleResolution.ts | 4 +- .../unittests/tscWatch/incremental.ts | 3 + .../reference/api/tsserverlibrary.d.ts | 4 + tests/baselines/reference/api/typescript.d.ts | 4 + ...t-correctly-with-cts-and-mts-extensions.js | 343 ++++++++++++++++-- 10 files changed, 350 insertions(+), 35 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 2b578cecfc035..aec8cae3cea12 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -258,6 +258,14 @@ namespace ts { Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new Set(); } + if (useOldState) { + // Any time the interpretation of a source file changes, mark it as changed + forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => { + if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath)!.impliedFormat !== info.impliedFormat) { + state.changedFilesSet.add(sourceFilePath); + } + }); + } state.buildInfoEmitPending = !!state.changedFilesSet.size; return state; @@ -744,13 +752,13 @@ namespace ts { const actualSignature = signature ?? value.signature; return value.version === actualSignature ? value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true } : + { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : value.version : actualSignature !== undefined ? signature === undefined ? value : - { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope } : - { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; + { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); let referencedMap: ProgramBuildInfoReferencedMap | undefined; @@ -1243,10 +1251,10 @@ namespace ts { export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): BuilderState.FileInfo { return isString(fileInfo) ? - { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } : isString(fileInfo.signature) ? fileInfo as BuilderState.FileInfo : - { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat }; } export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram { diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index f48d52c3e9d6b..a64a6c13ed1e8 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -82,6 +82,7 @@ namespace ts { readonly version: string; signature: string | undefined; affectsGlobalScope: boolean | undefined; + impliedFormat: number | undefined; } export interface ReadonlyManyToManyPathMap { @@ -332,7 +333,7 @@ namespace ts { } } } - fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); + fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat }); } return { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 932fdebe43607..e446b32df7626 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -903,6 +903,7 @@ namespace ts { withExtension.extension = extensionFromPath(resolved.resolvedFileName); return withExtension; }); + moduleResolutionCache = host.getModuleResolutionCache?.(); } else { moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index b92741a3de8dc..e8c0b689c62f1 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -284,6 +284,7 @@ namespace ts { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!; compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader); + compilerHost.getModuleResolutionCache = () => moduleResolutionCache; } if (!compilerHost.resolveTypeReferenceDirectives) { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective!; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3652e55cd5e67..829498244e4e9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6609,6 +6609,10 @@ namespace ts { * 'throw new Error("NotImplemented")' */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 0bf612f192c89..0ac722293626f 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -148,8 +148,8 @@ namespace ts.tscWatch { { caption: "removes those errors when a package file is changed to cjs extensions", change: sys => { - replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"main": "build/index.js"`, `"main": "build/index.cjs"`); - sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`) + replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"build/index.js"`, `"build/index.cjs"`); + sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`); }, timeouts: runQueuedTimeoutCallbacks, }, diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts index bc6e541815a5c..8da2d0c09c4ba 100644 --- a/src/testRunner/unittests/tscWatch/incremental.ts +++ b/src/testRunner/unittests/tscWatch/incremental.ts @@ -163,16 +163,19 @@ namespace ts.tscWatch { version: system.createHash(libFile.content), signature: system.createHash(libFile.content), affectsGlobalScope: true, + impliedFormat: undefined, }); assert.deepEqual(state.fileInfos.get(file1.path as Path), { version: system.createHash(file1.content), signature: system.createHash(file1.content), affectsGlobalScope: undefined, + impliedFormat: undefined, }); assert.deepEqual(state.fileInfos.get(file2.path as Path), { version: system.createHash(fileModified.content), signature: system.createHash(fileModified.content), affectsGlobalScope: undefined, + impliedFormat: undefined, }); assert.deepEqual(state.compilerOptions, { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 8474b288eb1cc..1f4f871ddf5b5 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3163,6 +3163,10 @@ declare namespace ts { getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 273ac73c3011b..c96afc78fcbfd 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3163,6 +3163,10 @@ declare namespace ts { getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index 1d8fe17b077e9..1a445f232047e 100644 --- a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -95,8 +95,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exis Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. -Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. -'package.json' does not have a 'typesVersions' field. +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'. @@ -108,9 +107,9 @@ File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. ======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== -File '/a/lib/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. +File '/a/lib/package.json' does not exist according to earlier cached lookups. +File '/a/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. [12:01:07 AM] Found 0 errors. Watching for file changes. @@ -158,12 +157,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -193,7 +206,7 @@ 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},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"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.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},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"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] { @@ -212,7 +225,8 @@ export type { TheNum } from './const.cjs'; "../../../../../../../a/lib/lib.es2020.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 + "affectsGlobalScope": true, + "impliedFormat": 1 }, "../const.cts": { "version": "-11202312776-export type TheNum = 42;", @@ -245,7 +259,7 @@ export type { TheNum } from './const.cjs'; ] }, "version": "FakeTSVersion", - "size": 808 + "size": 826 } //// [/user/username/projects/myproject/packages/pkg1/build/index.js] @@ -261,6 +275,79 @@ Input:: Output:: +>> Screen clear +[12:01:11 AM] File change detected. Starting incremental compilation... + +[12:01:12 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:13 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +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'. +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. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +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/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'. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + +[12:01:14 AM] Found 1 error. Watching for file changes. + + + +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 +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -269,12 +356,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -295,6 +396,74 @@ Input:: Output:: +>> Screen clear +[12:01:18 AM] File change detected. Starting incremental compilation... + +[12:01:19 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:20 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +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'. +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. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +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/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'. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:24 AM] Found 0 errors. Watching for file changes. + + + +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 +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -303,12 +472,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -320,6 +503,7 @@ FsWatchesRecursive:: exitCode:: ExitStatus.undefined +//// [/user/username/projects/myproject/packages/pkg1/build/index.js] file written with same contents Change:: reports import errors after change to package file @@ -329,6 +513,79 @@ Input:: Output:: +>> Screen clear +[12:01:28 AM] File change detected. Starting incremental compilation... + +[12:01:29 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:30 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +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'. +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. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +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/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'. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +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. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + +[12:01:31 AM] Found 1 error. Watching for file changes. + + + +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 +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -337,12 +594,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -358,7 +629,9 @@ exitCode:: ExitStatus.undefined Change:: removes those errors when a package file is changed to cjs extensions Input:: -//// [/user/username/projects/myproject/packages/pkg2/package.json] file written with same contents +//// [/user/username/projects/myproject/packages/pkg2/package.json] +{"name":"pkg2","version":"1.0.0","main":"build/index.cjs","type":"module"} + //// [/user/username/projects/myproject/packages/pkg2/index.cts] export type { TheNum } from './const.cjs'; @@ -366,11 +639,11 @@ export type { TheNum } from './const.cjs'; Output:: >> Screen clear -[12:01:23 AM] File change detected. Starting incremental compilation... +[12:01:38 AM] File change detected. Starting incremental compilation... -[12:01:24 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' +[12:01:39 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' -[12:01:25 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... +[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'. @@ -384,7 +657,7 @@ File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -[12:01:34 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... +[12:01:49 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... @@ -407,12 +680,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/const.cts: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.cts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.cts","pollingInterval":250} @@ -429,7 +716,7 @@ 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},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n"}],"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.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},"-11202312776-export type TheNum = 42;",{"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] { @@ -448,7 +735,8 @@ exitCode:: ExitStatus.undefined "../../../../../../../a/lib/lib.es2020.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 + "affectsGlobalScope": true, + "impliedFormat": 1 }, "../const.cts": { "version": "-11202312776-export type TheNum = 42;", @@ -456,7 +744,8 @@ exitCode:: ExitStatus.undefined }, "../index.cts": { "version": "-9668872159-export type { TheNum } from './const.cjs';", - "signature": "-9835135925-export type { TheNum } from './const.cjs';\n" + "signature": "-9835135925-export type { TheNum } from './const.cjs';\n", + "impliedFormat": 1 } }, "options": { @@ -481,7 +770,7 @@ exitCode:: ExitStatus.undefined ] }, "version": "FakeTSVersion", - "size": 892 + "size": 928 } //// [/user/username/projects/myproject/packages/pkg2/build/index.cjs] From b12315f05de78eb6b2bf8f46325933454ebdb02a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Sep 2021 11:12:33 -0700 Subject: [PATCH 3/5] Minor PR feedback --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/emitter.ts | 21 +++++---------------- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 10 +++++----- src/services/stringCompletions.ts | 2 +- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 8762416d91d60..37f27b76a42e4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -3201,7 +3201,7 @@ namespace ts { // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. const supportedExtensions = getSupportedExtensions(options, extraFileExtensions); - const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); + const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Literal files are always included verbatim. An "include" or "exclude" specification cannot // remove a literal file. @@ -3447,7 +3447,7 @@ namespace ts { } for (const ext of extensionGroup) { if (fileExtensionIs(file, ext)) { - break; + return false; } const higherPriorityPath = keyMapper(changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { @@ -3478,7 +3478,7 @@ namespace ts { for (let i = extensionGroup.length - 1; i >= 0; i--) { const ext = extensionGroup[i]; if (fileExtensionIs(file, ext)) { - break; + return; } const lowerPriorityPath = keyMapper(changeExtension(file, ext)); wildcardFiles.delete(lowerPriorityPath); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 943dd14836e78..f8357b57394bd 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -108,22 +108,11 @@ namespace ts { /* @internal */ export function getOutputExtension(fileName: string, options: CompilerOptions): Extension { - if (fileExtensionIs(fileName, Extension.Json)) { - return Extension.Json; - } - - if (options.jsx === JsxEmit.Preserve) { - if (fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx])) { - return Extension.Jsx; - } - } - if (fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs])) { - return Extension.Mjs; - } - if (fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs])) { - return Extension.Cjs; - } - return Extension.Js; + return fileExtensionIs(fileName, Extension.Json) ? Extension.Json : + options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx : + fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs : + fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs : + Extension.Js; } function getOutputPathWithoutChangingExt(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, outputDir: string | undefined, getCommonSourceDirectory?: () => string) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 2db7b08f86b20..17de23668d22d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -883,7 +883,7 @@ namespace ts { const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); - const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); + const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = new Map(); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a700a98e5a4c1..627c0f8eb9b90 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6738,7 +6738,7 @@ namespace ts { } /** - * List of supported extensions in order of file resolution precedence. + * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]]; export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions); @@ -6769,9 +6769,9 @@ namespace ts { return extensions; } - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { if (!options || !options.resolveJsonModule) return supportedExtensions; if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson; if (supportedExtensions === supportedTSExtensions) return supportedTSExtensionsWithJson; @@ -6794,7 +6794,7 @@ namespace ts { if (!fileName) return false; const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions); - for (const extension of flatten(getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { + for (const extension of flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { if (fileExtensionIs(fileName, extension)) { return true; } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index f3c04d9ac8b82..cc81c6ab97f0e 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -347,7 +347,7 @@ namespace ts.Completions.StringCompletions { function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] { const extensions = getSupportedExtensions(compilerOptions); return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? - getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : + getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } From 15e1904fd7343a28486785ef63768d1f967c008a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Sep 2021 11:22:40 -0700 Subject: [PATCH 4/5] Adjust error message --- src/compiler/checker.ts | 4 +- src/compiler/diagnosticMessages.json | 4 +- ...esForbidenSyntax(module=node12).errors.txt | 96 +++++++++---------- ...ForbidenSyntax(module=nodenext).errors.txt | 96 +++++++++---------- 4 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1fc9416faf634..44e02840e046b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30560,7 +30560,7 @@ namespace ts { if (node.kind === SyntaxKind.TypeAssertionExpression) { const file = getSourceFileOfNode(node); if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { - grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Use_an_as_expression_instead); + grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } return checkAssertionWorker(node, node.type, node.expression); @@ -41806,7 +41806,7 @@ namespace ts { if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) { - grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Add_a_trailing_comma_or_explicit_constraint); + grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ca529d2e29539..66da25d3ec66a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5888,11 +5888,11 @@ "category": "Error", "code": 7058 }, - "This syntax is reserved in files with this extension. Use an `as` expression instead.": { + "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.": { "category": "Error", "code": 7059 }, - "This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.": { + "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.": { "category": "Error", "code": 7060 }, diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt index cf09fc77b2f5a..984483a332e29 100644 --- a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with this 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 this 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 this 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 this 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 this 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 this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +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) ==== @@ -32,21 +32,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 @@ -56,21 +56,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 @@ -80,41 +80,41 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt index cf09fc77b2f5a..984483a332e29 100644 --- a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with this 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 this 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 this 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 this 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 this 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 this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with this 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 this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +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) ==== @@ -32,21 +32,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 @@ -56,21 +56,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 @@ -80,41 +80,41 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 this extension. Add a trailing comma or explicit constraint. +!!! 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 this 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. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this 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 From 5bf44ac87b3e6998cf6e5c6dc0c9637a9d4c4ea7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 14 Sep 2021 19:38:07 -0700 Subject: [PATCH 5/5] Accept new error codes --- .../nodeModules1(module=node12).errors.txt | 24 +++++++++---------- .../nodeModules1(module=nodenext).errors.txt | 24 +++++++++---------- ...eModulesAllowJs1(module=node12).errors.txt | 24 +++++++++---------- ...odulesAllowJs1(module=nodenext).errors.txt | 24 +++++++++---------- ...t-correctly-with-cts-and-mts-extensions.js | 4 ++-- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/baselines/reference/nodeModules1(module=node12).errors.txt b/tests/baselines/reference/nodeModules1(module=node12).errors.txt index 72fc62c6aed5f..a2f68a704a96f 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=node12).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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(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/subfolder/index.ts (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/index.cts(12,22): error TS1445: Module './subfolder // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt index 72fc62c6aed5f..a2f68a704a96f 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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(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/subfolder/index.ts (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/index.cts(12,22): error TS1445: Module './subfolder // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt index 41443989a961d..365b00a0e162f 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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(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/subfolder/index.js (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1445: Module './s // ESM format imports below should error import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt index 41443989a961d..365b00a0e162f 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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 TS1445: 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(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/subfolder/index.js (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1445: Module './s // ESM format imports below should error import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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 TS1445: 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. +!!! 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"; void m1; void m2; diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index 1a445f232047e..6a2a409b814cf 100644 --- a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -326,7 +326,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~ @@ -564,7 +564,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~